]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinmodel.cpp
Increase version number to 1.5
[dolphin.git] / src / dolphinmodel.cpp
index 3b507a8957d7ced2c63bfcc4ab28bfa0fe8f7a6f..137274e0dffa7e12572568578ce3ed5e15807c72 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>
 #include <QDir>
 #include <QFileInfo>
 
-const char* DolphinModel::m_others = I18N_NOOP2("@title:group Name", "Others");
+const char* const DolphinModel::m_others = I18N_NOOP2("@title:group Name", "Others");
 
 DolphinModel::DolphinModel(QObject* parent) :
     KDirModel(parent),
     m_hasVersionData(false),
     m_revisionHash()
 {
+    setJobTransfersVisible(true);
 }
 
 DolphinModel::~DolphinModel()
@@ -101,24 +94,18 @@ QVariant DolphinModel::data(const QModelIndex& index, int role) const
         break;
 
     case Qt::DisplayRole:
-        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", "Unversioned");
-            }
+        switch (index.column()) {
+        case DolphinModel::LinkDest: {
+            const KDirModel *dirModel = qobject_cast<const KDirModel*>(index.model());
+            const KFileItem item = dirModel->itemForIndex(index);
+            return item.linkDest();
+        }
+
+        case DolphinModel::LocalPathOrUrl:
+            const KDirModel *dirModel = qobject_cast<const KDirModel*>(index.model());
+            const KFileItem item = dirModel->itemForIndex(index);
+            return item.localPath();
+            break;
         }
         break;
 
@@ -132,12 +119,14 @@ QVariant DolphinModel::data(const QModelIndex& index, int role) const
 QVariant DolphinModel::headerData(int section, Qt::Orientation orientation, int role) const
 {
     if ((orientation == Qt::Horizontal) && (role == Qt::DisplayRole)) {
-        if (section < KDirModel::ColumnCount) {
+        switch (section) {
+        case DolphinModel::LinkDest:
+            return i18nc("@title::column", "Link Destination");
+        case DolphinModel::LocalPathOrUrl:
+            return i18nc("@title::column", "Path");
+        default:
             return KDirModel::headerData(section, orientation, role);
         }
-
-        Q_ASSERT(section == DolphinModel::Version);
-        return i18nc("@title::column", "Version");
     }
     return QVariant();
 }
@@ -217,11 +206,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;
@@ -263,6 +248,11 @@ QVariant DolphinModel::displayRoleData(const QModelIndex& index) const
         }
 
         if (currentDate.year() == modifiedDate.year() && currentDate.month() == modifiedDate.month()) {
+            if (modifiedWeek > currentWeek) {
+                // use case: modified date = 2010-01-01, current date = 2010-01-22
+                //           modified week = 53,         current week = 3
+                modifiedWeek = 0;
+            }
             switch (currentWeek - modifiedWeek) {
             case 0:
                 switch (daysDistance) {
@@ -393,7 +383,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;
     }