on cfcde21 help sign in
unity8/tests/mocks/Unity/Launcher/MockLauncherItem.cpp
215 lines 4.4 kB history raw
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 <michael.zanetti@canonical.com>
18 */
20#include "MockLauncherItem.h"
21#include "MockQuickListModel.h"
23#include <paths.h>
25using namespace unity::shell::launcher;
27MockLauncherItem::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("../../tests/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))
46MockLauncherItem::~MockLauncherItem()
50QString MockLauncherItem::appId() const
52 return m_appId;
55QString MockLauncherItem::desktopFile() const
57 return m_desktopFile;
60QString MockLauncherItem::name() const
62 return m_name;
65QString MockLauncherItem::icon() const
67 return m_icon;
70QStringList MockLauncherItem::keywords() const
72 return m_keywords;
75bool MockLauncherItem::pinned() const
77 return m_pinned;
80void MockLauncherItem::setPinned(bool pinned)
82 if (m_pinned != pinned)
83 {
84 m_pinned = pinned;
85 Q_EMIT pinnedChanged(m_pinned);
86 }
89bool MockLauncherItem::running() const
91 return m_running;
94void MockLauncherItem::setRunning(bool running)
96 if (m_running != running)
97 {
98 m_running = running;
99 Q_EMIT runningChanged(running);
100 }
103bool MockLauncherItem::recent() const
105 return m_recent;
108void MockLauncherItem::setRecent(bool recent)
110 if (m_recent != recent)
111 {
112 m_recent = recent;
113 Q_EMIT recentChanged(recent);
114 }
117int MockLauncherItem::progress() const
119 return m_progress;
122void MockLauncherItem::setProgress(int progress)
124 if (m_progress != progress)
125 {
126 m_progress = progress;
127 Q_EMIT progressChanged(progress);
128 }
131int MockLauncherItem::count() const
133 return m_count;
136void MockLauncherItem::setCount(int count)
138 if (m_count != count)
139 {
140 m_count = count;
141 Q_EMIT countChanged(count);
142 if (m_countVisible) {
143 setAlerting(true);
144 }
145 }
148bool MockLauncherItem::countVisible() const
150 return m_countVisible;
153void MockLauncherItem::setCountVisible(bool countVisible)
155 if (m_countVisible != countVisible) {
156 m_countVisible = countVisible;
157 Q_EMIT countVisibleChanged(countVisible);
158 if (countVisible) {
159 setAlerting(true);
160 }
161 }
164bool MockLauncherItem::focused() const
166 return m_focused;
169void MockLauncherItem::setFocused(bool focused)
171 if (m_focused != focused)
172 {
173 m_focused = focused;
174 Q_EMIT focusedChanged(focused);
175 }
178bool MockLauncherItem::alerting() const
180 return m_alerting;
183void MockLauncherItem::setAlerting(bool alerting)
185 if (m_alerting != alerting) {
186 m_alerting = alerting;
187 Q_EMIT alertingChanged(alerting);
188 }
191int MockLauncherItem::surfaceCount() const
193 return m_surfaceCount;
196void MockLauncherItem::setSurfaceCount(int surfaceCount)
198 if (m_surfaceCount != surfaceCount) {
199 m_surfaceCount = surfaceCount;
200 Q_EMIT surfaceCountChanged(surfaceCount);
201 }
204unity::shell::launcher::QuickListModelInterface *MockLauncherItem::quickList() const
206 return m_quickList;
209void MockLauncherItem::setKeywords(const QStringList &keywords)
211 if (m_keywords != keywords) {
212 m_keywords = keywords;
213 Q_EMIT keywordsChanged(keywords);
214 }