]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kcategorydrawer.cpp
SVN_SILENT made messages (.desktop file)
[dolphin.git] / src / kcategorydrawer.cpp
index 56c538d4e7ced426c098697ac2c5e1d36e132c22..6d82bf96bbf9a3ec33ca1517566f41f1ff2a30d7 100644 (file)
@@ -1,6 +1,6 @@
 /**
   * This file is part of the KDE project
-  * Copyright (C) 2007 Rafael Fernández López <ereslibre@gmail.com>
+  * Copyright (C) 2007 Rafael Fernández López <ereslibre@kde.org>
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Library General Public
@@ -23,6 +23,7 @@
 #include <QPainter>
 #include <QStyleOption>
 
+#include <kiconloader.h>
 #include <kcategorizedsortfilterproxymodel.h>
 
 KCategoryDrawer::KCategoryDrawer()
@@ -34,11 +35,11 @@ KCategoryDrawer::~KCategoryDrawer()
 }
 
 void KCategoryDrawer::drawCategory(const QModelIndex &index,
-                                   int sortRole,
+                                   int /*sortRole*/,
                                    const QStyleOption &option,
                                    QPainter *painter) const
 {
-    const QString category = index.model()->data(index, KCategorizedSortFilterProxyModel::CategoryRole).toString();
+    const QString category = index.model()->data(index, KCategorizedSortFilterProxyModel::CategoryDisplayRole).toString();
 
     QColor color;
 
@@ -54,13 +55,6 @@ void KCategoryDrawer::drawCategory(const QModelIndex &index,
     painter->save();
     painter->setRenderHint(QPainter::Antialiasing);
 
-    QStyleOptionButton opt;
-
-    opt.rect = option.rect;
-    opt.palette = option.palette;
-    opt.direction = option.direction;
-    opt.text = category;
-
     if (option.state & QStyle::State_Selected)
     {
         QColor selected = option.palette.color(QPalette::Highlight);
@@ -91,15 +85,13 @@ void KCategoryDrawer::drawCategory(const QModelIndex &index,
 
     QFont painterFont = painter->font();
     painterFont.setWeight(QFont::Bold);
-    painterFont.setPointSize(painterFont.pointSize() + 2);
     QFontMetrics metrics(painterFont);
     painter->setFont(painterFont);
 
-    QPainterPath path;
-    path.addRect(option.rect.left(),
-                 option.rect.bottom() - 2,
-                 option.rect.width(),
-                 2);
+    QRect lineRect(option.rect.left(),
+                   option.rect.bottom() - 1,
+                   option.rect.width(),
+                   1);
 
     QLinearGradient gradient(option.rect.topLeft(),
                              option.rect.bottomRight());
@@ -108,8 +100,7 @@ void KCategoryDrawer::drawCategory(const QModelIndex &index,
     gradient.setColorAt(option.direction == Qt::LeftToRight ? 1
                                                             : 0, Qt::transparent);
 
-    painter->setBrush(gradient);
-    painter->fillPath(path, gradient);
+    painter->fillRect(lineRect, gradient);
 
     painter->setPen(color);
 
@@ -119,7 +110,9 @@ void KCategoryDrawer::drawCategory(const QModelIndex &index,
     painter->restore();
 }
 
-int KCategoryDrawer::categoryHeight(const QStyleOption &option) const
+int KCategoryDrawer::categoryHeight(const QModelIndex &index, const QStyleOption &option) const
 {
-    return option.fontMetrics.height() + 6 /* 4 separator; 2 gradient */;
+    Q_UNUSED(index);
+
+    return option.fontMetrics.height() + 4 /* 3 separator; 1 gradient */;
 }