/**
* 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()
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;
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);
painter->setPen(color);
- painter->drawText(option.rect, Qt::AlignVCenter | Qt::AlignLeft,
+ painter->drawText(opt.rect, Qt::AlignVCenter | Qt::AlignLeft,
metrics.elidedText(category, Qt::ElideRight, option.rect.width()));
painter->restore();