ui: fix for elided text in the smartlist
- code simplified.
- elided text fixed.
Tuleap: #275
Change-Id: I1d085253d1a4d2a298be00e80297b1bc65f4e5db
diff --git a/smartlistdelegate.cpp b/smartlistdelegate.cpp
index c53c129..56ba2b6 100644
--- a/smartlistdelegate.cpp
+++ b/smartlistdelegate.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2015-2016 by Savoir-faire Linux *
+ * Copyright (C) 2015-2016 by Savoir-faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
@@ -27,6 +27,7 @@
#include "person.h"
#include "recentmodel.h"
#include "call.h"
+#include "combar.h"
#include "ringthemeutils.h"
@@ -124,14 +125,8 @@
font.setBold(true);
painter->setFont(font);
QFontMetrics fontMetrics(font);
- QString nameStr = name.toString();
- auto realRect = fontMetrics.boundingRect(rect, Qt::AlignBottom | Qt::AlignLeft, nameStr);
- if (realRect.width() > (rect.width() - rectTexts.left() - 30)) {
- /* 30 here is the size of the video button */
- auto charToChop = (realRect.width() - (rect.width() - rectTexts.left())) / fontMetrics.averageCharWidth();
- nameStr.chop(charToChop + 8);
- nameStr.append(QStringLiteral("..."));
- }
+ QString nameStr = fontMetrics.elidedText(name.toString(), Qt::ElideRight
+ , rectTexts.width()- sizeImage_ - effectiveComBarSize_ - dx_);
painter->drawText(rectTexts, Qt::AlignBottom | Qt::AlignLeft, nameStr);
}
diff --git a/smartlistdelegate.h b/smartlistdelegate.h
index 705faef..313a15e 100644
--- a/smartlistdelegate.h
+++ b/smartlistdelegate.h
@@ -41,6 +41,7 @@
constexpr static int dx_ = 12;
constexpr static int fontSize_ = 10;
constexpr static int pinSize_ = 12;
+ constexpr static int effectiveComBarSize_ = 48;
int rowHighlighted_ = -1;
signals: