From be462ae1a61312fd6b625e00e35c1622bc006f41 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 19 Jun 2014 18:45:26 -0300 Subject: Change the Star Widget to use QImage instead of QPixmap Also, clean a few calls, this should make the widget a tiny bit faster. This patch also moves the grayImage function from the star widget to the global scope, so I can use it on the Calendar widget. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/modeldelegates.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'qt-ui/modeldelegates.cpp') diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp index d06c6621f..dc6af5665 100644 --- a/qt-ui/modeldelegates.cpp +++ b/qt-ui/modeldelegates.cpp @@ -47,10 +47,13 @@ void StarWidgetsDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o int deltaY = option.rect.height() / 2 - StarWidget::starActive().height() / 2; painter->save(); painter->setRenderHint(QPainter::Antialiasing, true); + const QPixmap active = QPixmap::fromImage(StarWidget::starActive()); + const QPixmap inactive = QPixmap::fromImage(StarWidget::starInactive()); + for (int i = 0; i < rating; i++) - painter->drawPixmap(option.rect.x() + i * IMG_SIZE + SPACING, option.rect.y() + deltaY, StarWidget::starActive()); + painter->drawPixmap(option.rect.x() + i * IMG_SIZE + SPACING, option.rect.y() + deltaY, active); for (int i = rating; i < TOTALSTARS; i++) - painter->drawPixmap(option.rect.x() + i * IMG_SIZE + SPACING, option.rect.y() + deltaY, StarWidget::starInactive()); + painter->drawPixmap(option.rect.x() + i * IMG_SIZE + SPACING, option.rect.y() + deltaY, inactive); painter->restore(); } -- cgit v1.2.3-70-g09d2