Commit 4df13613 authored by Volker Krause's avatar Volker Krause
Browse files

Port imap, pop3 and ews away from deprecated QSet::fromList

Reviewers: dvratil

Reviewed By: dvratil

Subscribers: kde-pim

Tags: #kde_pim

Differential Revision: https://phabricator.kde.org/D27759
parent 6d6866c2
...@@ -70,7 +70,11 @@ template<typename T> ...@@ -70,7 +70,11 @@ template<typename T>
CollectionStateMonitor<T>::CollectionStateMonitor(QObject *parent, const QHash<QString, T> &stateHash, const QString &inboxId, const StateComparisonFunc &comparisonFunc, int recheckInterval) CollectionStateMonitor<T>::CollectionStateMonitor(QObject *parent, const QHash<QString, T> &stateHash, const QString &inboxId, const StateComparisonFunc &comparisonFunc, int recheckInterval)
: StateMonitorBase(parent) : StateMonitorBase(parent)
, mMonitor(this) , mMonitor(this)
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
, mPending(stateHash.keys().toSet()) , mPending(stateHash.keys().toSet())
#else
, mPending(stateHash.keyBegin(), stateHash.keyEnd())
#endif
, mStateHash(stateHash) , mStateHash(stateHash)
, mComparisonFunc(comparisonFunc) , mComparisonFunc(comparisonFunc)
, mInboxId(inboxId) , mInboxId(inboxId)
......
...@@ -36,7 +36,7 @@ Akonadi::Item MessageHelper::createItemFromMessage(const KMime::Message::Ptr &me ...@@ -36,7 +36,7 @@ Akonadi::Item MessageHelper::createItemFromMessage(const KMime::Message::Ptr &me
if (scope.mode == KIMAP::FetchJob::FetchScope::Flags) { if (scope.mode == KIMAP::FetchJob::FetchScope::Flags) {
i.setRemoteId(QString::number(uid)); i.setRemoteId(QString::number(uid));
i.setMimeType(KMime::Message::mimeType()); i.setMimeType(KMime::Message::mimeType());
i.setFlags(Akonadi::Item::Flags::fromList(ResourceTask::toAkonadiFlags(flags))); i.setFlags(ResourceTask::toAkonadiFlags(flags));
} else { } else {
if (!message) { if (!message) {
qCWarning(IMAPRESOURCE_LOG) << "Got empty message: " << uid; qCWarning(IMAPRESOURCE_LOG) << "Got empty message: " << uid;
......
...@@ -464,24 +464,24 @@ QList<QByteArray> ResourceTask::fromAkonadiFlags(const QList<QByteArray> &flags) ...@@ -464,24 +464,24 @@ QList<QByteArray> ResourceTask::fromAkonadiFlags(const QList<QByteArray> &flags)
return newFlags; return newFlags;
} }
QList<QByteArray> ResourceTask::toAkonadiFlags(const QList<QByteArray> &flags) QSet<QByteArray> ResourceTask::toAkonadiFlags(const QList<QByteArray> &flags)
{ {
QList<QByteArray> newFlags; QSet<QByteArray> newFlags;
for (const QByteArray &oldFlag : flags) { for (const QByteArray &oldFlag : flags) {
if (oldFlag == ImapFlags::Seen) { if (oldFlag == ImapFlags::Seen) {
newFlags.append(Akonadi::MessageFlags::Seen); newFlags.insert(Akonadi::MessageFlags::Seen);
} else if (oldFlag == ImapFlags::Deleted) { } else if (oldFlag == ImapFlags::Deleted) {
newFlags.append(Akonadi::MessageFlags::Deleted); newFlags.insert(Akonadi::MessageFlags::Deleted);
} else if (oldFlag == ImapFlags::Answered) { } else if (oldFlag == ImapFlags::Answered) {
newFlags.append(Akonadi::MessageFlags::Answered); newFlags.insert(Akonadi::MessageFlags::Answered);
} else if (oldFlag == ImapFlags::Flagged) { } else if (oldFlag == ImapFlags::Flagged) {
newFlags.append(Akonadi::MessageFlags::Flagged); newFlags.insert(Akonadi::MessageFlags::Flagged);
} else if (oldFlag.isEmpty()) { } else if (oldFlag.isEmpty()) {
// filter out empty flags, to avoid isNull/isEmpty confusions higher up // filter out empty flags, to avoid isNull/isEmpty confusions higher up
continue; continue;
} else { } else {
newFlags.append(oldFlag); newFlags.insert(oldFlag);
} }
} }
......
...@@ -58,7 +58,7 @@ public: ...@@ -58,7 +58,7 @@ public:
static QList<QByteArray> fromAkonadiToSupportedImapFlags(const QList<QByteArray> &flags, const Akonadi::Collection &collection); static QList<QByteArray> fromAkonadiToSupportedImapFlags(const QList<QByteArray> &flags, const Akonadi::Collection &collection);
static QList<QByteArray> toAkonadiFlags(const QList<QByteArray> &flags); static QSet<QByteArray> toAkonadiFlags(const QList<QByteArray> &flags);
Q_SIGNALS: Q_SIGNALS:
void status(int status, const QString &message = QString()); void status(int status, const QString &message = QString());
......
...@@ -715,7 +715,11 @@ QList<int> POP3Resource::shouldDeleteId(int downloadedId) const ...@@ -715,7 +715,11 @@ QList<int> POP3Resource::shouldDeleteId(int downloadedId) const
mIdsToSaveValid = true; mIdsToSaveValid = true;
mIdsToSave.clear(); mIdsToSave.clear();
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
const QSet<int> idsOnServer = QSet<int>::fromList(idsToDeleteFromServer); const QSet<int> idsOnServer = QSet<int>::fromList(idsToDeleteFromServer);
#else
const QSet<int> idsOnServer(idsToDeleteFromServer.constBegin(), idsToDeleteFromServer.constEnd());
#endif
// If the time-limited leave rule is checked, add the newer messages to // If the time-limited leave rule is checked, add the newer messages to
// the list of messages to keep // the list of messages to keep
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment