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,
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 }
Roles
Definition: sims-list-model.h:48
Definition: connectivity.cpp:36
Definition: sims-list-model.h:53
std::shared_ptr< Priv > d
Definition: sims-list-model.h:94
Definition: sims-list-model.h:54
Definition: sims-list-model.h:38
Definition: sims-list-model.h:55
QHash< int, QByteArray > roleNames() const override
Definition: sims-list-model.h:72
Definition: sims-list-model.h:51
Definition: sims-list-model.h:56