2 * Copyright 2013 Canonical Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
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.
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/>.
17 * Michael Zanetti <michael.zanetti@canonical.com>
20#include "MockLauncherModel.h"
21#include "MockLauncherItem.h"
23MockLauncherModel::MockLauncherModel(QObject* parent): LauncherModelInterface(parent)
25 MockLauncherItem *item = new MockLauncherItem("phone-app", "/usr/share/applications/phone-app.desktop", "Phone", "phone-app", this);
27 item = new MockLauncherItem("camera-app", "/usr/share/applications/camera-app.desktop", "Camera", "camera", this);
29 item = new MockLauncherItem("gallery-app", "/usr/share/applications/gallery-app.desktop", "Gallery", "gallery", this);
31 item = new MockLauncherItem("facebook-webapp", "/usr/share/applications/facebook-webapp.desktop", "Facebook", "facebook", this);
33 item = new MockLauncherItem("webbrowser-app", "/usr/share/applications/webbrowser-app.desktop", "Browser", "browser", this);
35 item = new MockLauncherItem("twitter-webapp", "/usr/share/applications/twitter-webapp.desktop", "Twitter", "twitter", this);
37 item = new MockLauncherItem("gmail-webapp", "/usr/share/applications/gmail-webapp.desktop", "GMail", "gmail", this);
39 item = new MockLauncherItem("ubuntu-weather-app", "/usr/share/applications/ubuntu-weather-app.desktop", "Weather", "weather", this);
41 item = new MockLauncherItem("notes-app", "/usr/share/applications/notes-app.desktop", "Notepad", "notepad", this);
43 item = new MockLauncherItem("calendar-app", "/usr/share/applications/calendar-app.desktop","Calendar", "calendar", this);
47MockLauncherModel::~MockLauncherModel()
51int MockLauncherModel::rowCount(const QModelIndex& parent) const
54 return m_list.count();
57QVariant MockLauncherModel::data(const QModelIndex& index, int role) const
59 LauncherItemInterface *item = m_list.at(index.row());
63 return item->desktopFile();
69 return item->pinned();
71 return item->running();
73 return item->recent();
75 return item->progress();
83unity::shell::launcher::LauncherItemInterface *MockLauncherModel::get(int index) const
85 if (index < 0 || index >= m_list.count())
89 return m_list.at(index);
92void MockLauncherModel::move(int oldIndex, int newIndex)
94 beginMoveRows(QModelIndex(), oldIndex, oldIndex, QModelIndex(), newIndex);
95 m_list.move(oldIndex, newIndex);
99void MockLauncherModel::pin(const QString &appId, int index)
101 int currentIndex = findApp(appId);
103 if (currentIndex >= 0) {
104 if (index == -1 || index == currentIndex) {
105 m_list.at(currentIndex)->setPinned(true);
106 QModelIndex modelIndex = this->index(currentIndex);
107 Q_EMIT dataChanged(modelIndex, modelIndex);
109 move(currentIndex, index);
112 beginInsertRows(QModelIndex(), index, index);
113 m_list.insert(index, new MockLauncherItem(appId,
117 m_list.at(index)->setPinned(true);
122void MockLauncherModel::requestRemove(const QString &appId)
124 int index = findApp(appId);
126 beginRemoveRows(QModelIndex(), index, 0);
127 m_list.takeAt(index)->deleteLater();
132void MockLauncherModel::quickListActionInvoked(const QString &appId, int actionIndex)
134 Q_EMIT quickListTriggered(appId, actionIndex);
137int MockLauncherModel::findApp(const QString &appId)
139 for (int i = 0; i < m_list.count(); ++i) {
140 MockLauncherItem *item = m_list.at(i);
141 if (item->appId() == appId) {
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list