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>
CollectionStateMonitor<T>::CollectionStateMonitor(QObject *parent, const QHash<QString, T> &stateHash, const QString &inboxId, const StateComparisonFunc &comparisonFunc, int recheckInterval)
: StateMonitorBase(parent)
, mMonitor(this)
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
, mPending(stateHash.keys().toSet())
#else
, mPending(stateHash.keyBegin(), stateHash.keyEnd())
#endif
, mStateHash(stateHash)
, mComparisonFunc(comparisonFunc)
, mInboxId(inboxId)
......
......@@ -36,7 +36,7 @@ Akonadi::Item MessageHelper::createItemFromMessage(const KMime::Message::Ptr &me
if (scope.mode == KIMAP::FetchJob::FetchScope::Flags) {
i.setRemoteId(QString::number(uid));
i.setMimeType(KMime::Message::mimeType());
i.setFlags(Akonadi::Item::Flags::fromList(ResourceTask::toAkonadiFlags(flags)));
i.setFlags(ResourceTask::toAkonadiFlags(flags));
} else {
if (!message) {
qCWarning(IMAPRESOURCE_LOG) << "Got empty message: " << uid;
......
......@@ -464,24 +464,24 @@ QList<QByteArray> ResourceTask::fromAkonadiFlags(const QList<QByteArray> &flags)
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) {
if (oldFlag == ImapFlags::Seen) {
newFlags.append(Akonadi::MessageFlags::Seen);
newFlags.insert(Akonadi::MessageFlags::Seen);
} else if (oldFlag == ImapFlags::Deleted) {
newFlags.append(Akonadi::MessageFlags::Deleted);
newFlags.insert(Akonadi::MessageFlags::Deleted);
} else if (oldFlag == ImapFlags::Answered) {
newFlags.append(Akonadi::MessageFlags::Answered);
newFlags.insert(Akonadi::MessageFlags::Answered);
} else if (oldFlag == ImapFlags::Flagged) {
newFlags.append(Akonadi::MessageFlags::Flagged);
newFlags.insert(Akonadi::MessageFlags::Flagged);
} else if (oldFlag.isEmpty()) {
// filter out empty flags, to avoid isNull/isEmpty confusions higher up
continue;
} else {
newFlags.append(oldFlag);
newFlags.insert(oldFlag);
}
}
......
......@@ -58,7 +58,7 @@ public:
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:
void status(int status, const QString &message = QString());
......
......@@ -715,7 +715,11 @@ QList<int> POP3Resource::shouldDeleteId(int downloadedId) const
mIdsToSaveValid = true;
mIdsToSave.clear();
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
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
// 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