From b9ddeaa23863f515c4b3bd84cb5f548089e6d080 Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Tue, 4 Sep 2007 17:59:52 +0000 Subject: [PATCH] Center decoration in 'Show In Menu' column of Manage Profiles dialog. I'm sure there must be an easier way. svn path=/trunk/KDE/kdebase/apps/konsole/; revision=708382 --- src/ManageProfilesDialog.cpp | 13 +++++++++++++ src/ManageProfilesDialog.h | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/src/ManageProfilesDialog.cpp b/src/ManageProfilesDialog.cpp index e90a6e6a2..716534e02 100644 --- a/src/ManageProfilesDialog.cpp +++ b/src/ManageProfilesDialog.cpp @@ -296,6 +296,19 @@ ProfileItemDelegate::ProfileItemDelegate(QObject* parent) : QItemDelegate(parent) { } +// Is there a simpler way of centering the decoration than re-implementing +// drawDecoration? +void ProfileItemDelegate::drawDecoration(QPainter* painter, + const QStyleOptionViewItem& option, + const QRect& rect,const QPixmap& pixmap) const +{ + QStyleOptionViewItem centeredOption(option); + centeredOption.decorationAlignment = Qt::AlignCenter; + QItemDelegate::drawDecoration(painter, + centeredOption, + QStyle::alignedRect(Qt::LeftToRight,Qt::AlignCenter,rect.size(),option.rect), + pixmap); +} bool ProfileItemDelegate::editorEvent(QEvent* event,QAbstractItemModel*, const QStyleOptionViewItem&,const QModelIndex& index) { diff --git a/src/ManageProfilesDialog.h b/src/ManageProfilesDialog.h index 5e26769df..dd2a05f95 100644 --- a/src/ManageProfilesDialog.h +++ b/src/ManageProfilesDialog.h @@ -98,6 +98,11 @@ public: virtual bool editorEvent(QEvent* event,QAbstractItemModel* model, const QStyleOptionViewItem& option,const QModelIndex& index); + +protected: + virtual void drawDecoration(QPainter*,const QStyleOptionViewItem&,const QRect&, + const QPixmap&) const; + }; }