2 * Copyright (C) 2016 The Qt Company Ltd.
3 * Copyright (C) 2016 Mentor Graphics Development (Deutschland) GmbH
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #include "applicationmodel.h"
21 #include <QtDBus/QDBusInterface>
22 #include <QtDBus/QDBusReply>
24 class ApplicationModel::Private
27 Private(ApplicationModel *parent);
36 ApplicationModel::Private::Private(ApplicationModel *parent)
38 , proxy(QStringLiteral("org.agl.homescreenappframeworkbinder"), QStringLiteral("/AppFramework"), QStringLiteral("org.agl.appframework"), QDBusConnection::sessionBus())
40 QDBusReply<QList<AppInfo>> reply = proxy.call("getAvailableApps");
41 if (false)/*reply.isValid()) TODO: test for CES! */ {
44 data.append(AppInfo(QStringLiteral("HVAC"), QStringLiteral("HVAC"), QStringLiteral("hvac@0.1")));
45 data.append(AppInfo(QStringLiteral("Navigation"), QStringLiteral("NAVIGATION"), QStringLiteral("navigation@0.1")));
46 data.append(AppInfo(QStringLiteral("Phone"), QStringLiteral("PHONE"), QStringLiteral("phone@0.1")));
47 data.append(AppInfo(QStringLiteral("Radio"), QStringLiteral("RADIO"), QStringLiteral("radio@0.1")));
48 data.append(AppInfo(QStringLiteral("Multimedia"), QStringLiteral("MULTIMEDIA"), QStringLiteral("multimedia@0.1")));
49 data.append(AppInfo(QStringLiteral("Connectivity"), QStringLiteral("CONNECTIVITY"), QStringLiteral("connectivity@0.1")));
50 data.append(AppInfo(QStringLiteral("Dashboard"), QStringLiteral("DASHBOARD"), QStringLiteral("dashboard@0.1")));
51 data.append(AppInfo(QStringLiteral("Settings"), QStringLiteral("SETTINGS"), QStringLiteral("settings@0.1")));
52 data.append(AppInfo(QStringLiteral("POI"), QStringLiteral("POINT OF\nINTEREST"), QStringLiteral("poi@0.1")));
55 void ApplicationModel::changeLanguage(const QString &lang)
56 { //todo: use QT translator instead of hardcoded strings.
58 d->data[0].setName("CLIMATISATION");
59 d->data[1].setName("NAVIGATION");
60 d->data[2].setName("TÉLÉPHONE");
61 d->data[3].setName("RADIO");
62 d->data[4].setName("MULTIMÉDIA");
63 d->data[5].setName("CONNEXIONS");
64 d->data[6].setName("TABLEAU DE\nBORD");
65 d->data[7].setName("PARAMÈTRES");
66 d->data[8].setName("POINT D'INTÉRÊT");
68 d->data[0].setName("HVAC");
69 d->data[1].setName("NAVIGATION");
70 d->data[2].setName("PHONE");
71 d->data[3].setName("RADIO");
72 d->data[4].setName("MULTIMEDIA");
73 d->data[5].setName("CONNECTIVITY");
74 d->data[6].setName("DASHBOARD");
75 d->data[7].setName("SETTINGS");
76 d->data[8].setName("POINT OF\nINTEREST");
80 ApplicationModel::ApplicationModel(QObject *parent)
81 : QAbstractListModel(parent)
82 , d(new Private(this))
84 setObjectName("ApplicationModel");
87 ApplicationModel::~ApplicationModel()
92 int ApplicationModel::rowCount(const QModelIndex &parent) const
97 return d->data.count();
100 QVariant ApplicationModel::data(const QModelIndex &index, int role) const
103 if (!index.isValid())
107 case Qt::DecorationRole:
108 ret = d->data[index.row()].iconPath();
110 case Qt::DisplayRole:
111 ret = d->data[index.row()].name();
114 ret = d->data[index.row()].id();
123 QHash<int, QByteArray> ApplicationModel::roleNames() const
125 QHash<int, QByteArray> roles;
126 roles[Qt::DecorationRole] = "icon";
127 roles[Qt::DisplayRole] = "name";
128 roles[Qt::UserRole] = "id";