Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
NetworkConnectionModel.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
9
10#include <QAbstractListModel>
11#include <QDBusConnection>
12#include <QDBusObjectPath>
13
14namespace PhosphorServiceNetwork {
15
22class PHOSPHORSERVICENETWORK_EXPORT NetworkConnectionModel : public QAbstractListModel
23{
24 Q_OBJECT
25 Q_DISABLE_COPY_MOVE(NetworkConnectionModel)
26 Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
27
28public:
35 Q_ENUM(Roles)
36
37 explicit NetworkConnectionModel(QObject* parent = nullptr);
39
40 [[nodiscard]] int rowCount(const QModelIndex& parent = {}) const override;
41 [[nodiscard]] QVariant data(const QModelIndex& index, int role) const override;
42 [[nodiscard]] QHash<int, QByteArray> roleNames() const override;
44
45Q_SIGNALS:
47
48private Q_SLOTS:
49 void _q_onNewConnection(const QDBusObjectPath& path);
50 void _q_onConnectionRemoved(const QDBusObjectPath& path);
51
52private:
53 void refresh();
54 quint64 m_generation = 0;
55 void addConnection(const QString& path);
56 void removeConnection(const QString& path);
57 void connectConnection(NetworkConnection* connection);
58
59 QDBusConnection m_bus = QDBusConnection::systemBus();
60 // Row objects owned by the model (parented to it).
61 QList<NetworkConnection*> m_rows;
62};
63
64} // namespace PhosphorServiceNetwork
int rowCount(const QModelIndex &parent={}) const override
Roles
Definition NetworkConnectionModel.h:29
@ ConnectionTypeRole
Definition NetworkConnectionModel.h:33
@ IdRole
Definition NetworkConnectionModel.h:31
@ ConnectionRole
Definition NetworkConnectionModel.h:30
@ UuidRole
Definition NetworkConnectionModel.h:32
NetworkConnectionModel(QObject *parent=nullptr)
QHash< int, QByteArray > roleNames() const override
QVariant data(const QModelIndex &index, int role) const override
PhosphorServiceNetwork::NetworkConnection * connectionAt(int index) const
One saved profile — an org.freedesktop.NetworkManager.Settings.Connection.
Definition NetworkConnection.h:20
Definition AccessPoint.h:13