[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/workspace/systemsettings
From: Fredrik Höglund <fredrik () kde ! org>
Date: 2008-03-11 22:46:17
Message-ID: 1205275577.670389.13445.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 784651 by fredrik:
Delete the ModuleIconItemDelegate code and use QStyledItemDelegate so
we get a themed look.
M +0 -1 mainwindow.cpp
M +0 -63 moduleiconitem.cpp
M +0 -13 moduleiconitem.h
M +0 -1 modulesview.h
--- trunk/KDE/kdebase/workspace/systemsettings/mainwindow.cpp #784650:784651
@@ -158,7 +158,6 @@
tv->setSpacing(KDialog::spacingHint());
tv->setCategoryDrawer( drawer );
tv->setViewMode( QListView::IconMode );
- tv->setItemDelegate( new ModuleIconItemDelegate( this ) );
tv->setMouseTracking( true );
tv->viewport()->setAttribute( Qt::WA_Hover );
KCategorizedSortFilterProxyModel * kcsfpm = new SystemSettingsProxyModel( \
this );
--- trunk/KDE/kdebase/workspace/systemsettings/moduleiconitem.cpp #784650:784651
@@ -32,70 +32,7 @@
#define IMAGE_SIZE 32
#define ICON_WIDTH 100
-ModuleIconItemDelegate::ModuleIconItemDelegate(QObject *parent) : \
QItemDelegate(parent)
-{
-}
-void ModuleIconItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem \
&option, const QModelIndex &index) const
-{
- painter->save();
- painter->setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
-
- QStyle *style;
- bool selected = option.state & QStyle::State_Selected || option.state & \
QStyle::State_HasFocus;
- if (const QStyleOptionViewItemV3 *v3 = qstyleoption_cast<const \
QStyleOptionViewItemV3 *>(&option)) {
- style = v3->widget->style();
- if (!v3->widget->hasFocus()) selected = false;
- } else {
- style = QApplication::style();
- }
-
- if (selected) {
- painter->fillPath(roundedRectangle(option.rect, 10), \
option.palette.brush(QPalette::Highlight));
- painter->setPen(option.palette.color(QPalette::HighlightedText));
- }
-
- if (!selected && (option.state & QStyle::State_MouseOver)) {
- QColor hover = option.palette.color(QPalette::Highlight);
- hover.setAlpha(88);
- painter->fillPath(roundedRectangle(option.rect, 10), hover);
- }
-
- if( index.data( Qt::UserRole ).toInt() == KIconLoader::DisabledState ) {
- painter->setPen( option.palette.color( QPalette::Disabled, QPalette::Text ) );
- }
-
- const QSize &decorationSize = option.decorationSize;
- QIcon::Mode iconMode = QIcon::Normal;
- if (selected) iconMode = QIcon::Selected;
- const QPixmap &pixmap = \
qvariant_cast<QIcon>(index.data(Qt::DecorationRole)).pixmap(option.decorationSize, \
iconMode);
- int iconX = option.rect.left() + (option.rect.width() - decorationSize.width()) / \
2;
- painter->drawPixmap(iconX, option.rect.top() + \
style->pixelMetric(QStyle::PM_FocusFrameVMargin), decorationSize.width(), \
decorationSize.height(), pixmap);
-
- QRect textRectangle = option.rect;
- textRectangle.setTop(textRectangle.top() + decorationSize.height() + \
style->pixelMetric(QStyle::PM_FocusFrameVMargin));
- painter->drawText(textRectangle, Qt::AlignHCenter | Qt::TextWordWrap, \
index.data(Qt::DisplayRole).toString());
- painter->restore();
-}
-
-// Method taken from KFileItemDelegate. Check whether it has been moved to
-// kdefx/kdrawutil.cpp as the comment says on Fredrik's code. If so, remove
-// this code (duplication), and use the library one.
-QPainterPath ModuleIconItemDelegate::roundedRectangle(const QRectF &rect, qreal \
radius) const
-{
- QPainterPath path(QPointF(rect.left(), rect.top() + radius));
- path.quadTo(rect.left(), rect.top(), rect.left() + radius, rect.top()); // \
Top left corner
- path.lineTo(rect.right() - radius, rect.top()); // \
Top side
- path.quadTo(rect.right(), rect.top(), rect.right(), rect.top() + radius); // \
Top right corner
- path.lineTo(rect.right(), rect.bottom() - radius); // \
Right side
- path.quadTo(rect.right(), rect.bottom(), rect.right() - radius, rect.bottom()); // \
Bottom right corner
- path.lineTo(rect.left() + radius, rect.bottom()); // \
Bottom side
- path.quadTo(rect.left(), rect.bottom(), rect.left(), rect.bottom() - radius); // \
Bottom left corner
- path.closeSubpath();
-
- return path;
-}
-
ModuleIconItem::ModuleIconItem( QListWidget* parent, const KCModuleInfo& module)
: QListWidgetItem(SmallIcon( module.icon(), IMAGE_SIZE ), module.moduleName(), \
parent), imageName(module.icon())
--- trunk/KDE/kdebase/workspace/systemsettings/moduleiconitem.h #784650:784651
@@ -30,20 +30,7 @@
class KCModuleInfo;
-class ModuleIconItemDelegate : public QItemDelegate
-{
- public:
- ModuleIconItemDelegate(QObject *parent);
-
- void paint(QPainter *painter, const QStyleOptionViewItem &option, const \
QModelIndex &index) const;
- private:
- // Method taken from KFileItemDelegate. Check whether it has been moved to
- // kdefx/kdrawutil.cpp as the comment says on Fredrik's code. If so, remove
- // this code (duplication), and use the library one.
- QPainterPath roundedRectangle(const QRectF &rect, qreal radius) const;
-};
-
/**
* Stores information about what modules goes with this item.
* Also provides means of loading the enabled/disabled image (see kcmsearch).
--- trunk/KDE/kdebase/workspace/systemsettings/modulesview.h #784650:784651
@@ -41,7 +41,6 @@
setMovement(Static);
setFrameShape(NoFrame);
setWordWrap(true);
- setItemDelegate(new ModuleIconItemDelegate(this));
}
// Figure out the hight/width to have only one row
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic