#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 RevisionControlPlugin::RevisionState state = static_cast<RevisionControlPlugin::RevisionState>(value.toInt());
- if (m_revisionHash.value(key, RevisionControlPlugin::UnversionedRevision) != 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::UnversionedRevision);
+ 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::UnversionedRevision)) {
- case RevisionControlPlugin::NormalRevision:
- return i18nc("@item::intable", "Normal");
- case RevisionControlPlugin::UpdateRequiredRevision:
- return i18nc("@item::intable", "Update required");
- case RevisionControlPlugin::LocallyModifiedRevision:
- return i18nc("@item::intable", "Locally modified");
- case RevisionControlPlugin::AddedRevision:
- return i18nc("@item::intable", "Added");
- case RevisionControlPlugin::RemovedRevision:
- return i18nc("@item::intable", "Removed");
- case RevisionControlPlugin::ConflictingRevision:
- return i18nc("@item::intable", "Conflicting");
- case RevisionControlPlugin::UnversionedRevision:
- 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:
+ // 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", "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);
}
-void DolphinModel::clearRevisionData()
+void DolphinModel::clearVersionData()
{
m_revisionHash.clear();
- m_hasRevisionData = false;
+ m_hasVersionData = false;
}
-bool DolphinModel::hasRevisionData() const
+bool DolphinModel::hasVersionData() const
{
- return m_hasRevisionData;
+ return m_hasVersionData;
}
void DolphinModel::slotRowsRemoved(const QModelIndex& parent, int start, int end)
{
- if (m_hasRevisionData) {
+ 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;
}