lomiri-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
23
24#include <QAbstractItemModel>
25#include <lomiri/util/DefinesPtrs.h>
26
27namespace connectivityqt
28{
29namespace internal
30{
31struct VpnConnectionsListModelParameters;
32}
33
34class Q_DECL_EXPORT VpnConnectionsListModel : public QAbstractListModel
35{
36 Q_OBJECT
37
38 Q_ENUMS(Roles)
39
40public:
42
51
52 VpnConnectionsListModel(const internal::VpnConnectionsListModelParameters& parameters);
53
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
77public Q_SLOTS:
78 void add(VpnConnection::Type type);
79
80 void importFile(VpnConnection::Type type, const QString &filepath);
81
82 void remove(VpnConnection* connection);
83
84Q_SIGNALS:
85 void addFinished(VpnConnection * connection);
86
87protected:
88 class Priv;
89 std::shared_ptr<Priv> d;
90};
91
92}
93
94Q_DECLARE_METATYPE(connectivityqt::VpnConnection*)
Definition vpn-connection.h:32
Type
Definition vpn-connection.h:41
Definition vpn-connections-list-model.h:35
Roles
Definition vpn-connections-list-model.h:44
@ RoleActivatable
Definition vpn-connections-list-model.h:47
@ RoleType
Definition vpn-connections-list-model.h:48
@ RoleActive
Definition vpn-connections-list-model.h:46
@ RoleId
Definition vpn-connections-list-model.h:45
QHash< int, QByteArray > roleNames() const override
Definition vpn-connections-list-model.h:66
LOMIRI_DEFINES_PTRS(VpnConnectionsListModel)
std::shared_ptr< Priv > d
Definition vpn-connections-list-model.h:89
void addFinished(VpnConnection *connection)
Definition connectivity.cpp:37