/**
* 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
#include <QPainter>
#include <QStyleOption>
+#include <kiconloader.h>
#include <kcategorizedsortfilterproxymodel.h>
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;
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);
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());
gradient.setColorAt(option.direction == Qt::LeftToRight ? 1
: 0, Qt::transparent);
- painter->setBrush(gradient);
- painter->fillPath(path, gradient);
+ painter->fillRect(lineRect, gradient);
painter->setPen(color);
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 */;
}