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");
27 item = new MockLauncherItem("camera-app", "/usr/share/applications/camera-app.desktop", "Camera", "camera");
29 item = new MockLauncherItem("gallery-app", "/usr/share/applications/gallery-app.desktop", "Gallery", "gallery");
31 item = new MockLauncherItem("facebook-webapp", "/usr/share/applications/facebook-webapp.desktop", "Facebook", "facebook");
33 item = new MockLauncherItem("webbrowser-app", "/usr/share/applications/webbrowser-app.desktop", "Browser", "browser");
35 item = new MockLauncherItem("twitter-webapp", "/usr/share/applications/twitter-webapp.desktop", "Twitter", "twitter");
37 item = new MockLauncherItem("gmail-webapp", "/usr/share/applications/gmail-webapp.desktop", "GMail", "gmail");
39 item = new MockLauncherItem("ubuntu-weather-app", "/usr/share/applications/ubuntu-weather-app.desktop", "Weather", "weather");
41 item = new MockLauncherItem("notes-app", "/usr/share/applications/notes-app.desktop", "Notepad", "notepad");
43 item = new MockLauncherItem("calendar-app", "/usr/share/applications/calendar-app.desktop","Calendar", "calendar");
47MockLauncherModel::~MockLauncherModel()
49 while (!m_list.empty())
51 m_list.takeFirst()->deleteLater();
55int MockLauncherModel::rowCount(const QModelIndex& parent) const
58 return m_list.count();
61QVariant MockLauncherModel::data(const QModelIndex& index, int role) const
63 LauncherItemInterface *item = m_list.at(index.row());
67 return item->desktopFile();
73 return item->pinned();
75 return item->running();
77 return item->recent();
79 return item->progress();
87unity::shell::launcher::LauncherItemInterface *MockLauncherModel::get(int index) const
89 if (index < 0 || index >= m_list.count())
93 return m_list.at(index);
96void MockLauncherModel::move(int oldIndex, int newIndex)
98 beginMoveRows(QModelIndex(), oldIndex, oldIndex, QModelIndex(), newIndex);
99 m_list.move(oldIndex, newIndex);
103void MockLauncherModel::pin(const QString &appId, int index)
105 int currentIndex = findApp(appId);
107 if (currentIndex >= 0) {
108 if (index == -1 || index == currentIndex) {
109 m_list.at(currentIndex)->setPinned(true);
110 QModelIndex modelIndex = this->index(currentIndex);
111 Q_EMIT dataChanged(modelIndex, modelIndex);
113 move(currentIndex, index);
116 beginInsertRows(QModelIndex(), index, index);
117 m_list.insert(index, new MockLauncherItem(appId,
121 m_list.at(index)->setPinned(true);
126void MockLauncherModel::requestRemove(const QString &appId)
128 int index = findApp(appId);
130 beginRemoveRows(QModelIndex(), index, 0);
131 m_list.takeAt(index)->deleteLater();
136void MockLauncherModel::quickListActionInvoked(const QString &appId, int actionIndex)
139 Q_UNUSED(actionIndex)
140 // Nothing to mock yet...
143int MockLauncherModel::findApp(const QString &appId)
145 for (int i = 0; i < m_list.count(); ++i) {
146 MockLauncherItem *item = m_list.at(i);
147 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