File indexing completed on 2025-01-12 05:01:06
0001 /* 0002 SPDX-FileCopyrightText: 2016-2018 Jan Grulich <jgrulich@redhat.com> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #ifndef PLASMA_NM_CREATABLE_CONNECTIONS_MODEL_H 0008 #define PLASMA_NM_CREATABLE_CONNECTIONS_MODEL_H 0009 0010 #include "plasmanm_internal_export.h" 0011 0012 #include <NetworkManagerQt/ConnectionSettings> 0013 #include <QAbstractListModel> 0014 0015 #include <qqmlregistration.h> 0016 0017 class PLASMANM_INTERNAL_EXPORT CreatableConnectionItem : public QObject 0018 { 0019 Q_OBJECT 0020 public: 0021 explicit CreatableConnectionItem(const QString &typeName, 0022 const QString &typeSection, // Visible properties 0023 const QString &description, 0024 const QString &icon, // Visible properties 0025 NetworkManager::ConnectionSettings::ConnectionType type, // Properties needed for creating 0026 const QString &vpnType = QString(), // Properties needed for creating 0027 const QString &specificType = QString(), // Properties needed for creating 0028 bool shared = false, // Properties needed for creating 0029 QObject *parent = nullptr); 0030 explicit CreatableConnectionItem(QObject *parent = nullptr); 0031 ~CreatableConnectionItem() override; 0032 0033 NetworkManager::ConnectionSettings::ConnectionType connectionType() const; 0034 void setConnectionType(NetworkManager::ConnectionSettings::ConnectionType type); 0035 0036 QString description() const; 0037 void setDescription(const QString &description); 0038 0039 QString icon() const; 0040 void setIcon(const QString &icon); 0041 0042 QString specificType() const; 0043 void setSpecificType(const QString &specificType); 0044 0045 bool shared() const; 0046 void setShared(bool shared); 0047 0048 QString typeName() const; 0049 void setTypeName(const QString &typeName); 0050 0051 QString typeSection() const; 0052 void setTypeSection(const QString &typeSection); 0053 0054 QString vpnType() const; 0055 void setVpnType(const QString &vpnType); 0056 0057 private: 0058 bool m_shared; 0059 NetworkManager::ConnectionSettings::ConnectionType m_connectionType; 0060 QString m_description; 0061 QString m_icon; 0062 QString m_specificType; 0063 QString m_typeName; 0064 QString m_typeSection; 0065 QString m_vpnType; 0066 }; 0067 0068 class PLASMANM_INTERNAL_EXPORT CreatableConnectionsModel : public QAbstractListModel 0069 { 0070 Q_OBJECT 0071 QML_ELEMENT 0072 public: 0073 explicit CreatableConnectionsModel(QObject *parent = nullptr); 0074 ~CreatableConnectionsModel() override; 0075 0076 enum ItemRole { 0077 ConnectionDescription = Qt::UserRole + 1, 0078 ConnectionIcon, 0079 ConnectionSpeficType, 0080 ConnectionShared, 0081 ConnectionType, 0082 ConnectionTypeName, 0083 ConnectionTypeSection, 0084 ConnectionVpnType, 0085 }; 0086 0087 int rowCount(const QModelIndex &parent) const override; 0088 QVariant data(const QModelIndex &index, int role) const override; 0089 QHash<int, QByteArray> roleNames() const override; 0090 0091 private: 0092 void populateModel(); 0093 QList<CreatableConnectionItem *> m_list; 0094 }; 0095 0096 #endif // PLASMA_NM_CREATABLE_CONNECTIONS_MODEL_H