connectivity-api: connectivityqt/vpn-connections-list-model.h Source File

connectivity-api

vpn-connections-list-model.h
Go to the documentation of this file.
1 /*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Pete Woods <pete.woods@canonical.com>
18 */
19
20 #pragma once
21
22 #include <connectivityqt/vpn-connection.h>
23
24 #include <QAbstractItemModel>
25 #include <unity/util/DefinesPtrs.h>
26
27 namespace connectivityqt
28 {
29 namespace internal
30 {
31 struct VpnConnectionsListModelParameters;
32 }
33
34 class Q_DECL_EXPORT VpnConnectionsListModel : public QAbstractListModel
35 {
36 Q_OBJECT
37
38 Q_ENUMS(Roles)
39
40 public:
41 UNITY_DEFINES_PTRS(VpnConnectionsListModel);
42
43 enum Roles
44 {
45 RoleId,
46 RoleActive,
47 RoleActivatable,
48 RoleType,
49 RoleConnection
50 };
51
52 VpnConnectionsListModel(const internal::VpnConnectionsListModelParameters& parameters);
53
54 ~VpnConnectionsListModel();
55
56 int columnCount(const QModelIndex &parent) const override;
57
58 int rowCount(const QModelIndex &parent) const override;
59
60 QVariant data(const QModelIndex &index, int role) const override;
61
62 bool setData(const QModelIndex &index, const QVariant &value, int role) override;
63
64 Qt::ItemFlags flags(const QModelIndex & index) const override;
65
66 QHash<int, QByteArray> roleNames() const override
67 {
68 QHash<int, QByteArray> roles;
69 roles[RoleId] = "id";
70 roles[RoleActive] = "active";
71 roles[RoleActivatable] = "activatable";
72 roles[RoleType] = "type";
73 roles[RoleConnection] = "connection";
74 return roles;
75 }
76
77 public Q_SLOTS:
78 void add(VpnConnection::Type type);
79
80 void remove(VpnConnection* connection);
81
82 Q_SIGNALS:
83 void addFinished(VpnConnection * connection);
84
85 protected:
86 class Priv;
87 std::shared_ptr<Priv> d;
88 };
89
90 }
91
92 Q_DECLARE_METATYPE(connectivityqt::VpnConnection*)
vpn-connection.h
connectivityqt::VpnConnectionsListModel
Definition: vpn-connections-list-model.h:35
connectivityqt::VpnConnectionsListModel::RoleId
@ RoleId
Definition: vpn-connections-list-model.h:45
connectivityqt::VpnConnectionsListModel::UNITY_DEFINES_PTRS
UNITY_DEFINES_PTRS(VpnConnectionsListModel)
connectivityqt::VpnConnectionsListModel::Roles
Roles
Definition: vpn-connections-list-model.h:44
connectivityqt::VpnConnection
Definition: vpn-connection.h:32
connectivityqt::VpnConnectionsListModel::RoleType
@ RoleType
Definition: vpn-connections-list-model.h:48
connectivityqt
Definition: connectivity.cpp:37
connectivityqt::VpnConnectionsListModel::RoleActivatable
@ RoleActivatable
Definition: vpn-connections-list-model.h:47
connectivityqt::VpnConnection::Type
Type
Definition: vpn-connection.h:41
connectivityqt::VpnConnectionsListModel::d
std::shared_ptr< Priv > d
Definition: vpn-connections-list-model.h:86
connectivityqt::VpnConnectionsListModel::RoleActive
@ RoleActive
Definition: vpn-connections-list-model.h:46
connectivityqt::VpnConnectionsListModel::roleNames
QHash< int, QByteArray > roleNames() const override
Definition: vpn-connections-list-model.h:66
connectivityqt::VpnConnectionsListModel::addFinished
void addFinished(VpnConnection *connection)