diff options
| author | Rafael Fernández López <[email protected]> | 2008-01-02 01:21:39 +0000 |
|---|---|---|
| committer | Rafael Fernández López <[email protected]> | 2008-01-02 01:21:39 +0000 |
| commit | 743bec375187a51ed6b88256ff070e9f7e9f4929 (patch) | |
| tree | cc6948abd9d21ecc0b5074883f7d4dcaa21f9382 /src/kcategorydrawer.cpp | |
| parent | c6a4a3aa063fb25e163bed8dac8587efef8c02b5 (diff) | |
Better looking categories. Thanks to Aurélien Gâteau for the original patch.
CCMAIL: [email protected]
svn path=/trunk/KDE/kdebase/apps/; revision=755674
Diffstat (limited to 'src/kcategorydrawer.cpp')
| -rw-r--r-- | src/kcategorydrawer.cpp | 41 |
1 files changed, 11 insertions, 30 deletions
diff --git a/src/kcategorydrawer.cpp b/src/kcategorydrawer.cpp index 53cf059f1..6d82bf96b 100644 --- a/src/kcategorydrawer.cpp +++ b/src/kcategorydrawer.cpp @@ -35,7 +35,7 @@ KCategoryDrawer::~KCategoryDrawer() } void KCategoryDrawer::drawCategory(const QModelIndex &index, - int sortRole, + int /*sortRole*/, const QStyleOption &option, QPainter *painter) const { @@ -55,24 +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; - - int iconSize = KIconLoader::global()->currentSize(KIconLoader::Small); - - if (option.direction == Qt::LeftToRight) - { - opt.rect.setLeft(opt.rect.left() + (iconSize / 4)); - } - else - { - opt.rect.setRight(opt.rect.width() - (iconSize / 4)); - } - if (option.state & QStyle::State_Selected) { QColor selected = option.palette.color(QPalette::Highlight); @@ -103,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()); @@ -120,18 +100,19 @@ 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); - painter->drawText(opt.rect, Qt::AlignVCenter | Qt::AlignLeft, + painter->drawText(option.rect, Qt::AlignVCenter | Qt::AlignLeft, metrics.elidedText(category, Qt::ElideRight, option.rect.width())); 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 */; } |
