Merge lp:~aacid/unity-2d/unity-2d_remove_places_code into lp:unity-2d
- unity-2d_remove_places_code
- Merge into trunk
Proposed by
Albert Astals Cid
Status: | Merged |
---|---|
Approved by: | Gerry Boland |
Approved revision: | 857 |
Merged at revision: | 857 |
Proposed branch: | lp:~aacid/unity-2d/unity-2d_remove_places_code |
Merge into: | lp:unity-2d |
Diff against target: |
2066 lines (+0/-2002) 8 files modified
libunity-2d-private/Unity2d/plugin.cpp (+0/-7) libunity-2d-private/src/CMakeLists.txt (+0/-3) libunity-2d-private/src/launcherplaceslist.cpp (+0/-139) libunity-2d-private/src/launcherplaceslist.h (+0/-54) libunity-2d-private/src/place.cpp (+0/-456) libunity-2d-private/src/place.h (+0/-116) libunity-2d-private/src/placeentry.cpp (+0/-937) libunity-2d-private/src/placeentry.h (+0/-290) |
To merge this branch: | bzr merge lp:~aacid/unity-2d/unity-2d_remove_places_code |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gerry Boland (community) | Approve | ||
Review via email: mp+89250@code.launchpad.net |
Commit message
Description of the change
Remove Places related code as it is not used anymore
To post a comment you must log in.
Revision history for this message
Gerry Boland (gerboland) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'libunity-2d-private/Unity2d/plugin.cpp' |
2 | --- libunity-2d-private/Unity2d/plugin.cpp 2011-11-29 12:13:27 +0000 |
3 | +++ libunity-2d-private/Unity2d/plugin.cpp 2012-01-19 14:43:26 +0000 |
4 | @@ -24,15 +24,12 @@ |
5 | |
6 | #include "dashsettings.h" |
7 | #include "launcherapplication.h" |
8 | -#include "place.h" |
9 | -#include "placeentry.h" |
10 | #include "launcherdevice.h" |
11 | #include "trash.h" |
12 | #include "workspaces.h" |
13 | #include "listaggregatormodel.h" |
14 | #include "launcherapplicationslist.h" |
15 | #include "launcherdeviceslist.h" |
16 | -#include "launcherplaceslist.h" |
17 | #include "iconimageprovider.h" |
18 | #include "blendedimageprovider.h" |
19 | #include "qsortfilterproxymodelqml.h" |
20 | @@ -130,10 +127,6 @@ |
21 | qmlRegisterType<LauncherApplicationsList>(uri, 0, 1, "LauncherApplicationsList"); |
22 | qmlRegisterType<LauncherApplication>(uri, 0, 1, "LauncherApplication"); |
23 | |
24 | - qmlRegisterType<LauncherPlacesList>(uri, 0, 1, "LauncherPlacesList"); |
25 | - qmlRegisterType<Place>(uri, 0, 1, "Place"); |
26 | - qmlRegisterType<PlaceEntry>(uri, 0, 1, "PlaceEntry"); |
27 | - /* DeeListModel is exposed to QML by PlaceEntry */ |
28 | qmlRegisterType<DeeListModel>(uri, 0, 1, "DeeListModel"); |
29 | |
30 | qmlRegisterType<LauncherDevicesList>(uri, 0, 1, "LauncherDevicesList"); |
31 | |
32 | === modified file 'libunity-2d-private/src/CMakeLists.txt' |
33 | --- libunity-2d-private/src/CMakeLists.txt 2011-11-29 12:13:27 +0000 |
34 | +++ libunity-2d-private/src/CMakeLists.txt 2012-01-19 14:43:26 +0000 |
35 | @@ -50,9 +50,6 @@ |
36 | launcherdevice.cpp |
37 | launcherdeviceslist.cpp |
38 | launcherutility.cpp |
39 | - placeentry.cpp |
40 | - place.cpp |
41 | - launcherplaceslist.cpp |
42 | trash.cpp |
43 | launchermenu.cpp |
44 | webfavorite.cpp |
45 | |
46 | === removed file 'libunity-2d-private/src/launcherplaceslist.cpp' |
47 | --- libunity-2d-private/src/launcherplaceslist.cpp 2011-07-29 13:49:34 +0000 |
48 | +++ libunity-2d-private/src/launcherplaceslist.cpp 1970-01-01 00:00:00 +0000 |
49 | @@ -1,139 +0,0 @@ |
50 | -/* |
51 | - * Copyright (C) 2010 Canonical, Ltd. |
52 | - * |
53 | - * Authors: |
54 | - * Olivier Tilloy <olivier.tilloy@canonical.com> |
55 | - * |
56 | - * This program is free software; you can redistribute it and/or modify |
57 | - * it under the terms of the GNU General Public License as published by |
58 | - * the Free Software Foundation; version 3. |
59 | - * |
60 | - * This program is distributed in the hope that it will be useful, |
61 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
62 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
63 | - * GNU General Public License for more details. |
64 | - * |
65 | - * You should have received a copy of the GNU General Public License |
66 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
67 | - */ |
68 | - |
69 | -#include "launcherplaceslist.h" |
70 | -#include "place.h" |
71 | - |
72 | -#include <QDir> |
73 | - |
74 | -#define PLACES_DIR "/usr/share/unity/places/" |
75 | -#define FILTER "*.place" |
76 | - |
77 | -LauncherPlacesList::LauncherPlacesList(QObject* parent) : |
78 | - ListAggregatorModel(parent) |
79 | -{ |
80 | - QHash<int, QByteArray> roles; |
81 | - roles[Place::RoleItem] = "item"; |
82 | - roles[Place::RoleShowEntry] = "showEntry"; |
83 | - setRoleNames(roles); |
84 | - |
85 | - QDir dir(PLACES_DIR); |
86 | - QStringList filters; |
87 | - filters << FILTER; |
88 | - dir.setNameFilters(filters); |
89 | - m_placeFiles = dir.entryList(); |
90 | - QStringList::const_iterator iter; |
91 | - for (iter = m_placeFiles.begin(); iter != m_placeFiles.end(); ++iter) { |
92 | - addPlace(dir.absoluteFilePath(*iter)); |
93 | - } |
94 | - |
95 | - // Monitor the directory for new/deleted places |
96 | - m_watch = new QFileSystemWatcher; |
97 | - m_watch->addPath(dir.absolutePath()); |
98 | - QObject::connect(m_watch, SIGNAL(directoryChanged(const QString&)), |
99 | - this, SLOT(onDirectoryChanged(const QString&))); |
100 | -} |
101 | - |
102 | -LauncherPlacesList::~LauncherPlacesList() |
103 | -{ |
104 | - delete m_watch; |
105 | - |
106 | - QList<QAbstractItemModel*>::iterator iter; |
107 | - for(iter = m_models.begin(); iter != m_models.end(); ) { |
108 | - Place* place = static_cast<Place*>(*iter); |
109 | - removeListModel(place); |
110 | - delete place; |
111 | - iter = m_models.begin(); |
112 | - } |
113 | -} |
114 | - |
115 | -Place* |
116 | -LauncherPlacesList::addPlace(const QString& file) |
117 | -{ |
118 | - Place* place = new Place(this); |
119 | - aggregateListModel(place); |
120 | - place->setFileName(file); |
121 | - return place; |
122 | -} |
123 | - |
124 | -Place* |
125 | -LauncherPlacesList::removePlace(const QString& file) |
126 | -{ |
127 | - QList<QAbstractItemModel*>::iterator iter; |
128 | - for (iter = m_models.begin(); iter != m_models.end(); ++iter) { |
129 | - Place* place = static_cast<Place*>(*iter); |
130 | - if (place->fileName() == file) { |
131 | - removeListModel(place); |
132 | - return place; |
133 | - } |
134 | - } |
135 | - return NULL; |
136 | -} |
137 | - |
138 | -void |
139 | -LauncherPlacesList::onDirectoryChanged(const QString& path) |
140 | -{ |
141 | - QDir dir(path); |
142 | - QStringList filters; |
143 | - filters << FILTER; |
144 | - dir.setNameFilters(filters); |
145 | - QStringList newPlaceFiles = dir.entryList(); |
146 | - QStringList::const_iterator iter; |
147 | - |
148 | - // Any places removed? |
149 | - for (iter = m_placeFiles.begin(); iter != m_placeFiles.end(); ++iter) { |
150 | - if (!newPlaceFiles.contains(*iter)) { |
151 | - Place* place = removePlace(dir.absoluteFilePath(*iter)); |
152 | - delete place; |
153 | - } |
154 | - } |
155 | - |
156 | - // Any new places? |
157 | - for (iter = newPlaceFiles.begin(); iter != newPlaceFiles.end(); ++iter) { |
158 | - if (!m_placeFiles.contains(*iter)) { |
159 | - addPlace(dir.absoluteFilePath(*iter)); |
160 | - } |
161 | - } |
162 | - |
163 | - m_placeFiles = newPlaceFiles; |
164 | -} |
165 | - |
166 | -PlaceEntry* |
167 | -LauncherPlacesList::findPlaceEntry(const QString& fileName, const QString& groupName) |
168 | -{ |
169 | - Q_FOREACH(QAbstractItemModel* model, m_models) { |
170 | - Place* place = static_cast<Place*>(model); |
171 | - if (place->fileName() == fileName) { |
172 | - return place->findPlaceEntry(groupName); |
173 | - } |
174 | - } |
175 | - |
176 | - return NULL; |
177 | -} |
178 | - |
179 | -void |
180 | -LauncherPlacesList::startAllPlaceServices() |
181 | -{ |
182 | - Q_FOREACH(QAbstractItemModel* model, m_models) { |
183 | - Place* place = static_cast<Place*>(model); |
184 | - place->connectToRemotePlace(); |
185 | - } |
186 | -} |
187 | - |
188 | -#include "launcherplaceslist.moc" |
189 | |
190 | === removed file 'libunity-2d-private/src/launcherplaceslist.h' |
191 | --- libunity-2d-private/src/launcherplaceslist.h 2011-07-29 13:49:34 +0000 |
192 | +++ libunity-2d-private/src/launcherplaceslist.h 1970-01-01 00:00:00 +0000 |
193 | @@ -1,54 +0,0 @@ |
194 | -/* |
195 | - * Copyright (C) 2010 Canonical, Ltd. |
196 | - * |
197 | - * Authors: |
198 | - * Olivier Tilloy <olivier.tilloy@canonical.com> |
199 | - * |
200 | - * This program is free software; you can redistribute it and/or modify |
201 | - * it under the terms of the GNU General Public License as published by |
202 | - * the Free Software Foundation; version 3. |
203 | - * |
204 | - * This program is distributed in the hope that it will be useful, |
205 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
206 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
207 | - * GNU General Public License for more details. |
208 | - * |
209 | - * You should have received a copy of the GNU General Public License |
210 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
211 | - */ |
212 | - |
213 | -#ifndef LAUNCHERPLACESLIST_H |
214 | -#define LAUNCHERPLACESLIST_H |
215 | - |
216 | -#include "listaggregatormodel.h" |
217 | - |
218 | -#include <QStringList> |
219 | -#include <QFileSystemWatcher> |
220 | - |
221 | -class Place; |
222 | -class PlaceEntry; |
223 | - |
224 | -class LauncherPlacesList : public ListAggregatorModel |
225 | -{ |
226 | - Q_OBJECT |
227 | - |
228 | -public: |
229 | - LauncherPlacesList(QObject* parent = 0); |
230 | - ~LauncherPlacesList(); |
231 | - |
232 | - Q_INVOKABLE PlaceEntry* findPlaceEntry(const QString& fileName, const QString& groupName); |
233 | - Q_INVOKABLE void startAllPlaceServices(); |
234 | - |
235 | -private: |
236 | - QStringList m_placeFiles; |
237 | - QFileSystemWatcher* m_watch; |
238 | - |
239 | - Place* addPlace(const QString& file); |
240 | - Place* removePlace(const QString& file); |
241 | - |
242 | -private Q_SLOTS: |
243 | - void onDirectoryChanged(const QString&); |
244 | -}; |
245 | - |
246 | -#endif // LAUNCHERPLACESLIST_H |
247 | - |
248 | |
249 | === removed file 'libunity-2d-private/src/place.cpp' |
250 | --- libunity-2d-private/src/place.cpp 2012-01-13 15:05:44 +0000 |
251 | +++ libunity-2d-private/src/place.cpp 1970-01-01 00:00:00 +0000 |
252 | @@ -1,456 +0,0 @@ |
253 | -/* |
254 | - * Copyright (C) 2010 Canonical, Ltd. |
255 | - * |
256 | - * Authors: |
257 | - * Olivier Tilloy <olivier.tilloy@canonical.com> |
258 | - * |
259 | - * This program is free software; you can redistribute it and/or modify |
260 | - * it under the terms of the GNU General Public License as published by |
261 | - * the Free Software Foundation; version 3. |
262 | - * |
263 | - * This program is distributed in the hope that it will be useful, |
264 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
265 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
266 | - * GNU General Public License for more details. |
267 | - * |
268 | - * You should have received a copy of the GNU General Public License |
269 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
270 | - */ |
271 | - |
272 | -#include "launcherapplication.h" |
273 | -#include "place.h" |
274 | - |
275 | -// libunity-2d |
276 | -#include <unity2dtr.h> |
277 | -#include <debug_p.h> |
278 | - |
279 | -#include <QHash> |
280 | -#include <QByteArray> |
281 | -#include <QStringList> |
282 | -#include <QDBusPendingReply> |
283 | -#include <QDBusServiceWatcher> |
284 | -#include <QDBusConnectionInterface> |
285 | -#include <QTimer> |
286 | -#include <QUrl> |
287 | -#include <QDesktopServices> |
288 | -#include <QDBusReply> |
289 | - |
290 | -static const char* UNITY_PLACE_INTERFACE = "com.canonical.Unity.Place"; |
291 | -static const char* UNITY_ACTIVATION_INTERFACE = "com.canonical.Unity.Activation"; |
292 | - |
293 | -Place::Place(QObject* parent) : |
294 | - QAbstractListModel(parent), |
295 | - m_file(NULL), |
296 | - m_online(false), |
297 | - m_dbusIface(NULL), |
298 | - m_querying(false) |
299 | -{ |
300 | - QHash<int, QByteArray> roles; |
301 | - roles[RoleItem] = "item"; |
302 | - roles[RoleShowEntry] = "showEntry"; |
303 | - setRoleNames(roles); |
304 | - |
305 | - m_serviceWatcher = new QDBusServiceWatcher(this); |
306 | - m_serviceWatcher->setConnection(QDBusConnection::sessionBus()); |
307 | - connect(m_serviceWatcher, SIGNAL(serviceRegistered(QString)), |
308 | - SLOT(onPlaceServiceRegistered())); |
309 | - connect(m_serviceWatcher, SIGNAL(serviceUnregistered(QString)), |
310 | - SLOT(onPlaceServiceUnregistered())); |
311 | -} |
312 | - |
313 | -Place::Place(const Place &other) |
314 | -{ |
315 | - if (other.m_file != NULL) { |
316 | - setFileName(other.m_file->fileName()); |
317 | - } |
318 | -} |
319 | - |
320 | -Place::~Place() |
321 | -{ |
322 | - delete m_dbusIface; |
323 | - delete m_file; |
324 | - m_entries.clear(); |
325 | - m_static_entries.clear(); |
326 | -} |
327 | - |
328 | -QString |
329 | -Place::fileName() const |
330 | -{ |
331 | - return m_file->fileName(); |
332 | -} |
333 | - |
334 | -void |
335 | -Place::setFileName(const QString &file) |
336 | -{ |
337 | - if (!m_dbusName.isNull()) { |
338 | - m_serviceWatcher->removeWatchedService(m_dbusName); |
339 | - } |
340 | - |
341 | - if (m_dbusIface != NULL) { |
342 | - delete m_dbusIface; |
343 | - } |
344 | - |
345 | - m_file = new QSettings(file, QSettings::IniFormat); |
346 | - if (m_file->childGroups().contains("Place")) { |
347 | - m_dbusName = m_file->value("Place/DBusName").toString(); |
348 | - m_dbusObjectPath = m_file->value("Place/dbusObjectPath").toString(); |
349 | - |
350 | - QString gettextDomain = m_file->value("Desktop Entry/X-Ubuntu-Gettext-Domain").toString(); |
351 | - |
352 | - QStringList entries = m_file->childGroups().filter("Entry:"); |
353 | - QStringList::const_iterator iter; |
354 | - uint i = 0; |
355 | - for(iter = entries.begin(); iter != entries.end(); ++iter) { |
356 | - PlaceEntry* entry = new PlaceEntry(this); |
357 | - entry->setFileName(file); |
358 | - entry->setGroupName(iter->mid(6)); |
359 | - m_file->beginGroup(*iter); |
360 | - entry->setDbusName(m_dbusName); |
361 | - entry->setDbusObjectPath(m_file->value("DBusObjectPath").toString()); |
362 | - entry->setName(u2dTr(m_file->value("Name").toString().toUtf8().constData(), |
363 | - gettextDomain.toUtf8().constData())); |
364 | - entry->setIcon(m_file->value("Icon").toString()); |
365 | - entry->setSearchHint(u2dTr(m_file->value("SearchHint").toString().toUtf8().constData(), |
366 | - gettextDomain.toUtf8().constData())); |
367 | - if (m_file->contains("Shortcut")) { |
368 | - QString value = m_file->value("Shortcut").toString(); |
369 | - if (value.size() == 1) { |
370 | - Qt::Key key = (Qt::Key) value.at(0).toUpper().unicode(); |
371 | - entry->setShortcutKey(key); |
372 | - } else { |
373 | - /* Note: some text editors insert the decomposed form of |
374 | - e.g. accented characters (e.g. 0xc3 + 0xa9 for "É" |
375 | - instead of the canonical form 0xc9). Unfortunately Qt |
376 | - doesn’t seem to be able to perform composition, so in |
377 | - such cases setting the shortcut key fails. See |
378 | - http://www.unicode.org/reports/tr15/ for details. */ |
379 | - UQ_WARNING << "Invalid shorcut key (should be one single character):" << value; |
380 | - } |
381 | - } |
382 | - if (!m_file->contains("ShowEntry")) { |
383 | - entry->setShowEntry(true); |
384 | - } else { |
385 | - entry->setShowEntry(m_file->value("ShowEntry").toBool()); |
386 | - } |
387 | - m_file->endGroup(); |
388 | - entry->setPosition(i++); |
389 | - connect(entry, SIGNAL(positionChanged(uint)), |
390 | - SLOT(onEntryPositionChanged(uint))); |
391 | - m_static_entries[entry->dbusObjectPath()] = entry; |
392 | - int index = m_entries.size(); |
393 | - beginInsertRows(QModelIndex(), index, index); |
394 | - m_entries.append(entry); |
395 | - endInsertRows(); |
396 | - } |
397 | - |
398 | - /* Monitor the corresponding D-Bus place service */ |
399 | - m_serviceWatcher->addWatchedService(m_dbusName); |
400 | - |
401 | - /* Connect to the live place immediately if the service is already running |
402 | - otherwise wait for around 10 seconds as to not impact startup time */ |
403 | - QDBusConnectionInterface* iface = QDBusConnection::sessionBus().interface(); |
404 | - QDBusReply<bool> registered = iface->isServiceRegistered(m_dbusName); |
405 | - if (registered) { |
406 | - onPlaceServiceRegistered(); |
407 | - } else { |
408 | - QTimer::singleShot(10000, this, SLOT(connectToRemotePlace())); |
409 | - } |
410 | - } else { |
411 | - delete m_file; |
412 | - m_file = NULL; |
413 | - UQ_WARNING << "Invalid place file, missing [Place] group"; |
414 | - } |
415 | -} |
416 | - |
417 | -QString |
418 | -Place::dbusName() const |
419 | -{ |
420 | - return m_dbusName; |
421 | -} |
422 | - |
423 | -QString |
424 | -Place::dbusObjectPath() const |
425 | -{ |
426 | - return m_dbusObjectPath; |
427 | -} |
428 | - |
429 | -bool |
430 | -Place::online() const |
431 | -{ |
432 | - return m_online; |
433 | -} |
434 | - |
435 | -QVariant |
436 | -Place::data(const QModelIndex& index, int role) const |
437 | -{ |
438 | - if (!index.isValid()) { |
439 | - return QVariant(); |
440 | - } |
441 | - |
442 | - PlaceEntry* entry = m_entries.at(index.row()); |
443 | - if (role == Place::RoleItem) { |
444 | - return QVariant::fromValue(entry); |
445 | - } else if (role == Place::RoleShowEntry) { |
446 | - return QVariant::fromValue(QString(entry->showEntry() ? "true" : "false")); |
447 | - } else { |
448 | - return QVariant(); |
449 | - } |
450 | -} |
451 | - |
452 | -int |
453 | -Place::rowCount(const QModelIndex& parent) const |
454 | -{ |
455 | - Q_UNUSED(parent) |
456 | - |
457 | - return m_entries.size(); |
458 | -} |
459 | - |
460 | -void |
461 | -Place::connectToRemotePlace() |
462 | -{ |
463 | - if ((m_dbusIface != NULL) && m_dbusIface->isValid()) { |
464 | - return; |
465 | - } |
466 | - |
467 | - if (m_dbusIface == NULL) { |
468 | - m_dbusIface = new QDBusInterface(m_dbusName, m_dbusObjectPath, |
469 | - UNITY_PLACE_INTERFACE); |
470 | - } |
471 | - |
472 | - QDBusConnection connection = m_dbusIface->connection(); |
473 | - if (!connection.isConnected()) { |
474 | - UQ_WARNING << "ERROR: unable to connect to bus:" |
475 | - << connection.lastError(); |
476 | - return; |
477 | - } |
478 | - |
479 | - if (!m_dbusIface->isValid()) { |
480 | - /* A call to the interface will spawn the corresponding place daemon. */ |
481 | - getEntries(); |
482 | - } |
483 | -} |
484 | - |
485 | -void |
486 | -Place::getEntries() |
487 | -{ |
488 | - if (m_querying) { |
489 | - /* A call to GetEntries is already pending. */ |
490 | - return; |
491 | - } |
492 | - m_querying = true; |
493 | - |
494 | - /* Update the list of online entries. */ |
495 | - QDBusPendingCall pcall = m_dbusIface->asyncCall("GetEntries"); |
496 | - QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher(pcall, this); |
497 | - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), |
498 | - SLOT(gotEntries(QDBusPendingCallWatcher*))); |
499 | -} |
500 | - |
501 | -void |
502 | -Place::startMonitoringEntries() |
503 | -{ |
504 | - QDBusConnection connection = m_dbusIface->connection(); |
505 | - connection.connect(m_dbusName, m_dbusObjectPath, UNITY_PLACE_INTERFACE, |
506 | - "EntryAdded", this, SLOT(onEntryAdded(const PlaceEntryInfoStruct&))); |
507 | - connection.connect(m_dbusName, m_dbusObjectPath, UNITY_PLACE_INTERFACE, |
508 | - "EntryRemoved", this, SLOT(onEntryRemoved(const QString&))); |
509 | -} |
510 | - |
511 | -void |
512 | -Place::stopMonitoringEntries() |
513 | -{ |
514 | - QDBusConnection connection = m_dbusIface->connection(); |
515 | - connection.disconnect(m_dbusName, m_dbusObjectPath, UNITY_PLACE_INTERFACE, |
516 | - "EntryAdded", this, SLOT(onEntryAdded(const PlaceEntryInfoStruct&))); |
517 | - connection.disconnect(m_dbusName, m_dbusObjectPath, UNITY_PLACE_INTERFACE, |
518 | - "EntryRemoved", this, SLOT(onEntryRemoved(const QString&))); |
519 | -} |
520 | - |
521 | -void |
522 | -Place::onPlaceServiceRegistered() |
523 | -{ |
524 | - connectToRemotePlace(); |
525 | - |
526 | - m_online = true; |
527 | - Q_EMIT onlineChanged(m_online); |
528 | - |
529 | - startMonitoringEntries(); |
530 | - getEntries(); |
531 | -} |
532 | - |
533 | -void |
534 | -Place::onPlaceServiceUnregistered() |
535 | -{ |
536 | - m_online = false; |
537 | - Q_EMIT onlineChanged(m_online); |
538 | - |
539 | - stopMonitoringEntries(); |
540 | - |
541 | - for (int i = rowCount() - 1; i >= 0; --i) { |
542 | - PlaceEntry* entry = m_entries.at(i); |
543 | - if (!m_static_entries.contains(entry->dbusObjectPath())) { |
544 | - beginRemoveRows(QModelIndex(), i, i); |
545 | - m_entries.removeAt(i); |
546 | - endRemoveRows(); |
547 | - delete entry; |
548 | - } else { |
549 | - entry->setSensitive(false); |
550 | - } |
551 | - } |
552 | -} |
553 | - |
554 | -void |
555 | -Place::onEntryAdded(const PlaceEntryInfoStruct& p) |
556 | -{ |
557 | - PlaceEntry* entry = NULL; |
558 | - if (m_static_entries.contains(p.dbus_path)) { |
559 | - entry = m_static_entries.value(p.dbus_path); |
560 | - } else { |
561 | - entry = new PlaceEntry(this); |
562 | - entry->setDbusName(m_dbusName); |
563 | - entry->setDbusObjectPath(p.dbus_path); |
564 | - } |
565 | - |
566 | - entry->updateInfo(p); |
567 | - connect(entry, SIGNAL(positionChanged(uint)), |
568 | - SLOT(onEntryPositionChanged(uint)), Qt::UniqueConnection); |
569 | - entry->setSensitive(true); |
570 | - int index = m_entries.size(); |
571 | - beginInsertRows(QModelIndex(), index, index); |
572 | - m_entries.append(entry); |
573 | - endInsertRows(); |
574 | - entry->connectToRemotePlaceEntry(); |
575 | - Q_EMIT entryAdded(entry); |
576 | -} |
577 | - |
578 | -void |
579 | -Place::onEntryRemoved(const QString& dbusObjectPath) |
580 | -{ |
581 | - PlaceEntry* entry = NULL; |
582 | - QList<PlaceEntry*>::const_iterator i; |
583 | - for (i = m_entries.constBegin(); i != m_entries.constEnd(); ++i) { |
584 | - if ((*i)->dbusObjectPath() == dbusObjectPath) { |
585 | - entry = *i; |
586 | - break; |
587 | - } |
588 | - } |
589 | - |
590 | - if (entry != NULL) { |
591 | - Q_EMIT entryRemoved(entry); |
592 | - int index = m_entries.indexOf(entry); |
593 | - beginRemoveRows(QModelIndex(), index, index); |
594 | - m_entries.removeOne(entry); |
595 | - endRemoveRows(); |
596 | - |
597 | - if (!m_static_entries.contains(entry->dbusObjectPath())) { |
598 | - delete entry; |
599 | - } else { |
600 | - entry->setSensitive(false); |
601 | - } |
602 | - } |
603 | -} |
604 | - |
605 | -void |
606 | -Place::onEntryPositionChanged(uint position) |
607 | -{ |
608 | - /* This doesn’t seem to be implemented/used in Unity, but it can’t hurt… */ |
609 | - // TODO: may require some sanity checks. |
610 | - PlaceEntry* entry = static_cast<PlaceEntry*>(sender()); |
611 | - int from = m_entries.indexOf(entry); |
612 | - if (from != -1) { |
613 | - beginMoveRows(QModelIndex(), from, from, QModelIndex(), position); |
614 | - m_entries.move(from, position); |
615 | - endMoveRows(); |
616 | - } |
617 | -} |
618 | - |
619 | -void |
620 | -Place::gotEntries(QDBusPendingCallWatcher* watcher) |
621 | -{ |
622 | - QDBusPendingReply<QList<PlaceEntryInfoStruct> > reply = *watcher; |
623 | - if (reply.isError()) { |
624 | - UQ_WARNING << "ERROR:" << m_dbusName << reply.error().message(); |
625 | - onPlaceServiceUnregistered(); |
626 | - } else { |
627 | - QList<PlaceEntryInfoStruct> entries = reply.argumentAt<0>(); |
628 | - QList<PlaceEntryInfoStruct>::const_iterator i; |
629 | - for (i = entries.constBegin(); i != entries.constEnd(); ++i) { |
630 | - if (m_static_entries.contains(i->dbus_path)) { |
631 | - PlaceEntry* entry = m_static_entries.value(i->dbus_path); |
632 | - entry->updateInfo(*i); |
633 | - if (m_entries.contains(entry)) { |
634 | - entry->setSensitive(true); |
635 | - } else { |
636 | - int index = m_entries.size(); |
637 | - beginInsertRows(QModelIndex(), index, index); |
638 | - m_entries.append(entry); |
639 | - endInsertRows(); |
640 | - } |
641 | - entry->connectToRemotePlaceEntry(); |
642 | - } else { |
643 | - onEntryAdded(*i); |
644 | - } |
645 | - } |
646 | - } |
647 | - watcher->deleteLater(); |
648 | - m_querying = false; |
649 | -} |
650 | - |
651 | -PlaceEntry* |
652 | -Place::findPlaceEntry(const QString& groupName) |
653 | -{ |
654 | - Q_FOREACH(PlaceEntry* entry, m_entries) { |
655 | - if (entry->groupName() == groupName) { |
656 | - return entry; |
657 | - } |
658 | - } |
659 | - |
660 | - return NULL; |
661 | -} |
662 | - |
663 | -void |
664 | -Place::activate(const QString& uri) |
665 | -{ |
666 | - /* Tries various methods to trigger a sensible action for the given 'uri'. |
667 | - First it asks the place backend via its 'Activate' method. If that fails |
668 | - it does its best to select a relevant action for the uri's scheme. If it |
669 | - has no understanding of the given scheme it falls back on asking Qt to |
670 | - open the uri. |
671 | - */ |
672 | - QUrl url(uri); |
673 | - if (url.scheme() == "file") { |
674 | - /* Override the files place's default URI handler: we want the file |
675 | - manager to handle opening folders, not the dash. |
676 | - |
677 | - Ref: https://bugs.launchpad.net/upicek/+bug/689667 |
678 | - */ |
679 | - QDesktopServices::openUrl(url); |
680 | - return; |
681 | - } |
682 | - |
683 | - QDBusInterface dbusActivationInterface(m_dbusName, m_dbusObjectPath, |
684 | - UNITY_ACTIVATION_INTERFACE); |
685 | - QDBusReply<uint> reply = dbusActivationInterface.call("Activate", uri); |
686 | - if (reply != 0) { |
687 | - return; |
688 | - } |
689 | - |
690 | - if (url.scheme() == "application") { |
691 | - LauncherApplication application; |
692 | - /* Cannot set the desktop file to url.host(), because the QUrl constructor |
693 | - converts the host name to lower case to conform to the Nameprep |
694 | - RFC (see http://doc.qt.nokia.com/qurl.html#FormattingOption-enum). |
695 | - Ref: https://bugs.launchpad.net/unity-place-applications/+bug/784478 */ |
696 | - QString desktopFile = uri.mid(uri.indexOf("://") + 3); |
697 | - application.setDesktopFile(desktopFile); |
698 | - application.activate(); |
699 | - return; |
700 | - } |
701 | - |
702 | - UQ_WARNING << "FIXME: Possibly no handler for scheme: " << url.scheme(); |
703 | - UQ_WARNING << "Trying to open" << uri; |
704 | - /* Try our luck */ |
705 | - QDesktopServices::openUrl(url); |
706 | -} |
707 | - |
708 | -#include "place.moc" |
709 | |
710 | === removed file 'libunity-2d-private/src/place.h' |
711 | --- libunity-2d-private/src/place.h 2012-01-13 15:05:44 +0000 |
712 | +++ libunity-2d-private/src/place.h 1970-01-01 00:00:00 +0000 |
713 | @@ -1,116 +0,0 @@ |
714 | -/* |
715 | - * Copyright (C) 2010 Canonical, Ltd. |
716 | - * |
717 | - * Authors: |
718 | - * Olivier Tilloy <olivier.tilloy@canonical.com> |
719 | - * |
720 | - * This program is free software; you can redistribute it and/or modify |
721 | - * it under the terms of the GNU General Public License as published by |
722 | - * the Free Software Foundation; version 3. |
723 | - * |
724 | - * This program is distributed in the hope that it will be useful, |
725 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
726 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
727 | - * GNU General Public License for more details. |
728 | - * |
729 | - * You should have received a copy of the GNU General Public License |
730 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
731 | - */ |
732 | - |
733 | -#ifndef PLACE_H |
734 | -#define PLACE_H |
735 | - |
736 | -#include <QAbstractListModel> |
737 | -#include <QString> |
738 | -#include <QSettings> |
739 | -#include <QList> |
740 | -#include <QHash> |
741 | -#include <QMetaType> |
742 | -#include <QDBusInterface> |
743 | -#include <QDBusPendingCallWatcher> |
744 | -#include <QDBusServiceWatcher> |
745 | - |
746 | -#include "placeentry.h" |
747 | - |
748 | -class Place : public QAbstractListModel |
749 | -{ |
750 | - Q_OBJECT |
751 | - |
752 | - Q_ENUMS(Roles) |
753 | - |
754 | - Q_PROPERTY(QString fileName READ fileName WRITE setFileName) |
755 | - Q_PROPERTY(QString dbusName READ dbusName) |
756 | - Q_PROPERTY(QString dbusObjectPath READ dbusObjectPath) |
757 | - Q_PROPERTY(bool online READ online NOTIFY onlineChanged) |
758 | - |
759 | -public: |
760 | - Place(QObject* parent = 0); |
761 | - Place(const Place& other); |
762 | - ~Place(); |
763 | - |
764 | - enum Roles { |
765 | - RoleItem, |
766 | - RoleShowEntry |
767 | - }; |
768 | - |
769 | - /* getters */ |
770 | - QString fileName() const; |
771 | - QString dbusName() const; |
772 | - QString dbusObjectPath() const; |
773 | - bool online() const; |
774 | - |
775 | - /* setters */ |
776 | - void setFileName(const QString& file); |
777 | - |
778 | - /* methods */ |
779 | - QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; |
780 | - int rowCount(const QModelIndex& parent = QModelIndex()) const; |
781 | - |
782 | - PlaceEntry* findPlaceEntry(const QString& groupName); |
783 | - Q_INVOKABLE void activate(const QString& uri); |
784 | - |
785 | -Q_SIGNALS: |
786 | - void entryAdded(PlaceEntry*); |
787 | - void entryRemoved(PlaceEntry*); |
788 | - |
789 | - void onlineChanged(bool); |
790 | - |
791 | -private: |
792 | - QSettings* m_file; |
793 | - QString m_dbusName; |
794 | - QString m_dbusObjectPath; |
795 | - QDBusServiceWatcher* m_serviceWatcher; |
796 | - |
797 | - /* Initial dictionary (dbusObjectPath → entry) as parsed in the place file */ |
798 | - QHash<QString, PlaceEntry*> m_static_entries; |
799 | - |
800 | - /* Online entries (ordered) */ |
801 | - QList<PlaceEntry*> m_entries; |
802 | - |
803 | - bool m_online; |
804 | - QDBusInterface* m_dbusIface; |
805 | - |
806 | - void getEntries(); |
807 | - void startMonitoringEntries(); |
808 | - void stopMonitoringEntries(); |
809 | - bool m_querying; |
810 | - |
811 | -public Q_SLOTS: |
812 | - /* Connect to the remote representation of the place on DBus and monitor |
813 | - changes. */ |
814 | - void connectToRemotePlace(); |
815 | - |
816 | -private Q_SLOTS: |
817 | - void onEntryAdded(const PlaceEntryInfoStruct&); |
818 | - void onEntryRemoved(const QString&); |
819 | - void onEntryPositionChanged(uint); |
820 | - |
821 | - void onPlaceServiceRegistered(); |
822 | - void onPlaceServiceUnregistered(); |
823 | - |
824 | - void gotEntries(QDBusPendingCallWatcher*); |
825 | -}; |
826 | - |
827 | -Q_DECLARE_METATYPE(Place*) |
828 | - |
829 | -#endif // PLACE_H |
830 | |
831 | === removed file 'libunity-2d-private/src/placeentry.cpp' |
832 | --- libunity-2d-private/src/placeentry.cpp 2012-01-13 15:05:44 +0000 |
833 | +++ libunity-2d-private/src/placeentry.cpp 1970-01-01 00:00:00 +0000 |
834 | @@ -1,937 +0,0 @@ |
835 | -/* |
836 | - * Copyright (C) 2010 Canonical, Ltd. |
837 | - * |
838 | - * Authors: |
839 | - * Olivier Tilloy <olivier.tilloy@canonical.com> |
840 | - * |
841 | - * This program is free software; you can redistribute it and/or modify |
842 | - * it under the terms of the GNU General Public License as published by |
843 | - * the Free Software Foundation; version 3. |
844 | - * |
845 | - * This program is distributed in the hope that it will be useful, |
846 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
847 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
848 | - * GNU General Public License for more details. |
849 | - * |
850 | - * You should have received a copy of the GNU General Public License |
851 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
852 | - */ |
853 | - |
854 | -#include "placeentry.h" |
855 | -#include "place.h" |
856 | -#include "launchermenu.h" |
857 | - |
858 | -// libunity-2d |
859 | -#include <dashclient.h> |
860 | -#include <debug_p.h> |
861 | - |
862 | -// QtDee |
863 | -#include "deelistmodel.h" |
864 | - |
865 | -#include <QDBusMetaType> |
866 | -#include <QAction> |
867 | -#include <QDebug> |
868 | - |
869 | -// Marshall the RendererInfoStruct data into a D-Bus argument |
870 | -QDBusArgument &operator<<(QDBusArgument &argument, const RendererInfoStruct &r) |
871 | -{ |
872 | - argument.beginStructure(); |
873 | - argument << r.default_renderer; |
874 | - argument << r.groups_model; |
875 | - argument << r.results_model; |
876 | - argument.beginMap(QVariant::String, QVariant::String); |
877 | - QMap<QString, QString>::const_iterator i; |
878 | - for (i = r.renderer_hints.constBegin(); i != r.renderer_hints.constEnd(); ++i) { |
879 | - argument.beginMapEntry(); |
880 | - argument << i.key() << i.value(); |
881 | - argument.endMapEntry(); |
882 | - } |
883 | - argument.endMap(); |
884 | - argument.endStructure(); |
885 | - return argument; |
886 | -} |
887 | - |
888 | -// Retrieve the RendererInfoStruct data from the D-Bus argument |
889 | -const QDBusArgument &operator>>(const QDBusArgument &argument, RendererInfoStruct &r) |
890 | -{ |
891 | - argument.beginStructure(); |
892 | - argument >> r.default_renderer; |
893 | - argument >> r.groups_model; |
894 | - argument >> r.results_model; |
895 | - r.renderer_hints.clear(); |
896 | - argument.beginMap(); |
897 | - while (!argument.atEnd()) { |
898 | - QString key; |
899 | - QString value; |
900 | - argument.beginMapEntry(); |
901 | - argument >> key >> value; |
902 | - argument.endMapEntry(); |
903 | - r.renderer_hints[key] = value; |
904 | - } |
905 | - argument.endMap(); |
906 | - argument.endStructure(); |
907 | - return argument; |
908 | -} |
909 | - |
910 | - |
911 | -// Marshall the PlaceEntryInfoStruct data into a D-Bus argument |
912 | -QDBusArgument &operator<<(QDBusArgument &argument, const PlaceEntryInfoStruct &p) |
913 | -{ |
914 | - argument.beginStructure(); |
915 | - argument << p.dbus_path; |
916 | - argument << p.name; |
917 | - argument << p.icon; |
918 | - argument << p.position; |
919 | - argument.beginArray(QVariant::String); |
920 | - QStringList::const_iterator i; |
921 | - for (i = p.mimetypes.constBegin(); i != p.mimetypes.constEnd(); ++i) { |
922 | - argument << *i; |
923 | - } |
924 | - argument.endArray(); |
925 | - argument << p.sensitive; |
926 | - argument << p.sections_model; |
927 | - argument.beginMap(QVariant::String, QVariant::String); |
928 | - QMap<QString, QString>::const_iterator j; |
929 | - for (j = p.hints.constBegin(); j != p.hints.constEnd(); ++j) { |
930 | - argument.beginMapEntry(); |
931 | - argument << j.key() << j.value(); |
932 | - argument.endMapEntry(); |
933 | - } |
934 | - argument.endMap(); |
935 | - argument << p.entry_renderer_info; |
936 | - argument << p.global_renderer_info; |
937 | - argument.endStructure(); |
938 | - return argument; |
939 | -} |
940 | - |
941 | -// Retrieve the PlaceEntryInfoStruct data from the D-Bus argument |
942 | -const QDBusArgument &operator>>(const QDBusArgument &argument, PlaceEntryInfoStruct &p) |
943 | -{ |
944 | - argument.beginStructure(); |
945 | - argument >> p.dbus_path; |
946 | - argument >> p.name; |
947 | - argument >> p.icon; |
948 | - argument >> p.position; |
949 | - argument.beginArray(); |
950 | - p.mimetypes.clear(); |
951 | - while (!argument.atEnd()) { |
952 | - QString mimetype; |
953 | - argument >> mimetype; |
954 | - p.mimetypes.append(mimetype); |
955 | - } |
956 | - argument.endArray(); |
957 | - argument >> p.sensitive; |
958 | - argument >> p.sections_model; |
959 | - p.hints.clear(); |
960 | - argument.beginMap(); |
961 | - while (!argument.atEnd()) { |
962 | - QString key; |
963 | - QString value; |
964 | - argument.beginMapEntry(); |
965 | - argument >> key >> value; |
966 | - argument.endMapEntry(); |
967 | - p.hints[key] = value; |
968 | - } |
969 | - argument.endMap(); |
970 | - /* The PlaceEntryInfoChanged signal on the com.canonical.Unity.PlaceEntry |
971 | - interface omits the two RenderingInfo structs. */ |
972 | - if (!argument.atEnd()) { |
973 | - argument >> p.entry_renderer_info; |
974 | - argument >> p.global_renderer_info; |
975 | - } |
976 | - argument.endStructure(); |
977 | - return argument; |
978 | -} |
979 | - |
980 | - |
981 | -static const char* UNITY_PLACE_ENTRY_INTERFACE = "com.canonical.Unity.PlaceEntry"; |
982 | -static const char* SECTION_PROPERTY = "section"; |
983 | - |
984 | -PlaceEntry::PlaceEntry(QObject* parent) : |
985 | - LauncherItem(parent), |
986 | - m_position(0), |
987 | - m_sensitive(false), |
988 | - m_sections(NULL), |
989 | - m_showEntry(false), |
990 | - m_activeSection(-1), |
991 | - m_active(false), |
992 | - m_place((Place*)parent), |
993 | - m_entryGroupsModel(NULL), |
994 | - m_entryResultsModel(NULL), |
995 | - m_globalGroupsModel(NULL), |
996 | - m_globalResultsModel(NULL), |
997 | - m_dbusIface(NULL) |
998 | -{ |
999 | - qDBusRegisterMetaType<RendererInfoStruct>(); |
1000 | - qDBusRegisterMetaType<PlaceEntryInfoStruct>(); |
1001 | - qDBusRegisterMetaType<QList<PlaceEntryInfoStruct> >(); |
1002 | - qDBusRegisterMetaType<QHash<QString, QString>>(); |
1003 | - |
1004 | - connect(DashClient::instance(), SIGNAL(activePageChanged(const QString&)), |
1005 | - SLOT(slotActivePageChanged(const QString&))); |
1006 | -} |
1007 | - |
1008 | -PlaceEntry::PlaceEntry(const PlaceEntry& other) : |
1009 | - m_fileName(other.m_fileName), |
1010 | - m_groupName(other.m_groupName), |
1011 | - m_dbusName(other.m_dbusName), |
1012 | - m_dbusObjectPath(other.m_dbusObjectPath), |
1013 | - m_icon(other.m_icon), |
1014 | - m_name(other.m_name), |
1015 | - m_position(other.m_position), |
1016 | - m_mimetypes(other.m_mimetypes), |
1017 | - m_sensitive(other.m_sensitive), |
1018 | - m_activeSection(other.m_activeSection), |
1019 | - m_active(other.m_active), |
1020 | - m_place(other.m_place), |
1021 | - |
1022 | - m_entrySearchQuery(other.m_entrySearchQuery), |
1023 | - m_entryRendererName(other.m_entryRendererName), |
1024 | - m_entryGroupsModelName(other.m_entryGroupsModelName), |
1025 | - m_entryResultsModelName(other.m_entryResultsModelName), |
1026 | - |
1027 | - m_globalSearchQuery(other.m_globalSearchQuery), |
1028 | - m_globalRendererName(other.m_globalRendererName), |
1029 | - m_globalGroupsModelName(other.m_globalGroupsModelName), |
1030 | - m_globalResultsModelName(other.m_globalResultsModelName) |
1031 | -{ |
1032 | - setSections(other.m_sections); |
1033 | - setHints(other.m_hints); |
1034 | - |
1035 | - setEntryGroupsModel(other.m_entryGroupsModel); |
1036 | - setEntryResultsModel(other.m_entryResultsModel); |
1037 | - setEntryRendererHints(other.m_entryRendererHints); |
1038 | - |
1039 | - setGlobalGroupsModel(other.m_globalGroupsModel); |
1040 | - setGlobalResultsModel(other.m_globalResultsModel); |
1041 | - setGlobalRendererHints(other.m_globalRendererHints); |
1042 | -} |
1043 | - |
1044 | -PlaceEntry::~PlaceEntry() |
1045 | -{ |
1046 | - delete m_sections; |
1047 | - delete m_dbusIface; |
1048 | -} |
1049 | - |
1050 | -bool |
1051 | -PlaceEntry::running() const |
1052 | -{ |
1053 | - return false; |
1054 | -} |
1055 | - |
1056 | -int |
1057 | -PlaceEntry::windowCount() const |
1058 | -{ |
1059 | - return 0; |
1060 | -} |
1061 | - |
1062 | -bool |
1063 | -PlaceEntry::urgent() const |
1064 | -{ |
1065 | - return false; |
1066 | -} |
1067 | - |
1068 | -QString |
1069 | -PlaceEntry::name() const |
1070 | -{ |
1071 | - return m_name; |
1072 | -} |
1073 | - |
1074 | -void |
1075 | -PlaceEntry::setName(const QString& name) |
1076 | -{ |
1077 | - m_name = name; |
1078 | -} |
1079 | - |
1080 | -QString |
1081 | -PlaceEntry::icon() const |
1082 | -{ |
1083 | - return m_icon; |
1084 | -} |
1085 | - |
1086 | -void |
1087 | -PlaceEntry::setIcon(const QString& icon) |
1088 | -{ |
1089 | - m_icon = icon; |
1090 | -} |
1091 | - |
1092 | -bool |
1093 | -PlaceEntry::launching() const |
1094 | -{ |
1095 | - /* This basically means no launching animation when opening the device. |
1096 | - Unity behaves likes this. */ |
1097 | - return false; |
1098 | -} |
1099 | - |
1100 | -QString |
1101 | -PlaceEntry::fileName() const |
1102 | -{ |
1103 | - return m_fileName; |
1104 | -} |
1105 | - |
1106 | -void |
1107 | -PlaceEntry::setFileName(const QString& fileName) |
1108 | -{ |
1109 | - m_fileName = fileName; |
1110 | -} |
1111 | - |
1112 | -QString |
1113 | -PlaceEntry::groupName() const |
1114 | -{ |
1115 | - return m_groupName; |
1116 | -} |
1117 | - |
1118 | -void |
1119 | -PlaceEntry::setGroupName(const QString& groupName) |
1120 | -{ |
1121 | - m_groupName = groupName; |
1122 | -} |
1123 | - |
1124 | -QString |
1125 | -PlaceEntry::dbusName() const |
1126 | -{ |
1127 | - return m_dbusName; |
1128 | -} |
1129 | - |
1130 | -QString |
1131 | -PlaceEntry::dbusObjectPath() const |
1132 | -{ |
1133 | - return m_dbusObjectPath; |
1134 | -} |
1135 | - |
1136 | -uint |
1137 | -PlaceEntry::position() const |
1138 | -{ |
1139 | - return m_position; |
1140 | -} |
1141 | - |
1142 | -QStringList |
1143 | -PlaceEntry::mimetypes() const |
1144 | -{ |
1145 | - return m_mimetypes; |
1146 | -} |
1147 | - |
1148 | -bool |
1149 | -PlaceEntry::sensitive() const |
1150 | -{ |
1151 | - return m_sensitive; |
1152 | -} |
1153 | - |
1154 | -DeeListModel* |
1155 | -PlaceEntry::sections() const |
1156 | -{ |
1157 | - return m_sections; |
1158 | -} |
1159 | - |
1160 | -QMap<QString, QVariant> |
1161 | -PlaceEntry::hints() const |
1162 | -{ |
1163 | - return m_hints; |
1164 | -} |
1165 | - |
1166 | -QString |
1167 | -PlaceEntry::searchHint() const |
1168 | -{ |
1169 | - return m_searchHint; |
1170 | -} |
1171 | - |
1172 | -bool |
1173 | -PlaceEntry::showEntry() const |
1174 | -{ |
1175 | - return m_showEntry; |
1176 | -} |
1177 | - |
1178 | -int |
1179 | -PlaceEntry::activeSection() const |
1180 | -{ |
1181 | - return m_activeSection; |
1182 | -} |
1183 | - |
1184 | -bool |
1185 | -PlaceEntry::active() const |
1186 | -{ |
1187 | - return m_active; |
1188 | -} |
1189 | - |
1190 | -Place* |
1191 | -PlaceEntry::place() const |
1192 | -{ |
1193 | - return m_place; |
1194 | -} |
1195 | - |
1196 | -QString |
1197 | -PlaceEntry::entrySearchQuery() const |
1198 | -{ |
1199 | - return m_entrySearchQuery; |
1200 | -} |
1201 | - |
1202 | -QString |
1203 | -PlaceEntry::entryRendererName() const |
1204 | -{ |
1205 | - return m_entryRendererName; |
1206 | -} |
1207 | - |
1208 | -QString |
1209 | -PlaceEntry::entryGroupsModelName() const |
1210 | -{ |
1211 | - return m_entryGroupsModelName; |
1212 | -} |
1213 | - |
1214 | -DeeListModel* |
1215 | -PlaceEntry::entryGroupsModel() |
1216 | -{ |
1217 | - if (m_entryGroupsModel == NULL) { |
1218 | - if (!m_entryGroupsModelName.isNull()) { |
1219 | - m_entryGroupsModel = new DeeListModel; |
1220 | - m_entryGroupsModel->setName(m_entryGroupsModelName); |
1221 | - } |
1222 | - } |
1223 | - return m_entryGroupsModel; |
1224 | -} |
1225 | - |
1226 | -QString |
1227 | -PlaceEntry::entryResultsModelName() const |
1228 | -{ |
1229 | - return m_entryResultsModelName; |
1230 | -} |
1231 | - |
1232 | -DeeListModel* |
1233 | -PlaceEntry::entryResultsModel() |
1234 | -{ |
1235 | - if (m_entryResultsModel == NULL) { |
1236 | - if (!m_entryResultsModelName.isNull()) { |
1237 | - m_entryResultsModel = new DeeListModel; |
1238 | - m_entryResultsModel->setName(m_entryResultsModelName); |
1239 | - } |
1240 | - } |
1241 | - return m_entryResultsModel; |
1242 | -} |
1243 | - |
1244 | -QMap<QString, QVariant> |
1245 | -PlaceEntry::entryRendererHints() const |
1246 | -{ |
1247 | - return m_entryRendererHints; |
1248 | -} |
1249 | - |
1250 | -QString |
1251 | -PlaceEntry::globalSearchQuery() const |
1252 | -{ |
1253 | - return m_globalSearchQuery; |
1254 | -} |
1255 | - |
1256 | -QString |
1257 | -PlaceEntry::globalRendererName() const |
1258 | -{ |
1259 | - return m_globalRendererName; |
1260 | -} |
1261 | - |
1262 | -QString |
1263 | -PlaceEntry::globalGroupsModelName() const |
1264 | -{ |
1265 | - return m_globalGroupsModelName; |
1266 | -} |
1267 | - |
1268 | -DeeListModel* |
1269 | -PlaceEntry::globalGroupsModel() |
1270 | -{ |
1271 | - if (m_globalGroupsModel == NULL) { |
1272 | - if (!m_globalGroupsModelName.isNull()) { |
1273 | - m_globalGroupsModel = new DeeListModel; |
1274 | - m_globalGroupsModel->setName(m_globalGroupsModelName); |
1275 | - } |
1276 | - } |
1277 | - return m_globalGroupsModel; |
1278 | -} |
1279 | - |
1280 | -QString |
1281 | -PlaceEntry::globalResultsModelName() const |
1282 | -{ |
1283 | - return m_globalResultsModelName; |
1284 | -} |
1285 | - |
1286 | -DeeListModel* |
1287 | -PlaceEntry::globalResultsModel() |
1288 | -{ |
1289 | - if (m_globalResultsModel == NULL) { |
1290 | - if (!m_globalResultsModelName.isNull()) { |
1291 | - m_globalResultsModel = new DeeListModel; |
1292 | - m_globalResultsModel->setName(m_globalResultsModelName); |
1293 | - } |
1294 | - } |
1295 | - return m_globalResultsModel; |
1296 | -} |
1297 | - |
1298 | -QMap<QString, QVariant> |
1299 | -PlaceEntry::globalRendererHints() const |
1300 | -{ |
1301 | - return m_globalRendererHints; |
1302 | -} |
1303 | - |
1304 | -void |
1305 | -PlaceEntry::setDbusName(const QString& dbusName) |
1306 | -{ |
1307 | - m_dbusName = dbusName; |
1308 | -} |
1309 | - |
1310 | -void |
1311 | -PlaceEntry::setDbusObjectPath(const QString& dbusObjectPath) |
1312 | -{ |
1313 | - m_dbusObjectPath = dbusObjectPath; |
1314 | -} |
1315 | - |
1316 | -void |
1317 | -PlaceEntry::setPosition(uint position) |
1318 | -{ |
1319 | - if (position != m_position) { |
1320 | - m_position = position; |
1321 | - Q_EMIT positionChanged(position); |
1322 | - } |
1323 | -} |
1324 | - |
1325 | -void |
1326 | -PlaceEntry::setMimetypes(const QStringList& mimetypes) |
1327 | -{ |
1328 | - m_mimetypes = mimetypes; |
1329 | - Q_EMIT mimetypesChanged(); |
1330 | -} |
1331 | - |
1332 | -void |
1333 | -PlaceEntry::setSensitive(bool sensitive) |
1334 | -{ |
1335 | - if (sensitive != m_sensitive) { |
1336 | - m_sensitive = sensitive; |
1337 | - Q_EMIT sensitiveChanged(sensitive); |
1338 | - } |
1339 | -} |
1340 | - |
1341 | -void |
1342 | -PlaceEntry::setSections(DeeListModel* sections) |
1343 | -{ |
1344 | - if (sections == NULL) { |
1345 | - return; |
1346 | - } |
1347 | - if (m_sections != NULL) { |
1348 | - delete m_sections; |
1349 | - } |
1350 | - m_sections = sections; |
1351 | - Q_EMIT sectionsChanged(); |
1352 | -} |
1353 | - |
1354 | -void |
1355 | -PlaceEntry::setHints(const QMap<QString, QVariant>& hints) |
1356 | -{ |
1357 | - m_hints = hints; |
1358 | - Q_EMIT hintsChanged(); |
1359 | -} |
1360 | - |
1361 | -void |
1362 | -PlaceEntry::setSearchHint(const QString& searchHint) |
1363 | -{ |
1364 | - if (m_searchHint != searchHint) { |
1365 | - m_searchHint = searchHint; |
1366 | - Q_EMIT searchHintChanged(m_searchHint); |
1367 | - } |
1368 | -} |
1369 | - |
1370 | -void |
1371 | -PlaceEntry::setShowEntry(bool showEntry) |
1372 | -{ |
1373 | - if (m_showEntry != showEntry) { |
1374 | - m_showEntry = showEntry; |
1375 | - Q_EMIT showEntryChanged(m_showEntry); |
1376 | - } |
1377 | -} |
1378 | - |
1379 | -void |
1380 | -PlaceEntry::setActiveSection(int activeSection) |
1381 | -{ |
1382 | - if (activeSection != m_activeSection) { |
1383 | - m_activeSection = activeSection; |
1384 | - if (m_dbusIface != NULL) { |
1385 | - /* the cast to uint is necessary for the D-Bus call to succeed as the |
1386 | - interface expects that type */ |
1387 | - m_dbusIface->asyncCall("SetActiveSection", (uint)m_activeSection); |
1388 | - } |
1389 | - Q_EMIT activeSectionChanged(); |
1390 | - } |
1391 | -} |
1392 | - |
1393 | -void |
1394 | -PlaceEntry::setActive(bool active) |
1395 | -{ |
1396 | - if (active != m_active) { |
1397 | - m_active = active; |
1398 | - if (m_dbusIface != NULL) { |
1399 | - m_dbusIface->asyncCall("SetActive", m_active); |
1400 | - } |
1401 | - Q_EMIT activeChanged(); |
1402 | - |
1403 | - if (m_dbusIface && m_active) { |
1404 | - /* SetActiveSection needs to be called after SetActive(true) |
1405 | - in order for it to have an effect. */ |
1406 | - m_dbusIface->asyncCall("SetActiveSection", m_activeSection); |
1407 | - } |
1408 | - } |
1409 | -} |
1410 | - |
1411 | -void |
1412 | -PlaceEntry::setEntrySearchQuery(const QString& entrySearchQuery) |
1413 | -{ |
1414 | - if (entrySearchQuery != m_entrySearchQuery) { |
1415 | - m_entrySearchQuery = entrySearchQuery; |
1416 | - if (m_dbusIface != NULL) { |
1417 | - QHash<QString, QString> searchHints; |
1418 | - m_dbusIface->asyncCall("SetSearch", m_entrySearchQuery, qVariantFromValue(searchHints)); |
1419 | - } |
1420 | - Q_EMIT entrySearchQueryChanged(); |
1421 | - } |
1422 | -} |
1423 | - |
1424 | -void |
1425 | -PlaceEntry::setEntryRendererName(const QString& entryRendererName) |
1426 | -{ |
1427 | - if (entryRendererName != m_entryRendererName) { |
1428 | - m_entryRendererName = entryRendererName; |
1429 | - Q_EMIT entryRendererNameChanged(); |
1430 | - } |
1431 | -} |
1432 | - |
1433 | -void |
1434 | -PlaceEntry::setEntryGroupsModelName(const QString& entryGroupsModelName) |
1435 | -{ |
1436 | - if (entryGroupsModelName != m_entryGroupsModelName) { |
1437 | - m_entryGroupsModelName = entryGroupsModelName; |
1438 | - delete m_entryGroupsModel; |
1439 | - m_entryGroupsModel = NULL; |
1440 | - Q_EMIT entryGroupsModelNameChanged(); |
1441 | - Q_EMIT entryGroupsModelChanged(); |
1442 | - } |
1443 | -} |
1444 | - |
1445 | -void |
1446 | -PlaceEntry::setEntryGroupsModel(DeeListModel* entryGroupsModel) |
1447 | -{ |
1448 | - if (entryGroupsModel == NULL) { |
1449 | - return; |
1450 | - } |
1451 | - if (m_entryGroupsModel != NULL) { |
1452 | - delete m_entryGroupsModel; |
1453 | - } |
1454 | - m_entryGroupsModel = entryGroupsModel; |
1455 | - Q_EMIT entryGroupsModelChanged(); |
1456 | -} |
1457 | - |
1458 | -void |
1459 | -PlaceEntry::setEntryResultsModelName(const QString& entryResultsModelName) |
1460 | -{ |
1461 | - if (entryResultsModelName != m_entryResultsModelName) { |
1462 | - m_entryResultsModelName = entryResultsModelName; |
1463 | - delete m_entryResultsModel; |
1464 | - m_entryResultsModel = NULL; |
1465 | - Q_EMIT entryResultsModelNameChanged(); |
1466 | - Q_EMIT entryResultsModelChanged(); |
1467 | - } |
1468 | -} |
1469 | - |
1470 | -void |
1471 | -PlaceEntry::setEntryResultsModel(DeeListModel* entryResultsModel) |
1472 | -{ |
1473 | - if (entryResultsModel == NULL) { |
1474 | - return; |
1475 | - } |
1476 | - if (m_entryResultsModel != NULL) { |
1477 | - delete m_entryResultsModel; |
1478 | - } |
1479 | - m_entryResultsModel = entryResultsModel; |
1480 | - Q_EMIT entryResultsModelChanged(); |
1481 | -} |
1482 | - |
1483 | -void |
1484 | -PlaceEntry::setEntryRendererHints(const QMap<QString, QVariant>& entryRendererHints) |
1485 | -{ |
1486 | - m_entryRendererHints = entryRendererHints; |
1487 | - Q_EMIT entryRendererHintsChanged(); |
1488 | -} |
1489 | - |
1490 | -void |
1491 | -PlaceEntry::setGlobalSearchQuery(const QString& globalSearchQuery) |
1492 | -{ |
1493 | - if (globalSearchQuery != m_globalSearchQuery) { |
1494 | - m_globalSearchQuery = globalSearchQuery; |
1495 | - if (m_dbusIface != NULL) { |
1496 | - QHash<QString, QString> searchHints; |
1497 | - m_dbusIface->asyncCall("SetGlobalSearch", m_globalSearchQuery, qVariantFromValue(searchHints)); |
1498 | - } |
1499 | - Q_EMIT globalSearchQueryChanged(); |
1500 | - } |
1501 | -} |
1502 | - |
1503 | -void |
1504 | -PlaceEntry::setGlobalRendererName(const QString& globalRendererName) |
1505 | -{ |
1506 | - if (globalRendererName != m_globalRendererName) { |
1507 | - m_globalRendererName = globalRendererName; |
1508 | - Q_EMIT globalRendererNameChanged(); |
1509 | - } |
1510 | -} |
1511 | - |
1512 | -void |
1513 | -PlaceEntry::setGlobalGroupsModelName(const QString& globalGroupsModelName) |
1514 | -{ |
1515 | - if (globalGroupsModelName != m_globalGroupsModelName) { |
1516 | - m_globalGroupsModelName = globalGroupsModelName; |
1517 | - delete m_globalGroupsModel; |
1518 | - m_globalGroupsModel = NULL; |
1519 | - Q_EMIT globalGroupsModelNameChanged(); |
1520 | - Q_EMIT globalGroupsModelChanged(); |
1521 | - } |
1522 | -} |
1523 | - |
1524 | -void |
1525 | -PlaceEntry::setGlobalGroupsModel(DeeListModel* globalGroupsModel) |
1526 | -{ |
1527 | - if (globalGroupsModel == NULL) { |
1528 | - return; |
1529 | - } |
1530 | - if (m_globalGroupsModel != NULL) { |
1531 | - delete m_globalGroupsModel; |
1532 | - } |
1533 | - m_globalGroupsModel = globalGroupsModel; |
1534 | - Q_EMIT globalGroupsModelChanged(); |
1535 | -} |
1536 | - |
1537 | -void |
1538 | -PlaceEntry::setGlobalResultsModelName(const QString& globalResultsModelName) |
1539 | -{ |
1540 | - if (globalResultsModelName != m_globalResultsModelName) { |
1541 | - m_globalResultsModelName = globalResultsModelName; |
1542 | - delete m_globalResultsModel; |
1543 | - m_globalResultsModel = NULL; |
1544 | - Q_EMIT globalResultsModelNameChanged(); |
1545 | - Q_EMIT globalResultsModelChanged(); |
1546 | - } |
1547 | -} |
1548 | - |
1549 | -void |
1550 | -PlaceEntry::setGlobalResultsModel(DeeListModel* globalResultsModel) |
1551 | -{ |
1552 | - if (globalResultsModel == NULL) { |
1553 | - return; |
1554 | - } |
1555 | - if (m_globalResultsModel != NULL) { |
1556 | - delete m_globalResultsModel; |
1557 | - } |
1558 | - m_globalResultsModel = globalResultsModel; |
1559 | - Q_EMIT globalResultsModelChanged(); |
1560 | -} |
1561 | - |
1562 | -void |
1563 | -PlaceEntry::setGlobalRendererHints(const QMap<QString, QVariant>& globalRendererHints) |
1564 | -{ |
1565 | - m_globalRendererHints = globalRendererHints; |
1566 | - Q_EMIT globalRendererHintsChanged(); |
1567 | -} |
1568 | - |
1569 | - |
1570 | -void |
1571 | -PlaceEntry::slotActivePageChanged(const QString& page) |
1572 | -{ |
1573 | - bool active = false; |
1574 | - if (!m_dbusObjectPath.isEmpty() && page == m_dbusObjectPath) { |
1575 | - active = true; |
1576 | - } |
1577 | - |
1578 | - if (active != m_active) { |
1579 | - m_active = active; |
1580 | - Q_EMIT activeChanged(); |
1581 | - } |
1582 | -} |
1583 | - |
1584 | -void |
1585 | -PlaceEntry::activate() |
1586 | -{ |
1587 | - activateEntry(0); |
1588 | -} |
1589 | - |
1590 | -void |
1591 | -PlaceEntry::activateEntry(const int section) |
1592 | -{ |
1593 | - if (!m_sensitive) { |
1594 | - startRemotePlaceOnDemand(); |
1595 | - } |
1596 | - |
1597 | - if (m_active) { |
1598 | - DashClient::instance()->setActivePage(QString()); |
1599 | - } else { |
1600 | - /* FIXME: DashClient::setActivePage has changed but PlaceEntry is deprecated anyway */ |
1601 | - //DashClient::instance()->setActivePage(m_dbusObjectPath, m_fileName, m_groupName, section); |
1602 | - } |
1603 | -} |
1604 | - |
1605 | -void |
1606 | -PlaceEntry::startRemotePlaceOnDemand() |
1607 | -{ |
1608 | - /* On-demand startup of the place. */ |
1609 | - Place* place = qobject_cast<Place*>(parent()); |
1610 | - place->connectToRemotePlace(); |
1611 | -} |
1612 | - |
1613 | -void |
1614 | -PlaceEntry::createMenuActions() |
1615 | -{ |
1616 | - if (!m_sensitive) { |
1617 | - /* Monitor updates to the list of sections upon starting the remote |
1618 | - place. */ |
1619 | - startMonitoringSections(); |
1620 | - |
1621 | - startRemotePlaceOnDemand(); |
1622 | - } |
1623 | - |
1624 | - if (m_sections == NULL) { |
1625 | - return; |
1626 | - } |
1627 | - |
1628 | - for (int i = 0; i < m_sections->rowCount(); ++i) { |
1629 | - QAction* section = new QAction(m_menu); |
1630 | - QString sectionName = m_sections->data(m_sections->index(i)).toString(); |
1631 | - /* Escape ampersands so that they are not considered as keyboard accelerators. */ |
1632 | - sectionName.replace("&", "&&"); |
1633 | - section->setText(sectionName); |
1634 | - section->setProperty(SECTION_PROPERTY, QVariant(i)); |
1635 | - m_menu->addAction(section); |
1636 | - QObject::connect(section, SIGNAL(triggered()), this, SLOT(onSectionTriggered())); |
1637 | - } |
1638 | -} |
1639 | - |
1640 | -void |
1641 | -PlaceEntry::startMonitoringSections() |
1642 | -{ |
1643 | - connect(this, SIGNAL(sectionsChanged()), SLOT(slotSectionsChanged())); |
1644 | -} |
1645 | - |
1646 | -void |
1647 | -PlaceEntry::stopMonitoringSections() |
1648 | -{ |
1649 | - disconnect(SIGNAL(sectionsChanged()), this, SLOT(slotSectionsChanged())); |
1650 | -} |
1651 | - |
1652 | -void |
1653 | -PlaceEntry::slotSectionsChanged() |
1654 | -{ |
1655 | - /* This is a one-shot slot. */ |
1656 | - stopMonitoringSections(); |
1657 | - |
1658 | - createMenuActions(); |
1659 | -} |
1660 | - |
1661 | -void |
1662 | -PlaceEntry::onSectionTriggered() |
1663 | -{ |
1664 | - QAction* action = static_cast<QAction*>(sender()); |
1665 | - int section = action->property(SECTION_PROPERTY).toInt(); |
1666 | - m_menu->hide(); |
1667 | - activateEntry(section); |
1668 | -} |
1669 | - |
1670 | -void |
1671 | -PlaceEntry::connectToRemotePlaceEntry() |
1672 | -{ |
1673 | - delete m_dbusIface; |
1674 | - m_dbusIface = new QDBusInterface(m_dbusName, m_dbusObjectPath, |
1675 | - UNITY_PLACE_ENTRY_INTERFACE); |
1676 | - QDBusConnection connection = m_dbusIface->connection(); |
1677 | - if (!connection.isConnected()) { |
1678 | - return; |
1679 | - } |
1680 | - |
1681 | - // Connect to RendererInfoChanged and PlaceEntryInfoChanged signals |
1682 | - connection.connect(m_dbusName, m_dbusObjectPath, UNITY_PLACE_ENTRY_INTERFACE, |
1683 | - "RendererInfoChanged", this, |
1684 | - SLOT(onRendererInfoChanged(const RendererInfoStruct&))); |
1685 | - connection.connect(m_dbusName, m_dbusObjectPath, UNITY_PLACE_ENTRY_INTERFACE, |
1686 | - "PlaceEntryInfoChanged", this, |
1687 | - SLOT(updateInfo(const PlaceEntryInfoStruct&))); |
1688 | - |
1689 | - /* Update state of D-Bus daemon according to the values of local properties */ |
1690 | - QHash<QString, QString> searchHints; |
1691 | - m_dbusIface->asyncCall("SetSearch", m_entrySearchQuery, qVariantFromValue(searchHints)); |
1692 | - m_dbusIface->asyncCall("SetGlobalSearch", m_globalSearchQuery, qVariantFromValue(searchHints)); |
1693 | - m_dbusIface->asyncCall("SetActive", m_active); |
1694 | - m_dbusIface->asyncCall("SetActiveSection", m_activeSection); |
1695 | -} |
1696 | - |
1697 | -void |
1698 | -PlaceEntry::updateInfo(const PlaceEntryInfoStruct& info) |
1699 | -{ |
1700 | - if (!info.name.isEmpty()) { |
1701 | - setName(info.name); |
1702 | - } |
1703 | - if (!info.icon.isEmpty()) { |
1704 | - setIcon(info.icon); |
1705 | - } |
1706 | - setPosition(info.position); |
1707 | - setMimetypes(info.mimetypes); |
1708 | - setSensitive(info.sensitive); |
1709 | - setSection(info.sections_model); |
1710 | - |
1711 | - QMap<QString, QVariant> hints; |
1712 | - QMap<QString, QString>::const_iterator i; |
1713 | - for (i = info.hints.constBegin(); i != info.hints.constEnd(); ++i) { |
1714 | - hints[i.key()] = QVariant(i.value()); |
1715 | - } |
1716 | - setHints(hints); |
1717 | - |
1718 | - setEntryRendererName(info.entry_renderer_info.default_renderer); |
1719 | - setEntryGroupsModelName(info.entry_renderer_info.groups_model); |
1720 | - setEntryResultsModelName(info.entry_renderer_info.results_model); |
1721 | - |
1722 | - QMap<QString, QVariant> entryRendererHints; |
1723 | - for (i = info.entry_renderer_info.renderer_hints.constBegin(); |
1724 | - i != info.entry_renderer_info.renderer_hints.constEnd(); ++i) { |
1725 | - entryRendererHints[i.key()] = QVariant(i.value()); |
1726 | - } |
1727 | - setEntryRendererHints(entryRendererHints); |
1728 | - |
1729 | - setGlobalRendererName(info.global_renderer_info.default_renderer); |
1730 | - setGlobalGroupsModelName(info.global_renderer_info.groups_model); |
1731 | - setGlobalResultsModelName(info.global_renderer_info.results_model); |
1732 | - |
1733 | - QMap<QString, QVariant> globalRendererHints; |
1734 | - for (i = info.global_renderer_info.renderer_hints.constBegin(); |
1735 | - i != info.global_renderer_info.renderer_hints.constEnd(); ++i) { |
1736 | - globalRendererHints[i.key()] = QVariant(i.value()); |
1737 | - } |
1738 | - setGlobalRendererHints(globalRendererHints); |
1739 | - |
1740 | - Q_EMIT updated(); |
1741 | - Q_EMIT rendererInfoChanged(); |
1742 | -} |
1743 | - |
1744 | -void |
1745 | -PlaceEntry::setSection(const QString& sectionModelName) |
1746 | -{ |
1747 | - DeeListModel* sections = new DeeListModel; |
1748 | - sections->setName(sectionModelName); |
1749 | - setSections(sections); |
1750 | -} |
1751 | - |
1752 | -void |
1753 | -PlaceEntry::onRendererInfoChanged(const RendererInfoStruct& r) |
1754 | -{ |
1755 | - setEntryRendererName(r.default_renderer); |
1756 | - setEntryGroupsModelName(r.groups_model); |
1757 | - setEntryResultsModelName(r.results_model); |
1758 | - |
1759 | - QMap<QString, QVariant> entryRendererHints; |
1760 | - QMap<QString, QString>::const_iterator i; |
1761 | - for (i = r.renderer_hints.constBegin(); |
1762 | - i != r.renderer_hints.constEnd(); ++i) { |
1763 | - entryRendererHints[i.key()] = QVariant(i.value()); |
1764 | - } |
1765 | - setEntryRendererHints(entryRendererHints); |
1766 | - |
1767 | - Q_EMIT updated(); |
1768 | - Q_EMIT rendererInfoChanged(); |
1769 | -} |
1770 | - |
1771 | -#include "placeentry.moc" |
1772 | |
1773 | === removed file 'libunity-2d-private/src/placeentry.h' |
1774 | --- libunity-2d-private/src/placeentry.h 2012-01-13 15:05:44 +0000 |
1775 | +++ libunity-2d-private/src/placeentry.h 1970-01-01 00:00:00 +0000 |
1776 | @@ -1,290 +0,0 @@ |
1777 | -/* |
1778 | - * Copyright (C) 2010 Canonical, Ltd. |
1779 | - * |
1780 | - * Authors: |
1781 | - * Olivier Tilloy <olivier.tilloy@canonical.com> |
1782 | - * |
1783 | - * This program is free software; you can redistribute it and/or modify |
1784 | - * it under the terms of the GNU General Public License as published by |
1785 | - * the Free Software Foundation; version 3. |
1786 | - * |
1787 | - * This program is distributed in the hope that it will be useful, |
1788 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1789 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1790 | - * GNU General Public License for more details. |
1791 | - * |
1792 | - * You should have received a copy of the GNU General Public License |
1793 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1794 | - */ |
1795 | - |
1796 | -#ifndef PLACEENTRY_H |
1797 | -#define PLACEENTRY_H |
1798 | - |
1799 | -#include "launcheritem.h" |
1800 | - |
1801 | -// QtDee |
1802 | -class DeeListModel; |
1803 | - |
1804 | -#include <QMetaType> |
1805 | -#include <QDBusInterface> |
1806 | -#include <QDBusArgument> |
1807 | - |
1808 | -// https://wiki.ubuntu.com/Unity/Places#RendererInfo |
1809 | -struct RendererInfoStruct |
1810 | -{ |
1811 | - QString default_renderer; |
1812 | - QString groups_model; |
1813 | - QString results_model; |
1814 | - QMap<QString, QString> renderer_hints; |
1815 | -}; |
1816 | -Q_DECLARE_METATYPE(RendererInfoStruct) |
1817 | - |
1818 | -// Marshalling and unmarshalling of RendererInfoStruct |
1819 | -QDBusArgument &operator<<(QDBusArgument &, const RendererInfoStruct &); |
1820 | -const QDBusArgument &operator>>(const QDBusArgument &, RendererInfoStruct &); |
1821 | - |
1822 | - |
1823 | -// https://wiki.ubuntu.com/Unity/Places#PlaceEntryInfo |
1824 | -struct PlaceEntryInfoStruct |
1825 | -{ |
1826 | - QString dbus_path; |
1827 | - QString name; |
1828 | - QString icon; |
1829 | - uint position; |
1830 | - QStringList mimetypes; |
1831 | - bool sensitive; |
1832 | - QString sections_model; |
1833 | - QMap<QString, QString> hints; |
1834 | - RendererInfoStruct entry_renderer_info; |
1835 | - RendererInfoStruct global_renderer_info; |
1836 | -}; |
1837 | -Q_DECLARE_METATYPE(PlaceEntryInfoStruct) |
1838 | -Q_DECLARE_METATYPE(QList<PlaceEntryInfoStruct>) |
1839 | - |
1840 | -// Marshalling and unmarshalling of PlaceEntryInfoStruct |
1841 | -QDBusArgument &operator<<(QDBusArgument &, const PlaceEntryInfoStruct &); |
1842 | -const QDBusArgument &operator>>(const QDBusArgument &, PlaceEntryInfoStruct &); |
1843 | - |
1844 | -class Place; |
1845 | - |
1846 | -class PlaceEntry : public LauncherItem |
1847 | -{ |
1848 | - Q_OBJECT |
1849 | - |
1850 | - Q_PROPERTY(QString fileName READ fileName WRITE setFileName) |
1851 | - Q_PROPERTY(QString groupName READ groupName WRITE setGroupName) |
1852 | - Q_PROPERTY(QString dbusName READ dbusName WRITE setDbusName) |
1853 | - Q_PROPERTY(QString dbusObjectPath READ dbusObjectPath WRITE setDbusObjectPath) |
1854 | - Q_PROPERTY(uint position READ position WRITE setPosition NOTIFY positionChanged) |
1855 | - Q_PROPERTY(QStringList mimetypes READ mimetypes WRITE setMimetypes NOTIFY mimetypesChanged) |
1856 | - Q_PROPERTY(bool sensitive READ sensitive WRITE setSensitive NOTIFY sensitiveChanged) |
1857 | - Q_PROPERTY(DeeListModel* sections READ sections WRITE setSections NOTIFY sectionsChanged) |
1858 | - Q_PROPERTY(QMap hints READ hints WRITE setHints NOTIFY hintsChanged) |
1859 | - Q_PROPERTY(QString searchHint READ searchHint WRITE setSearchHint NOTIFY searchHintChanged) |
1860 | - Q_PROPERTY(bool showEntry READ showEntry WRITE setShowEntry NOTIFY showEntryChanged) |
1861 | - Q_PROPERTY(int activeSection READ activeSection WRITE setActiveSection NOTIFY activeSectionChanged) |
1862 | - Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged) |
1863 | - Q_PROPERTY(Place* place READ place) |
1864 | - |
1865 | - /* Entry rendering info */ |
1866 | - Q_PROPERTY(QString entrySearchQuery READ entrySearchQuery WRITE setEntrySearchQuery NOTIFY entrySearchQueryChanged) |
1867 | - Q_PROPERTY(QString entryRendererName READ entryRendererName WRITE setEntryRendererName NOTIFY entryRendererNameChanged) |
1868 | - Q_PROPERTY(QString entryGroupsModelName READ entryGroupsModelName WRITE setEntryGroupsModelName NOTIFY entryGroupsModelNameChanged) |
1869 | - Q_PROPERTY(DeeListModel* entryGroupsModel READ entryGroupsModel WRITE setEntryGroupsModel NOTIFY entryGroupsModelChanged) |
1870 | - Q_PROPERTY(QString entryResultsModelName READ entryResultsModelName WRITE setEntryResultsModelName NOTIFY entryResultsModelNameChanged) |
1871 | - Q_PROPERTY(DeeListModel* entryResultsModel READ entryResultsModel WRITE setEntryResultsModel NOTIFY entryResultsModelChanged) |
1872 | - Q_PROPERTY(QMap entryRendererHints READ entryRendererHints WRITE setEntryRendererHints NOTIFY entryRendererHintsChanged) |
1873 | - |
1874 | - /* Global rendering info */ |
1875 | - Q_PROPERTY(QString globalSearchQuery READ globalSearchQuery WRITE setGlobalSearchQuery NOTIFY globalSearchQueryChanged) |
1876 | - Q_PROPERTY(QString globalRendererName READ globalRendererName WRITE setGlobalRendererName NOTIFY globalRendererNameChanged) |
1877 | - Q_PROPERTY(QString globalGroupsModelName READ globalGroupsModelName WRITE setGlobalGroupsModelName NOTIFY globalGroupsModelNameChanged) |
1878 | - Q_PROPERTY(DeeListModel* globalGroupsModel READ globalGroupsModel WRITE setGlobalGroupsModel NOTIFY globalGroupsModelChanged) |
1879 | - Q_PROPERTY(QString globalResultsModelName READ globalResultsModelName WRITE setGlobalResultsModelName NOTIFY globalResultsModelNameChanged) |
1880 | - Q_PROPERTY(DeeListModel* globalResultsModel READ globalResultsModel WRITE setGlobalResultsModel NOTIFY globalResultsModelChanged) |
1881 | - Q_PROPERTY(QMap globalRendererHints READ globalRendererHints WRITE setGlobalRendererHints NOTIFY globalRendererHintsChanged) |
1882 | - |
1883 | -public: |
1884 | - PlaceEntry(QObject* parent = 0); |
1885 | - PlaceEntry(const PlaceEntry& other); |
1886 | - ~PlaceEntry(); |
1887 | - |
1888 | - /* getters */ |
1889 | - virtual bool active() const; |
1890 | - virtual bool running() const; |
1891 | - virtual int windowCount() const; |
1892 | - virtual bool urgent() const; |
1893 | - virtual QString name() const; |
1894 | - virtual QString icon() const; |
1895 | - virtual bool launching() const; |
1896 | - QString fileName() const; |
1897 | - QString groupName() const; |
1898 | - QString dbusName() const; |
1899 | - QString dbusObjectPath() const; |
1900 | - uint position() const; |
1901 | - QStringList mimetypes() const; |
1902 | - bool sensitive() const; |
1903 | - DeeListModel* sections() const; |
1904 | - QMap<QString, QVariant> hints() const; |
1905 | - QString searchHint() const; |
1906 | - bool showEntry() const; |
1907 | - int activeSection() const; |
1908 | - Place* place() const; |
1909 | - |
1910 | - QString entrySearchQuery() const; |
1911 | - QString entryRendererName() const; |
1912 | - QString entryGroupsModelName() const; |
1913 | - DeeListModel* entryGroupsModel(); |
1914 | - QString entryResultsModelName() const; |
1915 | - DeeListModel* entryResultsModel(); |
1916 | - QMap<QString, QVariant> entryRendererHints() const; |
1917 | - |
1918 | - QString globalSearchQuery() const; |
1919 | - QString globalRendererName() const; |
1920 | - QString globalGroupsModelName() const; |
1921 | - DeeListModel* globalGroupsModel(); |
1922 | - QString globalResultsModelName() const; |
1923 | - DeeListModel* globalResultsModel(); |
1924 | - QMap<QString, QVariant> globalRendererHints() const; |
1925 | - |
1926 | - /* setters */ |
1927 | - void setName(const QString &); |
1928 | - void setIcon(const QString &); |
1929 | - void setFileName(const QString &); |
1930 | - void setGroupName(const QString &); |
1931 | - void setDbusName(const QString &); |
1932 | - void setDbusObjectPath(const QString &); |
1933 | - void setPosition(uint); |
1934 | - void setMimetypes(const QStringList &); |
1935 | - void setSensitive(bool); |
1936 | - void setSections(DeeListModel*); |
1937 | - void setHints(const QMap<QString, QVariant> &); |
1938 | - void setSearchHint(const QString&); |
1939 | - void setShowEntry(bool); |
1940 | - void setActiveSection(int); |
1941 | - void setActive(bool); |
1942 | - |
1943 | - void setEntrySearchQuery(const QString &); |
1944 | - void setEntryRendererName(const QString &); |
1945 | - void setEntryGroupsModelName(const QString &); |
1946 | - void setEntryGroupsModel(DeeListModel*); |
1947 | - void setEntryResultsModelName(const QString &); |
1948 | - void setEntryResultsModel(DeeListModel*); |
1949 | - void setEntryRendererHints(const QMap<QString, QVariant> &); |
1950 | - |
1951 | - void setGlobalSearchQuery(const QString &); |
1952 | - void setGlobalRendererName(const QString &); |
1953 | - void setGlobalGroupsModelName(const QString &); |
1954 | - void setGlobalGroupsModel(DeeListModel*); |
1955 | - void setGlobalResultsModelName(const QString &); |
1956 | - void setGlobalResultsModel(DeeListModel*); |
1957 | - void setGlobalRendererHints(const QMap<QString, QVariant>&); |
1958 | - |
1959 | - /* methods */ |
1960 | - Q_INVOKABLE virtual void activate(); |
1961 | - Q_INVOKABLE virtual void createMenuActions(); |
1962 | - |
1963 | - /* Connect to the remote representation of the entry on DBus and monitor |
1964 | - changes. */ |
1965 | - void connectToRemotePlaceEntry(); |
1966 | - |
1967 | - void updateInfo(const PlaceEntryInfoStruct& info); |
1968 | - |
1969 | -Q_SIGNALS: |
1970 | - void positionChanged(uint); |
1971 | - void mimetypesChanged(); |
1972 | - void sensitiveChanged(bool); |
1973 | - void sectionsChanged(); |
1974 | - void hintsChanged(); |
1975 | - void searchHintChanged(QString); |
1976 | - void showEntryChanged(bool); |
1977 | - void activeSectionChanged(); |
1978 | - void activeChanged(); |
1979 | - |
1980 | - void entrySearchQueryChanged(); |
1981 | - void entryRendererNameChanged(); |
1982 | - void entryGroupsModelNameChanged(); |
1983 | - void entryGroupsModelChanged(); |
1984 | - void entryResultsModelNameChanged(); |
1985 | - void entryResultsModelChanged(); |
1986 | - void entryRendererHintsChanged(); |
1987 | - |
1988 | - void globalSearchQueryChanged(); |
1989 | - void globalRendererNameChanged(); |
1990 | - void globalGroupsModelNameChanged(); |
1991 | - void globalGroupsModelChanged(); |
1992 | - void globalResultsModelNameChanged(); |
1993 | - void globalResultsModelChanged(); |
1994 | - void globalRendererHintsChanged(); |
1995 | - |
1996 | - void updated(); |
1997 | - void rendererInfoChanged(); |
1998 | - |
1999 | -private: |
2000 | - QString m_fileName; |
2001 | - QString m_groupName; |
2002 | - QString m_dbusName; |
2003 | - QString m_dbusObjectPath; |
2004 | - QString m_icon; |
2005 | - QString m_name; |
2006 | - uint m_position; |
2007 | - QStringList m_mimetypes; |
2008 | - bool m_sensitive; |
2009 | - DeeListModel* m_sections; |
2010 | - /* m_hints should be a QMap<QString, QString> really, but it has to hold |
2011 | - QVariant values in order to allow exposing it as a property (see |
2012 | - http://doc.trolltech.com/properties.html#requirements-for-declaring-properties). */ |
2013 | - QMap<QString, QVariant> m_hints; |
2014 | - QString m_searchHint; |
2015 | - bool m_showEntry; |
2016 | - int m_activeSection; |
2017 | - bool m_active; |
2018 | - Place* m_place; |
2019 | - |
2020 | - QString m_entrySearchQuery; |
2021 | - QString m_entryRendererName; |
2022 | - QString m_entryGroupsModelName; |
2023 | - DeeListModel* m_entryGroupsModel; |
2024 | - QString m_entryResultsModelName; |
2025 | - DeeListModel* m_entryResultsModel; |
2026 | - /* The remark about m_hints also applies to m_entryRendererHints. */ |
2027 | - QMap<QString, QVariant> m_entryRendererHints; |
2028 | - |
2029 | - QString m_globalSearchQuery; |
2030 | - QString m_globalRendererName; |
2031 | - QString m_globalGroupsModelName; |
2032 | - DeeListModel* m_globalGroupsModel; |
2033 | - QString m_globalResultsModelName; |
2034 | - DeeListModel* m_globalResultsModel; |
2035 | - /* The remark about m_hints also applies to m_globalRendererHints. */ |
2036 | - QMap<QString, QVariant> m_globalRendererHints; |
2037 | - |
2038 | - QDBusInterface* m_dbusIface; |
2039 | - |
2040 | - void setSection(const QString&); |
2041 | - void activateEntry(const int section); |
2042 | - |
2043 | - void startRemotePlaceOnDemand(); |
2044 | - |
2045 | -private Q_SLOTS: |
2046 | - void onRendererInfoChanged(const RendererInfoStruct&); |
2047 | - |
2048 | - void startMonitoringSections(); |
2049 | - void stopMonitoringSections(); |
2050 | - void slotSectionsChanged(); |
2051 | - |
2052 | - void slotActivePageChanged(const QString& page); |
2053 | - |
2054 | - /* Contextual menu callbacks */ |
2055 | - void onSectionTriggered(); |
2056 | -}; |
2057 | - |
2058 | -Q_DECLARE_METATYPE(PlaceEntry*) |
2059 | - |
2060 | -/* Necessary workaround otherwise the preprocessor complains about |
2061 | - Q_DECLARE_METATYPE receiving 2 arguments instead of 1 */ |
2062 | -typedef QHash<QString, QString> __QHashQStringQString; |
2063 | -Q_DECLARE_METATYPE(__QHashQStringQString) |
2064 | - |
2065 | -#endif // PLACEENTRY_H |
2066 | - |