/* * SPDX-FileCopyrightText: 2024 Bohdan Onofriichuk * * SPDX-License-Identifier: GPL-2.0-or-later */ #pragma once #include "actionscontrol.h" #include #include #include "deviceerrormonitor_p.h" #include "devicestatemonitor_p.h" #include "spacemonitor_p.h" class DeviceControl : public QAbstractListModel { Q_OBJECT public: enum DeviceModels { Udi = Qt::UserRole + 1, Description, Type, Icon, Emblems, IsRemovable, FreeSpace, Size, FreeSpaceText, SizeText, Mounted, OperationResult, Timestamp, Error, ErrorMessage, Actions, }; Q_ENUM(DeviceModels) explicit DeviceControl(QObject *parent = nullptr); ~DeviceControl() override; int rowCount(const QModelIndex &parent) const override; QVariant data(const QModelIndex &index, int role) const override; QHash roleNames() const override; private Q_SLOTS: void onDeviceAdded(const QString &udi); void onDeviceRemoved(const QString &udi); void onDeviceChanged(const QMap &props); void onDeviceSizeChanged(const QString &udi); void onDeviceStatusChanged(const QString &udi); void onDeviceErrorChanged(const QString &udi); private: void deviceDelayRemove(const QString &udi, const QString &parentUdi); QList m_devices; QHash m_actions; // save device type to properly sort and icon and description as workaround because // solid removes it and list model show empty device(without icon and description). // first = type // second.first = icon // second.second = description QHash>> m_deviceTypes; QHash> m_parentDevices; struct RemoveTimerData { QTimer *timer = nullptr; QString udi; QString parentUdi; }; QHash m_removeTimers; Solid::Predicate m_predicateDeviceMatch; Solid::Predicate m_encryptedPredicate; const QList m_types; bool m_isVisible = false; std::shared_ptr m_spaceMonitor; std::shared_ptr m_stateMonitor; std::shared_ptr m_errorMonitor; };