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