From 7840105a9828127720a67e7a636e09169b362bce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Mon, 27 Dec 2010 10:13:18 +0100 Subject: Elide group header when necessary. Resolves: #677 diff --git a/Swift/QtUI/Roster/GroupItemDelegate.cpp b/Swift/QtUI/Roster/GroupItemDelegate.cpp index 6691b26..ffe0a98 100644 --- a/Swift/QtUI/Roster/GroupItemDelegate.cpp +++ b/Swift/QtUI/Roster/GroupItemDelegate.cpp @@ -61,11 +61,11 @@ void GroupItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& opt contactCountWidth = groupMetrics.width(countString) + 2 * common_.horizontalMargin; int offsetAmount = textRect.width() - contactCountWidth + common_.horizontalMargin; QRect countRect = textRect.adjusted(offsetAmount, 0, 0/*-1 * offsetAmount*/, 0); - //qDebug() << "Painting count string " << countString << " at " << countRect << " from offset " << offsetAmount; paintShadowText(painter, countRect, countString); } - QRect nameTextRect = textRect.adjusted(0, 0, contactCountWidth, 0); - paintShadowText(painter, nameTextRect, name); + QRect nameTextRect = expanded ? textRect : textRect.adjusted(0, 0, -contactCountWidth, 0); + QString elidedName = fontMetrics.elidedText(name, Qt::ElideRight, nameTextRect.width(), Qt::TextShowMnemonic); + paintShadowText(painter, nameTextRect, elidedName); painter->restore(); } -- cgit v0.10.2-6-g49f6