2 * Copyright (C) 2016 The Qt Company Ltd.
3 * Copyright (C) 2016, 2017 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("mediaplayer@0.1")));
49 data.append(AppInfo(QStringLiteral("Mixer"), QStringLiteral("MIXER"), QStringLiteral("mixer@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")));
56 ApplicationModel::ApplicationModel(QObject *parent)
57 : QAbstractListModel(parent)
58 , d(new Private(this))
62 ApplicationModel::~ApplicationModel()
67 int ApplicationModel::rowCount(const QModelIndex &parent) const
72 return d->data.count();
75 QVariant ApplicationModel::data(const QModelIndex &index, int role) const
82 case Qt::DecorationRole:
83 ret = d->data[index.row()].iconPath();
86 ret = d->data[index.row()].name();
89 ret = d->data[index.row()].id();
98 QHash<int, QByteArray> ApplicationModel::roleNames() const
100 QHash<int, QByteArray> roles;
101 roles[Qt::DecorationRole] = "icon";
102 roles[Qt::DisplayRole] = "name";
103 roles[Qt::UserRole] = "id";