removed magic 5, removed unnecessary QPainter function calls
Signed-off-by: Tayou <tayou@gmx.net>
This commit is contained in:
parent
1dc7f80034
commit
8211befc29
@ -120,7 +120,7 @@ VisualGroup::HitResults VisualGroup::hitScan(const QPoint& pos) const
|
|||||||
VisualGroup::HitResults results = VisualGroup::NoHit;
|
VisualGroup::HitResults results = VisualGroup::NoHit;
|
||||||
int y_start = verticalPosition();
|
int y_start = verticalPosition();
|
||||||
int body_start = y_start + headerHeight();
|
int body_start = y_start + headerHeight();
|
||||||
int body_end = body_start + contentHeight() + 5; // FIXME: wtf is this 5?
|
int body_end = body_start + contentHeight();
|
||||||
int y = pos.y();
|
int y = pos.y();
|
||||||
// int x = pos.x();
|
// int x = pos.x();
|
||||||
if (y < y_start) {
|
if (y < y_start) {
|
||||||
@ -147,8 +147,7 @@ void VisualGroup::drawHeader(QPainter* painter, const QStyleOptionViewItem& opti
|
|||||||
QFont font(QApplication::font());
|
QFont font(QApplication::font());
|
||||||
font.setBold(true);
|
font.setBold(true);
|
||||||
const QFontMetrics fontMetrics = QFontMetrics(font);
|
const QFontMetrics fontMetrics = QFontMetrics(font);
|
||||||
|
painter->setFont(font);
|
||||||
int centerHeight = optRect.top() + fontMetrics.height() / 2;
|
|
||||||
|
|
||||||
QPen pen;
|
QPen pen;
|
||||||
pen.setWidth(2);
|
pen.setWidth(2);
|
||||||
@ -157,14 +156,15 @@ void VisualGroup::drawHeader(QPainter* painter, const QStyleOptionViewItem& opti
|
|||||||
pen.setColor(penColor);
|
pen.setColor(penColor);
|
||||||
painter->setPen(pen);
|
painter->setPen(pen);
|
||||||
|
|
||||||
|
// sizes and offsets, to keep things consistent below
|
||||||
int arrowOffsetLeft = fontMetrics.height() / 2 + 7;
|
int arrowOffsetLeft = fontMetrics.height() / 2 + 7;
|
||||||
int textOffsetLeft = arrowOffsetLeft * 2;
|
int textOffsetLeft = arrowOffsetLeft * 2;
|
||||||
int arrowSize = 6;
|
int arrowSize = 6;
|
||||||
|
int centerHeight = optRect.top() + fontMetrics.height() / 2;
|
||||||
|
|
||||||
// BEGIN: arrow
|
// BEGIN: arrow
|
||||||
{
|
{
|
||||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||||
painter->save();
|
|
||||||
|
|
||||||
QPolygon polygon;
|
QPolygon polygon;
|
||||||
if (collapsed) {
|
if (collapsed) {
|
||||||
@ -178,7 +178,6 @@ void VisualGroup::drawHeader(QPainter* painter, const QStyleOptionViewItem& opti
|
|||||||
<< QPoint(arrowOffsetLeft + arrowSize, centerHeight - arrowSize / 2);
|
<< QPoint(arrowOffsetLeft + arrowSize, centerHeight - arrowSize / 2);
|
||||||
painter->drawPolyline(polygon);
|
painter->drawPolyline(polygon);
|
||||||
}
|
}
|
||||||
painter->restore();
|
|
||||||
}
|
}
|
||||||
// END: arrow
|
// END: arrow
|
||||||
|
|
||||||
@ -191,10 +190,7 @@ void VisualGroup::drawHeader(QPainter* painter, const QStyleOptionViewItem& opti
|
|||||||
textRect.setHeight(fontMetrics.height());
|
textRect.setHeight(fontMetrics.height());
|
||||||
textRect.setRight(textRect.right() - 7);
|
textRect.setRight(textRect.right() - 7);
|
||||||
|
|
||||||
painter->save();
|
|
||||||
painter->setFont(font);
|
|
||||||
painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, !text.isEmpty() ? text : QObject::tr("Ungrouped"));
|
painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, !text.isEmpty() ? text : QObject::tr("Ungrouped"));
|
||||||
painter->restore();
|
|
||||||
}
|
}
|
||||||
// END: text
|
// END: text
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user