summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2009-08-28 06:51:55 (GMT)
committerKevin Smith <git@kismith.co.uk>2009-08-28 06:51:55 (GMT)
commitbae5ca20ee46d03112bdfabd49b5770684f77e2c (patch)
tree031620f1965e3efc99a5984c8dd18be40917eff3
parentaa8719c03e56b0d7a85b1b5594c2fd49f09edac3 (diff)
downloadswift-bae5ca20ee46d03112bdfabd49b5770684f77e2c.zip
swift-bae5ca20ee46d03112bdfabd49b5770684f77e2c.tar.bz2
Centralise the group headings vertically.
-rw-r--r--Swift/QtUI/Roster/RosterDelegate.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/Swift/QtUI/Roster/RosterDelegate.cpp b/Swift/QtUI/Roster/RosterDelegate.cpp
index 0353e2f..27ba3b4 100644
--- a/Swift/QtUI/Roster/RosterDelegate.cpp
+++ b/Swift/QtUI/Roster/RosterDelegate.cpp
@@ -29,9 +29,8 @@ QSize RosterDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelI
}
QSize RosterDelegate::groupSizeHint(const QStyleOptionViewItem& option, const QModelIndex& index ) const {
- QFontMetrics nameMetrics(groupFont_);
- return QSize(150, nameMetrics.height() + 2);
- return QStyledItemDelegate::sizeHint(option, index);
+ QFontMetrics groupMetrics(groupFont_);
+ return QSize(150, groupMetrics.height() + 2);
}
QSize RosterDelegate::contactSizeHint(const QStyleOptionViewItem& option, const QModelIndex& index ) const {
@@ -73,7 +72,10 @@ void RosterDelegate::paintGroup(QPainter* painter, const QStyleOptionViewItem& o
linePath.addRoundedRect(region, groupCornerRadius_, groupCornerRadius_);
painter->fillPath(fillPath, backgroundBrush);
painter->drawPath(linePath);
- QRect textRect = region.adjusted(2 * horizontalMargin_ + 1, 0, -1 * horizontalMargin_, 0);
+ int textLeftOffset = 2 * horizontalMargin_ + 1;
+ QFontMetrics fontMetrics(groupFont_);
+ int textTopOffset = (option.rect.height() - fontMetrics.height()) / 2;
+ QRect textRect = region.adjusted(textLeftOffset, textTopOffset, -1 * textLeftOffset, -1 * textTopOffset);
painter->setFont(groupFont_);
painter->setPen(QPen(QColor(254, 254, 254)));
painter->drawText(textRect.adjusted(0, 1, 0, 0), Qt::AlignTop, index.data(Qt::DisplayRole).toString());