#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_hasRevisionData(false),
+ m_hasVersionData(false),
m_revisionHash()
{
}
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 RevisionControlPlugin::RevisionState state = static_cast<RevisionControlPlugin::RevisionState>(value.toInt());
- if (m_revisionHash.value(key, RevisionControlPlugin::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);
return sortRoleData(index);
case Qt::DecorationRole:
- if (index.column() == DolphinModel::Revision) {
- return m_revisionHash.value(index, RevisionControlPlugin::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, RevisionControlPlugin::LocalRevision)) {
- case RevisionControlPlugin::LatestRevision:
- return i18nc("@item::intable", "Latest");
- case RevisionControlPlugin::EditingRevision:
- return i18nc("@item::intable", "Editing");
- case RevisionControlPlugin::UpdateRequiredRevision:
+ 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 RevisionControlPlugin::LocalRevision:
+ 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;
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();
}
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));
+ }
}
}
}
}
- if (!validCategory) {
- retString = validCategory ? *currA : i18nc("@title:group Name", m_others);
- } else {
- retString = *currA;
- }
+ retString = validCategory ? *currA : i18nc("@title:group Name", m_others);
}
}
break;
}
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) {
retString = item.mimeComment();
break;
- case DolphinModel::Revision:
+ case DolphinModel::Version:
retString = "test";
break;
}
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;
}