Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
AccessPointModel.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6#include <PhosphorServiceNetwork/phosphorservicenetwork_export.h>
7
10
11#include <QAbstractListModel>
12#include <QDBusConnection>
13#include <QDBusObjectPath>
14
15namespace PhosphorServiceNetwork {
16
24class PHOSPHORSERVICENETWORK_EXPORT AccessPointModel : public QAbstractListModel
25{
26 Q_OBJECT
27 Q_DISABLE_COPY_MOVE(AccessPointModel)
29 Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
30
31public:
41 Q_ENUM(Roles)
42
43 explicit AccessPointModel(QObject* parent = nullptr);
44 ~AccessPointModel() override;
45
46 [[nodiscard]] NetworkDevice* device() const;
48
49 [[nodiscard]] int rowCount(const QModelIndex& parent = {}) const override;
50 [[nodiscard]] QVariant data(const QModelIndex& index, int role) const override;
51 [[nodiscard]] QHash<int, QByteArray> roleNames() const override;
53
54Q_SIGNALS:
57
58private Q_SLOTS:
59 void _q_onAccessPointAdded(const QDBusObjectPath& path);
60 void _q_onAccessPointRemoved(const QDBusObjectPath& path);
61
62private:
63 void subscribe();
64 void unsubscribe();
65 void rebuild();
66 void clearRows();
67 void addAccessPoint(const QString& path);
68 void removeAccessPoint(const QString& path);
69 void connectAccessPoint(AccessPoint* ap);
70
71 NetworkDevice* m_device = nullptr;
72 // The device path the AccessPointAdded/Removed match rules were
73 // registered against. Cached so unsubscribe() never has to touch
74 // m_device — which is unsafe from the device-destroyed handler, where
75 // QObject::destroyed fires after NetworkDevice's pimpl is already gone.
76 QString m_subscribedPath;
77 QDBusConnection m_bus = QDBusConnection::systemBus();
78 // Row objects owned by the model (parented to it). data()/rowCount
79 // index into this list.
80 QList<AccessPoint*> m_rows;
81};
82
83} // namespace PhosphorServiceNetwork
AccessPointModel(QObject *parent=nullptr)
QVariant data(const QModelIndex &index, int role) const override
void setDevice(NetworkDevice *device)
QHash< int, QByteArray > roleNames() const override
Roles
Definition AccessPointModel.h:32
@ SecurityRole
Definition AccessPointModel.h:38
@ SecuredRole
Definition AccessPointModel.h:39
@ SsidRole
Definition AccessPointModel.h:34
@ FrequencyRole
Definition AccessPointModel.h:36
@ StrengthRole
Definition AccessPointModel.h:35
@ BssidRole
Definition AccessPointModel.h:37
@ AccessPointRole
Definition AccessPointModel.h:33
PhosphorServiceNetwork::AccessPoint * accessPointAt(int index) const
int rowCount(const QModelIndex &parent={}) const override
One org.freedesktop.NetworkManager.AccessPoint — a Wi-Fi network as seen by a wireless device's last ...
Definition AccessPoint.h:22
One org.freedesktop.NetworkManager.Device object.
Definition NetworkDevice.h:23
Definition AccessPoint.h:13