X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/2df2d4ea7ee63a43a327b4ffb1c5cddd176aff91..fa4680cb38028aceb68d41e1937d27c71d1f121b:/src/dolphinfileitemdelegate.cpp diff --git a/src/dolphinfileitemdelegate.cpp b/src/dolphinfileitemdelegate.cpp index 9be70647b..6478baf3b 100644 --- a/src/dolphinfileitemdelegate.cpp +++ b/src/dolphinfileitemdelegate.cpp @@ -19,12 +19,13 @@ #include "dolphinfileitemdelegate.h" +#include +#include + #include #include #include - -#include -#include +#include DolphinFileItemDelegate::DolphinFileItemDelegate(QObject* parent) : KFileItemDelegate(parent), @@ -40,17 +41,19 @@ void DolphinFileItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { + const QAbstractProxyModel* proxyModel = static_cast(index.model()); + const DolphinModel* dolphinModel = static_cast(proxyModel->sourceModel()); + if (m_hasMinimizedNameColumn && (index.column() == KDirModel::Name)) { QStyleOptionViewItemV4 opt(option); - const QAbstractProxyModel* proxyModel = static_cast(index.model()); - const KDirModel* dirModel = static_cast(proxyModel->sourceModel()); const QModelIndex dirIndex = proxyModel->mapToSource(index); - const KFileItem item = dirModel->itemForIndex(dirIndex); + const KFileItem item = dolphinModel->itemForIndex(dirIndex); if (!item.isNull()) { - // Symbolic links are displayed in an italic font - if (item.isLink()) + // symbolic links are displayed in an italic font + if (item.isLink()) { opt.font.setItalic(true); + } const int width = nameColumnWidth(item.text(), opt); opt.rect.setWidth(width); @@ -59,6 +62,26 @@ void DolphinFileItemDelegate::paint(QPainter* painter, } else { KFileItemDelegate::paint(painter, option, index); } + + if (dolphinModel->hasRevisionData()) { + // The currently shown items are under revision control. Show the current revision + // state above the decoration. + const QModelIndex dirIndex = proxyModel->mapToSource(index); + const QModelIndex revisionIndex = dolphinModel->index(dirIndex.row(), DolphinModel::Revision); + const QVariant data = dolphinModel->data(revisionIndex, Qt::DecorationRole); + const DolphinModel::RevisionState state = static_cast(data.toInt()); + + if (state != DolphinModel::LocalRevision) { + // TODO: The following code is just a proof of concept. Icons will be used later... + QColor color(200, 0, 0, 32); + switch (state) { + case DolphinModel::LatestRevision: color = QColor(0, 180, 0, 32); break; + // ... + default: break; + } + painter->fillRect(option.rect, color); + } + } } int DolphinFileItemDelegate::nameColumnWidth(const QString& name, const QStyleOptionViewItem& option)