summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-10-31 10:24:25 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-10-31 10:24:25 (GMT)
commitd45e53ce6d5013c3a0e1032dacf0c3372cd46952 (patch)
treecd6c6d240978a541f5845f6cf53e2b3757b1a86f
parentbd55796d134b45400a76dcfdc0b97dd233bb0f86 (diff)
downloadswift-d45e53ce6d5013c3a0e1032dacf0c3372cd46952.zip
swift-d45e53ce6d5013c3a0e1032dacf0c3372cd46952.tar.bz2
Fix triangle drawing.
Resolves: #634
-rw-r--r--Swift/QtUI/Roster/GroupItemDelegate.cpp41
1 files changed, 20 insertions, 21 deletions
diff --git a/Swift/QtUI/Roster/GroupItemDelegate.cpp b/Swift/QtUI/Roster/GroupItemDelegate.cpp
index 819352d..bca83c7 100644
--- a/Swift/QtUI/Roster/GroupItemDelegate.cpp
+++ b/Swift/QtUI/Roster/GroupItemDelegate.cpp
@@ -69,30 +69,29 @@ void GroupItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& opt
}
void GroupItemDelegate::paintExpansionTriangle(QPainter* painter, const QRect& region, int width, int height, bool expanded) const {
- QBrush triangleBrush(QColor(110, 110, 110));
- QBrush triangleShadowBrush(QColor(47, 47, 47));
- QPainterPath trianglePath;
- QPainterPath triangleShadowPath;
+ // height is the height of the downward pointing triangle
QPolygonF triangle;
- QPolygonF triangleShadow;
- QPointF triangleTopLeft(region.left(), region.top() + region.height() / 2 - height / 2);
- QPointF shadowOffset(0,-1);
- QPointF trianglePoint2;
- QPointF trianglePoint3;
-
if (expanded) {
- triangleTopLeft += QPoint(0, 1);
- trianglePoint2 = triangleTopLeft + QPointF(width, 0);
- trianglePoint3 = trianglePoint2 + QPointF(-1 * (width / 2), height);
- //qDebug() << "Plotting expanded" << triangleTopLeft << ", " << trianglePoint2 << ", " << trianglePoint3;
- } else {
- trianglePoint2 = triangleTopLeft + QPointF(0, width);
- trianglePoint3 = trianglePoint2 + QPointF(height, -1 * (width / 2));
- //qDebug() << "Plotting collapsed" << triangleTopLeft << ", " << trianglePoint2 << ", " << trianglePoint3;
+ QPointF triangleTopLeft(region.left(), region.top() + region.height() / 2 - height / 2);
+ triangle << triangleTopLeft;
+ triangle << triangleTopLeft + QPointF(width, 0);
+ triangle << triangleTopLeft + QPointF(width / 2, height);
}
- triangle << triangleTopLeft << trianglePoint2 << trianglePoint3 << triangleTopLeft;
- triangleShadow << triangleTopLeft + shadowOffset << trianglePoint2 + shadowOffset << trianglePoint3 + shadowOffset << triangleTopLeft + shadowOffset;
-
+ else {
+ QPointF triangleTopLeft(region.left(), region.top() + region.height() / 2 - width / 2);
+ triangle << triangleTopLeft;
+ triangle << triangleTopLeft + QPointF(height, width / 2);
+ triangle << triangleTopLeft + QPointF(0, width);
+ }
+ //qDebug() << "Painting triangle: " << triangle;
+
+ QPolygonF triangleShadow(triangle);
+ triangleShadow.translate(QPointF(0, -1));
+
+ QPainterPath trianglePath;
+ QPainterPath triangleShadowPath;
+ QBrush triangleBrush(QColor(110, 110, 110));
+ QBrush triangleShadowBrush(QColor(47, 47, 47));
trianglePath.addPolygon(triangle);
triangleShadowPath.addPolygon(triangleShadow);
painter->fillPath(triangleShadowPath, triangleShadowBrush);