Branch 'kolab/integration/4.13.0' - 3 commits - akonadi/changerecorder_p.cpp akonadi/changerecorder_p.h akonadi/entitytreemodel.cpp akonadi/entitytreemodel.h akonadi/entitytreemodel_p.cpp akonadi/entitytreemodel_p.h akonadi/itemmodifyjob.cpp
Christian Mollekopf
mollekopf at kolabsys.com
Fri Oct 24 15:57:54 CEST 2014
akonadi/changerecorder_p.cpp | 134 ++++++++++++++----------------------------
akonadi/changerecorder_p.h | 2
akonadi/entitytreemodel.cpp | 2
akonadi/entitytreemodel.h | 3
akonadi/entitytreemodel_p.cpp | 33 ----------
akonadi/entitytreemodel_p.h | 2
akonadi/itemmodifyjob.cpp | 8 +-
7 files changed, 54 insertions(+), 130 deletions(-)
New commits:
commit c9b49056dd276762d924545dcb2a85ef96eb19a1
Author: Christian Mollekopf <chrigi_1 at fastmail.fm>
Date: Fri Oct 24 15:57:22 2014 +0200
ItemModifyJob: support an empty set of tags.
Required to clear tags.
diff --git a/akonadi/itemmodifyjob.cpp b/akonadi/itemmodifyjob.cpp
index 4d52cdf..075aade 100644
--- a/akonadi/itemmodifyjob.cpp
+++ b/akonadi/itemmodifyjob.cpp
@@ -119,9 +119,13 @@ void ItemModifyJobPrivate::setSilent( bool silent )
QByteArray ItemModifyJobPrivate::tagsToCommandParameter(const Tag::List &tags) const
{
QByteArray c;
- if (tags.first().id() >= 0) {
+ if (tags.isEmpty() || (tags.first().id() >= 0)) {
c += "TAGS";
- c += ' ' + ProtocolHelper::tagSetToImapSequenceSet(tags);
+ if (tags.isEmpty()) {
+ c += " ()";
+ } else {
+ c += ' ' + ProtocolHelper::tagSetToImapSequenceSet(tags);
+ }
} else if (std::find_if(tags.constBegin(), tags.constEnd(),
boost::bind(&QByteArray::isEmpty, boost::bind(&Tag::remoteId, _1)))
== tags.constEnd()) {
commit 111641b04459b0569a8ed6ec1670076fa1232ce3
Author: Christian Mollekopf <chrigi_1 at fastmail.fm>
Date: Fri Oct 24 13:19:24 2014 +0200
ChangeRecorder: Fixed dumpNotificationListToString
Instead of reimplementing the change file reading (including bugs), reuse what is there already.
diff --git a/akonadi/changerecorder_p.cpp b/akonadi/changerecorder_p.cpp
index 6b3fb4f..54eb240 100644
--- a/akonadi/changerecorder_p.cpp
+++ b/akonadi/changerecorder_p.cpp
@@ -119,7 +119,7 @@ void ChangeRecorderPrivate::loadNotifications()
QFile file(changesFileName);
if (file.open(QIODevice::ReadOnly)) {
m_needFullSave = false;
- pendingNotifications = loadFrom(&file);
+ pendingNotifications = loadFrom(&file, m_needFullSave);
} else {
m_needFullSave = true;
}
@@ -130,7 +130,7 @@ static const quint64 s_currentVersion = Q_UINT64_C(0x000300000000);
static const quint64 s_versionMask = Q_UINT64_C(0xFFFF00000000);
static const quint64 s_sizeMask = Q_UINT64_C(0x0000FFFFFFFF);
-QQueue<NotificationMessageV3> ChangeRecorderPrivate::loadFrom(QIODevice *device)
+QQueue<NotificationMessageV3> ChangeRecorderPrivate::loadFrom(QIODevice *device, bool &needsFullSave) const
{
QDataStream stream(device);
stream.setVersion(QDataStream::Qt_4_6);
@@ -157,7 +157,7 @@ QQueue<NotificationMessageV3> ChangeRecorderPrivate::loadFrom(QIODevice *device)
// If we skip the first N items, then we'll need to rewrite the file on saving.
// Also, if the file is old, it needs to be rewritten.
- m_needFullSave = startOffset > 0 || version == 0;
+ needsFullSave = startOffset > 0 || version == 0;
for (quint64 i = 0; i < size && !stream.atEnd(); ++i) {
NotificationMessageV2 msg;
@@ -238,73 +238,44 @@ QQueue<NotificationMessageV3> ChangeRecorderPrivate::loadFrom(QIODevice *device)
return list;
}
+static QString join(const QSet<QByteArray> &set)
+{
+ QString string;
+ Q_FOREACH (const QByteArray &b, set) {
+ string += QString::fromLatin1(b) + QLatin1String(", ");
+ }
+ return string;
+}
+
+static QString join(const QList<qint64> &set)
+{
+ QString string;
+ Q_FOREACH (qint64 b, set) {
+ string += QString::number(b) + QLatin1String(", ");
+ }
+ return string;
+}
+
QString ChangeRecorderPrivate::dumpNotificationListToString() const
{
if (!settings) {
return QString::fromLatin1("No settings set in ChangeRecorder yet.");
}
- QString result;
const QString changesFileName = notificationsFileName();
QFile file(changesFileName);
+
if (!file.open(QIODevice::ReadOnly)) {
return QString::fromLatin1("Error reading ") + changesFileName;
}
- QDataStream stream(&file);
- stream.setVersion(QDataStream::Qt_4_6);
-
- QByteArray sessionId, resource, destResource;
- int type, operation, entityCnt;
- quint64 parentCollection, parentDestCollection;
- QString remoteId, remoteRevision, mimeType;
- QSet<QByteArray> itemParts, addedFlags, removedFlags;
- QSet<qint64> addedTags, removedTags;
- QVariantList items;
-
- QStringList list;
-
- quint64 sizeAndVersion;
- stream >> sizeAndVersion;
-
- const quint64 size = sizeAndVersion & s_sizeMask;
- const quint64 version = (sizeAndVersion & s_versionMask) >> 32;
-
- quint64 startOffset = 0;
- if (version >= 1) {
- stream >> startOffset;
- }
-
- for (quint64 i = 0; i < size && !stream.atEnd(); ++i) {
- stream >> sessionId;
- stream >> type;
- stream >> operation;
- stream >> entityCnt;
- for (int j = 0; j < entityCnt; ++j) {
- QVariantMap map;
- stream >> map[QLatin1String("uid")];
- stream >> map[QLatin1String("remoteId")];
- stream >> map[QLatin1String("remoteRevision")];
- stream >> map[QLatin1String("mimeType")];
- items << map;
- }
- stream >> resource;
- stream >> destResource;
- stream >> parentCollection;
- stream >> parentDestCollection;
- stream >> itemParts;
- stream >> addedFlags;
- stream >> removedFlags;
- if (version == 3) {
- stream >> addedTags;
- stream >> removedTags;
- }
-
- if (i < startOffset) {
- continue;
- }
+ QString result;
+ bool dummy;
+ const QQueue<NotificationMessageV3> notifications = loadFrom(&file, dummy);
+ Q_FOREACH(const NotificationMessageV3 &n, notifications) {
+ n.toString();
QString typeString;
- switch (type) {
+ switch (n.type()) {
case NotificationMessageV2::Collections:
typeString = QLatin1String("Collections");
break;
@@ -320,7 +291,7 @@ QString ChangeRecorderPrivate::dumpNotificationListToString() const
};
QString operationString;
- switch (operation) {
+ switch (n.operation()) {
case NotificationMessageV2::Add:
operationString = QLatin1String("Add");
break;
@@ -356,41 +327,26 @@ QString ChangeRecorderPrivate::dumpNotificationListToString() const
break;
};
- QStringList itemPartsList, addedFlagsList, removedFlagsList, addedTagsList, removedTagsList;
- foreach (const QByteArray &b, itemParts) {
- itemPartsList.push_back(QString::fromLatin1(b));
- }
- foreach (const QByteArray &b, addedFlags) {
- addedFlagsList.push_back(QString::fromLatin1(b));
- }
- foreach (const QByteArray &b, removedFlags) {
- removedFlagsList.push_back(QString::fromLatin1(b));
- }
- foreach (qint64 id, addedTags) {
- addedTagsList.push_back(QString::number(id));
- }
- foreach (qint64 id, removedTags) {
- removedTagsList.push_back(QString::number(id)) ;
- }
+ const QString entities = join(n.entities().keys());
+ const QString addedTags = join(n.addedTags().toList());
+ const QString removedTags = join(n.removedTags().toList());
const QString entry = QString::fromLatin1("session=%1 type=%2 operation=%3 items=%4 resource=%5 destResource=%6 parentCollection=%7 parentDestCollection=%8 itemParts=%9 addedFlags=%10 removedFlags=%11 addedTags=%12 removedTags=%13")
- .arg(QString::fromLatin1(sessionId))
- .arg(typeString)
- .arg(operationString)
- .arg(QVariant(items).toString())
- .arg(QString::fromLatin1(resource))
- .arg(QString::fromLatin1(destResource))
- .arg(parentCollection)
- .arg(parentDestCollection)
- .arg(itemPartsList.join(QLatin1String(", ")))
- .arg(addedFlagsList.join(QLatin1String(", ")))
- .arg(removedFlagsList.join(QLatin1String(", ")))
- .arg(addedTagsList.join(QLatin1String(", ")))
- .arg(removedTagsList.join(QLatin1String(", ")));
-
+ .arg(QString::fromLatin1(n.sessionId()))
+ .arg(typeString)
+ .arg(operationString)
+ .arg(entities)
+ .arg(QString::fromLatin1(n.resource()))
+ .arg(QString::fromLatin1(n.destinationResource()))
+ .arg(n.parentCollection())
+ .arg(n.parentDestCollection())
+ .arg(join(n.itemParts()))
+ .arg(join(n.addedFlags()))
+ .arg(join(n.removedFlags()))
+ .arg(addedTags)
+ .arg(removedTags);
result += entry + QLatin1Char('\n');
}
-
return result;
}
diff --git a/akonadi/changerecorder_p.h b/akonadi/changerecorder_p.h
index d25b6ff..408be91 100644
--- a/akonadi/changerecorder_p.h
+++ b/akonadi/changerecorder_p.h
@@ -47,7 +47,7 @@ public:
QString notificationsFileName() const;
void loadNotifications();
- QQueue<NotificationMessageV3> loadFrom(QIODevice *device);
+ QQueue<NotificationMessageV3> loadFrom(QIODevice *device, bool &needsFullSave) const;
QString dumpNotificationListToString() const;
void addToStream(QDataStream &stream, const NotificationMessageV3 &msg);
void saveNotifications();
commit 029e3adcf428a4f90382e5ba4ffd02d576299ff5
Author: David Faure <faure at kde.org>
Date: Fri Oct 17 09:02:09 2014 +0200
Remove per-collection sync progress, unused and slow.
It was only used by the QML GUI, and it triggers a large amount of dataChanged
signals in a model that has many many layers of proxymodels on top.
diff --git a/akonadi/entitytreemodel.cpp b/akonadi/entitytreemodel.cpp
index fbfa817..5cc824f 100644
--- a/akonadi/entitytreemodel.cpp
+++ b/akonadi/entitytreemodel.cpp
@@ -314,7 +314,7 @@ QVariant EntityTreeModel::data(const QModelIndex &index, int role) const
return d->m_pendingCollectionRetrieveJobs.contains(collection.id()) ? FetchingState : IdleState;
}
case CollectionSyncProgressRole: {
- return d->m_collectionSyncProgress.value(collection.id());
+ return QVariant(); // no longer supported
}
case IsPopulatedRole: {
return d->m_populatedCols.contains(collection.id());
diff --git a/akonadi/entitytreemodel.h b/akonadi/entitytreemodel.h
index 1e2a544..6795eed 100644
--- a/akonadi/entitytreemodel.h
+++ b/akonadi/entitytreemodel.h
@@ -349,7 +349,7 @@ public:
EntityUrlRole, ///< The akonadi:/ Url of the entity as a string. Item urls will contain the mimetype.
UnreadCountRole, ///< Returns the number of unread items in a collection. @since 4.5
FetchStateRole, ///< Returns the FetchState of a particular item. @since 4.5
- CollectionSyncProgressRole, ///< Returns the progress of synchronization in percent for a particular collection. @since 4.6
+ CollectionSyncProgressRole, ///< Returns the progress of synchronization in percent for a particular collection. @since 4.6. Deprecated since 4.14.3.
IsPopulatedRole, ///< Returns whether a Collection has been populated, i.e. whether its items have been fetched. @since 4.10
UserRole = Qt::UserRole + 500, ///< First role for user extensions.
TerminalUserRole = 2000, ///< Last role for user extensions. Don't use a role beyond this or headerData will break.
@@ -753,7 +753,6 @@ private:
Q_PRIVATE_SLOT(d_func(), void monitoredItemUnlinked(const Akonadi::Item &, const Akonadi::Collection &))
Q_PRIVATE_SLOT(d_func(), void changeFetchState(const Akonadi::Collection &))
- Q_PRIVATE_SLOT(d_func(), void agentInstanceAdvancedStatusChanged(const QString &, const QVariantMap &))
Q_PRIVATE_SLOT(d_func(), void agentInstanceRemoved(Akonadi::AgentInstance))
Q_PRIVATE_SLOT(d_func(), void monitoredItemsRetrieved(KJob *job))
//@endcond
diff --git a/akonadi/entitytreemodel_p.cpp b/akonadi/entitytreemodel_p.cpp
index 3c3d4d2..1f480ab 100644
--- a/akonadi/entitytreemodel_p.cpp
+++ b/akonadi/entitytreemodel_p.cpp
@@ -90,14 +90,6 @@ EntityTreeModelPrivate::EntityTreeModelPrivate(EntityTreeModel *parent)
// using collection as a parameter of a queued call in runItemFetchJob()
qRegisterMetaType<Collection>();
- org::freedesktop::Akonadi::AgentManager *manager =
- new org::freedesktop::Akonadi::AgentManager(ServerManager::serviceName(Akonadi::ServerManager::Control),
- QLatin1String("/AgentManager"),
- DBusConnectionPool::threadConnection(), q_ptr);
-
- QObject::connect(manager, SIGNAL(agentInstanceAdvancedStatusChanged(QString,QVariantMap)),
- q_ptr, SLOT(agentInstanceAdvancedStatusChanged(QString,QVariantMap)));
-
Akonadi::AgentManager *agentManager = Akonadi::AgentManager::self();
QObject::connect(agentManager, SIGNAL(instanceRemoved(Akonadi::AgentInstance)),
q_ptr, SLOT(agentInstanceRemoved(Akonadi::AgentInstance)));
@@ -221,31 +213,6 @@ void EntityTreeModelPrivate::agentInstanceRemoved(const Akonadi::AgentInstance &
}
}
-void EntityTreeModelPrivate::agentInstanceAdvancedStatusChanged(const QString &, const QVariantMap &status)
-{
- const QString key = status.value(QLatin1String("key")).toString();
- if (key != QLatin1String("collectionSyncProgress")) {
- return;
- }
-
- const Collection::Id collectionId = status.value(QLatin1String("collectionId")).toLongLong();
- const uint percent = status.value(QLatin1String("percent")).toUInt();
- if (m_collectionSyncProgress.value(collectionId) == percent) {
- return;
- }
- m_collectionSyncProgress.insert(collectionId, percent);
-
- const QModelIndex collectionIndex = indexForCollection(Collection(collectionId));
- if (!collectionIndex.isValid()) {
- return;
- }
-
- Q_Q(EntityTreeModel);
- // This is really slow (80 levels of method calls in proxy models...), and called
- // very often during an imap sync...
- q->dataChanged(collectionIndex, collectionIndex);
-}
-
void EntityTreeModelPrivate::fetchItems(const Collection &parent)
{
Q_Q(const EntityTreeModel);
diff --git a/akonadi/entitytreemodel_p.h b/akonadi/entitytreemodel_p.h
index 39f4e1c..d022226 100644
--- a/akonadi/entitytreemodel_p.h
+++ b/akonadi/entitytreemodel_p.h
@@ -124,7 +124,6 @@ public:
void fillModel();
void changeFetchState(const Collection &parent);
- void agentInstanceAdvancedStatusChanged(const QString &, const QVariantMap &);
void agentInstanceRemoved(const Akonadi::AgentInstance &instace);
QHash<Collection::Id, Collection> m_collections;
@@ -150,7 +149,6 @@ public:
bool m_includeStatistics;
bool m_showRootCollection;
bool m_collectionTreeFetched;
- QHash<Collection::Id, uint> m_collectionSyncProgress;
/**
* Called after the root collection was fetched by fillModel
More information about the commits
mailing list