on d0fa5d7 help sign in
unity8/tests/mocks/Unity/Launcher/MockLauncherItem.cpp
188 lines 3.8 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(qmlDirectory() + "/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_quickList(new MockQuickListModel(this))
45MockLauncherItem::~MockLauncherItem()
49QString MockLauncherItem::appId() const
51 return m_appId;
54QString MockLauncherItem::desktopFile() const
56 return m_desktopFile;
59QString MockLauncherItem::name() const
61 return m_name;
64QString MockLauncherItem::icon() const
66 return m_icon;
69bool MockLauncherItem::pinned() const
71 return m_pinned;
74void MockLauncherItem::setPinned(bool pinned)
76 if (m_pinned != pinned)
77 {
78 m_pinned = pinned;
79 Q_EMIT pinnedChanged(m_pinned);
80 }
83bool MockLauncherItem::running() const
85 return m_running;
88void MockLauncherItem::setRunning(bool running)
90 if (m_running != running)
91 {
92 m_running = running;
93 Q_EMIT runningChanged(running);
94 }
97bool MockLauncherItem::recent() const
99 return m_recent;
102void MockLauncherItem::setRecent(bool recent)
104 if (m_recent != recent)
105 {
106 m_recent = recent;
107 Q_EMIT recentChanged(recent);
108 }
111int MockLauncherItem::progress() const
113 return m_progress;
116void MockLauncherItem::setProgress(int progress)
118 if (m_progress != progress)
119 {
120 m_progress = progress;
121 Q_EMIT progressChanged(progress);
122 }
125int MockLauncherItem::count() const
127 return m_count;
130void MockLauncherItem::setCount(int count)
132 if (m_count != count)
133 {
134 m_count = count;
135 Q_EMIT countChanged(count);
136 if (m_countVisible) {
137 setAlerting(true);
138 }
139 }
142bool MockLauncherItem::countVisible() const
144 return m_countVisible;
147void MockLauncherItem::setCountVisible(bool countVisible)
149 if (m_countVisible != countVisible) {
150 m_countVisible = countVisible;
151 Q_EMIT countVisibleChanged(countVisible);
152 if (countVisible) {
153 setAlerting(true);
154 }
155 }
158bool MockLauncherItem::focused() const
160 return m_focused;
163void MockLauncherItem::setFocused(bool focused)
165 if (m_focused != focused)
166 {
167 m_focused = focused;
168 Q_EMIT focusedChanged(focused);
169 }
172bool MockLauncherItem::alerting() const
174 return m_alerting;
177void MockLauncherItem::setAlerting(bool alerting)
179 if (m_alerting != alerting) {
180 m_alerting = alerting;
181 Q_EMIT alertingChanged(alerting);
182 }
185unity::shell::launcher::QuickListModelInterface *MockLauncherItem::quickList() const
187 return m_quickList;