Warning, file /plasma/plasma-vault/plasma/vaultsmodel.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * SPDX-FileCopyrightText: 2017, 2018, 2019 Ivan Cukic <ivan.cukic (at) kde.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #ifndef PLASMAVAULT_PLASMA_VAULTSMODEL_H 0008 #define PLASMAVAULT_PLASMA_VAULTSMODEL_H 0009 0010 #include <QAbstractListModel> 0011 #include <QSortFilterProxyModel> 0012 0013 #include <KActivities/Consumer> 0014 0015 #include <common/vaultinfo.h> 0016 0017 class VaultsModel : public QAbstractListModel 0018 { 0019 Q_OBJECT 0020 0021 Q_PROPERTY(bool isBusy READ isBusy NOTIFY isBusyChanged) 0022 Q_PROPERTY(bool hasError READ hasError NOTIFY hasErrorChanged) 0023 Q_PROPERTY(int count READ rowCount NOTIFY rowCountChanged) 0024 0025 public: 0026 explicit VaultsModel(QObject *parent = nullptr); 0027 ~VaultsModel() override; 0028 0029 // This forces detection of removable drives 0030 void reloadDevices(); 0031 0032 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0033 0034 QVariant data(const QModelIndex &index, int role) const override; 0035 0036 QHash<int, QByteArray> roleNames() const override; 0037 0038 enum Roles { 0039 VaultName = Qt::UserRole + 1, ///< The user defined name of the vault 0040 VaultDevice, ///< Path to the encrypted data 0041 VaultMountPoint, ///< Where the data should be visible from 0042 VaultIcon, ///< Icon for the fault 0043 VaultIsBusy, ///< Is the vault currently being opened or closed 0044 VaultIsOpened, ///< Is the vault open 0045 VaultStatus, ///< Status of the vault, @see VaultInfo::Status 0046 VaultActivities, ///< To which activities does this vault belong to 0047 VaultIsOfflineOnly, ///< Should the networking be off when this vault is mounted 0048 VaultMessage, ///< Message to be shown for the vault 0049 VaultIsEnabled, ///< Can the vault be mounted 0050 }; 0051 0052 public Q_SLOTS: 0053 void refresh(); 0054 0055 // Open (unlock) a vault 0056 void open(const QString &device); 0057 0058 // Close the vault 0059 void close(const QString &device); 0060 0061 // Open the vault if it is closed, or close it otherwise 0062 void toggle(const QString &device); 0063 0064 // Opens the new-vault wizard 0065 void requestNewVault(); 0066 0067 // Kills all applications using the vault and closes it 0068 void forceClose(const QString &device); 0069 0070 // Opens the configuration dialogue for the vault 0071 void configure(const QString &device); 0072 0073 // Open in file manager 0074 void openInFileManager(const QString &device); 0075 0076 bool isBusy() const; 0077 bool hasError() const; 0078 0079 Q_SIGNALS: 0080 void isBusyChanged(bool isBusy); 0081 void hasErrorChanged(bool hasError); 0082 void rowCountChanged(int count); 0083 0084 private: 0085 class Private; 0086 friend class Private; 0087 QScopedPointer<Private> d; 0088 }; 0089 0090 class SortedVaultsModelProxy : public QSortFilterProxyModel 0091 { 0092 Q_OBJECT 0093 0094 public: 0095 explicit SortedVaultsModelProxy(QObject *parent); 0096 0097 bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; 0098 0099 bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; 0100 0101 public Q_SLOTS: 0102 QObject *actionsModel() const; 0103 0104 // This forces detection of removable drives 0105 void reloadDevices(); 0106 0107 private: 0108 VaultsModel *m_source; 0109 KActivities::Consumer *m_kamd; 0110 }; 0111 0112 #endif // include guard