/************************************************************************** * Copyright (C) 2009-2010 Trever Fischer * * Copyright (C) 2015 Kai Uwe Broulik * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ #ifndef DEVICEMODEL_H #define DEVICEMODEL_H #include #include #include #include #include class AutomounterSettings; class DeviceModel : public QAbstractItemModel { Q_OBJECT public: explicit DeviceModel(AutomounterSettings *m_settings, QObject *parent = nullptr); ~DeviceModel() override = default; enum DeviceType { Attached, Detatched }; enum { UdiRole = Qt::UserRole, TypeRole }; Qt::ItemFlags flags(const QModelIndex &index) const override; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; QModelIndex parent(const QModelIndex &index) const override; bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; void setAutomaticMountOnLogin(bool automaticLogin); void setAutomaticMountOnPlugin(bool automaticAttached); public slots: void forgetDevice(const QString &udi); void reload(); private slots: void deviceAttached(const QString &udi); void deviceRemoved(const QString &udi); private: void addNewDevice(const QString &udi); QList m_attached; QList m_disconnected; QHash m_loginForced; QHash m_attachedForced; bool m_automaticLogin; bool m_automaticAttached; AutomounterSettings *m_settings; }; #endif