From: Flavio Tordini Date: Fri, 9 Oct 2009 22:20:48 +0000 (+0200) Subject: Performance optimization: Initialize fonts in constructor, not on every X-Git-Tag: 0.7~7 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=521b230734d76184667461b7ab87e4e7b165d52c;p=minitube Performance optimization: Initialize fonts in constructor, not on every paint --- diff --git a/src/playlist/PrettyItemDelegate.cpp b/src/playlist/PrettyItemDelegate.cpp index 59843fe..2c6f21f 100644 --- a/src/playlist/PrettyItemDelegate.cpp +++ b/src/playlist/PrettyItemDelegate.cpp @@ -9,6 +9,12 @@ const qreal PrettyItemDelegate::THUMB_WIDTH = 120.0; const qreal PrettyItemDelegate::PADDING = 10.0; PrettyItemDelegate::PrettyItemDelegate( QObject* parent ) : QStyledItemDelegate( parent ) { + + boldFont.setBold(true); + smallerFont.setPointSize(smallerFont.pointSize()*.85); + smallerBoldFont.setBold(true); + smallerBoldFont.setPointSize(smallerBoldFont.pointSize()*.85); + createPlayIcon(); } @@ -60,14 +66,6 @@ void PrettyItemDelegate::paintBody( QPainter* painter, QPalette palette; - QFont boldFont; - boldFont.setBold(true); - QFont smallerFont; - smallerFont.setPointSize(smallerFont.pointSize()*.85); - QFont smallerBoldFont; - smallerBoldFont.setBold(true); - smallerBoldFont.setPointSize(smallerBoldFont.pointSize()*.85); - const bool isActive = index.data( ActiveTrackRole ).toBool(); const bool isSelected = option.state & QStyle::State_Selected; diff --git a/src/playlist/PrettyItemDelegate.h b/src/playlist/PrettyItemDelegate.h index 723dcaa..6fc547b 100644 --- a/src/playlist/PrettyItemDelegate.h +++ b/src/playlist/PrettyItemDelegate.h @@ -34,6 +34,9 @@ private: static const qreal PADDING; QPixmap playIcon; + QFont boldFont; + QFont smallerFont; + QFont smallerBoldFont; }; #endif