57
bool DolphinModel::setData(const QModelIndex& index, const QVariant& value, int role)
59
if ((index.column() == DolphinModel::Version) && (role == Qt::DecorationRole)) {
60
// TODO: remove data again when items are deleted...
62
const QPersistentModelIndex key = index;
63
const KVersionControlPlugin::VersionState state = static_cast<KVersionControlPlugin::VersionState>(value.toInt());
64
if (m_revisionHash.value(key, KVersionControlPlugin::UnversionedVersion) != state) {
65
if (!m_hasVersionData) {
66
connect(this, SIGNAL(rowsRemoved (const QModelIndex&, int, int)),
67
this, SLOT(slotRowsRemoved(const QModelIndex&, int, int)));
68
m_hasVersionData = true;
71
m_revisionHash.insert(key, state);
72
emit dataChanged(index, index);
77
return KDirModel::setData(index, value, role);
62
80
QVariant DolphinModel::data(const QModelIndex& index, int role) const
65
83
case KCategorizedSortFilterProxyModel::CategoryDisplayRole:
66
84
return displayRoleData(index);
67
86
case KCategorizedSortFilterProxyModel::CategorySortRole:
68
87
return sortRoleData(index);
89
case Qt::DecorationRole:
90
if (index.column() == DolphinModel::Version) {
91
return m_revisionHash.value(index, KVersionControlPlugin::UnversionedVersion);
96
if (index.column() == DolphinModel::Version) {
97
switch (m_revisionHash.value(index, KVersionControlPlugin::UnversionedVersion)) {
98
case KVersionControlPlugin::NormalVersion:
99
return i18nc("@item::intable", "Normal");
100
case KVersionControlPlugin::UpdateRequiredVersion:
101
return i18nc("@item::intable", "Update required");
102
case KVersionControlPlugin::LocallyModifiedVersion:
103
return i18nc("@item::intable", "Locally modified");
104
case KVersionControlPlugin::AddedVersion:
105
return i18nc("@item::intable", "Added");
106
case KVersionControlPlugin::RemovedVersion:
107
return i18nc("@item::intable", "Removed");
108
case KVersionControlPlugin::ConflictingVersion:
109
return i18nc("@item::intable", "Conflicting");
110
case KVersionControlPlugin::UnversionedVersion:
112
return i18nc("@item::intable", "Unversioned");
70
return KDirModel::data(index, role);
74
int DolphinModel::columnCount(const QModelIndex &parent) const
121
return KDirModel::data(index, role);
124
QVariant DolphinModel::headerData(int section, Qt::Orientation orientation, int role) const
126
if ((orientation == Qt::Horizontal) && (role == Qt::DisplayRole)) {
127
if (section < KDirModel::ColumnCount) {
128
return KDirModel::headerData(section, orientation, role);
131
Q_ASSERT(section == DolphinModel::Version);
132
return i18nc("@title::column", "Version");
137
int DolphinModel::columnCount(const QModelIndex& parent) const
76
139
return KDirModel::columnCount(parent) + (ExtraColumnCount - ColumnCount);
79
quint32 DolphinModel::ratingForIndex(const QModelIndex& index)
84
const DolphinModel* dolphinModel = static_cast<const DolphinModel*>(index.model());
85
KFileItem item = dolphinModel->itemForIndex(index);
87
const Nepomuk::Resource resource(item.url().url(), Soprano::Vocabulary::Xesam::File());
88
rating = resource.rating();
97
QString DolphinModel::tagsForIndex(const QModelIndex& index)
102
const DolphinModel* dolphinModel = static_cast<const DolphinModel*>(index.model());
103
KFileItem item = dolphinModel->itemForIndex(index);
104
if (!item.isNull()) {
105
const Nepomuk::Resource resource(item.url().url(), Soprano::Vocabulary::Xesam::File());
106
const QList<Nepomuk::Tag> tags = resource.tags();
107
QStringList stringList;
108
foreach (const Nepomuk::Tag& tag, tags) {
109
stringList.append(tag.label());
113
foreach (const QString& str, stringList) {
118
if (!tagsString.isEmpty()) {
119
tagsString.resize(tagsString.size() - 2);
142
void DolphinModel::clearVersionData()
144
m_revisionHash.clear();
145
m_hasVersionData = false;
148
bool DolphinModel::hasVersionData() const
150
return m_hasVersionData;
153
void DolphinModel::slotRowsRemoved(const QModelIndex& parent, int start, int end)
155
if (m_hasVersionData) {
156
const int column = parent.column();
157
for (int row = start; row <= end; ++row) {
158
m_revisionHash.remove(parent.child(row, column));
130
163
QVariant DolphinModel::displayRoleData(const QModelIndex& index) const