Commit a9316741 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port deprecated toSet method

parent 7bb7e3f4
......@@ -92,13 +92,24 @@ void Backuper::backup(const QString &filename, const QList<Akonadi::Collection::
void Backuper::onCollectionsFetched(KJob *job)
{
if (job->error() == 0) {
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
QSet<QString> mimeTypeSet = KCalendarCore::Incidence::mimeTypes().toSet();
#else
const QStringList mimetypes = KCalendarCore::Incidence::mimeTypes();
QSet<QString> mimeTypeSet = QSet<QString>(mimetypes.begin(), mimetypes.end());
#endif
Akonadi::CollectionFetchJob *cfj = qobject_cast<Akonadi::CollectionFetchJob *>(job);
foreach (const Akonadi::Collection &collection, cfj->collections()) {
if (!m_requestedCollectionIds.isEmpty() && !m_requestedCollectionIds.contains(collection.id())) {
continue;
}
if (!mimeTypeSet.intersect(collection.contentMimeTypes().toSet()).isEmpty()) {
const QStringList contentMimeTypesLst = collection.contentMimeTypes();
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
QSet<QString> collectionMimeTypeSet = contentMimeTypesLst.toSet();
#else
QSet<QString> collectionMimeTypeSet = QSet<QString>(contentMimeTypesLst.begin(), contentMimeTypesLst.end());
#endif
if (!mimeTypeSet.intersect(collectionMimeTypeSet).isEmpty()) {
m_collections << collection;
loadCollection(collection);
}
......
......@@ -56,9 +56,20 @@ void CollectionLoader::onCollectionsLoaded(KJob *job)
if (job->error() == 0) {
Akonadi::CollectionFetchJob *cfj = qobject_cast<Akonadi::CollectionFetchJob *>(job);
Q_ASSERT(cfj);
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
QSet<QString> mimeTypeSet = KCalendarCore::Incidence::mimeTypes().toSet();
#else
const QStringList mimetypes = KCalendarCore::Incidence::mimeTypes();
QSet<QString> mimeTypeSet = QSet<QString>(mimetypes.begin(), mimetypes.end());
#endif
foreach (const Akonadi::Collection &collection, cfj->collections()) {
QSet<QString> mimeTypeSet = KCalendarCore::Incidence::mimeTypes().toSet();
if (!mimeTypeSet.intersect(collection.contentMimeTypes().toSet()).isEmpty()) {
const QStringList contentMimeTypesLst = collection.contentMimeTypes();
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
QSet<QString> collectionMimeTypeSet = contentMimeTypesLst.toSet();
#else
QSet<QString> collectionMimeTypeSet = QSet<QString>(contentMimeTypesLst.begin(), contentMimeTypesLst.end());
#endif
if (!mimeTypeSet.intersect(collectionMimeTypeSet).isEmpty()) {
m_collections << collection;
}
}
......
......@@ -105,8 +105,8 @@ bool KonsoleKalendar::printCalendarList()
cout << i18n("There are no calendars available.").toLocal8Bit().data() << endl;
} else {
cout << "--------------------------" << endl;
auto mimeTypeSet = mimeTypes.toSet(); // set changes by run method intersect
foreach (const Akonadi::Collection &collection, collections) {
auto mimeTypeSet = mimeTypes.toSet(); // set changes by run method intersect
if (!mimeTypeSet.intersect(collection.contentMimeTypes().toSet()).isEmpty()) {
QString colId = QString::number(collection.id()).leftJustified(6, QLatin1Char(' '));
colId += QLatin1String("- ");
......
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