| 1 |
/* |
| 2 |
* Copyright 2013 Canonical Ltd. |
| 3 |
* |
| 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. |
| 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 Lesser General Public License for more details. |
| 12 |
* |
| 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/>. |
| 15 |
* |
| 16 |
* Authors: |
| 17 |
* Michael Zanetti <[email protected]> |
| 18 |
*/ |
| 19 |
|
| 20 |
#include "MockLauncherItem.h" |
| 21 |
#include "MockQuickListModel.h" |
| 22 |
|
| 23 |
#include <paths.h> |
| 24 |
|
| 25 |
using namespace lomiri::shell::launcher; |
| 26 |
|
| 27 |
MockLauncherItem::MockLauncherItem(const QString &appId, const QString& desktopFile, const QString& name, const QString& icon, QObject* parent): |
| 28 |
LauncherItemInterface(parent), |
| 29 |
m_appId(appId), |
| 30 |
m_desktopFile(desktopFile), |
| 31 |
m_name(name), |
| 32 |
m_icon(testDataDir() + "/graphics/applicationIcons/" + icon + ".png"), |
| 33 |
m_pinned(false), |
| 34 |
m_running(false), |
| 35 |
m_recent(false), |
| 36 |
m_progress(-1), |
| 37 |
m_count(0), |
| 38 |
m_countVisible(false), |
| 39 |
m_focused(false), |
| 40 |
m_alerting(false), |
| 41 |
m_surfaceCount(0), |
| 42 |
m_quickList(new MockQuickListModel(this)) |
| 43 |
{ |
| 44 |
} |
| 45 |
|
| 46 |
MockLauncherItem::~MockLauncherItem() |
| 47 |
{ |
| 48 |
} |
| 49 |
|
| 50 |
QString MockLauncherItem::appId() const |
| 51 |
{ |
| 52 |
return m_appId; |
| 53 |
} |
| 54 |
|
| 55 |
QString MockLauncherItem::desktopFile() const |
| 56 |
{ |
| 57 |
return m_desktopFile; |
| 58 |
} |
| 59 |
|
| 60 |
QString MockLauncherItem::name() const |
| 61 |
{ |
| 62 |
return m_name; |
| 63 |
} |
| 64 |
|
| 65 |
QString MockLauncherItem::icon() const |
| 66 |
{ |
| 67 |
return m_icon; |
| 68 |
} |
| 69 |
|
| 70 |
QStringList MockLauncherItem::keywords() const |
| 71 |
{ |
| 72 |
return m_keywords; |
| 73 |
} |
| 74 |
|
| 75 |
uint MockLauncherItem::popularity() const |
| 76 |
{ |
| 77 |
return m_popularity; |
| 78 |
} |
| 79 |
|
| 80 |
bool MockLauncherItem::pinned() const |
| 81 |
{ |
| 82 |
return m_pinned; |
| 83 |
} |
| 84 |
|
| 85 |
void MockLauncherItem::setPinned(bool pinned) |
| 86 |
{ |
| 87 |
if (m_pinned != pinned) |
| 88 |
{ |
| 89 |
m_pinned = pinned; |
| 90 |
Q_EMIT pinnedChanged(m_pinned); |
| 91 |
} |
| 92 |
} |
| 93 |
|
| 94 |
bool MockLauncherItem::running() const |
| 95 |
{ |
| 96 |
return m_running; |
| 97 |
} |
| 98 |
|
| 99 |
void MockLauncherItem::setRunning(bool running) |
| 100 |
{ |
| 101 |
if (m_running != running) |
| 102 |
{ |
| 103 |
m_running = running; |
| 104 |
Q_EMIT runningChanged(running); |
| 105 |
} |
| 106 |
} |
| 107 |
|
| 108 |
bool MockLauncherItem::recent() const |
| 109 |
{ |
| 110 |
return m_recent; |
| 111 |
} |
| 112 |
|
| 113 |
void MockLauncherItem::setRecent(bool recent) |
| 114 |
{ |
| 115 |
if (m_recent != recent) |
| 116 |
{ |
| 117 |
m_recent = recent; |
| 118 |
Q_EMIT recentChanged(recent); |
| 119 |
} |
| 120 |
} |
| 121 |
|
| 122 |
int MockLauncherItem::progress() const |
| 123 |
{ |
| 124 |
return m_progress; |
| 125 |
} |
| 126 |
|
| 127 |
void MockLauncherItem::setProgress(int progress) |
| 128 |
{ |
| 129 |
if (m_progress != progress) |
| 130 |
{ |
| 131 |
m_progress = progress; |
| 132 |
Q_EMIT progressChanged(progress); |
| 133 |
} |
| 134 |
} |
| 135 |
|
| 136 |
int MockLauncherItem::count() const |
| 137 |
{ |
| 138 |
return m_count; |
| 139 |
} |
| 140 |
|
| 141 |
void MockLauncherItem::setCount(int count) |
| 142 |
{ |
| 143 |
if (m_count != count) |
| 144 |
{ |
| 145 |
m_count = count; |
| 146 |
Q_EMIT countChanged(count); |
| 147 |
if (m_countVisible) { |
| 148 |
setAlerting(true); |
| 149 |
} |
| 150 |
} |
| 151 |
} |
| 152 |
|
| 153 |
bool MockLauncherItem::countVisible() const |
| 154 |
{ |
| 155 |
return m_countVisible; |
| 156 |
} |
| 157 |
|
| 158 |
void MockLauncherItem::setCountVisible(bool countVisible) |
| 159 |
{ |
| 160 |
if (m_countVisible != countVisible) { |
| 161 |
m_countVisible = countVisible; |
| 162 |
Q_EMIT countVisibleChanged(countVisible); |
| 163 |
if (countVisible) { |
| 164 |
setAlerting(true); |
| 165 |
} |
| 166 |
} |
| 167 |
} |
| 168 |
|
| 169 |
bool MockLauncherItem::focused() const |
| 170 |
{ |
| 171 |
return m_focused; |
| 172 |
} |
| 173 |
|
| 174 |
void MockLauncherItem::setFocused(bool focused) |
| 175 |
{ |
| 176 |
if (m_focused != focused) |
| 177 |
{ |
| 178 |
m_focused = focused; |
| 179 |
Q_EMIT focusedChanged(focused); |
| 180 |
} |
| 181 |
} |
| 182 |
|
| 183 |
bool MockLauncherItem::alerting() const |
| 184 |
{ |
| 185 |
return m_alerting; |
| 186 |
} |
| 187 |
|
| 188 |
void MockLauncherItem::setAlerting(bool alerting) |
| 189 |
{ |
| 190 |
if (m_alerting != alerting) { |
| 191 |
m_alerting = alerting; |
| 192 |
Q_EMIT alertingChanged(alerting); |
| 193 |
} |
| 194 |
} |
| 195 |
|
| 196 |
int MockLauncherItem::surfaceCount() const |
| 197 |
{ |
| 198 |
return m_surfaceCount; |
| 199 |
} |
| 200 |
|
| 201 |
void MockLauncherItem::setSurfaceCount(int surfaceCount) |
| 202 |
{ |
| 203 |
if (m_surfaceCount != surfaceCount) { |
| 204 |
m_surfaceCount = surfaceCount; |
| 205 |
Q_EMIT surfaceCountChanged(surfaceCount); |
| 206 |
} |
| 207 |
} |
| 208 |
|
| 209 |
void MockLauncherItem::setPopularity(uint popularity) |
| 210 |
{ |
| 211 |
if (m_popularity != popularity) { |
| 212 |
m_popularity = popularity; |
| 213 |
Q_EMIT popularityChanged(m_popularity); |
| 214 |
} |
| 215 |
} |
| 216 |
|
| 217 |
lomiri::shell::launcher::QuickListModelInterface *MockLauncherItem::quickList() const |
| 218 |
{ |
| 219 |
return m_quickList; |
| 220 |
} |
| 221 |
|
| 222 |
void MockLauncherItem::setKeywords(const QStringList &keywords) |
| 223 |
{ |
| 224 |
if (m_keywords != keywords) { |
| 225 |
m_keywords = keywords; |
| 226 |
Q_EMIT keywordsChanged(keywords); |
| 227 |
} |
| 228 |
} |