Skip to content

Commit

Permalink
QSet: use the new Qt 5.15 API conditionaly
Browse files Browse the repository at this point in the history
  • Loading branch information
grulja committed Jan 20, 2021
1 parent ab45bac commit e7e357b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/linuxdrivemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,12 @@ void LinuxDriveProvider::init(QDBusPendingCallWatcher *w) {
mDebug() << this->metaObject()->className() << "Got a reply to GetManagedObjects, parsing";

QDBusPendingReply<DBusIntrospection> reply = *w;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
const QList<QDBusObjectPath> paths = m_drives.keys();
QSet<QDBusObjectPath> oldPaths(paths.begin(), paths.end());
#else
QSet<QDBusObjectPath> oldPaths = m_drives.keys().toSet();
#endif
QSet<QDBusObjectPath> newPaths;

if (reply.isError()) {
Expand Down Expand Up @@ -163,11 +167,18 @@ void LinuxDriveProvider::onPropertiesChanged(const QString &interface_name, cons
Q_UNUSED(interface_name)
const QSet<QString> watchedProperties = { "MediaAvailable", "Size" };
const QList<QString> changedPropertyKeys = changed_properties.keys();

#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
QSet<QString> changedPropertiesSet(changedPropertyKeys.begin(), changedPropertyKeys.end());
QSet<QString> 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);

Expand Down

0 comments on commit e7e357b

Please sign in to comment.