Commit 389a2296 authored by Nicolas Jager's avatar Nicolas Jager Committed by gerrit2

ui: fix for elided text in the smartlist

- code simplified.

- elided text fixed.

Tuleap: #275

Change-Id: I1d085253d1a4d2a298be00e80297b1bc65f4e5db
parent 17f382ea
/***************************************************************************
* 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 @@ SmartListDelegate::paint(QPainter* painter
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);
}
......
......@@ -41,6 +41,7 @@ private:
constexpr static int dx_ = 12;
constexpr static int fontSize_ = 10;
constexpr static int pinSize_ = 12;
constexpr static int effectiveComBarSize_ = 48;
int rowHighlighted_ = -1;
signals:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment