#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()
{
+ setJobTransfersVisible(true);
}
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);
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");
+ 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 LocalRevision:
- default:
- return i18nc("@item::intable", "Local");
- }
+ case DolphinModel::LocalPathOrUrl:
+ // TODO:
+ break;
}
break;
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::Revision);
- return i18nc("@title::column", "Revision");
}
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;
}