File indexing completed on 2024-10-06 13:24:50
0001 /* 0002 SPDX-FileCopyrightText: 2013-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_MODEL_NETWORK_MODEL_ITEM_H 0008 #define PLASMA_NM_MODEL_NETWORK_MODEL_ITEM_H 0009 0010 #include <NetworkManagerQt/ActiveConnection> 0011 #include <NetworkManagerQt/Connection> 0012 #include <NetworkManagerQt/ConnectionSettings> 0013 #include <NetworkManagerQt/Device> 0014 #include <NetworkManagerQt/Utils> 0015 #include <NetworkManagerQt/VpnConnection> 0016 0017 class Q_DECL_EXPORT NetworkModelItem : public QObject 0018 { 0019 Q_OBJECT 0020 public: 0021 enum ItemType { UnavailableConnection, AvailableConnection, AvailableAccessPoint }; 0022 0023 explicit NetworkModelItem(QObject *parent = nullptr); 0024 explicit NetworkModelItem(const NetworkModelItem *item, QObject *parent = nullptr); 0025 ~NetworkModelItem() override; 0026 0027 QString activeConnectionPath() const; 0028 void setActiveConnectionPath(const QString &path); 0029 0030 QString connectionPath() const; 0031 void setConnectionPath(const QString &path); 0032 0033 NetworkManager::ActiveConnection::State connectionState() const; 0034 void setConnectionState(NetworkManager::ActiveConnection::State state); 0035 0036 QStringList details() const; 0037 0038 QString deviceName() const; 0039 void setDeviceName(const QString &name); 0040 0041 QString devicePath() const; 0042 void setDevicePath(const QString &path); 0043 0044 QString deviceState() const; 0045 void setDeviceState(const NetworkManager::Device::State state); 0046 0047 bool duplicate() const; 0048 0049 void setIcon(const QString &icon); 0050 QString icon() const 0051 { 0052 return m_icon; 0053 } 0054 0055 ItemType itemType() const; 0056 0057 NetworkManager::WirelessSetting::NetworkMode mode() const; 0058 void setMode(const NetworkManager::WirelessSetting::NetworkMode mode); 0059 0060 QString name() const; 0061 void setName(const QString &name); 0062 0063 QString originalName() const; 0064 0065 QString sectionType() const; 0066 0067 NetworkManager::WirelessSecurityType securityType() const; 0068 void setSecurityType(NetworkManager::WirelessSecurityType type); 0069 0070 int signal() const; 0071 void setSignal(int signal); 0072 0073 bool slave() const; 0074 void setSlave(bool slave); 0075 0076 QString specificPath() const; 0077 void setSpecificPath(const QString &path); 0078 0079 QString ssid() const; 0080 void setSsid(const QString &ssid); 0081 0082 QDateTime timestamp() const; 0083 void setTimestamp(const QDateTime &date); 0084 0085 NetworkManager::ConnectionSettings::ConnectionType type() const; 0086 void setType(NetworkManager::ConnectionSettings::ConnectionType type); 0087 0088 QString accessibleDescription() const; 0089 0090 QString uni() const; 0091 0092 QString uuid() const; 0093 void setUuid(const QString &uuid); 0094 0095 QString vpnState() const; 0096 void setVpnState(NetworkManager::VpnConnection::State state); 0097 0098 QString vpnType() const; 0099 void setVpnType(const QString &type); 0100 0101 qulonglong rxBytes() const; 0102 void setRxBytes(qulonglong bytes); 0103 0104 qulonglong txBytes() const; 0105 void setTxBytes(qulonglong bytes); 0106 0107 bool delayModelUpdates() const; 0108 void setDelayModelUpdates(bool delay); 0109 0110 bool operator==(const NetworkModelItem *item) const; 0111 0112 QVector<int> changedRoles() const 0113 { 0114 return m_changedRoles; 0115 } 0116 void clearChangedRoles() 0117 { 0118 m_changedRoles.clear(); 0119 } 0120 0121 public Q_SLOTS: 0122 void invalidateDetails(); 0123 0124 private: 0125 QString computeIcon() const; 0126 void refreshIcon(); 0127 void updateDetails() const; 0128 0129 QString m_activeConnectionPath; 0130 QString m_connectionPath; 0131 NetworkManager::ActiveConnection::State m_connectionState; 0132 QString m_devicePath; 0133 QString m_deviceName; 0134 NetworkManager::Device::State m_deviceState; 0135 mutable QStringList m_details; 0136 mutable bool m_detailsValid; 0137 bool m_delayModelUpdates; 0138 bool m_duplicate; 0139 NetworkManager::WirelessSetting::NetworkMode m_mode; 0140 QString m_name; 0141 NetworkManager::WirelessSecurityType m_securityType; 0142 int m_signal; 0143 bool m_slave; 0144 QString m_specificPath; 0145 QString m_ssid; 0146 QDateTime m_timestamp; 0147 NetworkManager::ConnectionSettings::ConnectionType m_type; 0148 QString m_accessibleDescription; 0149 QString m_uuid; 0150 QString m_vpnType; 0151 NetworkManager::VpnConnection::State m_vpnState; 0152 qulonglong m_rxBytes; 0153 qulonglong m_txBytes; 0154 QString m_icon; 0155 QVector<int> m_changedRoles; 0156 }; 0157 0158 #endif // PLASMA_NM_MODEL_NETWORK_MODEL_ITEM_H