diff options
Diffstat (limited to 'src/plugins/General/hal')
| -rw-r--r-- | src/plugins/General/hal/haldevice.cpp | 4 | ||||
| -rw-r--r-- | src/plugins/General/hal/haldevice.h | 6 | ||||
| -rw-r--r-- | src/plugins/General/hal/halplugin.cpp | 9 |
3 files changed, 9 insertions, 10 deletions
diff --git a/src/plugins/General/hal/haldevice.cpp b/src/plugins/General/hal/haldevice.cpp index 54ba54fb2..446a8dcd6 100644 --- a/src/plugins/General/hal/haldevice.cpp +++ b/src/plugins/General/hal/haldevice.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2009 by Ilya Kotov * + * Copyright (C) 2009-2020 by Ilya Kotov * * forkotov02@ya.ru * * * * Copyright (C) 2006 by Kevin Ottens <ervin@kde.org> * @@ -88,7 +88,7 @@ HalDevice::~HalDevice() { } -QString HalDevice::udi() const +const QString &HalDevice::udi() const { return m_udi; } diff --git a/src/plugins/General/hal/haldevice.h b/src/plugins/General/hal/haldevice.h index 08583fe0e..f220eb8ff 100644 --- a/src/plugins/General/hal/haldevice.h +++ b/src/plugins/General/hal/haldevice.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2009 by Ilya Kotov * + * Copyright (C) 2009-2020 by Ilya Kotov * * forkotov02@ya.ru * * * * Copyright (C) 2006 by Kevin Ottens <ervin@kde.org> * @@ -46,12 +46,12 @@ class HalDevice : public QObject { Q_OBJECT public: - HalDevice(const QString &udi, QObject *parent = nullptr); + explicit HalDevice(const QString &udi, QObject *parent = nullptr); ~HalDevice(); QVariant property (const QString &key); - QString udi() const; + const QString &udi() const; signals: void propertyModified(int count, const QList<ChangeDescription> &changes); diff --git a/src/plugins/General/hal/halplugin.cpp b/src/plugins/General/hal/halplugin.cpp index 5c4bb9c0d..868144fc4 100644 --- a/src/plugins/General/hal/halplugin.cpp +++ b/src/plugins/General/hal/halplugin.cpp @@ -22,6 +22,7 @@ #include <QActionGroup> #include <QApplication> #include <QStyle> +#include <algorithm> #include <qmmpui/uihelper.h> #include <qmmpui/mediaplayer.h> #include <qmmpui/playlistmanager.h> @@ -83,11 +84,9 @@ void HalPlugin::removeDevice(const QString &udi) void HalPlugin::addDevice(const QString &udi) { - for(const HalDevice *device : qAsConst(m_devices)) //is it already exists? - { - if (device->udi() == udi) - return; - } + if(std::any_of(m_devices.cbegin(), m_devices.cend(), [udi](const HalDevice *device) { return device->udi() == udi; })) + return; + HalDevice *device = new HalDevice(udi, this); QStringList caps = device->property("info.capabilities").toStringList(); if (!caps.contains("block") || !caps.contains("volume") || |
