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

connectivity-api

sims-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 #include <connectivityqt/sim.h>
26
27 #include <unity/util/DefinesPtrs.h>
28
29 #include <memory>
30
31 namespace connectivityqt
32 {
33 namespace internal
34 {
35 struct SimsListModelParameters;
36 }
37
38 class Q_DECL_EXPORT SimsListModel : public QAbstractListModel
39 {
40 Q_OBJECT
41
42 Q_ENUMS(Roles)
43
44 public:
45
46 UNITY_DEFINES_PTRS(SimsListModel);
47
48 enum Roles
49 {
50 RoleIccid = Qt::UserRole + 1,
51 RoleImsi,
52 RolePrimaryPhoneNumber,
53 RoleLocked,
54 RolePresent,
55 RoleMcc,
56 RoleMnc,
57 RolePreferredLanguages,
58 RoleDataRoamingEnabled,
59 RoleSim
60 };
61
62 SimsListModel(const internal::SimsListModelParameters& parameters);
63
64 ~SimsListModel();
65
66 int columnCount(const QModelIndex &parent) const override;
67
68 int rowCount(const QModelIndex &parent) const override;
69
70 QVariant data(const QModelIndex &index, int role) const override;
71
72 QHash<int, QByteArray> roleNames() const override
73 {
74 QHash<int, QByteArray> roles;
75 roles[RoleIccid] = "Iccid";
76 roles[RoleImsi] = "Imsi";
77 roles[RolePrimaryPhoneNumber] = "PrimaryPhoneNumber";
78 roles[RoleLocked] = "Locked";
79 roles[RolePresent] = "Present";
80 roles[RoleMcc] = "Mcc";
81 roles[RoleMnc] = "Mnc";
82 roles[RolePreferredLanguages] = "PreferredLanguages";
83 roles[RoleDataRoamingEnabled] = "DataRoamingEnabled";
84 roles[RoleSim] = "Sim";
85 return roles;
86 }
87
88 Sim::SPtr getSimByPath(const QDBusObjectPath &path) const;
89
90 Q_SIGNALS:
91 void simsUpdated();
92
93 protected:
94 class Priv;
95 std::shared_ptr<Priv> d;
96 };
97
98 }
connectivityqt::SimsListModel::RolePresent
@ RolePresent
Definition: sims-list-model.h:54
connectivityqt::SimsListModel::RoleLocked
@ RoleLocked
Definition: sims-list-model.h:53
connectivityqt::SimsListModel::roleNames
QHash< int, QByteArray > roleNames() const override
Definition: sims-list-model.h:72
connectivityqt::SimsListModel::RolePrimaryPhoneNumber
@ RolePrimaryPhoneNumber
Definition: sims-list-model.h:52
connectivityqt::SimsListModel::RoleImsi
@ RoleImsi
Definition: sims-list-model.h:51
connectivityqt::SimsListModel::RoleMcc
@ RoleMcc
Definition: sims-list-model.h:55
connectivityqt::SimsListModel::RoleDataRoamingEnabled
@ RoleDataRoamingEnabled
Definition: sims-list-model.h:58
connectivityqt::SimsListModel::d
std::shared_ptr< Priv > d
Definition: sims-list-model.h:94
connectivityqt::SimsListModel::simsUpdated
void simsUpdated()
connectivityqt::SimsListModel::RolePreferredLanguages
@ RolePreferredLanguages
Definition: sims-list-model.h:57
connectivityqt::SimsListModel::UNITY_DEFINES_PTRS
UNITY_DEFINES_PTRS(SimsListModel)
connectivityqt
Definition: connectivity.cpp:37
connectivityqt::SimsListModel::RoleMnc
@ RoleMnc
Definition: sims-list-model.h:56
connectivityqt::SimsListModel
Definition: sims-list-model.h:39
sim.h
connectivityqt::SimsListModel::Roles
Roles
Definition: sims-list-model.h:49