diff options
| author | Peter Penz <[email protected]> | 2009-07-12 14:00:45 +0000 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2009-07-12 14:00:45 +0000 |
| commit | fa4680cb38028aceb68d41e1937d27c71d1f121b (patch) | |
| tree | da709625c38a42bf448077d985c75b0365a58252 /src/dolphinfileitemdelegate.cpp | |
| parent | 2df2d4ea7ee63a43a327b4ffb1c5cddd176aff91 (diff) | |
Enable Dolphin to show the revision states of files that are under revision control systems like SVN, Git, CVS, ... The current code is an early draft and it is planned that all plugins (SVN, Git, CVS, ...) are maintained outside Dolphin. If the API is stable enough, a discussion will be done at [email protected] regarding the location of the plugins (the current implementation of SubversionPlugin is only temporary located in Dolphin for testing purposes).
RevisionControlObserver is implemented in a way that no recognizable slowdown is given for directories that are not under revision control.
CCBUG: 192158
svn path=/trunk/KDE/kdebase/apps/; revision=995351
Diffstat (limited to 'src/dolphinfileitemdelegate.cpp')
| -rw-r--r-- | src/dolphinfileitemdelegate.cpp | 39 |
1 files changed, 31 insertions, 8 deletions
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 <dolphinmodel.h> +#include <kfileitem.h> + #include <QAbstractItemModel> #include <QAbstractProxyModel> #include <QFontMetrics> - -#include <kdirmodel.h> -#include <kfileitem.h> +#include <QPainter> 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<const QAbstractProxyModel*>(index.model()); + const DolphinModel* dolphinModel = static_cast<const DolphinModel*>(proxyModel->sourceModel()); + if (m_hasMinimizedNameColumn && (index.column() == KDirModel::Name)) { QStyleOptionViewItemV4 opt(option); - const QAbstractProxyModel* proxyModel = static_cast<const QAbstractProxyModel*>(index.model()); - const KDirModel* dirModel = static_cast<const KDirModel*>(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<DolphinModel::RevisionState>(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) |
