X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/737b74aa294e05cebc2cd1e48a4fa66cf62f222e..c33b01efb2aed904af9ffaef27fb3b0b4bdda37b:/src/dolphincategorydrawer.cpp diff --git a/src/dolphincategorydrawer.cpp b/src/dolphincategorydrawer.cpp index 9996672d7..b96387646 100644 --- a/src/dolphincategorydrawer.cpp +++ b/src/dolphincategorydrawer.cpp @@ -18,24 +18,22 @@ * Boston, MA 02110-1301, USA. */ +#include "config-nepomuk.h" + #include "dolphincategorydrawer.h" -#include "ratingpainter.h" #include #include #include +#ifdef HAVE_NEPOMUK +#include +#endif + #include #include #include #include -#include -#ifdef HAVE_NEPOMUK -#include -#include -#include -#endif - #include "dolphinview.h" #include "dolphinmodel.h" @@ -50,6 +48,8 @@ DolphinCategoryDrawer::~DolphinCategoryDrawer() void DolphinCategoryDrawer::drawCategory(const QModelIndex &index, int sortRole, const QStyleOption &option, QPainter *painter) const { + Q_UNUSED(sortRole); + QRect starRect = option.rect; int iconSize = KIconLoader::global()->currentSize(KIconLoader::Small); @@ -118,9 +118,9 @@ void DolphinCategoryDrawer::drawCategory(const QModelIndex &index, int sortRole, QPainterPath path; path.addRect(option.rect.left(), - option.rect.bottom() - 2, + option.rect.bottom() - 1, option.rect.width(), - 2); + 1); QLinearGradient gradient(option.rect.topLeft(), option.rect.bottomRight()); @@ -134,15 +134,15 @@ void DolphinCategoryDrawer::drawCategory(const QModelIndex &index, int sortRole, if (option.direction == Qt::LeftToRight) { - opt.rect.setLeft(opt.rect.left() + (iconSize / 4)); - starRect.setLeft(starRect.left() + (iconSize / 4)); - starRect.setRight(starRect.right() + (iconSize / 4)); + opt.rect.setLeft(opt.rect.left()); + starRect.setLeft(starRect.left()); + starRect.setRight(starRect.right()); } else { - opt.rect.setRight(opt.rect.width() - (iconSize / 4)); - starRect.setLeft(starRect.width() - iconSize); - starRect.setRight(starRect.width() - (iconSize / 4)); + opt.rect.setRight(opt.rect.width()); + starRect.setLeft(starRect.width()); + starRect.setRight(starRect.width()); } bool paintIcon = true; @@ -177,7 +177,7 @@ void DolphinCategoryDrawer::drawCategory(const QModelIndex &index, int sortRole, } else { - icon = KIconLoader::global()->loadIcon("user", KIconLoader::NoGroup, option.fontMetrics.height()); + icon = KIconLoader::global()->loadIcon("user-identity", KIconLoader::NoGroup, option.fontMetrics.height()); } opt.rect.setTop(opt.rect.top() - icon.height()); @@ -215,7 +215,7 @@ void DolphinCategoryDrawer::drawCategory(const QModelIndex &index, int sortRole, QRect ratingRect( option.rect ); ratingRect.setTop(option.rect.top() + (option.rect.height() / 2) - (iconSize / 2)); ratingRect.setHeight( iconSize ); - Nepomuk::RatingPainter::drawRating( painter, ratingRect, Qt::AlignLeft, category.toInt() ); + KRatingPainter::paintRating( painter, ratingRect, Qt::AlignLeft, category.toInt() ); break; } @@ -241,14 +241,14 @@ void DolphinCategoryDrawer::drawCategory(const QModelIndex &index, int sortRole, if (paintText) { opt.rect.setTop(option.rect.top() + (iconSize / 4)); - opt.rect.setBottom(opt.rect.bottom() - 2); + opt.rect.setBottom(opt.rect.bottom() - 1); painter->setPen(color); QRect textRect = opt.rect; if (option.direction == Qt::RightToLeft) { - textRect.setWidth(textRect.width() - (paintIcon ? icon.width() + (iconSize / 2) + textRect.setWidth(textRect.width() - (paintIcon ? icon.width() + (iconSize / 4) : -(iconSize / 4))); } @@ -259,9 +259,23 @@ void DolphinCategoryDrawer::drawCategory(const QModelIndex &index, int sortRole, painter->restore(); } -int DolphinCategoryDrawer::categoryHeight(const QStyleOption &option) const +int DolphinCategoryDrawer::categoryHeight(const QModelIndex &index, const QStyleOption &option) const { int iconSize = KIconLoader::global()->currentSize(KIconLoader::Small); + int heightWithoutIcon = option.fontMetrics.height() + (iconSize / 4) * 2 + 1; /* 1 pixel-width gradient */ + bool paintIcon; + + switch (index.column()) { + case KDirModel::Owner: + case KDirModel::Type: + paintIcon = true; + break; + default: + paintIcon = false; + } + + if (paintIcon) + return qMax(heightWithoutIcon, iconSize + (iconSize / 4) * 2 + 1) /* 1 pixel-width gradient */; - return qMax(option.fontMetrics.height() + (iconSize / 4) * 2 + 2, iconSize + (iconSize / 4) * 2 + 2) /* 2 gradient */; + return heightWithoutIcon; }