Verified Commit 686fc722 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

Port away from deprecated method

parent 77c5d7dd
......@@ -67,8 +67,14 @@ void MimeTypeCheckerTest::initTestCase()
QCOMPARE(mCalendarChecker.wantedMimeTypes(), QStringList() << textCalendar);
QCOMPARE(mSubTypeChecker.wantedMimeTypes().count(), 2);
const QSet<QString> calendarSubTypes = QSet<QString>::fromList(mCalendarSubTypes);
const QSet<QString> wantedSubTypes = QSet<QString>::fromList(mSubTypeChecker.wantedMimeTypes());
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
const auto calendarSubTypes = QSet<QString>::fromList(mCalendarSubTypes);
const auto wantedSubTypes = QSet<QString>::fromList(mSubTypeChecker.wantedMimeTypes());
#else
const auto calendarSubTypes = QSet<QString>(mCalendarSubTypes.begin(), mCalendarSubTypes.end());
const auto wantedMimeTypes = mSubTypeChecker.wantedMimeTypes();
const auto wantedSubTypes = QSet<QString>(wantedMimeTypes.begin(), wantedMimeTypes.end());
#endif
QCOMPARE(wantedSubTypes, calendarSubTypes);
QCOMPARE(mAliasChecker.wantedMimeTypes().count(), 1);
......
......@@ -85,13 +85,21 @@ private Q_SLOTS:
QVector<int> in = { 1, 2, 3, 4, 5 };
QCOMPARE(in | Actions::toQList, in.toList());
QCOMPARE(in | Actions::toQList | Actions::toQVector, in);
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
QCOMPARE(in | Actions::toQSet, in.toList().toSet()); // clazy:exclude=container-anti-pattern
#else
QCOMPARE(in | Actions::toQSet, QSet<int>(in.begin(), in.end()));
#endif
}
{
QList<int> in = { 1, 2, 3, 4, 5 };
QCOMPARE(in | Actions::toQVector, in.toVector());
QCOMPARE(in | Actions::toQVector | Actions::toQList, in);
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
QCOMPARE(in | Actions::toQSet, in.toSet());
#else
QCOMPARE(in | Actions::toQSet, QSet<int>(in.begin(), in.end()));
#endif
}
}
......
......@@ -48,7 +48,11 @@ bool MimeTypeChecker::hasWantedMimeTypes() const
void MimeTypeChecker::setWantedMimeTypes(const QStringList &mimeTypes)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
d->mWantedMimeTypes = QSet<QString>::fromList(mimeTypes);
#else
d->mWantedMimeTypes = QSet<QString>(mimeTypes.begin(), mimeTypes.end());
#endif
}
void MimeTypeChecker::addWantedMimeType(const QString &mimeType)
......
......@@ -26,6 +26,7 @@
#include <QTimer>
#include <QThread>
#include <QPointer>
#include <QRandomGenerator>
#include <QHostAddress>
#include <QApplication>
......@@ -316,7 +317,7 @@ void SessionPrivate::init(const QByteArray &id)
sessionId = id;
} else {
sessionId = QCoreApplication::instance()->applicationName().toUtf8()
+ '-' + QByteArray::number(qrand());
+ '-' + QByteArray::number(QRandomGenerator::global()->generate());
}
qCDebug(AKONADICORE_LOG) << "Initializing session with ID" << id;
......
......@@ -312,7 +312,11 @@ QByteArray ImapParser::join(const QList<QByteArray> &list, const QByteArray &sep
QByteArray ImapParser::join(const QSet<QByteArray> &set, const QByteArray &separator)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
const QList<QByteArray> list = QList<QByteArray>::fromSet(set);
#else
const QList<QByteArray> list(set.begin(), set.end());
#endif
return ImapParser::join(list, separator);
}
......
......@@ -49,7 +49,7 @@ void ItemMoveHandler::itemsRetrieved(const QVector<qint64> &ids)
const QDateTime mtime = QDateTime::currentDateTimeUtc();
// Split the list by source collection
QMap<Entity::Id /* collection */, PimItem> toMove;
QMultiMap<Entity::Id /* collection */, PimItem> toMove;
QMap<Entity::Id /* collection */, Collection> sources;
ImapSet toMoveIds;
for (PimItem item : items) { //krazy:exclude=foreach
......@@ -82,7 +82,7 @@ void ItemMoveHandler::itemsRetrieved(const QVector<qint64> &ids)
return;
}
toMove.insertMulti(source.id(), item);
toMove.insert(source.id(), item);
toMoveIds.add(QVector<qint64>{ item.id() });
}
......
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