]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinmodel.cpp
assure that the widgets of the panels are resized after receiving the Polish event
[dolphin.git] / src / dolphinmodel.cpp
index c5ea06a363b7bf05709bfdfae3515a6560fffbed..3467c8a3822056df2905fcbe28a79f9a5c851ba2 100644 (file)
 
 #include "kcategorizedview.h"
 
-#include <config-nepomuk.h>
-#ifdef HAVE_NEPOMUK
-#include <nepomuk/global.h>
-#include <nepomuk/resource.h>
-#include <nepomuk/tag.h>
-#include <Soprano/Vocabulary/Xesam>
-#endif
-
 #include <kdatetime.h>
 #include <kdirmodel.h>
 #include <kfileitem.h>
@@ -53,7 +45,7 @@ const char* DolphinModel::m_others = I18N_NOOP2("@title:group Name", "Others");
 
 DolphinModel::DolphinModel(QObject* parent) :
     KDirModel(parent),
-    m_hasRevisionData(false),
+    m_hasVersionData(false),
     m_revisionHash()
 {
 }
@@ -64,16 +56,16 @@ DolphinModel::~DolphinModel()
 
 bool DolphinModel::setData(const QModelIndex& index, const QVariant& value, int role)
 {
-    if ((index.column() == DolphinModel::Revision) && (role == Qt::DecorationRole)) {
+    if ((index.column() == DolphinModel::Version) && (role == Qt::DecorationRole)) {
         // TODO: remove data again when items are deleted...
 
         const QPersistentModelIndex key = index;
-        const RevisionState state = static_cast<RevisionState>(value.toInt());
-        if (m_revisionHash.value(key, LocalRevision) != state) {
-            if (!m_hasRevisionData) {
+        const KVersionControlPlugin::VersionState state = static_cast<KVersionControlPlugin::VersionState>(value.toInt());
+        if (m_revisionHash.value(key, KVersionControlPlugin::UnversionedVersion) != state) {
+            if (!m_hasVersionData) {
                 connect(this, SIGNAL(rowsRemoved (const QModelIndex&, int, int)),
                         this, SLOT(slotRowsRemoved(const QModelIndex&, int, int)));
-                m_hasRevisionData = true;
+                m_hasVersionData = true;
             }
 
             m_revisionHash.insert(key, state);
@@ -95,20 +87,29 @@ QVariant DolphinModel::data(const QModelIndex& index, int role) const
         return sortRoleData(index);
 
     case Qt::DecorationRole:
-        if (index.column() == DolphinModel::Revision) {
-            return m_revisionHash.value(index, LocalRevision);
+        if (index.column() == DolphinModel::Version) {
+            return m_revisionHash.value(index, KVersionControlPlugin::UnversionedVersion);
         }
         break;
 
     case Qt::DisplayRole:
-        if (index.column() == DolphinModel::Revision) {
-            switch (m_revisionHash.value(index, LocalRevision)) {
-            case LatestRevision:
-                return i18nc("@item::intable", "Latest");
-
-            case LocalRevision:
+        if (index.column() == DolphinModel::Version) {
+            switch (m_revisionHash.value(index, KVersionControlPlugin::UnversionedVersion)) {
+            case KVersionControlPlugin::NormalVersion:
+                return i18nc("@item::intable", "Normal");
+            case KVersionControlPlugin::UpdateRequiredVersion:
+                return i18nc("@item::intable", "Update required");
+            case KVersionControlPlugin::LocallyModifiedVersion:
+                return i18nc("@item::intable", "Locally modified");
+            case KVersionControlPlugin::AddedVersion:
+                return i18nc("@item::intable", "Added");
+            case KVersionControlPlugin::RemovedVersion:
+                return i18nc("@item::intable", "Removed");
+            case KVersionControlPlugin::ConflictingVersion:
+                return i18nc("@item::intable", "Conflicting");
+            case KVersionControlPlugin::UnversionedVersion:
             default:
-                return i18nc("@item::intable", "Local");
+                return i18nc("@item::intable", "Unversioned");
             }
         }
         break;
@@ -127,8 +128,8 @@ QVariant DolphinModel::headerData(int section, Qt::Orientation orientation, int
             return KDirModel::headerData(section, orientation, role);
         }
 
-        Q_ASSERT(section == DolphinModel::Revision);
-        return i18nc("@title::column", "Revision");
+        Q_ASSERT(section == DolphinModel::Version);
+        return i18nc("@title::column", "Version");
     }
     return QVariant();
 }
@@ -138,18 +139,24 @@ int DolphinModel::columnCount(const QModelIndex& parent) const
     return KDirModel::columnCount(parent) + (ExtraColumnCount - ColumnCount);
 }
 
-bool DolphinModel::hasRevisionData() const
+void DolphinModel::clearVersionData()
 {
-    return m_hasRevisionData;
+    m_revisionHash.clear();
+    m_hasVersionData = false;
 }
 
-void DolphinModel::slotRowsRemoved(const QModelIndex& parent, int start, int end)
+bool DolphinModel::hasVersionData() const
 {
-    Q_ASSERT(hasRevisionData());
+    return m_hasVersionData;
+}
 
-    const int column = parent.column();
-    for (int row = start; row <= end; ++row) {
-        m_revisionHash.remove(parent.child(row, column));
+void DolphinModel::slotRowsRemoved(const QModelIndex& parent, int start, int end)
+{
+    if (m_hasVersionData) {
+        const int column = parent.column();
+        for (int row = start; row <= end; ++row) {
+            m_revisionHash.remove(parent.child(row, column));
+        }
     }
 }
 
@@ -202,11 +209,7 @@ QVariant DolphinModel::displayRoleData(const QModelIndex& index) const
                     }
                 }
 
-                if (!validCategory) {
-                    retString = validCategory ? *currA : i18nc("@title:group Name", m_others);
-                } else {
-                    retString = *currA;
-                }
+                retString = validCategory ? *currA : i18nc("@title:group Name", m_others);
             }
         }
         break;
@@ -354,7 +357,7 @@ QVariant DolphinModel::displayRoleData(const QModelIndex& index) const
         retString = item.mimeComment();
         break;
 
-    case DolphinModel::Revision:
+    case DolphinModel::Version:
         retString = "test";
         break;
     }
@@ -378,7 +381,7 @@ QVariant DolphinModel::sortRoleData(const QModelIndex& index) const
         retVariant = data(index, KCategorizedSortFilterProxyModel::CategoryDisplayRole);
         if (retVariant == i18nc("@title:group Name", m_others)) {
             // assure that the "Others" group is always the last categorization
-            retVariant = QString(QChar(QChar::ReplacementCharacter));
+            retVariant = QString('Z').append(QChar::ReplacementCharacter);
         }
         break;
     }