on cfcde21 help sign in
unity8/tests/mocks/Unity/Launcher/MockAppDrawerModel.cpp
76 lines 3.4 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", "libreoffice", this);
50 m_list.append(item);
51 qDebug() << "mock model created";
53 qsrand(QDateTime::currentMSecsSinceEpoch() / 1000);
56int MockAppDrawerModel::rowCount(const QModelIndex &parent) const
58 Q_UNUSED(parent)
59 return m_list.count();
62QVariant MockAppDrawerModel::data(const QModelIndex &index, int role) const
64 switch (role) {
65 case RoleAppId:
66 return m_list.at(index.row())->appId();
67 case RoleName:
68 return m_list.at(index.row())->name();
69 case RoleIcon:
70 return m_list.at(index.row())->icon();
71 case RoleUsage:
72 return qrand();
73 }
75 return QVariant();