QFontComboBox: optimize handling of icons for delegate

Instead of move-assigning a new QIcon to the default-
constructed members, initialize them directly in the
ctor-init-list. Do this for the other data member, too,
for consistency.

Also use QStringLiteral instead of QLatin1String as
the argument to the QIcon ctor. This is correct, since
the string will never be modified, and saves two memory
allocations.

Change-Id: I9398bbe9d0fd63db9b6cf856dd240ab334364518
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
This commit is contained in:
Marc Mutz 2014-04-03 09:22:24 +02:00
parent f2d1f3f1c7
commit 587c183608

View File

@ -195,17 +195,17 @@ public:
QSize sizeHint(const QStyleOptionViewItem &option,
const QModelIndex &index) const Q_DECL_OVERRIDE;
QIcon truetype;
QIcon bitmap;
const QIcon truetype;
const QIcon bitmap;
QFontDatabase::WritingSystem writingSystem;
};
QFontFamilyDelegate::QFontFamilyDelegate(QObject *parent)
: QAbstractItemDelegate(parent)
: QAbstractItemDelegate(parent),
truetype(QStringLiteral(":/qt-project.org/styles/commonstyle/images/fonttruetype-16.png")),
bitmap(QStringLiteral(":/qt-project.org/styles/commonstyle/images/fontbitmap-16.png")),
writingSystem(QFontDatabase::Any)
{
truetype = QIcon(QLatin1String(":/qt-project.org/styles/commonstyle/images/fonttruetype-16.png"));
bitmap = QIcon(QLatin1String(":/qt-project.org/styles/commonstyle/images/fontbitmap-16.png"));
writingSystem = QFontDatabase::Any;
}
void QFontFamilyDelegate::paint(QPainter *painter,