From e7e357b3dc010d2741ac44574a076cd0e2697722 Mon Sep 17 00:00:00 2001 From: Jan Grulich Date: Wed, 20 Jan 2021 08:07:02 +0100 Subject: [PATCH] QSet: use the new Qt 5.15 API conditionaly --- app/linuxdrivemanager.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/linuxdrivemanager.cpp b/app/linuxdrivemanager.cpp index ebbb4e8a..9b727187 100644 --- a/app/linuxdrivemanager.cpp +++ b/app/linuxdrivemanager.cpp @@ -108,8 +108,12 @@ void LinuxDriveProvider::init(QDBusPendingCallWatcher *w) { mDebug() << this->metaObject()->className() << "Got a reply to GetManagedObjects, parsing"; QDBusPendingReply reply = *w; +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) const QList paths = m_drives.keys(); QSet oldPaths(paths.begin(), paths.end()); +#else + QSet oldPaths = m_drives.keys().toSet(); +#endif QSet newPaths; if (reply.isError()) { @@ -163,11 +167,18 @@ void LinuxDriveProvider::onPropertiesChanged(const QString &interface_name, cons Q_UNUSED(interface_name) const QSet watchedProperties = { "MediaAvailable", "Size" }; const QList changedPropertyKeys = changed_properties.keys(); + +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) QSet changedPropertiesSet(changedPropertyKeys.begin(), changedPropertyKeys.end()); QSet invalidatedPropertiesSet(invalidated_properties.begin(), invalidated_properties.end()); // not ideal but it works alright without a huge lot of code if (!changedPropertiesSet.intersect(watchedProperties).isEmpty() || !invalidatedPropertiesSet.intersect(watchedProperties).isEmpty()) { +#else + // not ideal but it works alright without a huge lot of code + if (!changed_properties.keys().toSet().intersect(watchedProperties).isEmpty() || + !invalidated_properties.toSet().intersect(watchedProperties).isEmpty()) { +#endif QDBusPendingCall pcall = m_objManager->asyncCall("GetManagedObjects"); QDBusPendingCallWatcher *w = new QDBusPendingCallWatcher(pcall, this);