diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2014-09-02 14:37:10 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2014-09-04 21:27:37 +0200 |
commit | 32a0e0cc616fa9c34ecb6f839b933588f7d4ff3e (patch) | |
tree | b84d41f97413ab60c59dd03c22f2a7e8ae683ca9 | |
parent | e35841e37456f4c5bc494a1674bb3f014a4d93c1 (diff) |
QCommonStyle: replace a QPolygon with a QPoint[] (I)
No need to allocate dynamic memory for a fixed-size point array
when QPainter has a (QPoint*,int) overload.
Change-Id: I50c69103bba47e9f6de4f5616e8f40fee522ddc2
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
-rw-r--r-- | src/widgets/styles/qcommonstyle.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index cc24c79c09..27431a4401 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -321,22 +321,24 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) { QPen oldPen = p->pen(); if (header->sortIndicator & QStyleOptionHeader::SortUp) { - QPolygon pa(3); p->setPen(QPen(opt->palette.light(), 0)); p->drawLine(opt->rect.x() + opt->rect.width(), opt->rect.y(), opt->rect.x() + opt->rect.width() / 2, opt->rect.y() + opt->rect.height()); p->setPen(QPen(opt->palette.dark(), 0)); - pa.setPoint(0, opt->rect.x() + opt->rect.width() / 2, opt->rect.y() + opt->rect.height()); - pa.setPoint(1, opt->rect.x(), opt->rect.y()); - pa.setPoint(2, opt->rect.x() + opt->rect.width(), opt->rect.y()); - p->drawPolyline(pa); + const QPoint points[] = { + QPoint(opt->rect.x() + opt->rect.width() / 2, opt->rect.y() + opt->rect.height()), + QPoint(opt->rect.x(), opt->rect.y()), + QPoint(opt->rect.x() + opt->rect.width(), opt->rect.y()), + }; + p->drawPolyline(points, sizeof points / sizeof *points); } else if (header->sortIndicator & QStyleOptionHeader::SortDown) { - QPolygon pa(3); p->setPen(QPen(opt->palette.light(), 0)); - pa.setPoint(0, opt->rect.x(), opt->rect.y() + opt->rect.height()); - pa.setPoint(1, opt->rect.x() + opt->rect.width(), opt->rect.y() + opt->rect.height()); - pa.setPoint(2, opt->rect.x() + opt->rect.width() / 2, opt->rect.y()); - p->drawPolyline(pa); + const QPoint points[] = { + QPoint(opt->rect.x(), opt->rect.y() + opt->rect.height()), + QPoint(opt->rect.x() + opt->rect.width(), opt->rect.y() + opt->rect.height()), + QPoint(opt->rect.x() + opt->rect.width() / 2, opt->rect.y()), + }; + p->drawPolyline(points, sizeof points / sizeof *points); p->setPen(QPen(opt->palette.dark(), 0)); p->drawLine(opt->rect.x(), opt->rect.y() + opt->rect.height(), opt->rect.x() + opt->rect.width() / 2, opt->rect.y()); |