on bionic help sign in
unity8/tests/mocks/Unity/Launcher/MockAppDrawerModel.cpp
74 lines 3.3 kB history raw
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17#include "MockAppDrawerModel.h"
19#include <QDebug>
20#include <QDateTime>
22MockAppDrawerModel::MockAppDrawerModel(QObject *parent):
23 AppDrawerModelInterface(parent)
25 MockLauncherItem *item = new MockLauncherItem("dialer-app", "/usr/share/applications/dialer-app.desktop", "Dialer", "dialer-app", this);
26 m_list.append(item);
27 item = new MockLauncherItem("camera-app", "/usr/share/applications/camera-app.desktop", "Camera", "camera", this);
28 m_list.append(item);
29 item = new MockLauncherItem("camera-app2", "/usr/share/applications/camera-app2.desktop", "Camera2", "camera", this);
30 m_list.append(item);
31 item = new MockLauncherItem("gallery-app", "/usr/share/applications/gallery-app.desktop", "Gallery", "gallery", this);
32 m_list.append(item);
33 item = new MockLauncherItem("music-app", "/usr/share/applications/music-app.desktop", "Music", "soundcloud", this);
34 m_list.append(item);
35 item = new MockLauncherItem("facebook-webapp", "/usr/share/applications/facebook-webapp.desktop", "Facebook", "facebook", this);
36 m_list.append(item);
37 item = new MockLauncherItem("webbrowser-app", "/usr/share/applications/webbrowser-app.desktop", "Browser", "browser", this);
38 m_list.append(item);
39 item = new MockLauncherItem("twitter-webapp", "/usr/share/applications/twitter-webapp.desktop", "Twitter", "twitter", this);
40 m_list.append(item);
41 item = new MockLauncherItem("gmail-webapp", "/usr/share/applications/gmail-webapp.desktop", "GMail", "gmail", this);
42 m_list.append(item);
43 item = new MockLauncherItem("ubuntu-weather-app", "/usr/share/applications/ubuntu-weather-app.desktop", "Weather", "weather", this);
44 m_list.append(item);
45 item = new MockLauncherItem("notes-app", "/usr/share/applications/notes-app.desktop", "Notepad", "notepad", this);
46 m_list.append(item);
47 item = new MockLauncherItem("calendar-app", "/usr/share/applications/calendar-app.desktop","Calendar", "calendar", this);
48 m_list.append(item);
49 item = new MockLauncherItem("libreoffice", "/usr/share/applications/libreoffice.desktop","Libre Office Writer", "libreoffice", this);
50 m_list.append(item);
52 qsrand(QDateTime::currentMSecsSinceEpoch() / 1000);
55int MockAppDrawerModel::rowCount(const QModelIndex & /*parent*/) const
57 return m_list.count();
60QVariant MockAppDrawerModel::data(const QModelIndex &index, int role) const
62 switch (role) {
63 case RoleAppId:
64 return m_list.at(index.row())->appId();
65 case RoleName:
66 return m_list.at(index.row())->name();
67 case RoleIcon:
68 return m_list.at(index.row())->icon();
69 case RoleUsage:
70 return qrand();
71 }
73 return QVariant();