X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/b3db0a708a630d9f59857ab7dcbfe8f29e3e8eb9..ac73af7bedeebe2afa451249e8a6500651a6ec00:/src/kcategorydrawer.cpp diff --git a/src/kcategorydrawer.cpp b/src/kcategorydrawer.cpp index 56c538d4e..6d82bf96b 100644 --- a/src/kcategorydrawer.cpp +++ b/src/kcategorydrawer.cpp @@ -1,6 +1,6 @@ /** * This file is part of the KDE project - * Copyright (C) 2007 Rafael Fernández López + * Copyright (C) 2007 Rafael Fernández López * * 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 #include +#include #include 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 */; }