Lomiri
launcheritem.cpp
1 /*
2  * Copyright 2014-2015 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 
17 #include "launcheritem.h"
18 #include "quicklistmodel.h"
19 
20 #include <libintl.h>
21 
22 LauncherItem::LauncherItem(const QString &appId, const QString &name, const QString &icon, QObject *parent) :
23  LauncherItemInterface(parent),
24  m_appId(appId),
25  m_name(name),
26  m_icon(icon),
27  m_pinned(false),
28  m_running(false),
29  m_recent(false),
30  m_progress(-1),
31  m_count(0),
32  m_countVisible(false),
33  m_focused(false),
34  m_alerting(false),
35  m_surfaceCount(0),
36  m_quickList(new QuickListModel(this))
37 {
38  QuickListEntry nameAction;
39  nameAction.setActionId(QStringLiteral("launch_item"));
40  nameAction.setText(m_name);
41  m_quickList->appendAction(nameAction);
42 }
43 
44 QString LauncherItem::appId() const
45 {
46  return m_appId;
47 }
48 
49 QString LauncherItem::name() const
50 {
51  return m_name;
52 }
53 
54 void LauncherItem::setName(const QString &name)
55 {
56  if (m_name != name) {
57  m_name = name;
58  QuickListEntry entry;
59  entry.setActionId(QStringLiteral("launch_item"));
60  entry.setText(m_name);
61  m_quickList->updateAction(entry);
62  Q_EMIT nameChanged(name);
63  }
64 }
65 
66 QString LauncherItem::icon() const
67 {
68  return m_icon;
69 }
70 
71 void LauncherItem::setIcon(const QString &icon)
72 {
73  if (m_icon != icon) {
74  m_icon = icon;
75  Q_EMIT iconChanged(icon);
76  }
77 }
78 
79 QStringList LauncherItem::keywords() const
80 {
81  return m_keywords;
82 }
83 
84 void LauncherItem::setKeywords(const QStringList &keywords)
85 {
86  if (m_keywords != keywords) {
87  m_keywords = keywords;
88  Q_EMIT keywordsChanged(keywords);
89  }
90 }
91 
92 uint LauncherItem::popularity() const
93 {
94  // Not exposing usage order in greeter session at this point.
95  return 0;
96 }
97 
98 bool LauncherItem::pinned() const
99 {
100  return m_pinned;
101 }
102 
103 void LauncherItem::setPinned(bool pinned)
104 {
105  if (m_pinned != pinned) {
106  m_pinned = pinned;
107  Q_EMIT pinnedChanged(pinned);
108  }
109 }
110 
111 bool LauncherItem::running() const
112 {
113  return m_running;
114 }
115 
116 void LauncherItem::setRunning(bool running)
117 {
118  if (m_running != running) {
119  m_running = running;
120  Q_EMIT runningChanged(running);
121  }
122 }
123 
124 bool LauncherItem::recent() const
125 {
126  return m_recent;
127 }
128 
129 void LauncherItem::setRecent(bool recent)
130 {
131  if (m_recent != recent) {
132  m_recent = recent;
133  Q_EMIT recentChanged(recent);
134  }
135 }
136 
137 int LauncherItem::progress() const
138 {
139  return m_progress;
140 }
141 
142 void LauncherItem::setProgress(int progress)
143 {
144  if (m_progress != progress) {
145  m_progress = progress;
146  Q_EMIT progressChanged(progress);
147  }
148 }
149 
150 int LauncherItem::count() const
151 {
152  return m_count;
153 }
154 
155 void LauncherItem::setCount(int count)
156 {
157  if (m_count != count) {
158  m_count = count;
159  Q_EMIT countChanged(count);
160  }
161 }
162 
163 bool LauncherItem::countVisible() const
164 {
165  return m_countVisible;
166 }
167 
168 void LauncherItem::setCountVisible(bool countVisible)
169 {
170  if (m_countVisible != countVisible) {
171  m_countVisible = countVisible;
172  Q_EMIT countVisibleChanged(countVisible);
173  }
174 }
175 
176 bool LauncherItem::focused() const
177 {
178  return m_focused;
179 }
180 
181 void LauncherItem::setFocused(bool focused)
182 {
183  if (m_focused != focused) {
184  m_focused = focused;
185  Q_EMIT focusedChanged(focused);
186  }
187 }
188 
189 bool LauncherItem::alerting() const
190 {
191  return m_alerting;
192 }
193 
194 void LauncherItem::setAlerting(bool alerting)
195 {
196  if (m_alerting != alerting) {
197  m_alerting = alerting;
198  Q_EMIT alertingChanged(alerting);
199  }
200 }
201 
202 int LauncherItem::surfaceCount() const
203 {
204  return m_surfaceCount;
205 }
206 
207 void LauncherItem::setSurfaceCount(int surfaceCount)
208 {
209  if (m_surfaceCount != surfaceCount) {
210  m_surfaceCount = surfaceCount;
211  Q_EMIT surfaceCountChanged(surfaceCount);
212  }
213 }
214 
215 lomiri::shell::launcher::QuickListModelInterface *LauncherItem::quickList() const
216 {
217  return m_quickList;
218 }