2 * Copyright (C) 2011 Canonical, Ltd.
5 * Michael Zanetti <michael.zanetti@canonical.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20#include "launchermodel.h"
22LauncherModel::LauncherModel(QObject *parent): QAbstractListModel(parent)
24 // FIXME: Dummy data... Aggregate real data from backends
27 LauncherItem *item = new LauncherItem("/usr/share/applications/phone-app.desktop", "Phone", "phone-app");
29 item = new LauncherItem("/usr/share/applications/camera-app.desktop", "Camera", "camera");
31 item = new LauncherItem("/usr/share/applications/gallery-app.desktop", "Gallery", "gallery");
33 item = new LauncherItem("/usr/share/applications/facebook-webapp.desktop", "Facebook", "facebook");
35 item = new LauncherItem("/usr/share/applications/webbrowser-app.desktop", "Browser", "browser");
37 item = new LauncherItem("/usr/share/applications/twitter-webapp.desktop", "Twitter", "twitter");
39 item = new LauncherItem("/usr/share/applications/gmail-webapp.desktop", "GMail", "gmail");
41 item = new LauncherItem("/usr/share/applications/ubuntu-weather-app.desktop", "Weather", "weather");
43 item = new LauncherItem("/usr/share/applications/notes-app.desktop", "Notepad", "notepad");
45 item = new LauncherItem("/usr/share/applications/ubuntu-calendar-app.desktop","Calendar", "calendar");
49LauncherModel::~LauncherModel()
51 while (!m_list.empty()) {
52 m_list.takeFirst()->deleteLater();
56int LauncherModel::rowCount(const QModelIndex &parent) const
59 return m_list.count();
62QVariant LauncherModel::data(const QModelIndex &index, int role) const
64 LauncherItem *item = m_list.at(index.row());
71 return item->favorite();
77LauncherItem *LauncherModel::get(int index) const
79 if (index < 0 || index >= m_list.count()) {
82 return m_list.at(index);
85void LauncherModel::move(int oldIndex, int newIndex)
87 beginMoveRows(QModelIndex(), oldIndex, oldIndex, QModelIndex(), newIndex);
88 m_list.move(oldIndex, newIndex);
92QHash<int, QByteArray> LauncherModel::roleNames() const
94 QHash<int, QByteArray> roles;
95 roles.insert(RoleDesktopFile, "desktopFile");
96 roles.insert(RoleName, "name");
97 roles.insert(RoleIcon, "icon");
98 roles.insert(RoleFavorite, "favorite");
99 roles.insert(RoleRunning, "runnng");
104LauncherItem::LauncherItem(const QString &desktopFile, const QString &name, const QString &icon, QObject *parent):
106 m_desktopFile(desktopFile),
114QString LauncherItem::desktopFile() const
116 return m_desktopFile;
119QString LauncherItem::name() const
124QString LauncherItem::icon() const
129bool LauncherItem::favorite() const
134void LauncherItem::setFavorite(bool favorite)
136 if (m_favorite != favorite) {
137 m_favorite = favorite;
138 Q_EMIT favoriteChanged(m_favorite);
142bool LauncherItem::running() const
147void LauncherItem::setRunning(bool running)
149 if (m_running != running) {
151 Q_EMIT runningChanged(running);
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