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

connectivity-api

modems-list-model.h
Go to the documentation of this file.
1 /*
2 * Copyright © 2016 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 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18 */
19
20 #pragma once
21
22 #include <QAbstractItemModel>
23 #include <QDBusConnection>
24 #include <QDBusObjectPath>
25
26 #include "sims-list-model.h"
27
28 #include <unity/util/DefinesPtrs.h>
29
30 #include <memory>
31
32 namespace connectivityqt
33 {
34 namespace internal
35 {
36 struct ModemsListModelParameters;
37 }
38
39 class Q_DECL_EXPORT ModemsListModel : public QAbstractListModel
40 {
41 Q_OBJECT
42
43 Q_ENUMS(Roles)
44
45 public:
46 UNITY_DEFINES_PTRS(ModemsListModel);
47
48 enum Roles
49 {
50 RoleIndex = Qt::UserRole + 1,
51 RoleSerial,
52 RoleModem,
53 RoleSim
54 };
55
56 ModemsListModel(const internal::ModemsListModelParameters& parameters);
57
58 ~ModemsListModel();
59
60 int columnCount(const QModelIndex &parent) const override;
61
62 int rowCount(const QModelIndex &parent) const override;
63
64 QVariant data(const QModelIndex &index, int role) const override;
65
66 QHash<int, QByteArray> roleNames() const override
67 {
68 QHash<int, QByteArray> roles;
69 roles[RoleIndex] = "Index";
70 roles[RoleSerial] = "Serial";
71 roles[RoleModem] = "Modem";
72 roles[RoleSim] = "Sim";
73 return roles;
74 }
75
76 public Q_SLOTS:
77
78 Q_SIGNALS:
79
80 protected:
81 class Priv;
82 std::shared_ptr<Priv> d;
83 };
84
85 }
connectivityqt::ModemsListModel::roleNames
QHash< int, QByteArray > roleNames() const override
Definition: modems-list-model.h:66
connectivityqt::ModemsListModel::RoleModem
@ RoleModem
Definition: modems-list-model.h:52
connectivityqt::ModemsListModel
Definition: modems-list-model.h:40
connectivityqt
Definition: connectivity.cpp:37
connectivityqt::ModemsListModel::d
std::shared_ptr< Priv > d
Definition: modems-list-model.h:81
connectivityqt::ModemsListModel::Roles
Roles
Definition: modems-list-model.h:49
connectivityqt::ModemsListModel::UNITY_DEFINES_PTRS
UNITY_DEFINES_PTRS(ModemsListModel)
sims-list-model.h
connectivityqt::ModemsListModel::RoleSerial
@ RoleSerial
Definition: modems-list-model.h:51