Merge lp:~mhr3/unity-scopes-shell/no-more-unity-core into lp:unity-scopes-shell

Proposed by Michal Hruby
Status: Merged
Approved by: Paweł Stołowski
Approved revision: 81
Merged at revision: 79
Proposed branch: lp:~mhr3/unity-scopes-shell/no-more-unity-core
Merge into: lp:unity-scopes-shell
Diff against target: 7076 lines (+44/-6051)
80 files modified
debian/changelog (+6/-0)
debian/control (+1/-5)
src/Unity/CMakeLists.txt (+9/-39)
src/Unity/abstractfilteroption.cpp (+0/-25)
src/Unity/abstractfilteroption.h (+0/-58)
src/Unity/applicationpreview.cpp (+0/-100)
src/Unity/applicationpreview.h (+0/-66)
src/Unity/categories.cpp (+0/-299)
src/Unity/categories.h (+0/-95)
src/Unity/categoryresults.cpp (+0/-121)
src/Unity/categoryresults.h (+0/-68)
src/Unity/checkoptionfilter.cpp (+0/-65)
src/Unity/checkoptionfilter.h (+0/-57)
src/Unity/filter.cpp (+0/-129)
src/Unity/filter.h (+0/-75)
src/Unity/filteroption.cpp (+0/-91)
src/Unity/filteroption.h (+0/-61)
src/Unity/filters.cpp (+0/-165)
src/Unity/filters.h (+0/-77)
src/Unity/genericoptionsmodel.cpp (+0/-187)
src/Unity/genericoptionsmodel.h (+0/-79)
src/Unity/genericpreview.cpp (+0/-31)
src/Unity/genericpreview.h (+0/-46)
src/Unity/iconutils.cpp (+7/-82)
src/Unity/iconutils.h (+1/-2)
src/Unity/moviepreview.cpp (+0/-67)
src/Unity/moviepreview.h (+0/-60)
src/Unity/multirangefilter.cpp (+0/-65)
src/Unity/multirangefilter.h (+0/-60)
src/Unity/musicpreview.cpp (+0/-53)
src/Unity/musicpreview.h (+0/-62)
src/Unity/musicpreviewtrackmodel.cpp (+0/-68)
src/Unity/musicpreviewtrackmodel.h (+0/-48)
src/Unity/plugin.cpp (+5/-36)
src/Unity/preview.cpp (+0/-199)
src/Unity/preview.h (+0/-89)
src/Unity/previewaction.cpp (+0/-75)
src/Unity/previewaction.h (+0/-71)
src/Unity/previewinfohint.cpp (+0/-67)
src/Unity/previewinfohint.h (+0/-58)
src/Unity/radiooptionfilter.cpp (+0/-61)
src/Unity/radiooptionfilter.h (+0/-59)
src/Unity/ratingfilteroption.cpp (+0/-62)
src/Unity/ratingfilteroption.h (+0/-53)
src/Unity/ratingoptionsmodel.cpp (+0/-33)
src/Unity/ratingoptionsmodel.h (+0/-33)
src/Unity/ratingsfilter.cpp (+0/-73)
src/Unity/ratingsfilter.h (+0/-66)
src/Unity/result.cpp (+0/-82)
src/Unity/result.h (+0/-69)
src/Unity/resultsmodel.cpp (+5/-17)
src/Unity/scope.cpp (+0/-1)
src/Unity/scope.h (+0/-154)
src/Unity/scopes-ng/CMakeLists.txt (+0/-26)
src/Unity/scopes.cpp (+0/-179)
src/Unity/scopes.h (+0/-95)
src/Unity/showallfilteroption.cpp (+0/-60)
src/Unity/showallfilteroption.h (+0/-51)
src/Unity/signalslist.cpp (+0/-39)
src/Unity/signalslist.h (+0/-38)
src/Unity/socialpreview.cpp (+0/-87)
src/Unity/socialpreview.h (+0/-63)
src/Unity/socialpreviewcomment.cpp (+0/-63)
src/Unity/socialpreviewcomment.h (+0/-57)
src/Unity/unityoptionsmodel.cpp (+0/-68)
src/Unity/unityoptionsmodel.h (+0/-50)
src/Unity/variantutils.cpp (+0/-82)
src/Unity/variantutils.h (+0/-35)
tests/CMakeLists.txt (+1/-20)
tests/data/mock-scope/CMakeLists.txt (+1/-1)
tests/filtersbindingstest.cpp (+0/-515)
tests/filtersbindingstest.h (+0/-47)
tests/previewbindingstest.cpp (+0/-194)
tests/previewbindingstest.h (+0/-35)
tests/resultstest-ng.cpp (+7/-7)
tests/resultstest.cpp (+0/-248)
tests/resultstest.h (+0/-39)
tests/signalslisttest.cpp (+0/-57)
tests/signalslisttest.h (+0/-30)
tests/utilstest-ng.cpp (+1/-1)
To merge this branch: bzr merge lp:~mhr3/unity-scopes-shell/no-more-unity-core
Reviewer Review Type Date Requested Status
Paweł Stołowski (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+212674@code.launchpad.net

Commit message

Remove support for unity-core based scopes.

Description of the change

Remove support for unity-core based scopes.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Paweł Stołowski (stolowski) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2014-03-24 13:09:23 +0000
3+++ debian/changelog 2014-03-25 16:56:23 +0000
4@@ -1,3 +1,9 @@
5+unity-scopes-shell (0.4.0+14.04.20140325-0ubuntu1) UNRELEASED; urgency=medium
6+
7+ * Drop support for unity-core based scopes
8+
9+ -- Michal Hruby <michal.hruby@canonical.com> Tue, 25 Mar 2014 16:48:16 +0000
10+
11 unity-scopes-shell (0.4.0+14.04.20140324-0ubuntu1) trusty; urgency=low
12
13 [ Michal Hruby ]
14
15=== modified file 'debian/control'
16--- debian/control 2014-03-06 17:10:12 +0000
17+++ debian/control 2014-03-25 16:56:23 +0000
18@@ -3,17 +3,14 @@
19 Section: libs
20 Build-Depends: cmake,
21 debhelper (>= 9),
22- libdee-qt5-dev (>= 3.2),
23- libglib2.0-dev,
24 libunity-api-dev,
25- libunity-core-6.0-dev (>= 7.1.2+14.04.20140213),
26 libunity-scopes-dev (>= 0.4.0~),
27 pkg-config,
28 qt5-default,
29 qtdeclarative5-dev,
30 qtdeclarative5-dev-tools,
31 qtdeclarative5-qtquick2-plugin,
32-Standards-Version: 3.9.4
33+Standards-Version: 3.9.5
34 Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
35 Homepage: https://launchpad.net/unity-scopes-shell
36 # if you don't have have commit access to this branch but would like to upload
37@@ -28,7 +25,6 @@
38 Pre-Depends: ${misc:Pre-Depends}
39 Depends: ${misc:Depends},
40 ${shlibs:Depends},
41- qtdeclarative5-dee-plugin,
42 Provides: unity-scopes-impl,
43 unity-scopes-impl-0,
44 Breaks: unity8-private (<< 7.84)
45
46=== modified file 'src/Unity/CMakeLists.txt'
47--- src/Unity/CMakeLists.txt 2014-02-19 17:43:25 +0000
48+++ src/Unity/CMakeLists.txt 2014-03-25 16:56:23 +0000
49@@ -3,66 +3,36 @@
50
51 # Dependencies
52 include(FindPkgConfig)
53-pkg_check_modules(QTDEE REQUIRED libdee-qt5>=3.2)
54-pkg_check_modules(UNITYCORE REQUIRED unity-core-6.0>=7.1.1)
55-pkg_check_modules(SCOPESLIB REQUIRED libunity-scopes>=0.3.1)
56+pkg_check_modules(SCOPESLIB REQUIRED libunity-scopes>=0.4.0)
57
58 include_directories(
59 ${CMAKE_CURRENT_SOURCE_DIR}
60 ${CMAKE_CURRENT_BINARY_DIR}
61- ${QTDEE_INCLUDE_DIRS}
62- ${UNITYCORE_INCLUDE_DIRS}
63 ${SCOPESLIB_INCLUDE_DIRS}
64 )
65
66 set(QMLPLUGIN_SRC
67- abstractfilteroption.cpp
68+ categories.cpp
69+ collectors.cpp
70+ previewmodel.cpp
71+ previewstack.cpp
72+ previewwidgetmodel.cpp
73+ resultsmodel.cpp
74 scope.cpp
75 scopes.cpp
76- categories.cpp
77- checkoptionfilter.cpp
78- filter.cpp
79- filteroption.cpp
80- filters.cpp
81- genericoptionsmodel.cpp
82- ratingoptionsmodel.cpp
83- unityoptionsmodel.cpp
84- categoryresults.cpp
85+ utils.cpp
86 plugin.cpp
87- multirangefilter.cpp
88- radiooptionfilter.cpp
89- ratingsfilter.cpp
90- ratingfilteroption.cpp
91- applicationpreview.cpp
92- genericpreview.cpp
93- moviepreview.cpp
94- musicpreview.cpp
95- musicpreviewtrackmodel.cpp
96- preview.cpp
97- previewaction.cpp
98- previewinfohint.cpp
99- result.cpp
100- showallfilteroption.cpp
101- signalslist.cpp
102- socialpreview.cpp
103- socialpreviewcomment.cpp
104 iconutils.cpp
105- variantutils.cpp
106 )
107
108-add_subdirectory(scopes-ng)
109-
110 add_library(Unity-qml SHARED ${QMLPLUGIN_SRC})
111
112 target_link_libraries(Unity-qml
113- ${QTDEE_LDFLAGS}
114- ${UNITYCORE_LDFLAGS}
115 ${SCOPESLIB_LDFLAGS}
116- ScopesNG-qml
117 )
118
119 qt5_use_modules(Unity-qml Qml Gui DBus)
120
121 # export the qmldir qmltypes and plugin files
122 export_qmlfiles(Unity Unity)
123-export_qmlplugin(Unity 0.1 Unity TARGETS Unity-qml)
124+export_qmlplugin(Unity 0.2 Unity TARGETS Unity-qml)
125
126=== removed file 'src/Unity/abstractfilteroption.cpp'
127--- src/Unity/abstractfilteroption.cpp 2013-11-08 17:01:37 +0000
128+++ src/Unity/abstractfilteroption.cpp 1970-01-01 00:00:00 +0000
129@@ -1,25 +0,0 @@
130-/*
131- * Copyright (C) 2013 Canonical, Ltd.
132- *
133- * Authors:
134- * Pawel Stolowski <pawel.stolowski@canonical.com>
135- *
136- * This program is free software; you can redistribute it and/or modify
137- * it under the terms of the GNU General Public License as published by
138- * the Free Software Foundation; version 3.
139- *
140- * This program is distributed in the hope that it will be useful,
141- * but WITHOUT ANY WARRANTY; without even the implied warranty of
142- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
143- * GNU General Public License for more details.
144- *
145- * You should have received a copy of the GNU General Public License
146- * along with this program. If not, see <http://www.gnu.org/licenses/>.
147- */
148-
149-#include "abstractfilteroption.h"
150-
151-AbstractFilterOption::AbstractFilterOption(QObject *parent)
152- : QObject(parent)
153-{
154-}
155
156=== removed file 'src/Unity/abstractfilteroption.h'
157--- src/Unity/abstractfilteroption.h 2013-11-08 17:01:37 +0000
158+++ src/Unity/abstractfilteroption.h 1970-01-01 00:00:00 +0000
159@@ -1,58 +0,0 @@
160-/*
161- * Copyright (C) 2013 Canonical, Ltd.
162- *
163- * Authors:
164- * Pawel Stolowski <pawel.stolowski@canonical.com>
165- *
166- * This program is free software; you can redistribute it and/or modify
167- * it under the terms of the GNU General Public License as published by
168- * the Free Software Foundation; version 3.
169- *
170- * This program is distributed in the hope that it will be useful,
171- * but WITHOUT ANY WARRANTY; without even the implied warranty of
172- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
173- * GNU General Public License for more details.
174- *
175- * You should have received a copy of the GNU General Public License
176- * along with this program. If not, see <http://www.gnu.org/licenses/>.
177- */
178-
179-#ifndef ABSTRACTFILTEROPTION_H
180-#define ABSTRACTFILTEROPTION_H
181-
182-// Qt
183-#include <QObject>
184-#include <QMetaType>
185-
186-class Q_DECL_EXPORT AbstractFilterOption : public QObject
187-{
188- Q_OBJECT
189-
190- Q_PROPERTY(QString id READ id NOTIFY idChanged)
191- Q_PROPERTY(QString name READ name NOTIFY nameChanged)
192- Q_PROPERTY(QString iconHint READ iconHint NOTIFY iconHintChanged)
193- Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
194-
195-public:
196- /* getters */
197- virtual QString id() const = 0;
198- virtual QString name() const = 0;
199- virtual QString iconHint() const = 0;
200- virtual bool active() const = 0;
201-
202- /* setters */
203- virtual void setActive(bool active) = 0;
204-
205-protected:
206- AbstractFilterOption(QObject *parent);
207-
208-Q_SIGNALS:
209- void idChanged(const QString &);
210- void nameChanged(const QString &);
211- void iconHintChanged(const QString &);
212- void activeChanged(bool);
213-};
214-
215-Q_DECLARE_METATYPE(AbstractFilterOption*)
216-
217-#endif // ABSTRACTFILTEROPTION_H
218
219=== removed file 'src/Unity/applicationpreview.cpp'
220--- src/Unity/applicationpreview.cpp 2013-11-08 17:01:37 +0000
221+++ src/Unity/applicationpreview.cpp 1970-01-01 00:00:00 +0000
222@@ -1,100 +0,0 @@
223-/*
224- * Copyright (C) 2013 Canonical, Ltd.
225- *
226- * Authors:
227- * Pawel Stolowski <pawel.stolowski@canonical.com>
228- *
229- * This program is free software; you can redistribute it and/or modify
230- * it under the terms of the GNU General Public License as published by
231- * the Free Software Foundation; version 3.
232- *
233- * This program is distributed in the hope that it will be useful,
234- * but WITHOUT ANY WARRANTY; without even the implied warranty of
235- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
236- * GNU General Public License for more details.
237- *
238- * You should have received a copy of the GNU General Public License
239- * along with this program. If not, see <http://www.gnu.org/licenses/>.
240- */
241-
242-// local
243-#include "applicationpreview.h"
244-#include "iconutils.h"
245-
246-#include <QDebug>
247-
248-ApplicationPreview::ApplicationPreview(QObject *parent):
249- Preview(parent),
250- m_unityAppPreview(nullptr)
251-{
252-}
253-
254-QString ApplicationPreview::lastUpdate() const
255-{
256- if (m_unityAppPreview) {
257- return QString::fromStdString(m_unityAppPreview->last_update());
258- } else {
259- qWarning() << "Preview not set";
260- }
261- return QString();
262-}
263-
264-QString ApplicationPreview::copyright() const
265-{
266- if (m_unityAppPreview) {
267- return QString::fromStdString(m_unityAppPreview->copyright());
268- } else {
269- qWarning() << "Preview not set";
270- }
271- return QString();
272-}
273-
274-QString ApplicationPreview::license() const
275-{
276- if (m_unityAppPreview) {
277- return QString::fromStdString(m_unityAppPreview->license());
278- } else {
279- qWarning() << "Preview not set";
280- }
281- return QString();
282-}
283-
284-QString ApplicationPreview::appIcon() const
285-{
286- if (m_unityAppPreview) {
287- auto giconString = g_icon_to_string(m_unityAppPreview->app_icon());
288- QString result(gIconToDeclarativeImageProviderString(QString::fromUtf8(giconString)));
289- g_free(giconString);
290- return result;
291- } else {
292- qWarning() << "Preview not set";
293- }
294- return QString();
295-}
296-
297-float ApplicationPreview::rating() const
298-{
299- if (m_unityAppPreview) {
300- return m_unityAppPreview->rating();
301- } else {
302- qWarning() << "Preview not set";
303- }
304- return 0.0f;
305-}
306-
307-unsigned int ApplicationPreview::numRatings() const
308-{
309- if (m_unityAppPreview) {
310- return m_unityAppPreview->num_ratings();
311- } else {
312- qWarning() << "Preview not set";
313- }
314- return 0;
315-}
316-
317-void ApplicationPreview::setUnityPreview(unity::dash::Preview::Ptr unityPreview)
318-{
319- m_unityAppPreview = std::dynamic_pointer_cast<unity::dash::ApplicationPreview>(unityPreview);
320-
321- Q_EMIT previewChanged();
322-}
323
324=== removed file 'src/Unity/applicationpreview.h'
325--- src/Unity/applicationpreview.h 2013-11-08 17:01:37 +0000
326+++ src/Unity/applicationpreview.h 1970-01-01 00:00:00 +0000
327@@ -1,66 +0,0 @@
328-/*
329- * Copyright (C) 2013 Canonical, Ltd.
330- *
331- * Authors:
332- * Pawel Stolowski <pawel.stolowski@canonical.com>
333- *
334- * This program is free software; you can redistribute it and/or modify
335- * it under the terms of the GNU General Public License as published by
336- * the Free Software Foundation; version 3.
337- *
338- * This program is distributed in the hope that it will be useful,
339- * but WITHOUT ANY WARRANTY; without even the implied warranty of
340- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
341- * GNU General Public License for more details.
342- *
343- * You should have received a copy of the GNU General Public License
344- * along with this program. If not, see <http://www.gnu.org/licenses/>.
345- */
346-
347-#ifndef APPLICATIONPREVIEW_H
348-#define APPLICATIONPREVIEW_H
349-
350-// local
351-#include "preview.h"
352-
353-// Qt
354-#include <QObject>
355-#include <QMetaType>
356-
357-// libunity-core
358-#include <UnityCore/ApplicationPreview.h>
359-
360-class Q_DECL_EXPORT ApplicationPreview: public Preview
361-{
362- Q_OBJECT
363-
364- Q_PROPERTY(QString lastUpdate READ lastUpdate NOTIFY previewChanged)
365- Q_PROPERTY(QString copyright READ copyright NOTIFY previewChanged)
366- Q_PROPERTY(QString license READ license NOTIFY previewChanged)
367- Q_PROPERTY(QString appIcon READ appIcon NOTIFY previewChanged)
368- Q_PROPERTY(float rating READ rating NOTIFY previewChanged)
369- Q_PROPERTY(unsigned int numRatings READ numRatings NOTIFY previewChanged)
370-
371-public:
372- explicit ApplicationPreview(QObject *parent = 0);
373-
374- QString lastUpdate() const;
375- QString copyright() const;
376- QString license() const;
377- QString appIcon() const;
378- float rating() const;
379- unsigned int numRatings() const;
380-
381-Q_SIGNALS:
382- void previewChanged();
383-
384-protected:
385- void setUnityPreview(unity::dash::Preview::Ptr unityPreview) override;
386-
387-private:
388- unity::dash::ApplicationPreview::Ptr m_unityAppPreview;
389-};
390-
391-Q_DECLARE_METATYPE(ApplicationPreview *)
392-
393-#endif
394
395=== removed file 'src/Unity/categories.cpp'
396--- src/Unity/categories.cpp 2013-11-08 17:01:37 +0000
397+++ src/Unity/categories.cpp 1970-01-01 00:00:00 +0000
398@@ -1,299 +0,0 @@
399-/*
400- * Copyright (C) 2013 Canonical, Ltd.
401- *
402- * Authors:
403- * Michał Sawicz <michal.sawicz@canonical.com>
404- * Michal Hruby <michal.hruby@canonical.com>
405- *
406- * This program is free software; you can redistribute it and/or modify
407- * it under the terms of the GNU General Public License as published by
408- * the Free Software Foundation; version 3.
409- *
410- * This program is distributed in the hope that it will be useful,
411- * but WITHOUT ANY WARRANTY; without even the implied warranty of
412- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
413- * GNU General Public License for more details.
414- *
415- * You should have received a copy of the GNU General Public License
416- * along with this program. If not, see <http://www.gnu.org/licenses/>.
417- */
418-
419-// self
420-#include "categories.h"
421-#include "categoryresults.h"
422-#include <QDebug>
423-
424-// TODO: use something from libunity once it's public
425-enum CategoryColumn {
426- ID,
427- DISPLAY_NAME,
428- ICON_HINT,
429- RENDERER_NAME,
430- HINTS
431-};
432-
433-Categories::Categories(QObject* parent)
434- : DeeListModel(parent)
435-{
436- m_roles[Categories::RoleCategoryId] = "categoryId";
437- m_roles[Categories::RoleName] = "name";
438- m_roles[Categories::RoleIcon] = "icon";
439- m_roles[Categories::RoleRenderer] = "renderer";
440- m_roles[Categories::RoleContentType] = "contentType";
441- m_roles[Categories::RoleRendererHint] = "rendererHint";
442- m_roles[Categories::RoleProgressSource] = "progressSource";
443- m_roles[Categories::RoleHints] = "hints";
444- m_roles[Categories::RoleResults] = "results";
445- m_roles[Categories::RoleCount] = "count";
446-
447- // TODO This should not be needed but accumulatting the count changes
448- // makes the visualization more stable and also makes crashes on fast
449- // change of the search term harder to reproduce
450- m_timer.setSingleShot(true);
451- m_timer.setInterval(50);
452- connect(&m_timer, &QTimer::timeout, this, &Categories::onEmitCountChanged);
453-}
454-
455-DeeListModel*
456-Categories::getResults(int index) const
457-{
458- if (!m_results.contains(index)) {
459- CategoryResults* results = new CategoryResults(const_cast<Categories*>(this));
460- results->setCategoryIndex(index);
461- connect(results, &DeeListModel::countChanged, this, &Categories::onCountChanged);
462-
463- unsigned categoryIndex = static_cast<unsigned>(index);
464- auto unity_results = m_unityScope->GetResultsForCategory(categoryIndex);
465- if (unity_results) {
466- results->setModel(unity_results->model());
467- } else {
468- // No results model returned by unity core; this can be the case when the global
469- // results model of this scope is still not set in unity core. Don't set backend
470- // model in DeeListModel - it will still beahve properly as an empty model. Since
471- // we're connected to the category model change signal, and it is set by unity core
472- // at the same time as results model (on channel opening), we'll reset category
473- // results models with proper models when we're notifed again.
474- qWarning() << "No results model for category" << categoryIndex;
475- }
476-
477- m_results.insert(index, results);
478- }
479-
480- return m_results[index];
481-}
482-
483-void Categories::onCategoriesModelChanged(unity::glib::Object<DeeModel> model)
484-{
485- m_updatedCategories.clear();
486- // FIXME: this might destroy the renderer view and re-create it, optimize?
487- Q_FOREACH(DeeListModel* model, m_results) {
488- delete model;
489- }
490- m_results.clear();
491- m_categoryOrder.clear();
492-
493- setModel(model);
494-}
495-
496-void Categories::onCategoryOrderChanged(const std::vector<unsigned int>& cat_order)
497-{
498- for (unsigned int pos = 0; pos<cat_order.size(); pos++)
499- {
500- unsigned int cat = cat_order[pos];
501- const int old_pos = m_categoryOrder.indexOf(cat);
502-
503- if (old_pos < 0) {
504- qWarning() << "No such category index:" << cat;
505- continue;
506- }
507-
508- if (static_cast<int>(pos) != old_pos) {
509- int target_pos = pos;
510- if (target_pos > old_pos)
511- target_pos++;
512- const bool status = beginMoveRows(QModelIndex(), old_pos, old_pos, QModelIndex(), target_pos);
513- if (status)
514- m_categoryOrder.move(old_pos, pos);
515- else
516- qWarning() << "beginMoveRows failed:" << old_pos << target_pos;
517- endMoveRows();
518- }
519- }
520-}
521-
522-void
523-Categories::setUnityScope(const unity::dash::Scope::Ptr& scope)
524-{
525- m_unityScope = scope;
526-
527- // no need to call this, we'll get notified
528- //setModel(m_unityScope->categories()->model());
529-
530- m_signals.disconnectAll();
531- m_signals << m_unityScope->categories()->model.changed.connect(sigc::mem_fun(this, &Categories::onCategoriesModelChanged));
532-
533- // FIXME: Don't handle category order changes for now as it causes UI issues (https://bugs.launchpad.net/unity8/+bug/1239584).
534- //m_signals << m_unityScope->category_order.changed.connect(sigc::mem_fun(this, &Categories::onCategoryOrderChanged));
535-}
536-
537-void
538-Categories::onCountChanged()
539-{
540- CategoryResults* results = qobject_cast<CategoryResults*>(sender());
541- if (results) {
542- if (!m_updatedCategories.contains(results->categoryIndex())) {
543- m_updatedCategories << results->categoryIndex();
544- }
545- m_timer.start();
546- }
547-}
548-
549-void Categories::onRowCountChanged()
550-{
551- QAbstractItemModel* model = qobject_cast<QAbstractItemModel*>(sender());
552- // find the corresponding category index
553- for (auto iter = m_overriddenCategories.begin(); iter != m_overriddenCategories.end(); ++iter) {
554- if (iter.value() == model) {
555- for (int i = 0; i < rowCount(); i++) {
556- auto id = data(index(i), RoleCategoryId).toString();
557- if (id != iter.key()) continue;
558- QVector<int> roles;
559- roles.append(RoleCount);
560- QModelIndex changedIndex = index(i);
561- Q_EMIT dataChanged(changedIndex, changedIndex, roles);
562- break;
563- }
564- }
565- }
566-}
567-
568-void
569-Categories::onEmitCountChanged()
570-{
571- QVector<int> roles;
572- roles.append(Categories::RoleCount);
573- Q_FOREACH(int categoryIndex, m_updatedCategories) {
574- if (!m_results.contains(categoryIndex)) continue;
575- const int realIndex = m_categoryOrder.indexOf(categoryIndex);
576- const QModelIndex changedIndex = index(realIndex);
577- Q_EMIT dataChanged(changedIndex, changedIndex, roles);
578- }
579- m_updatedCategories.clear();
580-}
581-
582-QHash<int, QByteArray>
583-Categories::roleNames() const
584-{
585- return m_roles;
586-}
587-
588-void Categories::onOverrideModelDestroyed()
589-{
590- QObject* model = sender();
591- auto iter = m_overriddenCategories.begin();
592- while (iter != m_overriddenCategories.end()) {
593- if (iter.value() == model) {
594- iter = m_overriddenCategories.erase(iter);
595- continue;
596- }
597- ++iter;
598- }
599-}
600-
601-void Categories::overrideResults(const QString& categoryId, QAbstractItemModel* model)
602-{
603- m_overriddenCategories[categoryId] = model;
604- // watch the model
605- connect(model, &QObject::destroyed, this, &Categories::onOverrideModelDestroyed);
606- connect(model, &QAbstractItemModel::rowsInserted, this, &Categories::onRowCountChanged);
607- connect(model, &QAbstractItemModel::rowsRemoved, this, &Categories::onRowCountChanged);
608- connect(model, &QAbstractItemModel::modelReset, this, &Categories::onRowCountChanged);
609-
610- // emit the dataChanged signal if the category is already in the model
611- for (int i = 0; i < rowCount(); i++) {
612- auto id = data(index(i), RoleCategoryId).toString();
613- if (id != categoryId) continue;
614- QVector<int> roles;
615- roles.append(RoleCount);
616- roles.append(RoleResults);
617- QModelIndex changedIndex = index(i);
618- Q_EMIT dataChanged(changedIndex, changedIndex, roles);
619- break;
620- }
621-}
622-
623-QVariant
624-Categories::data(const QModelIndex& index, int role) const
625-{
626- if (!index.isValid()) {
627- return QVariant();
628- }
629-
630- if (m_categoryOrder.size() != rowCount())
631- {
632- // populate category order vector with 0..n
633- m_categoryOrder.clear();
634- const unsigned int lim = rowCount();
635- for (unsigned int i = 0; i<lim; i++) {
636- m_categoryOrder.append(i);
637- }
638- }
639-
640- int realRow = index.row();
641- if (index.row() < m_categoryOrder.size()) {
642- realRow = m_categoryOrder[index.row()];
643- } else {
644- qWarning() << "Invalid index" << index.row();
645- return QVariant();
646- }
647-
648- const QModelIndex realIndex = createIndex(realRow, index.column());
649-
650- switch (role) {
651- case RoleCategoryId:
652- return DeeListModel::data(realIndex, CategoryColumn::ID);
653- case RoleName:
654- return DeeListModel::data(realIndex, CategoryColumn::DISPLAY_NAME);
655- case RoleIcon:
656- return DeeListModel::data(realIndex, CategoryColumn::ICON_HINT);
657- case RoleRenderer:
658- return DeeListModel::data(realIndex, CategoryColumn::RENDERER_NAME);
659- case RoleContentType:
660- {
661- auto hints = DeeListModel::data(realIndex, CategoryColumn::HINTS).toHash();
662- return hints.contains("content-type") ? hints["content-type"] : QVariant(QString("default"));
663- }
664- case RoleRendererHint:
665- {
666- auto hints = DeeListModel::data(realIndex, CategoryColumn::HINTS).toHash();
667- return hints.contains("renderer-hint") ? hints["renderer-hint"] : QVariant(QString());
668- }
669- case RoleProgressSource:
670- {
671- auto hints = DeeListModel::data(realIndex, CategoryColumn::HINTS).toHash();
672- return hints.contains("progress-source") ? hints["progress-source"] : QVariant();
673- }
674- case RoleHints:
675- return DeeListModel::data(realIndex, CategoryColumn::HINTS);
676- case RoleResults:
677- if (m_overriddenCategories.size() > 0)
678- {
679- auto id = DeeListModel::data(realIndex, CategoryColumn::ID).toString();
680- if (m_overriddenCategories.find(id) != m_overriddenCategories.end())
681- return QVariant::fromValue(m_overriddenCategories[id]);
682- }
683- return QVariant::fromValue(getResults(realRow));
684- case RoleCount:
685- if (m_overriddenCategories.size() > 0)
686- {
687- auto id = DeeListModel::data(realIndex, CategoryColumn::ID).toString();
688- if (m_overriddenCategories.find(id) != m_overriddenCategories.end())
689- {
690- return QVariant::fromValue(m_overriddenCategories[id]->rowCount());
691- }
692- }
693- return QVariant::fromValue(getResults(realRow)->rowCount());
694- default:
695- return QVariant();
696- }
697-}
698
699=== renamed file 'src/Unity/scopes-ng/categories.cpp' => 'src/Unity/categories.cpp'
700=== removed file 'src/Unity/categories.h'
701--- src/Unity/categories.h 2013-11-08 17:01:37 +0000
702+++ src/Unity/categories.h 1970-01-01 00:00:00 +0000
703@@ -1,95 +0,0 @@
704-/*
705- * Copyright (C) 2013 Canonical, Ltd.
706- *
707- * Authors:
708- * Michał Sawicz <michal.sawicz@canonical.com>
709- * Michal Hruby <michal.hruby@canonical.com>
710- *
711- * This program is free software; you can redistribute it and/or modify
712- * it under the terms of the GNU General Public License as published by
713- * the Free Software Foundation; version 3.
714- *
715- * This program is distributed in the hope that it will be useful,
716- * but WITHOUT ANY WARRANTY; without even the implied warranty of
717- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
718- * GNU General Public License for more details.
719- *
720- * You should have received a copy of the GNU General Public License
721- * along with this program. If not, see <http://www.gnu.org/licenses/>.
722- */
723-
724-
725-#ifndef CATEGORIES_H
726-#define CATEGORIES_H
727-
728-// unity-core
729-#include <UnityCore/Scope.h>
730-
731-// dee-qt
732-#include "deelistmodel.h"
733-
734-#include <QPointer>
735-#include <QSet>
736-#include <QTimer>
737-
738-// local
739-#include "signalslist.h"
740-
741-class Categories : public DeeListModel
742-{
743- Q_OBJECT
744-
745- Q_ENUMS(Roles)
746-
747-public:
748- explicit Categories(QObject* parent = 0);
749-
750- enum Roles {
751- RoleCategoryId,
752- RoleName,
753- RoleIcon,
754- RoleRenderer,
755- RoleContentType,
756- RoleRendererHint,
757- RoleProgressSource,
758- RoleHints,
759- RoleResults,
760- RoleCount
761- };
762-
763- Q_INVOKABLE void overrideResults(const QString& categoryId, QAbstractItemModel* model);
764-
765- QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
766-
767- QHash<int, QByteArray> roleNames() const;
768-
769- /* setters */
770- void setUnityScope(const unity::dash::Scope::Ptr& scope);
771-
772-private Q_SLOTS:
773- void onCountChanged();
774- void onRowCountChanged();
775- void onEmitCountChanged();
776- void onOverrideModelDestroyed();
777-
778-private:
779- void onCategoriesModelChanged(unity::glib::Object<DeeModel> model);
780- void onCategoryOrderChanged(const std::vector<unsigned int>& cat_order);
781-
782- DeeListModel* getResults(int index) const;
783-
784- unity::dash::Scope::Ptr m_unityScope;
785- QTimer m_timer;
786- QSet<int> m_updatedCategories;
787- QHash<int, QByteArray> m_roles;
788- QMap<QString, QAbstractItemModel*> m_overriddenCategories;
789- mutable QMap<int, DeeListModel*> m_results;
790- SignalsList m_signals;
791-
792- /* Category order array contains indices of actual categories in the underlying DeeListModel.
793- It's used internally to reflect category order reported by scope.
794- */
795- mutable QList<unsigned int> m_categoryOrder;
796-};
797-
798-#endif // CATEGORIES_H
799
800=== renamed file 'src/Unity/scopes-ng/categories.h' => 'src/Unity/categories.h'
801=== removed file 'src/Unity/categoryresults.cpp'
802--- src/Unity/categoryresults.cpp 2013-11-08 17:01:37 +0000
803+++ src/Unity/categoryresults.cpp 1970-01-01 00:00:00 +0000
804@@ -1,121 +0,0 @@
805-/*
806- * Copyright (C) 2013 Canonical, Ltd.
807- *
808- * Authors:
809- * Michal Hruby <michal.hruby@canonical.com>
810- *
811- * This program is free software; you can redistribute it and/or modify
812- * it under the terms of the GNU General Public License as published by
813- * the Free Software Foundation; version 3.
814- *
815- * This program is distributed in the hope that it will be useful,
816- * but WITHOUT ANY WARRANTY; without even the implied warranty of
817- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
818- * GNU General Public License for more details.
819- *
820- * You should have received a copy of the GNU General Public License
821- * along with this program. If not, see <http://www.gnu.org/licenses/>.
822- */
823-
824-// self
825-#include "categoryresults.h"
826-#include "iconutils.h"
827-
828-// TODO: use something from libunity once it's public
829-enum ResultsColumn {
830- URI,
831- ICON_HINT,
832- CATEGORY,
833- RESULT_TYPE,
834- MIMETYPE,
835- TITLE,
836- COMMENT,
837- DND_URI,
838- METADATA
839-};
840-
841-CategoryResults::CategoryResults(QObject* parent)
842- : DeeListModel(parent)
843- , m_categoryIndex(-1)
844-{
845- m_roles[CategoryResults::RoleUri] = "uri";
846- m_roles[CategoryResults::RoleIconHint] = "icon";
847- m_roles[CategoryResults::RoleCategory] = "category";
848- m_roles[CategoryResults::RoleMimetype] = "mimetype";
849- m_roles[CategoryResults::RoleTitle] = "title";
850- m_roles[CategoryResults::RoleComment] = "comment";
851- m_roles[CategoryResults::RoleDndUri] = "dndUri";
852- m_roles[CategoryResults::RoleMetadata] = "metadata";
853- m_roles[CategoryResults::RoleRendererHints] = "rendererHints";
854-}
855-
856-int CategoryResults::categoryIndex() const
857-{
858- return m_categoryIndex;
859-}
860-
861-void CategoryResults::setCategoryIndex(int index)
862-{
863- if (m_categoryIndex != index) {
864- m_categoryIndex = index;
865- Q_EMIT categoryIndexChanged(m_categoryIndex);
866- }
867-}
868-
869-QHash<int, QByteArray>
870-CategoryResults::roleNames() const
871-{
872- return m_roles;
873-}
874-
875-QVariant
876-CategoryResults::data(const QModelIndex& index, int role) const
877-{
878- if (!index.isValid()) {
879- return QVariant();
880- }
881-
882- switch (role) {
883- case RoleUri:
884- return DeeListModel::data(index, ResultsColumn::URI);
885- case RoleIconHint: {
886- QString giconString(DeeListModel::data(index, ResultsColumn::ICON_HINT).toString());
887- if (giconString.isEmpty()) {
888- QString mimetype(DeeListModel::data(index, ResultsColumn::MIMETYPE).toString());
889- QString uri(DeeListModel::data(index, ResultsColumn::URI).toString());
890- QString thumbnailerUri(uriToThumbnailerProviderString(uri, mimetype, DeeListModel::data(index, ResultsColumn::METADATA).toHash()));
891- if (!thumbnailerUri.isNull()) {
892- return QVariant::fromValue(thumbnailerUri);
893- }
894- }
895- return QVariant::fromValue(gIconToDeclarativeImageProviderString(giconString));
896- }
897- case RoleCategory:
898- return DeeListModel::data(index, ResultsColumn::CATEGORY);
899- case RoleMimetype:
900- return DeeListModel::data(index, ResultsColumn::MIMETYPE);
901- case RoleTitle:
902- return DeeListModel::data(index, ResultsColumn::TITLE);
903- case RoleComment:
904- return DeeListModel::data(index, ResultsColumn::COMMENT);
905- case RoleDndUri:
906- return DeeListModel::data(index, ResultsColumn::DND_URI);
907- case RoleMetadata:
908- return DeeListModel::data(index, ResultsColumn::METADATA);
909- case RoleRendererHints:
910- {
911- QVariantHash hash(DeeListModel::data(index, ResultsColumn::METADATA).toHash());
912- if (hash.contains("content")) {
913- QVariantMap hints;
914- QVariantHash innerHash(hash["content"].toHash());
915- if (innerHash.contains("scope_disabled")) {
916- hints["scope_disabled"] = innerHash["scope_disabled"];
917- }
918- return hints.empty() ? QVariant() : QVariant::fromValue(hints);
919- }
920- return QVariant();
921- }
922- default:
923- return QVariant();
924- }
925-}
926
927=== removed file 'src/Unity/categoryresults.h'
928--- src/Unity/categoryresults.h 2013-11-08 17:01:37 +0000
929+++ src/Unity/categoryresults.h 1970-01-01 00:00:00 +0000
930@@ -1,68 +0,0 @@
931-/*
932- * Copyright (C) 2013 Canonical, Ltd.
933- *
934- * Authors:
935- * Michal Hruby <michal.hruby@canonical.com>
936- *
937- * This program is free software; you can redistribute it and/or modify
938- * it under the terms of the GNU General Public License as published by
939- * the Free Software Foundation; version 3.
940- *
941- * This program is distributed in the hope that it will be useful,
942- * but WITHOUT ANY WARRANTY; without even the implied warranty of
943- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
944- * GNU General Public License for more details.
945- *
946- * You should have received a copy of the GNU General Public License
947- * along with this program. If not, see <http://www.gnu.org/licenses/>.
948- */
949-
950-
951-#ifndef CATEGORY_RESULTS_H
952-#define CATEGORY_RESULTS_H
953-
954-// dee-qt
955-#include "deelistmodel.h"
956-
957-class Q_DECL_EXPORT CategoryResults : public DeeListModel
958-{
959- Q_OBJECT
960-
961- Q_ENUMS(Roles)
962-
963- Q_PROPERTY(int categoryIndex READ categoryIndex WRITE setCategoryIndex NOTIFY categoryIndexChanged)
964-
965-public:
966- explicit CategoryResults(QObject* parent = 0);
967-
968- enum Roles {
969- RoleUri,
970- RoleIconHint,
971- RoleCategory,
972- RoleMimetype,
973- RoleTitle,
974- RoleComment,
975- RoleDndUri,
976- RoleMetadata,
977- RoleRendererHints
978- };
979-
980- QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
981-
982- QHash<int, QByteArray> roleNames() const;
983-
984- /* getters */
985- int categoryIndex() const;
986-
987- /* setters */
988- void setCategoryIndex(int index);
989-
990-Q_SIGNALS:
991- void categoryIndexChanged(int index);
992-
993-private:
994- QHash<int, QByteArray> m_roles;
995- int m_categoryIndex;
996-};
997-
998-#endif // CATEGORY_RESULTS_H
999
1000=== removed file 'src/Unity/checkoptionfilter.cpp'
1001--- src/Unity/checkoptionfilter.cpp 2013-11-08 17:01:37 +0000
1002+++ src/Unity/checkoptionfilter.cpp 1970-01-01 00:00:00 +0000
1003@@ -1,65 +0,0 @@
1004-/*
1005- * Copyright (C) 2011 Canonical, Ltd.
1006- *
1007- * Authors:
1008- * Florian Boucault <florian.boucault@canonical.com>
1009- *
1010- * This program is free software; you can redistribute it and/or modify
1011- * it under the terms of the GNU General Public License as published by
1012- * the Free Software Foundation; version 3.
1013- *
1014- * This program is distributed in the hope that it will be useful,
1015- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1016- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1017- * GNU General Public License for more details.
1018- *
1019- * You should have received a copy of the GNU General Public License
1020- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1021- */
1022-
1023-// Self
1024-#include "checkoptionfilter.h"
1025-
1026-// local
1027-#include "unityoptionsmodel.h"
1028-
1029-CheckOptionFilter::CheckOptionFilter(QObject *parent) :
1030- Filter(parent),
1031- m_unityCheckOptionFilter(nullptr),
1032- m_options(nullptr)
1033-{
1034-}
1035-
1036-GenericOptionsModel* CheckOptionFilter::options() const
1037-{
1038- return m_options;
1039-}
1040-
1041-void CheckOptionFilter::setUnityFilter(unity::dash::Filter::Ptr filter)
1042-{
1043- Filter::setUnityFilter(filter);
1044- m_unityCheckOptionFilter = std::dynamic_pointer_cast<unity::dash::CheckOptionFilter>(m_unityFilter);
1045- onOptionsChanged(m_unityCheckOptionFilter->options);
1046-}
1047-
1048-void CheckOptionFilter::onOptionsChanged(unity::dash::CheckOptionFilter::CheckOptions options)
1049-{
1050- if (m_options != nullptr) {
1051- m_signals.disconnectAll();
1052- delete m_options;
1053- m_options = nullptr;
1054- }
1055-
1056- m_options = new UnityOptionsModel(this, options,
1057- m_unityCheckOptionFilter->option_added,
1058- m_unityCheckOptionFilter->option_removed,
1059- m_unityCheckOptionFilter->show_all_button);
1060-
1061- connect(m_options, SIGNAL(activeChanged(AbstractFilterOption *)), m_options, SLOT(ensureTheOnlyActive(AbstractFilterOption *)));
1062- connect(m_options, SIGNAL(showAllActivated()), this, SLOT(clear()));
1063-
1064- /* Property change signals */
1065- m_signals << m_unityCheckOptionFilter->options.changed.connect(sigc::mem_fun(this, &CheckOptionFilter::onOptionsChanged));
1066-
1067- Q_EMIT optionsChanged();
1068-}
1069
1070=== removed file 'src/Unity/checkoptionfilter.h'
1071--- src/Unity/checkoptionfilter.h 2013-11-08 17:01:37 +0000
1072+++ src/Unity/checkoptionfilter.h 1970-01-01 00:00:00 +0000
1073@@ -1,57 +0,0 @@
1074-/*
1075- * Copyright (C) 2011 Canonical, Ltd.
1076- *
1077- * Authors:
1078- * Florian Boucault <florian.boucault@canonical.com>
1079- *
1080- * This program is free software; you can redistribute it and/or modify
1081- * it under the terms of the GNU General Public License as published by
1082- * the Free Software Foundation; version 3.
1083- *
1084- * This program is distributed in the hope that it will be useful,
1085- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1086- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1087- * GNU General Public License for more details.
1088- *
1089- * You should have received a copy of the GNU General Public License
1090- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1091- */
1092-
1093-#ifndef CHECKOPTIONFILTER_H
1094-#define CHECKOPTIONFILTER_H
1095-
1096-// Qt
1097-#include <QObject>
1098-#include <QMetaType>
1099-
1100-// libunity-core
1101-#include <UnityCore/CheckOptionFilter.h>
1102-
1103-// Local
1104-#include "filter.h"
1105-#include "signalslist.h"
1106-
1107-class Q_DECL_EXPORT CheckOptionFilter : public Filter
1108-{
1109- Q_OBJECT
1110-
1111-public:
1112- explicit CheckOptionFilter(QObject *parent = nullptr);
1113-
1114- /* getters */
1115- GenericOptionsModel* options() const override;
1116-
1117-protected:
1118- void setUnityFilter(unity::dash::Filter::Ptr filter) override;
1119-
1120-private:
1121- void onOptionsChanged(unity::dash::CheckOptionFilter::CheckOptions filter);
1122-
1123- unity::dash::CheckOptionFilter::Ptr m_unityCheckOptionFilter;
1124- SignalsList m_signals;
1125- GenericOptionsModel* m_options;
1126-};
1127-
1128-Q_DECLARE_METATYPE(CheckOptionFilter*)
1129-
1130-#endif // CHECKOPTIONFILTER_H
1131
1132=== renamed file 'src/Unity/scopes-ng/collectors.cpp' => 'src/Unity/collectors.cpp'
1133=== renamed file 'src/Unity/scopes-ng/collectors.h' => 'src/Unity/collectors.h'
1134=== removed file 'src/Unity/filter.cpp'
1135--- src/Unity/filter.cpp 2013-11-08 17:01:37 +0000
1136+++ src/Unity/filter.cpp 1970-01-01 00:00:00 +0000
1137@@ -1,129 +0,0 @@
1138-/*
1139- * Copyright (C) 2011, 2013 Canonical, Ltd.
1140- *
1141- * Authors:
1142- * Florian Boucault <florian.boucault@canonical.com>
1143- * Pawel Stolowski <pawel.stolowski@canonical.com>
1144- *
1145- * This program is free software; you can redistribute it and/or modify
1146- * it under the terms of the GNU General Public License as published by
1147- * the Free Software Foundation; version 3.
1148- *
1149- * This program is distributed in the hope that it will be useful,
1150- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1151- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1152- * GNU General Public License for more details.
1153- *
1154- * You should have received a copy of the GNU General Public License
1155- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1156- */
1157-
1158-// Self
1159-#include "filter.h"
1160-
1161-// local
1162-#include "ratingsfilter.h"
1163-#include "radiooptionfilter.h"
1164-#include "checkoptionfilter.h"
1165-#include "multirangefilter.h"
1166-
1167-// libunity-core
1168-#include <UnityCore/Filter.h>
1169-#include <UnityCore/RatingsFilter.h>
1170-#include <UnityCore/RadioOptionFilter.h>
1171-#include <UnityCore/CheckOptionFilter.h>
1172-#include <UnityCore/MultiRangeFilter.h>
1173-
1174-// Qt
1175-#include <QDebug>
1176-
1177-Filter::Filter(QObject *parent) :
1178- QObject(parent)
1179-{
1180-}
1181-
1182-QString Filter::id() const
1183-{
1184- if (!m_unityFilter)
1185- return QString::Null();
1186- return QString::fromStdString(m_unityFilter->id());
1187-}
1188-
1189-QString Filter::name() const
1190-{
1191- if (!m_unityFilter)
1192- return QString::Null();
1193- return QString::fromStdString(m_unityFilter->name());
1194-}
1195-
1196-QString Filter::iconHint() const
1197-{
1198- if (!m_unityFilter)
1199- return QString::Null();
1200- return QString::fromStdString(m_unityFilter->icon_hint());
1201-}
1202-
1203-QString Filter::rendererName() const
1204-{
1205- if (!m_unityFilter)
1206- return QString::Null();
1207- return QString::fromStdString(m_unityFilter->renderer_name());
1208-}
1209-
1210-bool Filter::visible() const
1211-{
1212- if (!m_unityFilter)
1213- return false;
1214- return m_unityFilter->visible();
1215-}
1216-
1217-bool Filter::collapsed() const
1218-{
1219- if (!m_unityFilter)
1220- return false;
1221- return m_unityFilter->collapsed();
1222-}
1223-
1224-bool Filter::filtering() const
1225-{
1226- if (!m_unityFilter)
1227- return false;
1228- return m_unityFilter->filtering();
1229-}
1230-
1231-void Filter::clear()
1232-{
1233- if (m_unityFilter)
1234- m_unityFilter->Clear();
1235-}
1236-
1237-void Filter::setUnityFilter(unity::dash::Filter::Ptr unityFilter)
1238-{
1239- m_unityFilter = unityFilter;
1240-}
1241-
1242-Filter* Filter::newFromUnityFilter(unity::dash::Filter::Ptr unityFilter)
1243-{
1244- Filter* filter;
1245-
1246- if (typeid(*unityFilter) == typeid(unity::dash::RatingsFilter)) {
1247- filter = new RatingsFilter;
1248- } else if (typeid(*unityFilter) == typeid(unity::dash::CheckOptionFilter)) {
1249- filter = new CheckOptionFilter;
1250- } else if (typeid(*unityFilter) == typeid(unity::dash::RadioOptionFilter)) {
1251- filter = new RadioOptionFilter;
1252- } else if (typeid(*unityFilter) == typeid(unity::dash::MultiRangeFilter)) {
1253- filter = new MultiRangeFilter;
1254- } else {
1255- qWarning() << "Filter of unknown type: " << typeid(*unityFilter).name();
1256- return nullptr;
1257- }
1258-
1259- filter->setUnityFilter(unityFilter);
1260- return filter;
1261-}
1262-
1263-bool Filter::hasUnityFilter(unity::dash::Filter::Ptr unityFilter) const
1264-{
1265- return m_unityFilter == unityFilter;
1266-}
1267
1268=== removed file 'src/Unity/filter.h'
1269--- src/Unity/filter.h 2013-11-08 17:01:37 +0000
1270+++ src/Unity/filter.h 1970-01-01 00:00:00 +0000
1271@@ -1,75 +0,0 @@
1272-/*
1273- * Copyright (C) 2011, 2013 Canonical, Ltd.
1274- *
1275- * Authors:
1276- * Florian Boucault <florian.boucault@canonical.com>
1277- * Pawel Stolowski <pawel.stolowski@canonical.com>
1278- *
1279- * This program is free software; you can redistribute it and/or modify
1280- * it under the terms of the GNU General Public License as published by
1281- * the Free Software Foundation; version 3.
1282- *
1283- * This program is distributed in the hope that it will be useful,
1284- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1285- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1286- * GNU General Public License for more details.
1287- *
1288- * You should have received a copy of the GNU General Public License
1289- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1290- */
1291-
1292-#ifndef FILTER_H
1293-#define FILTER_H
1294-
1295-// Qt
1296-#include <QObject>
1297-#include <QMetaType>
1298-
1299-// libunity-core
1300-#include <UnityCore/Filter.h>
1301-
1302-class GenericOptionsModel;
1303-
1304-class Q_DECL_EXPORT Filter : public QObject
1305-{
1306- Q_OBJECT
1307-
1308- Q_PROPERTY(QString id READ id CONSTANT)
1309- Q_PROPERTY(QString name READ name CONSTANT)
1310- Q_PROPERTY(QString iconHint READ iconHint CONSTANT)
1311- Q_PROPERTY(QString rendererName READ rendererName CONSTANT)
1312- Q_PROPERTY(bool visible READ visible CONSTANT)
1313- Q_PROPERTY(bool collapsed READ collapsed CONSTANT)
1314- Q_PROPERTY(bool filtering READ filtering CONSTANT)
1315- Q_PROPERTY(GenericOptionsModel* options READ options NOTIFY optionsChanged)
1316-
1317-public:
1318- explicit Filter(QObject *parent = nullptr);
1319-
1320- /* getters */
1321- QString id() const;
1322- QString name() const;
1323- QString iconHint() const;
1324- QString rendererName() const;
1325- bool visible() const;
1326- bool collapsed() const;
1327- bool filtering() const;
1328- virtual GenericOptionsModel* options() const = 0;
1329-
1330- static Filter* newFromUnityFilter(unity::dash::Filter::Ptr unityFilter);
1331- bool hasUnityFilter(unity::dash::Filter::Ptr unityFilter) const;
1332-
1333-public Q_SLOTS:
1334- void clear();
1335-
1336-Q_SIGNALS:
1337- void optionsChanged();
1338-
1339-protected:
1340- unity::dash::Filter::Ptr m_unityFilter;
1341- virtual void setUnityFilter(unity::dash::Filter::Ptr unityFilter);
1342-};
1343-
1344-Q_DECLARE_METATYPE(Filter*)
1345-
1346-#endif // FILTER_H
1347
1348=== removed file 'src/Unity/filteroption.cpp'
1349--- src/Unity/filteroption.cpp 2013-11-08 17:01:37 +0000
1350+++ src/Unity/filteroption.cpp 1970-01-01 00:00:00 +0000
1351@@ -1,91 +0,0 @@
1352-/*
1353- * Copyright (C) 2011, 2013 Canonical, Ltd.
1354- *
1355- * Authors:
1356- * Florian Boucault <florian.boucault@canonical.com>
1357- * Pawel Stolowski <pawel.stolowski@canonical.com>
1358- *
1359- * This program is free software; you can redistribute it and/or modify
1360- * it under the terms of the GNU General Public License as published by
1361- * the Free Software Foundation; version 3.
1362- *
1363- * This program is distributed in the hope that it will be useful,
1364- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1365- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1366- * GNU General Public License for more details.
1367- *
1368- * You should have received a copy of the GNU General Public License
1369- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1370- */
1371-
1372-// Self
1373-#include "filteroption.h"
1374-
1375-// libunity-core
1376-#include <UnityCore/Filter.h>
1377-
1378-FilterOption::FilterOption(unity::dash::FilterOption::Ptr unityFilterOption, QObject *parent) :
1379- AbstractFilterOption(parent), m_unityFilterOption(nullptr)
1380-{
1381- setUnityFilterOption(unityFilterOption);
1382-}
1383-
1384-QString FilterOption::id() const
1385-{
1386- return QString::fromStdString(m_unityFilterOption->id());
1387-}
1388-
1389-QString FilterOption::name() const
1390-{
1391- return QString::fromStdString(m_unityFilterOption->name());
1392-}
1393-
1394-QString FilterOption::iconHint() const
1395-{
1396- return QString::fromStdString(m_unityFilterOption->icon_hint());
1397-}
1398-
1399-bool FilterOption::active() const
1400-{
1401- return m_unityFilterOption->active();
1402-}
1403-
1404-void FilterOption::setActive(bool active)
1405-{
1406- m_unityFilterOption->active = active;
1407-}
1408-
1409-void FilterOption::setUnityFilterOption(unity::dash::FilterOption::Ptr unityFilterOption)
1410-{
1411- if (m_unityFilterOption != nullptr) {
1412- m_signals.disconnectAll();
1413- }
1414-
1415- m_unityFilterOption = unityFilterOption;
1416-
1417- /* Property change signals */
1418- m_signals << m_unityFilterOption->id.changed.connect(sigc::mem_fun(this, &FilterOption::onIdChanged))
1419- << m_unityFilterOption->name.changed.connect(sigc::mem_fun(this, &FilterOption::onNameChanged))
1420- << m_unityFilterOption->icon_hint.changed.connect(sigc::mem_fun(this, &FilterOption::onIconHintChanged))
1421- << m_unityFilterOption->active.changed.connect(sigc::mem_fun(this, &FilterOption::onActiveChanged));
1422-}
1423-
1424-void FilterOption::onIdChanged(const std::string &id)
1425-{
1426- Q_EMIT idChanged(QString::fromStdString(id));
1427-}
1428-
1429-void FilterOption::onNameChanged(const std::string &name)
1430-{
1431- Q_EMIT nameChanged(QString::fromStdString(name));
1432-}
1433-
1434-void FilterOption::onIconHintChanged(const std::string &iconHint)
1435-{
1436- Q_EMIT iconHintChanged(QString::fromStdString(iconHint));
1437-}
1438-
1439-void FilterOption::onActiveChanged(bool active)
1440-{
1441- Q_EMIT activeChanged(active);
1442-}
1443
1444=== removed file 'src/Unity/filteroption.h'
1445--- src/Unity/filteroption.h 2013-11-08 17:01:37 +0000
1446+++ src/Unity/filteroption.h 1970-01-01 00:00:00 +0000
1447@@ -1,61 +0,0 @@
1448-/*
1449- * Copyright (C) 2011, 2013 Canonical, Ltd.
1450- *
1451- * Authors:
1452- * Florian Boucault <florian.boucault@canonical.com>
1453- * Pawel Stolowski <pawel.stolowski@canonical.com>
1454- *
1455- * This program is free software; you can redistribute it and/or modify
1456- * it under the terms of the GNU General Public License as published by
1457- * the Free Software Foundation; version 3.
1458- *
1459- * This program is distributed in the hope that it will be useful,
1460- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1461- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1462- * GNU General Public License for more details.
1463- *
1464- * You should have received a copy of the GNU General Public License
1465- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1466- */
1467-
1468-#ifndef FILTEROPTION_H
1469-#define FILTEROPTION_H
1470-
1471-// Local
1472-#include "abstractfilteroption.h"
1473-#include "signalslist.h"
1474-
1475-// libunity-core
1476-#include <UnityCore/Filter.h>
1477-
1478-class Q_DECL_EXPORT FilterOption : public AbstractFilterOption
1479-{
1480- Q_OBJECT
1481-
1482-public:
1483- explicit FilterOption(unity::dash::FilterOption::Ptr unityFilterOption, QObject *parent = nullptr);
1484-
1485- /* getters */
1486- QString id() const override;
1487- QString name() const override;
1488- QString iconHint() const override;
1489- bool active() const override;
1490-
1491- /* setters */
1492- void setActive(bool active) override;
1493-
1494-private:
1495- void onIdChanged(const std::string &id);
1496- void onNameChanged(const std::string &name);
1497- void onIconHintChanged(const std::string &iconHint);
1498- void onActiveChanged(bool active);
1499-
1500- void setUnityFilterOption(unity::dash::FilterOption::Ptr unityFilterOption);
1501- SignalsList m_signals;
1502-
1503- unity::dash::FilterOption::Ptr m_unityFilterOption;
1504-};
1505-
1506-Q_DECLARE_METATYPE(FilterOption*)
1507-
1508-#endif // FILTEROPTION_H
1509
1510=== removed file 'src/Unity/filters.cpp'
1511--- src/Unity/filters.cpp 2013-11-08 17:01:37 +0000
1512+++ src/Unity/filters.cpp 1970-01-01 00:00:00 +0000
1513@@ -1,165 +0,0 @@
1514-/*
1515- * Copyright (C) 2011, 2013 Canonical, Ltd.
1516- *
1517- * Authors:
1518- * Florian Boucault <florian.boucault@canonical.com>
1519- * Pawel Stolowski <pawel.stolowski@canonical.com>
1520- *
1521- * This program is free software; you can redistribute it and/or modify
1522- * it under the terms of the GNU General Public License as published by
1523- * the Free Software Foundation; version 3.
1524- *
1525- * This program is distributed in the hope that it will be useful,
1526- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1527- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1528- * GNU General Public License for more details.
1529- *
1530- * You should have received a copy of the GNU General Public License
1531- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1532- */
1533-
1534-// Self
1535-#include "filters.h"
1536-
1537-// Local
1538-#include "filter.h"
1539-#include "genericoptionsmodel.h"
1540-
1541-// Qt
1542-#include <QDebug>
1543-
1544-Filters::Filters(unity::dash::Filters::Ptr unityFilters, QObject *parent) :
1545- QAbstractListModel(parent), m_unityFilters(unityFilters)
1546-{
1547- for (unsigned int i=0; i<m_unityFilters->count(); i++) {
1548- unity::dash::Filter::Ptr unityFilter = m_unityFilters->FilterAtIndex(i);
1549- addFilter(unityFilter, i);
1550- }
1551- m_unityFilters->filter_added.connect(sigc::mem_fun(this, &Filters::onFilterAdded));
1552- m_unityFilters->filter_changed.connect(sigc::mem_fun(this, &Filters::onFilterChanged));
1553- m_unityFilters->filter_removed.connect(sigc::mem_fun(this, &Filters::onFilterRemoved));
1554-}
1555-
1556-Filters::~Filters()
1557-{
1558- while (!m_filters.isEmpty()) {
1559- delete m_filters.takeFirst();
1560- }
1561-}
1562-
1563-int Filters::rowCount(const QModelIndex& parent) const
1564-{
1565- Q_UNUSED(parent)
1566-
1567- return m_unityFilters->count();
1568-}
1569-
1570-QVariant Filters::data(const QModelIndex& index, int role) const
1571-{
1572- if (!index.isValid()) {
1573- return QVariant();
1574- }
1575-
1576- Filter* filter = m_filters.at(index.row());
1577- switch (role)
1578- {
1579- case Filters::RoleId:
1580- return filter->id();
1581- case Filters::RoleName:
1582- case Qt::DisplayRole:
1583- return filter->name();
1584- case Filters::RoleIconHint:
1585- return filter->iconHint();
1586- case Filters::RoleRendererName:
1587- return filter->rendererName();
1588- case Filters::RoleVisible:
1589- return filter->visible();
1590- case Filters::RoleCollapsed:
1591- return filter->collapsed();
1592- case Filters::RoleFiltering:
1593- return filter->filtering();
1594- case Filters::RoleOptions:
1595- return QVariant::fromValue(filter->options());
1596- default:
1597- break;
1598- }
1599- return QVariant();
1600-}
1601-
1602-QHash<int, QByteArray> Filters::roleNames() const
1603-{
1604- QHash<int, QByteArray> roles;
1605- roles[Filters::RoleId] = "id";
1606- roles[Filters::RoleName] = "name";
1607- roles[Filters::RoleIconHint] = "iconHint";
1608- roles[Filters::RoleRendererName] = "rendererName";
1609- roles[Filters::RoleVisible] = "visible";
1610- roles[Filters::RoleCollapsed] = "collapsed";
1611- roles[Filters::RoleFiltering] = "filtering";
1612- roles[Filters::RoleOptions] = "options";
1613- return roles;
1614-}
1615-
1616-Filter* Filters::getFilter(const QString& id) const
1617-{
1618- Q_FOREACH (Filter* filter, m_filters) {
1619- if (filter->id() == id) {
1620- return filter;
1621- }
1622- }
1623- return nullptr;
1624-}
1625-
1626-void Filters::onFilterAdded(unity::dash::Filter::Ptr unityFilter)
1627-{
1628- if (unityFilter == nullptr) {
1629- return;
1630- }
1631-
1632- int index = m_filters.count();
1633- addFilter(unityFilter, index);
1634-}
1635-
1636-void Filters::onFilterChanged(unity::dash::Filter::Ptr unityFilter)
1637-{
1638- if (unityFilter == nullptr) {
1639- return;
1640- }
1641-
1642- QModelIndex filterIndex = index(indexForFilter(unityFilter));
1643- Q_EMIT dataChanged(filterIndex, filterIndex);
1644-}
1645-
1646-void Filters::onFilterRemoved(unity::dash::Filter::Ptr unityFilter)
1647-{
1648- removeFilter(indexForFilter(unityFilter));
1649-}
1650-
1651-void Filters::addFilter(unity::dash::Filter::Ptr unityFilter, int index)
1652-{
1653- beginInsertRows(QModelIndex(), index, index);
1654- Filter* filter = Filter::newFromUnityFilter(unityFilter);
1655- if (filter != nullptr) {
1656- m_filters.insert(index, filter);
1657- }
1658- endInsertRows();
1659-}
1660-
1661-void Filters::removeFilter(int index)
1662-{
1663- beginRemoveRows(QModelIndex(), index, index);
1664- Filter* filter = m_filters.takeAt(index);
1665- delete filter;
1666- endRemoveRows();
1667-}
1668-
1669-int Filters::indexForFilter(unity::dash::Filter::Ptr unityFilter)
1670-{
1671- for (int index=0; index<m_filters.count(); index++) {
1672- if (m_filters[index]->hasUnityFilter(unityFilter)) {
1673- return index;
1674- }
1675- }
1676- qWarning() << "Filter" << QString::fromStdString(unityFilter->name()) << "not found in local cache.";
1677- return -1;
1678-}
1679
1680=== removed file 'src/Unity/filters.h'
1681--- src/Unity/filters.h 2013-11-08 17:01:37 +0000
1682+++ src/Unity/filters.h 1970-01-01 00:00:00 +0000
1683@@ -1,77 +0,0 @@
1684-/*
1685- * Copyright (C) 2011, 2013 Canonical, Ltd.
1686- *
1687- * Authors:
1688- * Florian Boucault <florian.boucault@canonical.com>
1689- * Pawel Stolowski <pawel.stolowski@canonical.com>
1690- *
1691- * This program is free software; you can redistribute it and/or modify
1692- * it under the terms of the GNU General Public License as published by
1693- * the Free Software Foundation; version 3.
1694- *
1695- * This program is distributed in the hope that it will be useful,
1696- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1697- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1698- * GNU General Public License for more details.
1699- *
1700- * You should have received a copy of the GNU General Public License
1701- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1702- */
1703-
1704-#ifndef FILTERS_H
1705-#define FILTERS_H
1706-
1707-// Qt
1708-#include <QAbstractListModel>
1709-#include <QList>
1710-
1711-// libunity-core
1712-#include <UnityCore/Filters.h>
1713-#include <UnityCore/Filter.h>
1714-
1715-class Filter;
1716-
1717-class Filters : public QAbstractListModel
1718-{
1719- Q_OBJECT
1720-
1721- Q_ENUMS(Roles)
1722-
1723-public:
1724- explicit Filters(unity::dash::Filters::Ptr unityFilters, QObject *parent = nullptr);
1725- ~Filters();
1726-
1727- enum Roles {
1728- RoleId = Qt::UserRole,
1729- RoleName,
1730- RoleIconHint,
1731- RoleRendererName,
1732- RoleVisible,
1733- RoleCollapsed,
1734- RoleFiltering,
1735- RoleOptions
1736- };
1737-
1738- QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
1739- int rowCount(const QModelIndex& parent = QModelIndex()) const override;
1740- QHash<int, QByteArray> roleNames() const override;
1741-
1742- Filter* getFilter(const QString& id) const;
1743-
1744-private:
1745- void onFilterAdded(unity::dash::Filter::Ptr unityFilter);
1746- void onFilterChanged(unity::dash::Filter::Ptr unityFilter);
1747- void onFilterRemoved(unity::dash::Filter::Ptr unityFilter);
1748-
1749- void addFilter(unity::dash::Filter::Ptr unityFilter, int index);
1750- void removeFilter(int index);
1751-
1752- int indexForFilter(unity::dash::Filter::Ptr unityFilter);
1753-
1754- unity::dash::Filters::Ptr m_unityFilters;
1755- QList<Filter*> m_filters;
1756-};
1757-
1758-Q_DECLARE_METATYPE(Filters*)
1759-
1760-#endif // FILTERS_H
1761
1762=== removed file 'src/Unity/genericoptionsmodel.cpp'
1763--- src/Unity/genericoptionsmodel.cpp 2013-11-08 17:01:37 +0000
1764+++ src/Unity/genericoptionsmodel.cpp 1970-01-01 00:00:00 +0000
1765@@ -1,187 +0,0 @@
1766-/*
1767- * Copyright (C) 2013 Canonical, Ltd.
1768- *
1769- * Authors:
1770- * Pawel Stolowski <pawel.stolowski@canonical.com>
1771- *
1772- * This program is free software; you can redistribute it and/or modify
1773- * it under the terms of the GNU General Public License as published by
1774- * the Free Software Foundation; version 3.
1775- *
1776- * This program is distributed in the hope that it will be useful,
1777- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1778- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1779- * GNU General Public License for more details.
1780- *
1781- * You should have received a copy of the GNU General Public License
1782- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1783- */
1784-
1785-// self
1786-#include "genericoptionsmodel.h"
1787-
1788-// local
1789-#include "abstractfilteroption.h"
1790-#include "showallfilteroption.h"
1791-
1792-GenericOptionsModel::GenericOptionsModel(bool showAllOption, QObject *parent)
1793- : QAbstractListModel(parent)
1794-{
1795- if (showAllOption)
1796- {
1797- auto showAll = new ShowAllFilterOption(this);
1798- connect(showAll, SIGNAL(activeChanged(bool)), this, SLOT(onOptionChanged()));
1799- connect(showAll, SIGNAL(activeChanged(bool)), this, SLOT(onShowAllClicked(bool)));
1800- addOption(showAll);
1801- }
1802-}
1803-
1804-GenericOptionsModel::~GenericOptionsModel()
1805-{
1806- Q_FOREACH(auto opt, m_options)
1807- {
1808- opt->deleteLater();
1809- }
1810-}
1811-
1812-QHash<int, QByteArray> GenericOptionsModel::roleNames() const
1813-{
1814- QHash<int, QByteArray> roles;
1815- roles[GenericOptionsModel::RoleId] = "id";
1816- roles[GenericOptionsModel::RoleName] = "name";
1817- roles[GenericOptionsModel::RoleIconHint] = "iconHint";
1818- roles[GenericOptionsModel::RoleActive] = "active";
1819- return roles;
1820-}
1821-
1822-QVariant GenericOptionsModel::data(const QModelIndex& index, int role) const
1823-{
1824- if (!index.isValid()) {
1825- return QVariant();
1826- }
1827-
1828- auto filterOption = m_options[index.row()];
1829- switch (role)
1830- {
1831- case GenericOptionsModel::RoleId:
1832- return filterOption->id();
1833- case GenericOptionsModel::RoleName:
1834- case Qt::DisplayRole:
1835- return filterOption->name();
1836- case GenericOptionsModel::RoleIconHint:
1837- return filterOption->iconHint();
1838- case GenericOptionsModel::RoleActive:
1839- return filterOption->active();
1840- default:
1841- break;
1842- }
1843-
1844- return QVariant();
1845-}
1846-
1847-int GenericOptionsModel::rowCount(const QModelIndex& /* parent */) const
1848-{
1849- return m_options.size();
1850-}
1851-
1852-void GenericOptionsModel::setActive(int idx, bool value)
1853-{
1854- if (idx >= 0 && idx < m_options.size())
1855- {
1856- m_options[idx]->setActive(value);
1857- }
1858-}
1859-
1860-void GenericOptionsModel::setActive(const QString &id, bool value)
1861-{
1862- Q_FOREACH(auto opt, m_options) {
1863- if (opt->id() == id) {
1864- opt->setActive(value);
1865- break;
1866- }
1867- }
1868-}
1869-
1870-AbstractFilterOption* GenericOptionsModel::getRawOption(QVector<AbstractFilterOption *>::size_type idx) const
1871-{
1872- if (idx < m_options.size())
1873- {
1874- return m_options[idx];
1875- }
1876- return nullptr;
1877-}
1878-
1879-void GenericOptionsModel::ensureTheOnlyActive(AbstractFilterOption *activeOption)
1880-{
1881- if (activeOption->active()) {
1882- // disable all other options
1883- Q_FOREACH(auto opt, m_options) {
1884- if (opt != activeOption && opt->active()) {
1885- opt->setActive(false);
1886- }
1887- }
1888- }
1889-}
1890-
1891-void GenericOptionsModel::addOption(AbstractFilterOption *option, int index)
1892-{
1893- if (index >= 0)
1894- m_options.insert(index, option);
1895- else
1896- m_options.append(option);
1897-
1898- connect(option, SIGNAL(idChanged(const QString &)), this, SLOT(onOptionChanged()));
1899- connect(option, SIGNAL(nameChanged(const QString &)), this, SLOT(onOptionChanged()));
1900- connect(option, SIGNAL(iconHintChanged(const QString &)), this, SLOT(onOptionChanged()));
1901- connect(option, SIGNAL(activeChanged(bool)), this, SLOT(onOptionChanged()));
1902- connect(option, SIGNAL(activeChanged(bool)), this, SLOT(onActiveChanged()));
1903-}
1904-
1905-void GenericOptionsModel::removeOption(int index)
1906-{
1907- m_options[index]->deleteLater();
1908- m_options.remove(index);
1909-}
1910-
1911-int GenericOptionsModel::indexOf(const QString &option_id)
1912-{
1913- int row = 0;
1914- Q_FOREACH(auto opt, m_options)
1915- {
1916- if (opt->id() == option_id)
1917- {
1918- return row;
1919- }
1920- ++row;
1921- }
1922- return -1;
1923-}
1924-
1925-void GenericOptionsModel::onOptionChanged()
1926-{
1927- AbstractFilterOption *option = dynamic_cast<AbstractFilterOption*>(QObject::sender());
1928- if (option)
1929- {
1930- int idx = indexOf(option->id());
1931- if (idx >= 0)
1932- {
1933- QModelIndex optionIndex = index(idx);
1934- Q_EMIT dataChanged(optionIndex, optionIndex);
1935- }
1936- }
1937-}
1938-
1939-void GenericOptionsModel::onActiveChanged()
1940-{
1941- AbstractFilterOption *option = dynamic_cast<AbstractFilterOption*>(QObject::sender());
1942- if (option)
1943- {
1944- Q_EMIT activeChanged(option);
1945- }
1946-}
1947-
1948-void GenericOptionsModel::onShowAllClicked(bool active)
1949-{
1950- if (active)
1951- Q_EMIT showAllActivated();
1952-}
1953
1954=== removed file 'src/Unity/genericoptionsmodel.h'
1955--- src/Unity/genericoptionsmodel.h 2013-11-08 17:01:37 +0000
1956+++ src/Unity/genericoptionsmodel.h 1970-01-01 00:00:00 +0000
1957@@ -1,79 +0,0 @@
1958-/*
1959- * Copyright (C) 2013 Canonical, Ltd.
1960- *
1961- * Authors:
1962- * Pawel Stolowski <pawel.stolowski@canonical.com>
1963- *
1964- * This program is free software; you can redistribute it and/or modify
1965- * it under the terms of the GNU General Public License as published by
1966- * the Free Software Foundation; version 3.
1967- *
1968- * This program is distributed in the hope that it will be useful,
1969- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1970- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1971- * GNU General Public License for more details.
1972- *
1973- * You should have received a copy of the GNU General Public License
1974- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1975- */
1976-
1977-#ifndef GENERICOPTIONSMODEL_H
1978-#define GENERICOPTIONSMODEL_H
1979-
1980-// Qt
1981-#include <QObject>
1982-#include <QAbstractListModel>
1983-#include <QHash>
1984-#include <QVector>
1985-
1986-class AbstractFilterOption;
1987-
1988-class Q_DECL_EXPORT GenericOptionsModel : public QAbstractListModel
1989-{
1990- Q_OBJECT
1991-
1992- Q_ENUMS(Roles)
1993-
1994-public:
1995- GenericOptionsModel(bool showAllOption = false, QObject *parent = nullptr);
1996- ~GenericOptionsModel();
1997-
1998- enum Roles {
1999- RoleId = Qt::UserRole,
2000- RoleName,
2001- RoleIconHint,
2002- RoleActive
2003- };
2004-
2005- QHash<int, QByteArray> roleNames() const override;
2006- QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
2007- int rowCount(const QModelIndex& parent = QModelIndex()) const override;
2008-
2009- Q_INVOKABLE void setActive(int idx, bool value);
2010- Q_INVOKABLE void setActive(const QString &id, bool value);
2011-
2012- AbstractFilterOption* getRawOption(QVector<AbstractFilterOption *>::size_type idx) const;
2013-
2014-public Q_SLOTS:
2015- virtual void ensureTheOnlyActive(AbstractFilterOption *activeOption);
2016-
2017-Q_SIGNALS:
2018- void activeChanged(AbstractFilterOption *option);
2019- void showAllActivated();
2020-
2021-protected Q_SLOTS:
2022- void onOptionChanged();
2023- void onActiveChanged();
2024- void onShowAllClicked(bool active);
2025-
2026-protected:
2027- void addOption(AbstractFilterOption *option, int index = -1);
2028- void removeOption(int index);
2029- int indexOf(const QString &option_id);
2030-
2031- QVector<AbstractFilterOption *> m_options;
2032-};
2033-
2034-Q_DECLARE_METATYPE(GenericOptionsModel*)
2035-
2036-#endif // GENERICOPTIONSMODEL_H
2037
2038=== removed file 'src/Unity/genericpreview.cpp'
2039--- src/Unity/genericpreview.cpp 2013-11-08 17:01:37 +0000
2040+++ src/Unity/genericpreview.cpp 1970-01-01 00:00:00 +0000
2041@@ -1,31 +0,0 @@
2042-/*
2043- * Copyright (C) 2013 Canonical, Ltd.
2044- *
2045- * Authors:
2046- * Pawel Stolowski <pawel.stolowski@canonical.com>
2047- *
2048- * This program is free software; you can redistribute it and/or modify
2049- * it under the terms of the GNU General Public License as published by
2050- * the Free Software Foundation; version 3.
2051- *
2052- * This program is distributed in the hope that it will be useful,
2053- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2054- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2055- * GNU General Public License for more details.
2056- *
2057- * You should have received a copy of the GNU General Public License
2058- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2059- */
2060-
2061-// local
2062-#include "genericpreview.h"
2063-
2064-GenericPreview::GenericPreview(QObject *parent):
2065- Preview(parent)
2066-{
2067-}
2068-
2069-void GenericPreview::setUnityPreview(unity::dash::Preview::Ptr /* unityPreview */)
2070-{
2071- Q_EMIT previewChanged();
2072-}
2073
2074=== removed file 'src/Unity/genericpreview.h'
2075--- src/Unity/genericpreview.h 2013-11-08 17:01:37 +0000
2076+++ src/Unity/genericpreview.h 1970-01-01 00:00:00 +0000
2077@@ -1,46 +0,0 @@
2078-/*
2079- * Copyright (C) 2013 Canonical, Ltd.
2080- *
2081- * Authors:
2082- * Pawel Stolowski <pawel.stolowski@canonical.com>
2083- *
2084- * This program is free software; you can redistribute it and/or modify
2085- * it under the terms of the GNU General Public License as published by
2086- * the Free Software Foundation; version 3.
2087- *
2088- * This program is distributed in the hope that it will be useful,
2089- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2090- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2091- * GNU General Public License for more details.
2092- *
2093- * You should have received a copy of the GNU General Public License
2094- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2095- */
2096-
2097-#ifndef GENERICPREVIEW_H
2098-#define GENERICPREVIEW_H
2099-
2100-// local
2101-#include "preview.h"
2102-
2103-// Qt
2104-#include <QObject>
2105-#include <QMetaType>
2106-
2107-class GenericPreview : public Preview
2108-{
2109- Q_OBJECT
2110-
2111-public:
2112- explicit GenericPreview(QObject *parent = 0);
2113-
2114-Q_SIGNALS:
2115- void previewChanged();
2116-
2117-protected:
2118- void setUnityPreview(unity::dash::Preview::Ptr unityPreview) override;
2119-};
2120-
2121-Q_DECLARE_METATYPE(GenericPreview *)
2122-
2123-#endif
2124
2125=== modified file 'src/Unity/iconutils.cpp'
2126--- src/Unity/iconutils.cpp 2014-02-19 17:51:44 +0000
2127+++ src/Unity/iconutils.cpp 2014-03-25 16:56:23 +0000
2128@@ -19,8 +19,6 @@
2129
2130 #include "iconutils.h"
2131
2132-#include <gio/gio.h>
2133-
2134 #include <QStringList>
2135 #include <QUrl>
2136 #include <QUrlQuery>
2137@@ -29,90 +27,17 @@
2138 #define BASE_THUMBNAILER_URI "image://thumbnailer/"
2139 #define BASE_ALBUMART_URI "image://albumart/"
2140
2141-QString gIconToDeclarativeImageProviderString(QString const &giconString)
2142-{
2143- if (giconString.isEmpty()) return giconString;
2144-
2145- if (giconString.startsWith('/') || giconString.startsWith(QLatin1String("http")) ||
2146- giconString.startsWith(QLatin1String("file:")) || giconString.startsWith(QLatin1String("image:"))) {
2147- return giconString;
2148- }
2149-
2150- if (!giconString.startsWith(QLatin1String(". "))) {
2151- // must be a themed icon
2152- QString themedIcon(BASE_THEME_ICON_URI);
2153- themedIcon.append(giconString);
2154- return themedIcon;
2155- }
2156-
2157- // special case annotated icon
2158- if (giconString.startsWith(QLatin1String(". UnityProtocolAnnotatedIcon "))) {
2159- QString annotatedIcon;
2160- QString serializedData(QUrl::fromPercentEncoding(giconString.mid(29).toUtf8()));
2161- GVariant *variant = g_variant_parse(G_VARIANT_TYPE_VARDICT, serializedData.toUtf8().constData(), NULL, NULL, NULL);
2162- gchar *baseUri;
2163- if (variant != NULL && g_variant_lookup(variant, "base-icon", "&s", &baseUri)) {
2164- annotatedIcon = gIconToDeclarativeImageProviderString(QString(baseUri));
2165- // FIXME: enclose in image://annotated/... once unity supports that
2166- }
2167- if (variant != NULL) g_variant_unref(variant);
2168-
2169- return annotatedIcon;
2170- }
2171-
2172- // handle real gicon strings
2173- QString result;
2174- GError *error = NULL;
2175- GIcon *icon = g_icon_new_for_string(giconString.toLocal8Bit().constData(), &error);
2176- if (error != NULL || icon == NULL) {
2177- qWarning("Unable to deserialize icon: %s", giconString.toLocal8Bit().constData());
2178- g_clear_error(&error);
2179- return result;
2180- }
2181-
2182- if (G_IS_THEMED_ICON(icon)) {
2183- QString themedIcon(BASE_THEME_ICON_URI);
2184- QStringList list;
2185- const char* const *iconNames = g_themed_icon_get_names(G_THEMED_ICON(icon));
2186- if (iconNames != NULL) {
2187- for (const char * const *iter = iconNames; *iter != NULL; ++iter) {
2188- list << QLatin1String(*iter);
2189- }
2190- }
2191- themedIcon.append(list.join(QString(",")));
2192- result = themedIcon;
2193- } else if (G_IS_FILE_ICON(icon)) {
2194- GFile *file = g_file_icon_get_file(G_FILE_ICON(icon));
2195- gchar *uri = g_file_get_uri(file);
2196- QString iconUri(uri);
2197- g_free(uri);
2198- result = iconUri;
2199- }
2200-
2201- g_object_unref(icon);
2202-
2203- return result;
2204-}
2205-
2206-QString uriToThumbnailerProviderString(QString const &uri, QString const &mimetype, QVariantHash const &metadata)
2207+QString uriToThumbnailerProviderString(QString const &uri, QVariantHash const &metadata)
2208 {
2209 if (uri.startsWith(QLatin1String("file:///")) || uri.startsWith(QLatin1String("album://"))) {
2210- bool isAudio = mimetype.startsWith(QLatin1String("audio/"));
2211+ bool isAlbum = metadata.contains("album") && metadata.contains("artist");
2212 QString thumbnailerUri;
2213- if (isAudio) {
2214+ if (isAlbum) {
2215 thumbnailerUri = BASE_ALBUMART_URI;
2216- if (metadata.contains("content")) {
2217- QVariantHash contentHash = metadata["content"].toHash();
2218- if (contentHash.contains("content")) { // nested content in Home?
2219- contentHash = contentHash["content"].toHash();
2220- }
2221- if (contentHash.contains("album") && contentHash.contains("artist")) {
2222- QUrlQuery query;
2223- query.addQueryItem(QStringLiteral("artist"), contentHash["artist"].toString());
2224- query.addQueryItem(QStringLiteral("album"), contentHash["album"].toString());
2225- thumbnailerUri.append(query.toString());
2226- }
2227- }
2228+ QUrlQuery query;
2229+ query.addQueryItem(QStringLiteral("artist"), metadata["artist"].toString());
2230+ query.addQueryItem(QStringLiteral("album"), metadata["album"].toString());
2231+ thumbnailerUri.append(query.toString());
2232 } else {
2233 thumbnailerUri = BASE_THUMBNAILER_URI;
2234 thumbnailerUri.append(uri.midRef(7));
2235
2236=== modified file 'src/Unity/iconutils.h'
2237--- src/Unity/iconutils.h 2013-11-08 17:01:37 +0000
2238+++ src/Unity/iconutils.h 2014-03-25 16:56:23 +0000
2239@@ -23,7 +23,6 @@
2240 #include <QString>
2241 #include <QVariant>
2242
2243-QString gIconToDeclarativeImageProviderString(QString const &giconString);
2244-QString uriToThumbnailerProviderString(QString const &uri, QString const &mimetype, QVariantHash const &metadata);
2245+QString uriToThumbnailerProviderString(QString const &uri, QVariantHash const &metadata);
2246
2247 #endif
2248
2249=== removed file 'src/Unity/moviepreview.cpp'
2250--- src/Unity/moviepreview.cpp 2013-11-08 17:01:37 +0000
2251+++ src/Unity/moviepreview.cpp 1970-01-01 00:00:00 +0000
2252@@ -1,67 +0,0 @@
2253-/*
2254- * Copyright (C) 2013 Canonical, Ltd.
2255- *
2256- * Authors:
2257- * Pawel Stolowski <pawel.stolowski@canonical.com>
2258- *
2259- * This program is free software; you can redistribute it and/or modify
2260- * it under the terms of the GNU General Public License as published by
2261- * the Free Software Foundation; version 3.
2262- *
2263- * This program is distributed in the hope that it will be useful,
2264- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2265- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2266- * GNU General Public License for more details.
2267- *
2268- * You should have received a copy of the GNU General Public License
2269- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2270- */
2271-
2272-// local
2273-#include "moviepreview.h"
2274-
2275-// Qt
2276-#include <QDebug>
2277-
2278-MoviePreview::MoviePreview(QObject *parent):
2279- Preview(parent),
2280- m_unityMoviePreview(nullptr)
2281-{
2282-}
2283-
2284-QString MoviePreview::year() const
2285-{
2286- if (m_unityMoviePreview) {
2287- return QString::fromStdString(m_unityMoviePreview->year());
2288- } else {
2289- qWarning() << "Preview not set";
2290- }
2291- return QString();
2292-}
2293-
2294-float MoviePreview::rating() const
2295-{
2296- if (m_unityMoviePreview) {
2297- return m_unityMoviePreview->rating();
2298- } else {
2299- qWarning() << "Preview not set";
2300- }
2301- return 0.0f;
2302-}
2303-
2304-unsigned int MoviePreview::numRatings() const
2305-{
2306- if (m_unityMoviePreview) {
2307- return m_unityMoviePreview->num_ratings();
2308- } else {
2309- qWarning() << "Preview not set";
2310- }
2311- return 0;
2312-}
2313-
2314-void MoviePreview::setUnityPreview(unity::dash::Preview::Ptr unityPreview)
2315-{
2316- m_unityMoviePreview = std::dynamic_pointer_cast<unity::dash::MoviePreview>(unityPreview);
2317-
2318- Q_EMIT previewChanged();
2319-}
2320
2321=== removed file 'src/Unity/moviepreview.h'
2322--- src/Unity/moviepreview.h 2013-11-08 17:01:37 +0000
2323+++ src/Unity/moviepreview.h 1970-01-01 00:00:00 +0000
2324@@ -1,60 +0,0 @@
2325-/*
2326- * Copyright (C) 2013 Canonical, Ltd.
2327- *
2328- * Authors:
2329- * Pawel Stolowski <pawel.stolowski@canonical.com>
2330- *
2331- * This program is free software; you can redistribute it and/or modify
2332- * it under the terms of the GNU General Public License as published by
2333- * the Free Software Foundation; version 3.
2334- *
2335- * This program is distributed in the hope that it will be useful,
2336- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2337- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2338- * GNU General Public License for more details.
2339- *
2340- * You should have received a copy of the GNU General Public License
2341- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2342- */
2343-
2344-#ifndef MOVIEPREVIEW_H
2345-#define MOVIEPREVIEW_H
2346-
2347-// local
2348-#include "preview.h"
2349-
2350-// Qt
2351-#include <QObject>
2352-#include <QMetaType>
2353-
2354-// libunity-core
2355-#include <UnityCore/MoviePreview.h>
2356-
2357-class Q_DECL_EXPORT MoviePreview: public Preview
2358-{
2359- Q_OBJECT
2360-
2361- Q_PROPERTY(QString year READ year NOTIFY previewChanged)
2362- Q_PROPERTY(float rating READ rating NOTIFY previewChanged)
2363- Q_PROPERTY(unsigned int numRatings READ numRatings NOTIFY previewChanged)
2364-
2365-public:
2366- explicit MoviePreview(QObject *parent = 0);
2367-
2368- QString year() const;
2369- float rating() const;
2370- unsigned int numRatings() const;
2371-
2372-Q_SIGNALS:
2373- void previewChanged();
2374-
2375-protected:
2376- void setUnityPreview(unity::dash::Preview::Ptr unityPreview) override;
2377-
2378-private:
2379- unity::dash::MoviePreview::Ptr m_unityMoviePreview;
2380-};
2381-
2382-Q_DECLARE_METATYPE(MoviePreview *)
2383-
2384-#endif
2385
2386=== removed file 'src/Unity/multirangefilter.cpp'
2387--- src/Unity/multirangefilter.cpp 2013-11-08 17:01:37 +0000
2388+++ src/Unity/multirangefilter.cpp 1970-01-01 00:00:00 +0000
2389@@ -1,65 +0,0 @@
2390-/*
2391- * Copyright (C) 2011, 2013 Canonical, Ltd.
2392- *
2393- * Authors:
2394- * Florian Boucault <florian.boucault@canonical.com>
2395- * Pawel Stolowski <pawel.stolowski@canonical.com>
2396- *
2397- * This program is free software; you can redistribute it and/or modify
2398- * it under the terms of the GNU General Public License as published by
2399- * the Free Software Foundation; version 3.
2400- *
2401- * This program is distributed in the hope that it will be useful,
2402- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2403- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2404- * GNU General Public License for more details.
2405- *
2406- * You should have received a copy of the GNU General Public License
2407- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2408- */
2409-
2410-// Self
2411-#include "multirangefilter.h"
2412-
2413-// local
2414-#include "unityoptionsmodel.h"
2415-
2416-MultiRangeFilter::MultiRangeFilter(QObject *parent) :
2417- Filter(parent), m_unityMultiRangeFilter(nullptr), m_options(nullptr)
2418-{
2419-}
2420-
2421-GenericOptionsModel* MultiRangeFilter::options() const
2422-{
2423- return m_options;
2424-}
2425-
2426-void MultiRangeFilter::setUnityFilter(unity::dash::Filter::Ptr filter)
2427-{
2428- Filter::setUnityFilter(filter);
2429- m_unityMultiRangeFilter = std::dynamic_pointer_cast<unity::dash::MultiRangeFilter>(m_unityFilter);
2430-
2431- onOptionsChanged(m_unityMultiRangeFilter->options);
2432-}
2433-
2434-void MultiRangeFilter::onOptionsChanged(unity::dash::MultiRangeFilter::Options options)
2435-{
2436- if (m_options != nullptr) {
2437- m_signals.disconnectAll();
2438- delete m_options;
2439- m_options = nullptr;
2440- }
2441-
2442- m_options = new UnityOptionsModel(this, options,
2443- m_unityMultiRangeFilter->option_added,
2444- m_unityMultiRangeFilter->option_removed,
2445- m_unityMultiRangeFilter->show_all_button);
2446-
2447- connect(m_options, SIGNAL(activeChanged(AbstractFilterOption *)), m_options, SLOT(ensureTheOnlyActive(AbstractFilterOption *)));
2448- connect(m_options, SIGNAL(showAllActivated()), this, SLOT(clear()));
2449-
2450- /* Property change signals */
2451- m_signals << m_unityMultiRangeFilter->options.changed.connect(sigc::mem_fun(this, &MultiRangeFilter::onOptionsChanged));
2452-
2453- Q_EMIT optionsChanged();
2454-}
2455
2456=== removed file 'src/Unity/multirangefilter.h'
2457--- src/Unity/multirangefilter.h 2013-11-08 17:01:37 +0000
2458+++ src/Unity/multirangefilter.h 1970-01-01 00:00:00 +0000
2459@@ -1,60 +0,0 @@
2460-/*
2461- * Copyright (C) 2011, 2013 Canonical, Ltd.
2462- *
2463- * Authors:
2464- * Florian Boucault <florian.boucault@canonical.com>
2465- * Pawel Stolowski <pawel.stolowski@canonical.com>
2466- *
2467- * This program is free software; you can redistribute it and/or modify
2468- * it under the terms of the GNU General Public License as published by
2469- * the Free Software Foundation; version 3.
2470- *
2471- * This program is distributed in the hope that it will be useful,
2472- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2473- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2474- * GNU General Public License for more details.
2475- *
2476- * You should have received a copy of the GNU General Public License
2477- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2478- */
2479-
2480-#ifndef MULTIRANGEFILTER_H
2481-#define MULTIRANGEFILTER_H
2482-
2483-// Qt
2484-#include <QObject>
2485-#include <QMetaType>
2486-
2487-// libunity-core
2488-#include <UnityCore/MultiRangeFilter.h>
2489-
2490-// Local
2491-#include "filter.h"
2492-#include "signalslist.h"
2493-
2494-class GenericOptionsModel;
2495-
2496-class Q_DECL_EXPORT MultiRangeFilter : public Filter
2497-{
2498- Q_OBJECT
2499-
2500-public:
2501- explicit MultiRangeFilter(QObject *parent = nullptr);
2502-
2503- /* getters */
2504- GenericOptionsModel* options() const override;
2505-
2506-protected:
2507- void setUnityFilter(unity::dash::Filter::Ptr filter) override;
2508-
2509-private:
2510- unity::dash::MultiRangeFilter::Ptr m_unityMultiRangeFilter;
2511- SignalsList m_signals;
2512- GenericOptionsModel* m_options;
2513-
2514- void onOptionsChanged(unity::dash::MultiRangeFilter::Options);
2515-};
2516-
2517-Q_DECLARE_METATYPE(MultiRangeFilter*)
2518-
2519-#endif // MULTIRANGEFILTER_H
2520
2521=== removed file 'src/Unity/musicpreview.cpp'
2522--- src/Unity/musicpreview.cpp 2013-11-25 11:21:45 +0000
2523+++ src/Unity/musicpreview.cpp 1970-01-01 00:00:00 +0000
2524@@ -1,53 +0,0 @@
2525-/*
2526- * Copyright (C) 2013 Canonical, Ltd.
2527- *
2528- * Authors:
2529- * Pawel Stolowski <pawel.stolowski@canonical.com>
2530- *
2531- * This program is free software; you can redistribute it and/or modify
2532- * it under the terms of the GNU General Public License as published by
2533- * the Free Software Foundation; version 3.
2534- *
2535- * This program is distributed in the hope that it will be useful,
2536- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2537- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2538- * GNU General Public License for more details.
2539- *
2540- * You should have received a copy of the GNU General Public License
2541- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2542- */
2543-
2544-#include "musicpreview.h"
2545-#include "musicpreviewtrackmodel.h"
2546-
2547-#include <QDebug>
2548-
2549-MusicPreview::MusicPreview(QObject *parent):
2550- Preview(parent),
2551- m_unityMusicPreview(nullptr)
2552-{
2553- m_tracks = new MusicPreviewTrackModel(this);
2554-}
2555-
2556-void MusicPreview::setUnityPreview(unity::dash::Preview::Ptr unityPreview)
2557-{
2558- m_unityMusicPreview = std::dynamic_pointer_cast<unity::dash::MusicPreview>(unityPreview);
2559- m_tracks->setModel(m_unityMusicPreview->GetTracksModel()->model());
2560- m_unityMusicPreview->GetTracksModel()->model.changed.connect(sigc::mem_fun(this, &MusicPreview::onTracksModelChanged));
2561-
2562- Q_EMIT previewChanged();
2563- Q_EMIT tracksChanged();
2564-}
2565-
2566-MusicPreviewTrackModel* MusicPreview::tracks() const
2567-{
2568- if (m_unityMusicPreview == nullptr) {
2569- qWarning() << "Preview not set";
2570- }
2571- return m_tracks;
2572-}
2573-
2574-void MusicPreview::onTracksModelChanged(unity::glib::Object<DeeModel> /* model */)
2575-{
2576- m_tracks->setModel(m_unityMusicPreview->GetTracksModel()->model());
2577-}
2578
2579=== removed file 'src/Unity/musicpreview.h'
2580--- src/Unity/musicpreview.h 2013-11-25 11:21:45 +0000
2581+++ src/Unity/musicpreview.h 1970-01-01 00:00:00 +0000
2582@@ -1,62 +0,0 @@
2583-/*
2584- * Copyright (C) 2013 Canonical, Ltd.
2585- *
2586- * Authors:
2587- * Pawel Stolowski <pawel.stolowski@canonical.com>
2588- *
2589- * This program is free software; you can redistribute it and/or modify
2590- * it under the terms of the GNU General Public License as published by
2591- * the Free Software Foundation; version 3.
2592- *
2593- * This program is distributed in the hope that it will be useful,
2594- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2595- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2596- * GNU General Public License for more details.
2597- *
2598- * You should have received a copy of the GNU General Public License
2599- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2600- */
2601-
2602-#ifndef MUSICPREVIEW_H
2603-#define MUSICPREVIEW_H
2604-
2605-// local
2606-#include "preview.h"
2607-
2608-// Qt
2609-#include <QObject>
2610-#include <QMetaType>
2611-
2612-// libunity-core
2613-#include <UnityCore/MusicPreview.h>
2614-
2615-class MusicPreviewTrackModel;
2616-
2617-class Q_DECL_EXPORT MusicPreview: public Preview
2618-{
2619- Q_OBJECT
2620-
2621- Q_PROPERTY(MusicPreviewTrackModel* tracks READ tracks NOTIFY tracksChanged)
2622-
2623-public:
2624- explicit MusicPreview(QObject *parent = 0);
2625-
2626- MusicPreviewTrackModel* tracks() const;
2627-
2628-Q_SIGNALS:
2629- void tracksChanged();
2630-
2631-protected:
2632- void setUnityPreview(unity::dash::Preview::Ptr unityPreview) override;
2633-
2634-private Q_SLOTS:
2635- void onTracksModelChanged(unity::glib::Object<DeeModel> model);
2636-
2637-private:
2638- unity::dash::MusicPreview::Ptr m_unityMusicPreview;
2639- MusicPreviewTrackModel *m_tracks;
2640-};
2641-
2642-Q_DECLARE_METATYPE(MusicPreview *)
2643-
2644-#endif
2645
2646=== removed file 'src/Unity/musicpreviewtrackmodel.cpp'
2647--- src/Unity/musicpreviewtrackmodel.cpp 2013-11-25 12:10:02 +0000
2648+++ src/Unity/musicpreviewtrackmodel.cpp 1970-01-01 00:00:00 +0000
2649@@ -1,68 +0,0 @@
2650-/*
2651- * Copyright (C) 2013 Canonical, Ltd.
2652- *
2653- * This program is free software; you can redistribute it and/or modify
2654- * it under the terms of the GNU General Public License as published by
2655- * the Free Software Foundation; version 3.
2656- *
2657- * This program is distributed in the hope that it will be useful,
2658- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2659- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2660- * GNU General Public License for more details.
2661- *
2662- * You should have received a copy of the GNU General Public License
2663- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2664- *
2665- * Authors:
2666- * Michael Zanetti <michael.zanetti@canonical.com>
2667- */
2668-
2669-#include "musicpreviewtrackmodel.h"
2670-
2671-#include <QTime>
2672-
2673-// TODO: use something from libunity once it's public
2674-enum ResultsColumn {
2675- URI,
2676- TRACK_NO,
2677- TITLE,
2678- LENGTH,
2679- PLAY_STATE,
2680- PROGRESS
2681-};
2682-
2683-MusicPreviewTrackModel::MusicPreviewTrackModel(QObject *parent): DeeListModel(parent)
2684-{
2685- m_roles.insert(RoleUri, "uri");
2686- m_roles.insert(RoleTrackNo, "trackNo");
2687- m_roles.insert(RoleTitle, "title");
2688- m_roles.insert(RoleLength, "length");
2689-}
2690-
2691-QVariant MusicPreviewTrackModel::data(const QModelIndex &index, int role) const
2692-{
2693- switch(role) {
2694- case RoleUri:
2695- return DeeListModel::data(index, ResultsColumn::URI);
2696- case RoleTrackNo:
2697- return DeeListModel::data(index, ResultsColumn::TRACK_NO);
2698- case RoleTitle:
2699- return DeeListModel::data(index, ResultsColumn::TITLE);
2700- case RoleLength: {
2701- QTime length = QTime(0,0).addSecs(DeeListModel::data(index, ResultsColumn::LENGTH).toInt());
2702- if (length.hour() > 0) {
2703- return length.toString("h:mm:ss");
2704- }
2705- if (!length.isNull()) {
2706- return length.toString("m:ss");
2707- }
2708- return QVariant();
2709- }
2710- }
2711- return QVariant();
2712-}
2713-
2714-QHash<int, QByteArray> MusicPreviewTrackModel::roleNames() const
2715-{
2716- return m_roles;
2717-}
2718
2719=== removed file 'src/Unity/musicpreviewtrackmodel.h'
2720--- src/Unity/musicpreviewtrackmodel.h 2013-11-25 12:10:02 +0000
2721+++ src/Unity/musicpreviewtrackmodel.h 1970-01-01 00:00:00 +0000
2722@@ -1,48 +0,0 @@
2723-/*
2724- * Copyright (C) 2013 Canonical, Ltd.
2725- *
2726- * This program is free software; you can redistribute it and/or modify
2727- * it under the terms of the GNU General Public License as published by
2728- * the Free Software Foundation; version 3.
2729- *
2730- * This program is distributed in the hope that it will be useful,
2731- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2732- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2733- * GNU General Public License for more details.
2734- *
2735- * You should have received a copy of the GNU General Public License
2736- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2737- *
2738- * Authors:
2739- * Michael Zanetti <michael.zanetti@canonical.com>
2740- */
2741-
2742-#ifndef MUSICPREVIEWTRACKMODEL_H
2743-#define MUSICPREVIEWTRACKMODEL_H
2744-
2745-#include "deelistmodel.h"
2746-
2747-class Q_DECL_EXPORT MusicPreviewTrackModel : public DeeListModel
2748-{
2749- Q_OBJECT
2750- Q_ENUMS(Roles)
2751-
2752-public:
2753- explicit MusicPreviewTrackModel(QObject* parent = 0);
2754-
2755- enum Roles {
2756- RoleUri,
2757- RoleTrackNo,
2758- RoleTitle,
2759- RoleLength
2760- };
2761-
2762- QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
2763-
2764- QHash<int, QByteArray> roleNames() const;
2765-
2766-private:
2767- QHash<int, QByteArray> m_roles;
2768-};
2769-
2770-#endif // MUSICPREVIEWTRACKMODEL_H
2771
2772=== modified file 'src/Unity/plugin.cpp'
2773--- src/Unity/plugin.cpp 2014-02-20 10:39:15 +0000
2774+++ src/Unity/plugin.cpp 2014-03-25 16:56:23 +0000
2775@@ -24,46 +24,18 @@
2776 #include "plugin.h"
2777
2778 // local
2779-#include "preview.h"
2780-#include "previewaction.h"
2781-#include "previewinfohint.h"
2782-#include "socialpreviewcomment.h"
2783+#include "scopes.h"
2784 #include "scope.h"
2785-#include "scopes.h"
2786 #include "categories.h"
2787-#include "categoryresults.h"
2788-#include "genericoptionsmodel.h"
2789-#include "result.h"
2790-#include "musicpreviewtrackmodel.h"
2791-
2792-#include "scopes-ng/scopes.h"
2793-#include "scopes-ng/scope.h"
2794-#include "scopes-ng/categories.h"
2795-#include "scopes-ng/resultsmodel.h"
2796-#include "scopes-ng/previewstack.h"
2797-#include "scopes-ng/previewmodel.h"
2798-#include "scopes-ng/previewwidgetmodel.h"
2799-
2800-// libqtdee
2801-#include "deelistmodel.h"
2802+#include "resultsmodel.h"
2803+#include "previewstack.h"
2804+#include "previewmodel.h"
2805+#include "previewwidgetmodel.h"
2806
2807 void UnityPlugin::registerTypes(const char *uri)
2808 {
2809 Q_ASSERT(uri == QLatin1String("Unity"));
2810
2811- qmlRegisterUncreatableType<Preview>(uri, 0, 1, "Preview", "Can't create Preview object in QML.");
2812- qmlRegisterUncreatableType<PreviewAction>(uri, 0, 1, "PreviewAction", "Can't create PreviewAction object in QML.");
2813- qmlRegisterUncreatableType<PreviewInfoHint>(uri, 0, 1, "PreviewInfoHint", "Can't create PreviewInfoHint object in QML.");
2814- qmlRegisterUncreatableType<SocialPreviewComment>(uri, 0, 1, "SocialPreviewComment", "Can't create SocialPreviewComment object in QML.");
2815- qmlRegisterUncreatableType<GenericOptionsModel>(uri, 0, 1, "GenericOptionsModel", "Can't create options model in QML.");
2816- qmlRegisterUncreatableType<Result>(uri, 0, 1, "Result", "Can't create result object in QML.");
2817- qmlRegisterType<Scope>(uri, 0, 1, "Scope");
2818- qmlRegisterType<Scopes>(uri, 0, 1, "Scopes");
2819- qmlRegisterType<Categories>(uri, 0, 1, "Categories");
2820- qmlRegisterUncreatableType<CategoryResults>(uri, 0, 1, "CategoryResults", "Can't create new Category Results in QML. Get them from Categories instance.");
2821- qmlRegisterType<DeeListModel>(uri, 0, 1, "DeeListModel");
2822- qmlRegisterType<MusicPreviewTrackModel>(uri, 0, 1, "MusicPreviewTrackModel");
2823-
2824 // new Scopes classes
2825 qmlRegisterType<scopes_ng::Scope>(uri, 0, 2, "Scope");
2826 qmlRegisterType<scopes_ng::Scopes>(uri, 0, 2, "Scopes");
2827@@ -77,7 +49,4 @@
2828 void UnityPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
2829 {
2830 QQmlExtensionPlugin::initializeEngine(engine, uri);
2831-#ifndef GLIB_VERSION_2_36
2832- g_type_init();
2833-#endif
2834 }
2835
2836=== removed file 'src/Unity/preview.cpp'
2837--- src/Unity/preview.cpp 2013-11-08 17:01:37 +0000
2838+++ src/Unity/preview.cpp 1970-01-01 00:00:00 +0000
2839@@ -1,199 +0,0 @@
2840-/*
2841- * Copyright (C) 2013 Canonical, Ltd.
2842- *
2843- * Authors:
2844- * Pawel Stolowski <pawel.stolowski@canonical.com>
2845- *
2846- * This program is free software; you can redistribute it and/or modify
2847- * it under the terms of the GNU General Public License as published by
2848- * the Free Software Foundation; version 3.
2849- *
2850- * This program is distributed in the hope that it will be useful,
2851- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2852- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2853- * GNU General Public License for more details.
2854- *
2855- * You should have received a copy of the GNU General Public License
2856- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2857- */
2858-
2859-// local
2860-#include "preview.h"
2861-#include "previewaction.h"
2862-#include "previewinfohint.h"
2863-#include "genericpreview.h"
2864-#include "applicationpreview.h"
2865-#include "moviepreview.h"
2866-#include "musicpreview.h"
2867-#include "socialpreview.h"
2868-#include "iconutils.h"
2869-#include "variantutils.h"
2870-
2871-// Qt
2872-#include <QDebug>
2873-#include <QtAlgorithms>
2874-
2875-#include <UnityCore/GenericPreview.h>
2876-#include <UnityCore/ApplicationPreview.h>
2877-#include <UnityCore/MoviePreview.h>
2878-#include <UnityCore/MusicPreview.h>
2879-#include <UnityCore/SocialPreview.h>
2880-
2881-#include <UnityCore/GLibWrapper.h>
2882-
2883-Preview::Preview(QObject *parent):
2884- QObject(parent),
2885- m_unityPreview(nullptr),
2886- m_result(new Result(this))
2887-{
2888-}
2889-
2890-QString Preview::rendererName() const
2891-{
2892- if (m_unityPreview) {
2893- return QString::fromStdString(m_unityPreview->renderer_name());
2894- } else {
2895- qWarning() << "Preview not set";
2896- }
2897- return QString();
2898-}
2899-
2900-QString Preview::title() const
2901-{
2902- if (m_unityPreview) {
2903- return QString::fromStdString(m_unityPreview->title());
2904- } else {
2905- qWarning() << "Preview not set";
2906- }
2907- return QString();
2908-}
2909-
2910-QString Preview::subtitle () const
2911-{
2912- if (m_unityPreview) {
2913- return QString::fromStdString(m_unityPreview->subtitle());
2914- } else {
2915- qWarning() << "Preview not set";
2916- }
2917- return QString();
2918-}
2919-
2920-QString Preview::description() const
2921-{
2922- if (m_unityPreview) {
2923- return QString::fromStdString(m_unityPreview->description());
2924- } else {
2925- qWarning() << "Preview not set";
2926- }
2927- return QString();
2928-}
2929-
2930-QVariant Preview::actions()
2931-{
2932- return QVariant::fromValue(m_actions);
2933-}
2934-
2935-QVariant Preview::infoHints()
2936-{
2937- return QVariant::fromValue(m_infoHints);
2938-}
2939-
2940-QVariantMap Preview::infoHintsHash() const
2941-{
2942- return m_infoHintsHash;
2943-}
2944-
2945-QString Preview::image() const
2946-{
2947- if (m_unityPreview) {
2948- if (m_unityPreview->image() != nullptr) {
2949- auto giconString = g_icon_to_string(m_unityPreview->image());
2950- QString result(gIconToDeclarativeImageProviderString(QString::fromUtf8(giconString)));
2951- g_free(giconString);
2952- return result;
2953- } else {
2954- QString sourceMedia(QString::fromStdString(m_unityPreview->image_source_uri()));
2955- QString thumbnailUri(uriToThumbnailerProviderString(sourceMedia, m_result->mimeType(), m_result->metadata().toHash()));
2956- if (!thumbnailUri.isNull()) return thumbnailUri;
2957- }
2958- } else {
2959- qWarning() << "Preview not set";
2960- }
2961- return QString::null;
2962-}
2963-
2964-QVariant Preview::result() const
2965-{
2966- return QVariant::fromValue(m_result);
2967-}
2968-
2969-Preview* Preview::newFromUnityPreview(unity::dash::Preview::Ptr unityPreview)
2970-{
2971- Preview* preview = nullptr;
2972-
2973- if (dynamic_cast<unity::dash::GenericPreview *>(unityPreview.get()) != nullptr) {
2974- preview = new GenericPreview();
2975- } else if (dynamic_cast<unity::dash::MusicPreview *>(unityPreview.get()) != nullptr) {
2976- preview = new MusicPreview();
2977- } else if (dynamic_cast<unity::dash::MoviePreview *>(unityPreview.get()) != nullptr) {
2978- preview = new MoviePreview();
2979- } else if (dynamic_cast<unity::dash::ApplicationPreview *>(unityPreview.get()) != nullptr) {
2980- preview = new ApplicationPreview();
2981- } else if (dynamic_cast<unity::dash::SocialPreview *>(unityPreview.get()) != nullptr) {
2982- preview = new SocialPreview();
2983- } else {
2984- qWarning() << "Unknown preview type: " << typeid(*unityPreview).name();
2985- preview = new GenericPreview();
2986- }
2987-
2988- preview->setUnityPreviewBase(unityPreview);
2989- preview->setUnityPreview(unityPreview);
2990-
2991- return preview;
2992-}
2993-
2994-void Preview::setUnityPreviewBase(unity::dash::Preview::Ptr unityPreview)
2995-{
2996- m_unityPreview = unityPreview;
2997- m_result->setPreview(unityPreview);
2998-
2999- qDeleteAll(m_infoHints);
3000- m_infoHints.clear();
3001- m_infoHintsHash.clear();
3002- qDeleteAll(m_actions);
3003- m_actions.clear();
3004-
3005- for (auto unityInfoHint: m_unityPreview->GetInfoHints()) {
3006- auto hint = new PreviewInfoHint(this);
3007- hint->setUnityInfoHint(unityInfoHint);
3008- m_infoHints.append(hint);
3009- m_infoHintsHash[hint->id()] = QVariant::fromValue(hint);
3010- }
3011-
3012- for (auto unityAction: m_unityPreview->GetActions()) {
3013- auto action = new PreviewAction(this);
3014- action->setUnityAction(unityAction);
3015- m_actions.append(action);
3016- }
3017-}
3018-
3019-void Preview::setUnityPreview(unity::dash::Preview::Ptr /* unityPreview */)
3020-{
3021- // default implementation does nothing
3022-}
3023-
3024-void Preview::execute(const QString& actionId, const QHash<QString, QVariant>& hints)
3025-{
3026- if (m_unityPreview) {
3027- auto unityHints = convertToHintsMap(hints);
3028- m_actionCancellable.Renew();
3029- m_unityPreview->PerformAction(actionId.toStdString(), unityHints, nullptr, m_actionCancellable);
3030- } else {
3031- qWarning() << "Preview not set";
3032- }
3033-}
3034-
3035-void Preview::cancelAction()
3036-{
3037- m_actionCancellable.Cancel();
3038-}
3039
3040=== removed file 'src/Unity/preview.h'
3041--- src/Unity/preview.h 2013-11-08 17:01:37 +0000
3042+++ src/Unity/preview.h 1970-01-01 00:00:00 +0000
3043@@ -1,89 +0,0 @@
3044-/*
3045- * Copyright (C) 2013 Canonical, Ltd.
3046- *
3047- * Authors:
3048- * Pawel Stolowski <pawel.stolowski@canonical.com>
3049- *
3050- * This program is free software; you can redistribute it and/or modify
3051- * it under the terms of the GNU General Public License as published by
3052- * the Free Software Foundation; version 3.
3053- *
3054- * This program is distributed in the hope that it will be useful,
3055- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3056- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3057- * GNU General Public License for more details.
3058- *
3059- * You should have received a copy of the GNU General Public License
3060- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3061- */
3062-
3063-#ifndef PREVIEW_H
3064-#define PREVIEW_H
3065-
3066-// Qt
3067-#include <QObject>
3068-#include <QString>
3069-#include <QMetaType>
3070-#include <QList>
3071-#include <QVariantMap>
3072-
3073-// libunity-core
3074-#include <UnityCore/Preview.h>
3075-
3076-// local
3077-#include "result.h"
3078-#include "previewaction.h"
3079-#include <UnityCore/GLibWrapper.h>
3080-
3081-class Q_DECL_EXPORT Preview : public QObject
3082-{
3083- Q_OBJECT
3084-
3085- Q_PROPERTY(QString rendererName READ rendererName NOTIFY previewChanged)
3086- Q_PROPERTY(QString title READ title NOTIFY previewChanged)
3087- Q_PROPERTY(QString subtitle READ subtitle NOTIFY previewChanged)
3088- Q_PROPERTY(QString description READ description NOTIFY previewChanged)
3089- Q_PROPERTY(QVariant actions READ actions NOTIFY previewChanged)
3090- Q_PROPERTY(QVariant infoHints READ infoHints NOTIFY previewChanged)
3091- Q_PROPERTY(QVariantMap infoMap READ infoHintsHash NOTIFY previewChanged)
3092- Q_PROPERTY(QString image READ image NOTIFY previewChanged)
3093- Q_PROPERTY(QVariant result READ result NOTIFY previewChanged)
3094-
3095-public:
3096- explicit Preview(QObject *parent = 0);
3097- static Preview* newFromUnityPreview(unity::dash::Preview::Ptr unityPreview);
3098-
3099- QString rendererName() const;
3100- QString title() const;
3101- QString subtitle() const;
3102- QString description() const;
3103- QVariant actions();
3104- QVariant infoHints();
3105- QVariantMap infoHintsHash() const;
3106- QString image() const;
3107- QVariant result() const;
3108-
3109- Q_INVOKABLE void execute(const QString& actionId, const QHash<QString, QVariant>& hints);
3110- Q_INVOKABLE void cancelAction();
3111-
3112-Q_SIGNALS:
3113- void previewChanged();
3114-
3115-protected:
3116- virtual void setUnityPreview(unity::dash::Preview::Ptr unityPreview);
3117-
3118- unity::dash::Preview::Ptr m_unityPreview;
3119- Result* m_result;
3120-
3121-private:
3122- void setUnityPreviewBase(unity::dash::Preview::Ptr unityPreview);
3123-
3124- QList<QObject *> m_actions;
3125- QList<QObject *> m_infoHints;
3126- QVariantMap m_infoHintsHash;
3127- unity::glib::Cancellable m_actionCancellable;
3128-};
3129-
3130-Q_DECLARE_METATYPE(Preview *)
3131-
3132-#endif
3133
3134=== removed file 'src/Unity/previewaction.cpp'
3135--- src/Unity/previewaction.cpp 2013-11-08 17:01:37 +0000
3136+++ src/Unity/previewaction.cpp 1970-01-01 00:00:00 +0000
3137@@ -1,75 +0,0 @@
3138-/*
3139- * Copyright (C) 2013 Canonical, Ltd.
3140- *
3141- * Authors:
3142- * Pawel Stolowski <pawel.stolowski@canonical.com>
3143- *
3144- * This program is free software; you can redistribute it and/or modify
3145- * it under the terms of the GNU General Public License as published by
3146- * the Free Software Foundation; version 3.
3147- *
3148- * This program is distributed in the hope that it will be useful,
3149- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3150- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3151- * GNU General Public License for more details.
3152- *
3153- * You should have received a copy of the GNU General Public License
3154- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3155- */
3156-
3157-#include "previewaction.h"
3158-
3159-PreviewAction::PreviewAction(QObject *parent)
3160- : QObject(parent),
3161- m_unityAction(nullptr)
3162-{
3163-}
3164-
3165-void PreviewAction::setUnityAction(unity::dash::Preview::ActionPtr unityAction)
3166-{
3167- m_unityAction = unityAction;
3168-
3169- Q_EMIT previewActionChanged();
3170-}
3171-
3172-QString PreviewAction::id() const
3173-{
3174- if (m_unityAction)
3175- return QString::fromStdString(m_unityAction->id);
3176- return QString();
3177-}
3178-
3179-QString PreviewAction::displayName() const
3180-{
3181- if (m_unityAction)
3182- return QString::fromStdString(m_unityAction->display_name);
3183- return QString();
3184-}
3185-
3186-QString PreviewAction::iconHint() const
3187-{
3188- if (m_unityAction)
3189- return QString::fromStdString(m_unityAction->icon_hint);
3190- return QString();
3191-}
3192-
3193-QString PreviewAction::extraText() const
3194-{
3195- if (m_unityAction)
3196- return QString::fromStdString(m_unityAction->extra_text);
3197- return QString();
3198-}
3199-
3200-QString PreviewAction::activationUri() const
3201-{
3202- if (m_unityAction)
3203- return QString::fromStdString(m_unityAction->activation_uri);
3204- return QString();
3205-}
3206-
3207-LayoutHint PreviewAction::layoutHint() const
3208-{
3209- if (m_unityAction)
3210- return static_cast<LayoutHint>(m_unityAction->layout_hint);
3211- return LayoutHint::None;
3212-}
3213
3214=== removed file 'src/Unity/previewaction.h'
3215--- src/Unity/previewaction.h 2013-11-08 17:01:37 +0000
3216+++ src/Unity/previewaction.h 1970-01-01 00:00:00 +0000
3217@@ -1,71 +0,0 @@
3218-/*
3219- * Copyright (C) 2013 Canonical, Ltd.
3220- *
3221- * Authors:
3222- * Pawel Stolowski <pawel.stolowski@canonical.com>
3223- *
3224- * This program is free software; you can redistribute it and/or modify
3225- * it under the terms of the GNU General Public License as published by
3226- * the Free Software Foundation; version 3.
3227- *
3228- * This program is distributed in the hope that it will be useful,
3229- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3230- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3231- * GNU General Public License for more details.
3232- *
3233- * You should have received a copy of the GNU General Public License
3234- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3235- */
3236-
3237-#ifndef PREVIEWACTION_H
3238-#define PREVIEWACTION_H
3239-
3240-// Qt
3241-#include <QObject>
3242-#include <QList>
3243-
3244-// libuinity-core
3245-#include <UnityCore/Preview.h>
3246-
3247-enum LayoutHint // keep in sync with unty::dash::LayoutHint
3248-{
3249- None,
3250- Left,
3251- Right,
3252- Top,
3253- Bottom
3254-};
3255-
3256-class Q_DECL_EXPORT PreviewAction : public QObject
3257-{
3258- Q_OBJECT
3259-
3260- Q_PROPERTY(QString id READ id NOTIFY previewActionChanged)
3261- Q_PROPERTY(QString displayName READ displayName NOTIFY previewActionChanged)
3262- Q_PROPERTY(QString iconHint READ iconHint NOTIFY previewActionChanged)
3263- Q_PROPERTY(QString extraText READ extraText NOTIFY previewActionChanged)
3264- Q_PROPERTY(QString activationUri READ activationUri NOTIFY previewActionChanged)
3265- Q_PROPERTY(LayoutHint layoutHint READ layoutHint NOTIFY previewActionChanged)
3266-
3267-public:
3268- explicit PreviewAction(QObject *parent = 0);
3269- void setUnityAction(unity::dash::Preview::ActionPtr unityAction);
3270-
3271- QString id() const;
3272- QString displayName() const;
3273- QString iconHint() const;
3274- QString extraText() const;
3275- QString activationUri() const;
3276- LayoutHint layoutHint() const;
3277-
3278-Q_SIGNALS:
3279- void previewActionChanged();
3280-
3281-private:
3282- unity::dash::Preview::ActionPtr m_unityAction;
3283-};
3284-
3285-Q_DECLARE_METATYPE(PreviewAction *)
3286-Q_DECLARE_METATYPE(LayoutHint)
3287-
3288-#endif
3289
3290=== removed file 'src/Unity/previewinfohint.cpp'
3291--- src/Unity/previewinfohint.cpp 2013-11-08 17:01:37 +0000
3292+++ src/Unity/previewinfohint.cpp 1970-01-01 00:00:00 +0000
3293@@ -1,67 +0,0 @@
3294-/*
3295- * Copyright (C) 2013 Canonical, Ltd.
3296- *
3297- * Authors:
3298- * Pawel Stolowski <pawel.stolowski@canonical.com>
3299- *
3300- * This program is free software; you can redistribute it and/or modify
3301- * it under the terms of the GNU General Public License as published by
3302- * the Free Software Foundation; version 3.
3303- *
3304- * This program is distributed in the hope that it will be useful,
3305- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3306- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3307- * GNU General Public License for more details.
3308- *
3309- * You should have received a copy of the GNU General Public License
3310- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3311- */
3312-
3313-#include <deelistmodel.h>
3314-// local
3315-#include "previewinfohint.h"
3316-
3317-PreviewInfoHint::PreviewInfoHint(QObject *parent):
3318- QObject(parent),
3319- m_unityInfoHint(nullptr)
3320-{
3321-}
3322-
3323-void PreviewInfoHint::setUnityInfoHint(unity::dash::Preview::InfoHintPtr unityInfoHint)
3324-{
3325- m_unityInfoHint = unityInfoHint;
3326-
3327- Q_EMIT previewInfoHintChanged();
3328-}
3329-
3330-QString PreviewInfoHint::id() const
3331-{
3332- if (m_unityInfoHint) {
3333- return QString::fromStdString(m_unityInfoHint->id);
3334- }
3335- return QString();
3336-}
3337-
3338-QString PreviewInfoHint::displayName() const
3339-{
3340- if (m_unityInfoHint) {
3341- return QString::fromStdString(m_unityInfoHint->display_name);
3342- }
3343- return QString();
3344-}
3345-
3346-QString PreviewInfoHint::iconHint() const
3347-{
3348- if (m_unityInfoHint) {
3349- return QString::fromStdString(m_unityInfoHint->icon_hint);
3350- }
3351- return QString();
3352-}
3353-
3354-QVariant PreviewInfoHint::value() const
3355-{
3356- if (m_unityInfoHint) {
3357- return DeeListModel::VariantForData(m_unityInfoHint->value);
3358- }
3359- return QVariant();
3360-}
3361
3362=== removed file 'src/Unity/previewinfohint.h'
3363--- src/Unity/previewinfohint.h 2013-11-08 17:01:37 +0000
3364+++ src/Unity/previewinfohint.h 1970-01-01 00:00:00 +0000
3365@@ -1,58 +0,0 @@
3366-/*
3367- * Copyright (C) 2013 Canonical, Ltd.
3368- *
3369- * Authors:
3370- * Pawel Stolowski <pawel.stolowski@canonical.com>
3371- *
3372- * This program is free software; you can redistribute it and/or modify
3373- * it under the terms of the GNU General Public License as published by
3374- * the Free Software Foundation; version 3.
3375- *
3376- * This program is distributed in the hope that it will be useful,
3377- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3378- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3379- * GNU General Public License for more details.
3380- *
3381- * You should have received a copy of the GNU General Public License
3382- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3383- */
3384-
3385-#ifndef PREVIEWINFOHINT_H
3386-#define PREVIEWINFOHINT_H
3387-
3388-// Qt
3389-#include <QObject>
3390-#include <QString>
3391-#include <QVariant>
3392-
3393-// libunity-core
3394-#include <UnityCore/Preview.h>
3395-
3396-class PreviewInfoHint : public QObject
3397-{
3398- Q_OBJECT
3399-
3400- Q_PROPERTY(QString id READ id NOTIFY previewInfoHintChanged)
3401- Q_PROPERTY(QString displayName READ displayName NOTIFY previewInfoHintChanged)
3402- Q_PROPERTY(QString iconHint READ iconHint NOTIFY previewInfoHintChanged)
3403- Q_PROPERTY(QVariant value READ value NOTIFY previewInfoHintChanged)
3404-
3405-public:
3406- explicit PreviewInfoHint(QObject *parent = 0);
3407- void setUnityInfoHint(unity::dash::Preview::InfoHintPtr unityInfoHint);
3408-
3409- QString id() const;
3410- QString displayName() const;
3411- QString iconHint() const;
3412- QVariant value() const;
3413-
3414-Q_SIGNALS:
3415- void previewInfoHintChanged();
3416-
3417-private:
3418- unity::dash::Preview::InfoHintPtr m_unityInfoHint;
3419-};
3420-
3421-Q_DECLARE_METATYPE(PreviewInfoHint *)
3422-
3423-#endif
3424
3425=== renamed file 'src/Unity/scopes-ng/previewmodel.cpp' => 'src/Unity/previewmodel.cpp'
3426=== renamed file 'src/Unity/scopes-ng/previewmodel.h' => 'src/Unity/previewmodel.h'
3427=== renamed file 'src/Unity/scopes-ng/previewstack.cpp' => 'src/Unity/previewstack.cpp'
3428=== renamed file 'src/Unity/scopes-ng/previewstack.h' => 'src/Unity/previewstack.h'
3429=== renamed file 'src/Unity/scopes-ng/previewwidgetmodel.cpp' => 'src/Unity/previewwidgetmodel.cpp'
3430=== renamed file 'src/Unity/scopes-ng/previewwidgetmodel.h' => 'src/Unity/previewwidgetmodel.h'
3431=== removed file 'src/Unity/radiooptionfilter.cpp'
3432--- src/Unity/radiooptionfilter.cpp 2013-11-08 17:01:37 +0000
3433+++ src/Unity/radiooptionfilter.cpp 1970-01-01 00:00:00 +0000
3434@@ -1,61 +0,0 @@
3435-/*
3436- * Copyright (C) 2011, 2013 Canonical, Ltd.
3437- *
3438- * Authors:
3439- * Florian Boucault <florian.boucault@canonical.com>
3440- * Pawel Stolowski <pawel.stolowski@canonical.com>
3441- *
3442- * This program is free software; you can redistribute it and/or modify
3443- * it under the terms of the GNU General Public License as published by
3444- * the Free Software Foundation; version 3.
3445- *
3446- * This program is distributed in the hope that it will be useful,
3447- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3448- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3449- * GNU General Public License for more details.
3450- *
3451- * You should have received a copy of the GNU General Public License
3452- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3453- */
3454-
3455-// Self
3456-#include "radiooptionfilter.h"
3457-
3458-// local
3459-#include "unityoptionsmodel.h"
3460-
3461-RadioOptionFilter::RadioOptionFilter(QObject *parent) :
3462- Filter(parent), m_unityRadioOptionFilter(nullptr), m_options(nullptr)
3463-{
3464-}
3465-
3466-GenericOptionsModel* RadioOptionFilter::options() const
3467-{
3468- return m_options;
3469-}
3470-
3471-void RadioOptionFilter::setUnityFilter(unity::dash::Filter::Ptr filter)
3472-{
3473- Filter::setUnityFilter(filter);
3474- m_unityRadioOptionFilter = std::dynamic_pointer_cast<unity::dash::RadioOptionFilter>(m_unityFilter);
3475-
3476- onOptionsChanged(m_unityRadioOptionFilter->options);
3477-}
3478-
3479-void RadioOptionFilter::onOptionsChanged(unity::dash::RadioOptionFilter::RadioOptions)
3480-{
3481- if (m_options != nullptr) {
3482- m_signals.disconnectAll();
3483- delete m_options;
3484- m_options = nullptr;
3485- }
3486- m_options = new UnityOptionsModel(this, m_unityRadioOptionFilter->options,
3487- m_unityRadioOptionFilter->option_added,
3488- m_unityRadioOptionFilter->option_removed,
3489- m_unityRadioOptionFilter->show_all_button);
3490- connect(m_options, SIGNAL(showAllActivated()), this, SLOT(clear()));
3491-
3492- m_signals << m_unityRadioOptionFilter->options.changed.connect(sigc::mem_fun(this, &RadioOptionFilter::onOptionsChanged));
3493-
3494- Q_EMIT optionsChanged();
3495-}
3496
3497=== removed file 'src/Unity/radiooptionfilter.h'
3498--- src/Unity/radiooptionfilter.h 2013-11-08 17:01:37 +0000
3499+++ src/Unity/radiooptionfilter.h 1970-01-01 00:00:00 +0000
3500@@ -1,59 +0,0 @@
3501-/*
3502- * Copyright (C) 2011, 2013 Canonical, Ltd.
3503- *
3504- * Authors:
3505- * Florian Boucault <florian.boucault@canonical.com>
3506- * Pawel Stolowski <pawel.stolowski@canonical.com>
3507- *
3508- * This program is free software; you can redistribute it and/or modify
3509- * it under the terms of the GNU General Public License as published by
3510- * the Free Software Foundation; version 3.
3511- *
3512- * This program is distributed in the hope that it will be useful,
3513- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3514- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3515- * GNU General Public License for more details.
3516- *
3517- * You should have received a copy of the GNU General Public License
3518- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3519- */
3520-
3521-#ifndef RADIOOPTIONFILTER_H
3522-#define RADIOOPTIONFILTER_H
3523-
3524-// Qt
3525-#include <QObject>
3526-#include <QMetaType>
3527-
3528-// libunity-core
3529-#include <UnityCore/RadioOptionFilter.h>
3530-
3531-// Local
3532-#include "filter.h"
3533-#include "filteroption.h"
3534-#include "signalslist.h"
3535-
3536-class Q_DECL_EXPORT RadioOptionFilter : public Filter
3537-{
3538- Q_OBJECT
3539-
3540-public:
3541- explicit RadioOptionFilter(QObject *parent = nullptr);
3542-
3543- /* getters */
3544- GenericOptionsModel* options() const override;
3545-
3546-protected:
3547- void setUnityFilter(unity::dash::Filter::Ptr filter) override;
3548-
3549-private:
3550- unity::dash::RadioOptionFilter::Ptr m_unityRadioOptionFilter;
3551- GenericOptionsModel* m_options;
3552- SignalsList m_signals;
3553-
3554- void onOptionsChanged(unity::dash::RadioOptionFilter::RadioOptions);
3555-};
3556-
3557-Q_DECLARE_METATYPE(RadioOptionFilter*)
3558-
3559-#endif // RADIOOPTIONFILTER_H
3560
3561=== removed file 'src/Unity/ratingfilteroption.cpp'
3562--- src/Unity/ratingfilteroption.cpp 2013-11-08 17:01:37 +0000
3563+++ src/Unity/ratingfilteroption.cpp 1970-01-01 00:00:00 +0000
3564@@ -1,62 +0,0 @@
3565-/*
3566- * Copyright (C) 2013 Canonical, Ltd.
3567- *
3568- * Authors:
3569- * Pawel Stolowski <pawel.stolowski@canonical.com>
3570- *
3571- * This program is free software; you can redistribute it and/or modify
3572- * it under the terms of the GNU General Public License as published by
3573- * the Free Software Foundation; version 3.
3574- *
3575- * This program is distributed in the hope that it will be useful,
3576- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3577- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3578- * GNU General Public License for more details.
3579- *
3580- * You should have received a copy of the GNU General Public License
3581- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3582- */
3583-
3584-// self
3585-#include "ratingfilteroption.h"
3586-
3587-RatingFilterOption::RatingFilterOption(const QString &id, float value, QObject *parent) :
3588- AbstractFilterOption(parent),
3589- m_active(false),
3590- m_id(id),
3591- m_value(value)
3592-{
3593-}
3594-
3595-QString RatingFilterOption::id() const
3596-{
3597- return m_id;
3598-}
3599-
3600-QString RatingFilterOption::name() const
3601-{
3602- return QString::Null();
3603-}
3604-
3605-QString RatingFilterOption::iconHint() const
3606-{
3607- return QString::Null();
3608-}
3609-
3610-float RatingFilterOption::value() const
3611-{
3612- return m_value;
3613-}
3614-
3615-bool RatingFilterOption::active() const
3616-{
3617- return m_active;
3618-}
3619-
3620-void RatingFilterOption::setActive(bool active)
3621-{
3622- if (active != m_active) {
3623- m_active = active;
3624- Q_EMIT activeChanged(m_active);
3625- }
3626-}
3627
3628=== removed file 'src/Unity/ratingfilteroption.h'
3629--- src/Unity/ratingfilteroption.h 2013-11-08 17:01:37 +0000
3630+++ src/Unity/ratingfilteroption.h 1970-01-01 00:00:00 +0000
3631@@ -1,53 +0,0 @@
3632-/*
3633- * Copyright (C) 2013 Canonical, Ltd.
3634- *
3635- * Authors:
3636- * Pawel Stolowski <pawel.stolowski@canonical.com>
3637- *
3638- * This program is free software; you can redistribute it and/or modify
3639- * it under the terms of the GNU General Public License as published by
3640- * the Free Software Foundation; version 3.
3641- *
3642- * This program is distributed in the hope that it will be useful,
3643- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3644- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3645- * GNU General Public License for more details.
3646- *
3647- * You should have received a copy of the GNU General Public License
3648- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3649- */
3650-
3651-#ifndef RATINGFILTEROPTION_H
3652-#define RATINGFILTEROPTION_H
3653-
3654-// local
3655-#include "abstractfilteroption.h"
3656-
3657-class Q_DECL_EXPORT RatingFilterOption : public AbstractFilterOption
3658-{
3659- Q_OBJECT
3660-
3661- Q_PROPERTY(float value READ value CONSTANT)
3662-
3663-public:
3664- explicit RatingFilterOption(const QString &id, float ratingValue, QObject *parent = nullptr);
3665-
3666- /* getters */
3667- QString id() const override;
3668- QString name() const override;
3669- QString iconHint() const override;
3670- bool active() const override;
3671- float value() const;
3672-
3673- /* setters */
3674- void setActive(bool active) override;
3675-
3676-private:
3677- bool m_active;
3678- QString m_id;
3679- float m_value;
3680-};
3681-
3682-Q_DECLARE_METATYPE(RatingFilterOption*)
3683-
3684-#endif // RATINGFILTEROPTION_H
3685
3686=== removed file 'src/Unity/ratingoptionsmodel.cpp'
3687--- src/Unity/ratingoptionsmodel.cpp 2013-11-08 17:01:37 +0000
3688+++ src/Unity/ratingoptionsmodel.cpp 1970-01-01 00:00:00 +0000
3689@@ -1,33 +0,0 @@
3690-/*
3691- * Copyright (C) 2013 Canonical, Ltd.
3692- *
3693- * Authors:
3694- * Pawel Stolowski <pawel.stolowski@canonical.com>
3695- *
3696- * This program is free software; you can redistribute it and/or modify
3697- * it under the terms of the GNU General Public License as published by
3698- * the Free Software Foundation; version 3.
3699- *
3700- * This program is distributed in the hope that it will be useful,
3701- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3702- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3703- * GNU General Public License for more details.
3704- *
3705- * You should have received a copy of the GNU General Public License
3706- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3707- */
3708-
3709-// self
3710-#include "ratingoptionsmodel.h"
3711-
3712-// local
3713-#include "ratingfilteroption.h"
3714-
3715-RatingOptionsModel::RatingOptionsModel(bool showAllOption, QObject *parent) :
3716- GenericOptionsModel(showAllOption, parent)
3717-{
3718- for (int i=1; i<=5; i++) {
3719- auto opt = new RatingFilterOption(QString::number(i), i*0.2f, this);
3720- addOption(opt);
3721- }
3722-}
3723
3724=== removed file 'src/Unity/ratingoptionsmodel.h'
3725--- src/Unity/ratingoptionsmodel.h 2013-11-08 17:01:37 +0000
3726+++ src/Unity/ratingoptionsmodel.h 1970-01-01 00:00:00 +0000
3727@@ -1,33 +0,0 @@
3728-/*
3729- * Copyright (C) 2013 Canonical, Ltd.
3730- *
3731- * Authors:
3732- * Pawel Stolowski <pawel.stolowski@canonical.com>
3733- *
3734- * This program is free software; you can redistribute it and/or modify
3735- * it under the terms of the GNU General Public License as published by
3736- * the Free Software Foundation; version 3.
3737- *
3738- * This program is distributed in the hope that it will be useful,
3739- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3740- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3741- * GNU General Public License for more details.
3742- *
3743- * You should have received a copy of the GNU General Public License
3744- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3745- */
3746-
3747-#ifndef RATINGOPTIONSMODEL_H
3748-#define RATINGOPTIONSMODEL_H
3749-
3750-#include "genericoptionsmodel.h"
3751-
3752-class RatingOptionsModel : public GenericOptionsModel
3753-{
3754- Q_OBJECT
3755-
3756-public:
3757- RatingOptionsModel(bool showAllOption, QObject *parent);
3758-};
3759-
3760-#endif // RATINGOPTIONSMODEL_H
3761
3762=== removed file 'src/Unity/ratingsfilter.cpp'
3763--- src/Unity/ratingsfilter.cpp 2013-11-08 17:01:37 +0000
3764+++ src/Unity/ratingsfilter.cpp 1970-01-01 00:00:00 +0000
3765@@ -1,73 +0,0 @@
3766-/*
3767- * Copyright (C) 2011, 2013 Canonical, Ltd.
3768- *
3769- * Authors:
3770- * Florian Boucault <florian.boucault@canonical.com>
3771- * Pawel Stolowski <pawel.stolowski@canonical.com>
3772- *
3773- * This program is free software; you can redistribute it and/or modify
3774- * it under the terms of the GNU General Public License as published by
3775- * the Free Software Foundation; version 3.
3776- *
3777- * This program is distributed in the hope that it will be useful,
3778- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3779- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3780- * GNU General Public License for more details.
3781- *
3782- * You should have received a copy of the GNU General Public License
3783- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3784- */
3785-
3786-// Self
3787-#include "ratingsfilter.h"
3788-
3789-// local
3790-#include "ratingfilteroption.h"
3791-#include "ratingoptionsmodel.h"
3792-
3793-RatingsFilter::RatingsFilter(QObject *parent) :
3794- Filter(parent),
3795- m_unityRatingsFilter(nullptr),
3796- m_options(nullptr)
3797-{
3798-}
3799-
3800-GenericOptionsModel* RatingsFilter::options() const
3801-{
3802- return m_options;
3803-}
3804-
3805-float RatingsFilter::rating() const
3806-{
3807- if (m_unityRatingsFilter)
3808- {
3809- return m_unityRatingsFilter->rating;
3810- }
3811- return 0.0f;
3812-}
3813-
3814-void RatingsFilter::setUnityFilter(unity::dash::Filter::Ptr filter)
3815-{
3816- Filter::setUnityFilter(filter);
3817- m_unityRatingsFilter = std::dynamic_pointer_cast<unity::dash::RatingsFilter>(m_unityFilter);
3818-
3819- delete m_options;
3820-
3821- m_options = new RatingOptionsModel(m_unityRatingsFilter->show_all_button, this);
3822- connect(m_options, SIGNAL(activeChanged(AbstractFilterOption *)), m_options, SLOT(ensureTheOnlyActive(AbstractFilterOption *)));
3823- connect(m_options, SIGNAL(activeChanged(AbstractFilterOption *)), this, SLOT(onActiveChanged(AbstractFilterOption *)));
3824- connect(m_options, SIGNAL(showAllActivated()), this, SLOT(clear()));
3825-
3826- Q_EMIT optionsChanged();
3827-}
3828-
3829-void RatingsFilter::onActiveChanged(AbstractFilterOption *option)
3830-{
3831- RatingFilterOption *ratingOption = dynamic_cast<RatingFilterOption*>(option);
3832- if (ratingOption != nullptr)
3833- {
3834- const float val = ratingOption->active() ? ratingOption->value() : 0.0f;
3835- m_unityRatingsFilter->rating = val;
3836- Q_EMIT ratingChanged(val);
3837- }
3838-}
3839
3840=== removed file 'src/Unity/ratingsfilter.h'
3841--- src/Unity/ratingsfilter.h 2013-11-08 17:01:37 +0000
3842+++ src/Unity/ratingsfilter.h 1970-01-01 00:00:00 +0000
3843@@ -1,66 +0,0 @@
3844-/*
3845- * Copyright (C) 2011, 2013 Canonical, Ltd.
3846- *
3847- * Authors:
3848- * Florian Boucault <florian.boucault@canonical.com>
3849- * Pawel Stolowski <pawel.stolowski@canonical.com>
3850- *
3851- * This program is free software; you can redistribute it and/or modify
3852- * it under the terms of the GNU General Public License as published by
3853- * the Free Software Foundation; version 3.
3854- *
3855- * This program is distributed in the hope that it will be useful,
3856- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3857- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3858- * GNU General Public License for more details.
3859- *
3860- * You should have received a copy of the GNU General Public License
3861- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3862- */
3863-
3864-#ifndef RATINGSFILTER_H
3865-#define RATINGSFILTER_H
3866-
3867-// Qt
3868-#include <QObject>
3869-#include <QMetaType>
3870-
3871-// libunity-core
3872-#include <UnityCore/RatingsFilter.h>
3873-
3874-// Local
3875-#include "filter.h"
3876-
3877-class GenericOptionsModel;
3878-class AbstractFilterOption;
3879-
3880-class Q_DECL_EXPORT RatingsFilter : public Filter
3881-{
3882- Q_OBJECT
3883-
3884- Q_PROPERTY(float rating READ rating NOTIFY ratingChanged)
3885-
3886-public:
3887- explicit RatingsFilter(QObject *parent = nullptr);
3888-
3889- /* getters */
3890- GenericOptionsModel* options() const override;
3891- float rating() const;
3892-
3893-Q_SIGNALS:
3894- void ratingChanged(float);
3895-
3896-protected:
3897- void setUnityFilter(unity::dash::Filter::Ptr filter) override;
3898-
3899-protected Q_SLOTS:
3900- void onActiveChanged(AbstractFilterOption *option);
3901-
3902-private:
3903- unity::dash::RatingsFilter::Ptr m_unityRatingsFilter;
3904- GenericOptionsModel *m_options;
3905-};
3906-
3907-Q_DECLARE_METATYPE(RatingsFilter*)
3908-
3909-#endif // RATINGSFILTER_H
3910
3911=== removed file 'src/Unity/result.cpp'
3912--- src/Unity/result.cpp 2013-11-08 17:01:37 +0000
3913+++ src/Unity/result.cpp 1970-01-01 00:00:00 +0000
3914@@ -1,82 +0,0 @@
3915-/*
3916- * Copyright (C) 2013 Canonical, Ltd.
3917- *
3918- * Authors:
3919- * Pawel Stolowski <pawel.stolowski@canonical.com>
3920- *
3921- * This program is free software; you can redistribute it and/or modify
3922- * it under the terms of the GNU General Public License as published by
3923- * the Free Software Foundation; version 3.
3924- *
3925- * This program is distributed in the hope that it will be useful,
3926- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3927- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3928- * GNU General Public License for more details.
3929- *
3930- * You should have received a copy of the GNU General Public License
3931- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3932- */
3933-
3934-#include "result.h"
3935-#include "variantutils.h"
3936-
3937-Result::Result(QObject *parent) :
3938- QObject(parent)
3939-{
3940-}
3941-
3942-Result::Result(unity::dash::Preview::Ptr preview, QObject *parent) :
3943- QObject(parent),
3944- m_preview(preview)
3945-{
3946-}
3947-
3948-void Result::setPreview(unity::dash::Preview::Ptr preview)
3949-{
3950- m_preview = preview;
3951-}
3952-
3953-QString Result::uri() const
3954-{
3955- return m_preview != nullptr ? QString::fromStdString(m_preview->preview_result.uri) : QString::null;
3956-}
3957-
3958-QString Result::iconHint() const
3959-{
3960- return m_preview != nullptr ? QString::fromStdString(m_preview->preview_result.icon_hint) : QString::null;
3961-}
3962-
3963-unsigned Result::categoryIndex() const
3964-{
3965- return m_preview != nullptr ? m_preview->preview_result.category_index : 0;
3966-}
3967-
3968-unsigned Result::resultType() const
3969-{
3970- return m_preview != nullptr ? m_preview->preview_result.result_type : 0;
3971-}
3972-
3973-QString Result::mimeType() const
3974-{
3975- return m_preview != nullptr ? QString::fromStdString(m_preview->preview_result.mimetype) : QString::null;
3976-}
3977-
3978-QString Result::title() const
3979-{
3980- return m_preview != nullptr ? QString::fromStdString(m_preview->preview_result.name) : QString::null;
3981-}
3982-
3983-QString Result::comment() const
3984-{
3985- return m_preview != nullptr ? QString::fromStdString(m_preview->preview_result.comment) : QString::null;
3986-}
3987-
3988-QString Result::dndUri() const
3989-{
3990- return m_preview != nullptr ? QString::fromStdString(m_preview->preview_result.dnd_uri) : QString::null;
3991-}
3992-
3993-QVariant Result::metadata() const
3994-{
3995- return m_preview != nullptr ? convertToQVariantHash(m_preview->preview_result.hints) : QVariant();
3996-}
3997
3998=== removed file 'src/Unity/result.h'
3999--- src/Unity/result.h 2014-01-22 17:58:23 +0000
4000+++ src/Unity/result.h 1970-01-01 00:00:00 +0000
4001@@ -1,69 +0,0 @@
4002-/*
4003- * Copyright (C) 2013 Canonical, Ltd.
4004- *
4005- * Authors:
4006- * Pawel Stolowski <pawel.stolowski@canonical.com>
4007- *
4008- * This program is free software; you can redistribute it and/or modify
4009- * it under the terms of the GNU General Public License as published by
4010- * the Free Software Foundation; version 3.
4011- *
4012- * This program is distributed in the hope that it will be useful,
4013- * but WITHOUT ANY WARRANTY; without even the implied warranty of
4014- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4015- * GNU General Public License for more details.
4016- *
4017- * You should have received a copy of the GNU General Public License
4018- * along with this program. If not, see <http://www.gnu.org/licenses/>.
4019- */
4020-
4021-#ifndef RESULT_H
4022-#define RESULT_H
4023-
4024-// Qt
4025-#include <QObject>
4026-#include <QVariant>
4027-
4028-// libunity-core
4029-#include <UnityCore/Preview.h>
4030-
4031-class Q_DECL_EXPORT Result : public QObject
4032-{
4033- Q_OBJECT
4034-
4035- Q_PROPERTY(QString uri READ uri CONSTANT)
4036- Q_PROPERTY(QString iconHint READ iconHint CONSTANT)
4037- Q_PROPERTY(unsigned categoryIndex READ categoryIndex CONSTANT)
4038- Q_PROPERTY(unsigned resultType READ resultType CONSTANT)
4039- Q_PROPERTY(QString mimeType READ mimeType CONSTANT)
4040- Q_PROPERTY(QString title READ title CONSTANT)
4041- Q_PROPERTY(QString comment READ comment CONSTANT)
4042- Q_PROPERTY(QString dndUri READ dndUri CONSTANT)
4043- Q_PROPERTY(QVariant metadata READ metadata CONSTANT)
4044-
4045-public:
4046- Result(QObject *parent = nullptr);
4047- Result(unity::dash::Preview::Ptr preview, QObject *parent = nullptr);
4048-
4049- void setPreview(unity::dash::Preview::Ptr preview);
4050-
4051- QString uri() const;
4052- QString iconHint() const;
4053- unsigned categoryIndex() const;
4054- unsigned resultType() const;
4055- QString mimeType() const;
4056- QString title() const;
4057- QString comment() const;
4058- QString dndUri() const;
4059- QVariant metadata() const;
4060-
4061-private:
4062- /* Keep reference to the original preview to access result attributes via it, rather than keeping copies of them;
4063- this will save us a bit on copying, especially as UI is mostly interested in just uri.
4064- */
4065- unity::dash::Preview::Ptr m_preview;
4066-};
4067-
4068-Q_DECLARE_METATYPE(Result*)
4069-
4070-#endif
4071
4072=== renamed file 'src/Unity/scopes-ng/resultsmodel.cpp' => 'src/Unity/resultsmodel.cpp'
4073--- src/Unity/scopes-ng/resultsmodel.cpp 2014-02-18 21:21:49 +0000
4074+++ src/Unity/resultsmodel.cpp 2014-03-25 16:56:23 +0000
4075@@ -22,7 +22,7 @@
4076
4077 // local
4078 #include "utils.h"
4079-#include "../iconutils.h"
4080+#include "iconutils.h"
4081
4082 namespace scopes_ng {
4083
4084@@ -177,24 +177,12 @@
4085 if (image.isEmpty()) {
4086 QString uri(QString::fromStdString(result->uri()));
4087 // FIXME: figure out a better way and get rid of this, it's an awful hack
4088- QString mimetype;
4089 QVariantHash result_meta;
4090- if (result->contains("mimetype")) {
4091- mimetype = scopeVariantToQVariant(result->value("mimetype")).toString();
4092- // if we have mimetype, we might have some more
4093- QVariantHash album_meta;
4094- if (result->contains("artist")) {
4095- album_meta["artist"] = scopeVariantToQVariant(result->value("artist"));
4096- }
4097- if (result->contains("album")) {
4098- album_meta["album"] = scopeVariantToQVariant(result->value("album"));
4099- }
4100- // nest the data, so we're compatible with the way old scopes did this
4101- if (album_meta.size() > 0) {
4102- result_meta["content"] = album_meta;
4103- }
4104+ if (result->contains("artist") && result->contains("album")) {
4105+ result_meta["artist"] = scopeVariantToQVariant(result->value("artist"));
4106+ result_meta["album"] = scopeVariantToQVariant(result->value("album"));
4107 }
4108- QString thumbnailerUri(uriToThumbnailerProviderString(uri, mimetype, result_meta));
4109+ QString thumbnailerUri(uriToThumbnailerProviderString(uri, result_meta));
4110 if (!thumbnailerUri.isNull()) {
4111 return thumbnailerUri;
4112 }
4113
4114=== renamed file 'src/Unity/scopes-ng/resultsmodel.h' => 'src/Unity/resultsmodel.h'
4115=== removed file 'src/Unity/scope.cpp'
4116--- src/Unity/scope.cpp 2014-02-07 18:41:00 +0000
4117+++ src/Unity/scope.cpp 1970-01-01 00:00:00 +0000
4118@@ -1,408 +0,0 @@
4119-/*
4120- * Copyright (C) 2011 Canonical, Ltd.
4121- *
4122- * Authors:
4123- * Florian Boucault <florian.boucault@canonical.com>
4124- * Michal Hruby <michal.hruby@canonical.com>
4125- *
4126- * This program is free software; you can redistribute it and/or modify
4127- * it under the terms of the GNU General Public License as published by
4128- * the Free Software Foundation; version 3.
4129- *
4130- * This program is distributed in the hope that it will be useful,
4131- * but WITHOUT ANY WARRANTY; without even the implied warranty of
4132- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4133- * GNU General Public License for more details.
4134- *
4135- * You should have received a copy of the GNU General Public License
4136- * along with this program. If not, see <http://www.gnu.org/licenses/>.
4137- */
4138-
4139-// Self
4140-#include "scope.h"
4141-
4142-// local
4143-#include "categories.h"
4144-#include "preview.h"
4145-#include "variantutils.h"
4146-
4147-// Qt
4148-#include <QUrl>
4149-#include <QUrlQuery>
4150-#include <QDebug>
4151-#include <QtGui/QDesktopServices>
4152-#include <QQmlEngine>
4153-#include <QFileInfo>
4154-#include <QDir>
4155-
4156-#include <UnityCore/Variant.h>
4157-#include <UnityCore/GLibWrapper.h>
4158-
4159-#include <libintl.h>
4160-#include <glib.h>
4161-
4162-Scope::Scope(QObject *parent) : QObject(parent)
4163- , m_formFactor("phone")
4164- , m_isActive(false)
4165- , m_searchInProgress(false)
4166-{
4167- m_categories.reset(new Categories(this));
4168-
4169- connect(this, &Scope::isActiveChanged, this, &Scope::scopeIsActiveChanged);
4170-}
4171-
4172-QString Scope::id() const
4173-{
4174- return QString::fromStdString(m_unityScope->id());
4175-}
4176-
4177-QString Scope::name() const
4178-{
4179- return QString::fromStdString(m_unityScope->name());
4180-}
4181-
4182-QString Scope::iconHint() const
4183-{
4184- return QString::fromStdString(m_unityScope->icon_hint());
4185-}
4186-
4187-QString Scope::description() const
4188-{
4189- return QString::fromStdString(m_unityScope->description());
4190-}
4191-
4192-QString Scope::searchHint() const
4193-{
4194- return QString::fromStdString(m_unityScope->search_hint());
4195-}
4196-
4197-bool Scope::searchInProgress() const
4198-{
4199- return m_searchInProgress;
4200-}
4201-
4202-bool Scope::visible() const
4203-{
4204- return m_unityScope->visible();
4205-}
4206-
4207-QString Scope::shortcut() const
4208-{
4209- return QString::fromStdString(m_unityScope->shortcut());
4210-}
4211-
4212-bool Scope::connected() const
4213-{
4214- return m_unityScope->connected();
4215-}
4216-
4217-Categories* Scope::categories() const
4218-{
4219- return m_categories.get();
4220-}
4221-
4222-QString Scope::searchQuery() const
4223-{
4224- return m_searchQuery;
4225-}
4226-
4227-QString Scope::noResultsHint() const
4228-{
4229- return m_noResultsHint;
4230-}
4231-
4232-QString Scope::formFactor() const
4233-{
4234- return m_formFactor;
4235-}
4236-
4237-bool Scope::isActive() const
4238-{
4239- return m_isActive;
4240-}
4241-
4242-Filters* Scope::filters() const
4243-{
4244- return m_filters.get();
4245-}
4246-
4247-void Scope::setSearchQuery(const QString& search_query)
4248-{
4249- /* Checking for m_searchQuery.isNull() which returns true only when the string
4250- has never been set is necessary because when search_query is the empty
4251- string ("") and m_searchQuery is the null string,
4252- search_query != m_searchQuery is still true.
4253- */
4254- using namespace std::placeholders;
4255-
4256- if (m_searchQuery.isNull() || search_query != m_searchQuery) {
4257- m_searchQuery = search_query;
4258- m_cancellable.Renew();
4259- m_unityScope->Search(search_query.toStdString(), std::bind(&Scope::onSearchFinished, this, _1, _2, _3), m_cancellable);
4260- Q_EMIT searchQueryChanged();
4261- if (!m_searchInProgress) {
4262- m_searchInProgress = true;
4263- Q_EMIT searchInProgressChanged();
4264- }
4265- }
4266-}
4267-
4268-void Scope::setNoResultsHint(const QString& hint) {
4269- if (hint != m_noResultsHint) {
4270- m_noResultsHint = hint;
4271- Q_EMIT noResultsHintChanged();
4272- }
4273-}
4274-
4275-void Scope::setFormFactor(const QString& form_factor) {
4276- if (form_factor != m_formFactor) {
4277- m_formFactor = form_factor;
4278- if (m_unityScope) {
4279- m_unityScope->form_factor = m_formFactor.toStdString();
4280- synchronizeStates(); // will trigger a re-search
4281- }
4282- Q_EMIT formFactorChanged();
4283- }
4284-}
4285-
4286-void Scope::setActive(const bool active) {
4287- if (active != m_isActive) {
4288- m_isActive = active;
4289- Q_EMIT isActiveChanged(m_isActive);
4290- }
4291-}
4292-
4293-unity::dash::LocalResult Scope::createLocalResult(const QVariant &uri, const QVariant &icon_hint,
4294- const QVariant &category, const QVariant &result_type,
4295- const QVariant &mimetype, const QVariant &title,
4296- const QVariant &comment, const QVariant &dnd_uri,
4297- const QVariant &metadata)
4298-{
4299- unity::dash::LocalResult res;
4300- res.uri = uri.toString().toStdString();
4301- res.icon_hint = icon_hint.toString().toStdString();
4302- res.category_index = category.toUInt();
4303- res.result_type = result_type.toUInt();
4304- res.mimetype = mimetype.toString().toStdString();
4305- res.name = title.toString().toStdString();
4306- res.comment = comment.toString().toStdString();
4307- res.dnd_uri = dnd_uri.toString().toStdString();
4308- res.hints = convertToHintsMap(metadata);
4309-
4310- return res;
4311-}
4312-
4313-// FIXME: Change to use row index.
4314-void Scope::activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
4315- const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
4316- const QVariant &comment, const QVariant &dnd_uri, const QVariant &metadata)
4317-{
4318- auto res = createLocalResult(uri, icon_hint, category, result_type, mimetype, title, comment, dnd_uri, metadata);
4319- m_unityScope->Activate(res);
4320-}
4321-
4322-// FIXME: Change to use row index.
4323-void Scope::preview(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
4324- const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
4325- const QVariant &comment, const QVariant &dnd_uri, const QVariant &metadata)
4326-{
4327- QVariant real_metadata(metadata);
4328- // handle overridden results, since QML doesn't support defining maps
4329- if (metadata.type() == QVariant::String) {
4330- real_metadata = QVariant::fromValue(subscopeUriToMetadataHash(metadata.toString()));
4331- }
4332-
4333- auto res = createLocalResult(uri, icon_hint, category, result_type, mimetype, title, comment, dnd_uri, real_metadata);
4334- m_previewCancellable.Renew();
4335-
4336- // canned queries don't have previews, must be activated
4337- if (uri.toString().startsWith("x-unity-no-preview-scopes-query://")) {
4338- m_unityScope->Activate(res);
4339- } else {
4340- m_unityScope->Preview(res, nullptr, m_previewCancellable);
4341- }
4342-}
4343-
4344-void Scope::cancelActivation()
4345-{
4346- m_previewCancellable.Cancel();
4347-}
4348-
4349-void Scope::onActivated(unity::dash::LocalResult const& result, unity::dash::ScopeHandledType type, unity::glib::HintsMap const& hints)
4350-{
4351- Q_EMIT activated();
4352- // note: we will not get called on SHOW_PREVIEW, instead UnityCore will signal preview_ready.
4353- switch (type)
4354- {
4355- case unity::dash::NOT_HANDLED:
4356- fallbackActivate(QString::fromStdString(result.uri));
4357- break;
4358- case unity::dash::SHOW_DASH:
4359- Q_EMIT showDash();
4360- break;
4361- case unity::dash::HIDE_DASH:
4362- Q_EMIT hideDash();
4363- break;
4364- case unity::dash::GOTO_DASH_URI:
4365- if (hints.find("goto-uri") != hints.end()) {
4366- Q_EMIT gotoUri(QString::fromStdString(g_variant_get_string(hints.at("goto-uri"), nullptr)));
4367- } else {
4368- qWarning() << "Missing goto-uri hint for GOTO_DASH_URI activation reply";
4369- }
4370- break;
4371- case unity::dash::PERFORM_SEARCH:
4372- if (hints.find("query") != hints.end()) {
4373- // note: this will emit searchQueryChanged, and shell will call setSearchQuery back with a new query,
4374- // but it will get ignored.
4375- setSearchQuery(QString::fromStdString(g_variant_get_string(hints.at("query"), nullptr)));
4376- }
4377- break;
4378- default:
4379- qWarning() << "Unhandled activation response:" << type;
4380- }
4381-}
4382-
4383-void Scope::onPreviewReady(unity::dash::LocalResult const& /* result */, unity::dash::Preview::Ptr const& preview)
4384-{
4385- Q_EMIT activated();
4386- auto prv = Preview::newFromUnityPreview(preview);
4387- // is this the best solution? QML may need to keep more than one preview instance around, so we can't own it.
4388- // passing it by value is not possible.
4389- QQmlEngine::setObjectOwnership(prv, QQmlEngine::JavaScriptOwnership);
4390- Q_EMIT previewReady(prv);
4391-}
4392-
4393-void Scope::fallbackActivate(const QString& uri)
4394-{
4395- /* Tries various methods to trigger a sensible action for the given 'uri'.
4396- If it has no understanding of the given scheme it falls back on asking
4397- Qt to open the uri.
4398- */
4399- QUrl url(uri);
4400- if (url.scheme() == "file") {
4401- /* Override the files place's default URI handler: we want the file
4402- manager to handle opening folders, not the dash.
4403-
4404- Ref: https://bugs.launchpad.net/upicek/+bug/689667
4405- */
4406- QDesktopServices::openUrl(url);
4407- return;
4408- }
4409- if (url.scheme() == "application") {
4410- QString path(url.path().isEmpty() ? url.authority() : url.path());
4411- if (path.startsWith('/')) {
4412- Q_FOREACH(const QString &dir, QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation)) {
4413- if (path.startsWith(dir)) {
4414- path.remove(dir);
4415- path.replace('/', '-');
4416- break;
4417- }
4418- }
4419- }
4420-
4421- Q_EMIT activateApplication(QFileInfo(path).completeBaseName());
4422- return;
4423- }
4424-
4425- qDebug() << "Trying to open" << uri;
4426-
4427- /* Try our luck */
4428- QDesktopServices::openUrl(uri); //url?
4429-}
4430-
4431-void Scope::setUnityScope(const unity::dash::Scope::Ptr& scope)
4432-{
4433- m_unityScope = scope;
4434-
4435- m_categories->setUnityScope(m_unityScope);
4436- m_filters.reset(new Filters(m_unityScope->filters, this));
4437-
4438- m_unityScope->form_factor = m_formFactor.toStdString();
4439- /* Property change signals */
4440- m_unityScope->id.changed.connect(sigc::mem_fun(this, &Scope::idChanged));
4441- m_unityScope->name.changed.connect(sigc::mem_fun(this, &Scope::nameChanged));
4442- m_unityScope->icon_hint.changed.connect(sigc::mem_fun(this, &Scope::iconHintChanged));
4443- m_unityScope->description.changed.connect(sigc::mem_fun(this, &Scope::descriptionChanged));
4444- m_unityScope->search_hint.changed.connect(sigc::mem_fun(this, &Scope::searchHintChanged));
4445- m_unityScope->visible.changed.connect(sigc::mem_fun(this, &Scope::visibleChanged));
4446- m_unityScope->shortcut.changed.connect(sigc::mem_fun(this, &Scope::shortcutChanged));
4447- m_unityScope->connected.changed.connect(sigc::mem_fun(this, &Scope::connectedChanged));
4448- m_unityScope->results_dirty.changed.connect(sigc::mem_fun(this, &Scope::resultsDirtyToggled));
4449-
4450- /* FIXME: signal should be forwarded instead of calling the handler directly */
4451- m_unityScope->activated.connect(sigc::mem_fun(this, &Scope::onActivated));
4452-
4453- m_unityScope->preview_ready.connect(sigc::mem_fun(this, &Scope::onPreviewReady));
4454-
4455- /* Synchronize local states with m_unityScope right now and whenever
4456- m_unityScope becomes connected */
4457- /* FIXME: should emit change notification signals for all properties */
4458- connect(this, SIGNAL(connectedChanged(bool)), SLOT(synchronizeStates()));
4459- synchronizeStates();
4460-}
4461-
4462-unity::dash::Scope::Ptr Scope::unityScope() const
4463-{
4464- return m_unityScope;
4465-}
4466-
4467-void Scope::synchronizeStates()
4468-{
4469- using namespace std::placeholders;
4470-
4471- if (connected()) {
4472- /* Forward local states to m_unityScope */
4473- if (!m_searchQuery.isNull()) {
4474- m_cancellable.Renew();
4475- m_unityScope->Search(m_searchQuery.toStdString(), std::bind(&Scope::onSearchFinished, this, _1, _2, _3), m_cancellable);
4476- if (!m_searchInProgress) {
4477- m_searchInProgress = true;
4478- Q_EMIT searchInProgressChanged();
4479- }
4480- }
4481- }
4482-}
4483-
4484-void Scope::scopeIsActiveChanged()
4485-{
4486- if (!isActive() || !m_unityScope || !m_unityScope->results_dirty()) return;
4487-
4488- // force new search
4489- synchronizeStates();
4490-}
4491-
4492-void Scope::resultsDirtyToggled(bool results_dirty)
4493-{
4494- if (!results_dirty || !isActive()) return;
4495-
4496- // force new search
4497- synchronizeStates();
4498-}
4499-
4500-void Scope::onSearchFinished(std::string const& /* query */, unity::glib::HintsMap const& hints, unity::glib::Error const& err)
4501-{
4502- QString hint;
4503-
4504- GError* error = const_cast<unity::glib::Error&>(err);
4505-
4506- if (!err || !g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
4507- if (m_searchInProgress) {
4508- m_searchInProgress = false;
4509- Q_EMIT searchInProgressChanged();
4510- }
4511- } else {
4512- // no need to check the results hint, we're still searching
4513- return;
4514- }
4515-
4516- if (!m_unityScope->results()->count()) {
4517- unity::glib::HintsMap::const_iterator it = hints.find("no-results-hint");
4518- if (it != hints.end()) {
4519- hint = QString::fromStdString(it->second.GetString());
4520- } else {
4521- hint = QString::fromUtf8(dgettext("unity", "Sorry, there is nothing that matches your search."));
4522- }
4523- }
4524-
4525- setNoResultsHint(hint);
4526-}
4527
4528=== renamed file 'src/Unity/scopes-ng/scope.cpp' => 'src/Unity/scope.cpp'
4529--- src/Unity/scopes-ng/scope.cpp 2014-03-06 18:41:48 +0000
4530+++ src/Unity/scope.cpp 2014-03-25 16:56:23 +0000
4531@@ -43,7 +43,6 @@
4532 #include <QDir>
4533
4534 #include <libintl.h>
4535-#include <glib.h>
4536
4537 #include <unity/scopes/ListenerBase.h>
4538 #include <unity/scopes/CategorisedResult.h>
4539
4540=== removed file 'src/Unity/scope.h'
4541--- src/Unity/scope.h 2013-11-28 17:33:23 +0000
4542+++ src/Unity/scope.h 1970-01-01 00:00:00 +0000
4543@@ -1,154 +0,0 @@
4544-/*
4545- * Copyright (C) 2011 Canonical, Ltd.
4546- *
4547- * Authors:
4548- * Florian Boucault <florian.boucault@canonical.com>
4549- *
4550- * This program is free software; you can redistribute it and/or modify
4551- * it under the terms of the GNU General Public License as published by
4552- * the Free Software Foundation; version 3.
4553- *
4554- * This program is distributed in the hope that it will be useful,
4555- * but WITHOUT ANY WARRANTY; without even the implied warranty of
4556- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4557- * GNU General Public License for more details.
4558- *
4559- * You should have received a copy of the GNU General Public License
4560- * along with this program. If not, see <http://www.gnu.org/licenses/>.
4561- */
4562-
4563-#ifndef SCOPE_H
4564-#define SCOPE_H
4565-
4566-// Qt
4567-#include <QObject>
4568-#include <QString>
4569-#include <QMetaType>
4570-
4571-// libunity-core
4572-#include <UnityCore/Scope.h>
4573-#include <UnityCore/Results.h>
4574-#include <UnityCore/GLibWrapper.h>
4575-
4576-#include "categories.h"
4577-#include "filters.h"
4578-
4579-class Preview;
4580-
4581-class Scope : public QObject
4582-{
4583- Q_OBJECT
4584-
4585- Q_PROPERTY(QString id READ id NOTIFY idChanged)
4586- Q_PROPERTY(QString name READ name NOTIFY nameChanged)
4587- Q_PROPERTY(QString iconHint READ iconHint NOTIFY iconHintChanged)
4588- Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
4589- Q_PROPERTY(QString searchHint READ searchHint NOTIFY searchHintChanged)
4590- Q_PROPERTY(bool searchInProgress READ searchInProgress NOTIFY searchInProgressChanged)
4591- Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged)
4592- Q_PROPERTY(QString shortcut READ shortcut NOTIFY shortcutChanged)
4593- Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)
4594- Q_PROPERTY(Categories* categories READ categories NOTIFY categoriesChanged)
4595- Q_PROPERTY(Filters* filters READ filters NOTIFY filtersChanged)
4596-
4597- Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
4598- Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
4599- Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
4600- Q_PROPERTY(bool isActive READ isActive WRITE setActive NOTIFY isActiveChanged)
4601-
4602-public:
4603- explicit Scope(QObject *parent = 0);
4604-
4605- /* getters */
4606- QString id() const;
4607- QString name() const;
4608- QString iconHint() const;
4609- QString description() const;
4610- QString searchHint() const;
4611- bool visible() const;
4612- QString shortcut() const;
4613- bool connected() const;
4614- bool searchInProgress() const;
4615- Categories* categories() const;
4616- Filters* filters() const;
4617- QString searchQuery() const;
4618- QString noResultsHint() const;
4619- QString formFactor() const;
4620- bool isActive() const;
4621-
4622- /* setters */
4623- void setSearchQuery(const QString& search_query);
4624- void setNoResultsHint(const QString& hint);
4625- void setFormFactor(const QString& form_factor);
4626- void setActive(const bool);
4627-
4628- Q_INVOKABLE void activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
4629- const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
4630- const QVariant &comment, const QVariant &dnd_uri, const QVariant &metadata);
4631- Q_INVOKABLE void preview(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
4632- const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
4633- const QVariant &comment, const QVariant &dnd_uri, const QVariant &metadata);
4634- Q_INVOKABLE void cancelActivation();
4635-
4636- void setUnityScope(const unity::dash::Scope::Ptr& scope);
4637- unity::dash::Scope::Ptr unityScope() const;
4638-
4639-Q_SIGNALS:
4640- void idChanged(const std::string&);
4641- void dbusNameChanged(const std::string&);
4642- void dbusPathChanged(const std::string&);
4643- void nameChanged(const std::string&);
4644- void iconHintChanged(const std::string&);
4645- void descriptionChanged(const std::string&);
4646- void searchHintChanged(const std::string&);
4647- void searchInProgressChanged();
4648- void visibleChanged(bool);
4649- void shortcutChanged(const std::string&);
4650- void connectedChanged(bool);
4651- void categoriesChanged();
4652- void searchQueryChanged();
4653- void noResultsHintChanged();
4654- void formFactorChanged();
4655- void isActiveChanged(bool);
4656- void filtersChanged();
4657-
4658- // signals triggered by activate(..) or preview(..) requests.
4659- void previewReady(Preview *preview);
4660- void showDash();
4661- void hideDash();
4662- void gotoUri(const QString &uri);
4663- void activated();
4664-
4665- void activateApplication(const QString &desktop);
4666-
4667-private Q_SLOTS:
4668- void synchronizeStates();
4669- void scopeIsActiveChanged();
4670- void onSearchFinished(std::string const &, unity::glib::HintsMap const &, unity::glib::Error const&);
4671-
4672-private:
4673- unity::dash::LocalResult createLocalResult(const QVariant &uri, const QVariant &icon_hint,
4674- const QVariant &category, const QVariant &result_type,
4675- const QVariant &mimetype, const QVariant &title,
4676- const QVariant &comment, const QVariant &dnd_uri,
4677- const QVariant &metadata);
4678- void onActivated(unity::dash::LocalResult const& result, unity::dash::ScopeHandledType type, unity::glib::HintsMap const& hints);
4679- void onPreviewReady(unity::dash::LocalResult const& result, unity::dash::Preview::Ptr const& preview);
4680- void fallbackActivate(const QString& uri);
4681- void resultsDirtyToggled(bool);
4682-
4683- unity::dash::Scope::Ptr m_unityScope;
4684- std::unique_ptr<Categories> m_categories;
4685- std::unique_ptr<Filters> m_filters;
4686- QString m_searchQuery;
4687- QString m_noResultsHint;
4688- QString m_formFactor;
4689- bool m_isActive;
4690- bool m_searchInProgress;
4691- unity::glib::Cancellable m_cancellable;
4692- unity::glib::Cancellable m_previewCancellable;
4693-};
4694-
4695-Q_DECLARE_METATYPE(Scope*)
4696-
4697-#endif // SCOPE_H
4698
4699=== renamed file 'src/Unity/scopes-ng/scope.h' => 'src/Unity/scope.h'
4700=== removed directory 'src/Unity/scopes-ng'
4701=== removed file 'src/Unity/scopes-ng/CMakeLists.txt'
4702--- src/Unity/scopes-ng/CMakeLists.txt 2014-02-19 17:43:25 +0000
4703+++ src/Unity/scopes-ng/CMakeLists.txt 1970-01-01 00:00:00 +0000
4704@@ -1,26 +0,0 @@
4705-# Dependencies
4706-include(FindPkgConfig)
4707-pkg_check_modules(SCOPESLIB REQUIRED libunity-scopes>=0.3.1)
4708-
4709-include_directories(
4710- ${CMAKE_CURRENT_SOURCE_DIR}
4711- ${CMAKE_CURRENT_BINARY_DIR}
4712- ${SCOPESLIB_INCLUDE_DIRS}
4713-)
4714-
4715-set(PLUGIN_SRC
4716- categories.cpp
4717- collectors.cpp
4718- previewmodel.cpp
4719- previewstack.cpp
4720- previewwidgetmodel.cpp
4721- resultsmodel.cpp
4722- scope.cpp
4723- scopes.cpp
4724- utils.cpp
4725-)
4726-
4727-add_library(ScopesNG-qml STATIC ${PLUGIN_SRC})
4728-set_target_properties(ScopesNG-qml PROPERTIES COMPILE_FLAGS "-fPIC")
4729-
4730-qt5_use_modules(ScopesNG-qml Qml Gui DBus)
4731
4732=== renamed file 'src/Unity/scopes-ng/scopes.cpp' => 'src/Unity/scopes.cpp'
4733=== removed file 'src/Unity/scopes.cpp'
4734--- src/Unity/scopes.cpp 2013-11-25 10:38:12 +0000
4735+++ src/Unity/scopes.cpp 1970-01-01 00:00:00 +0000
4736@@ -1,179 +0,0 @@
4737-/*
4738- * Copyright (C) 2011 Canonical, Ltd.
4739- *
4740- * Authors:
4741- * Florian Boucault <florian.boucault@canonical.com>
4742- *
4743- * This program is free software; you can redistribute it and/or modify
4744- * it under the terms of the GNU General Public License as published by
4745- * the Free Software Foundation; version 3.
4746- *
4747- * This program is distributed in the hope that it will be useful,
4748- * but WITHOUT ANY WARRANTY; without even the implied warranty of
4749- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4750- * GNU General Public License for more details.
4751- *
4752- * You should have received a copy of the GNU General Public License
4753- * along with this program. If not, see <http://www.gnu.org/licenses/>.
4754- */
4755-
4756-// Self
4757-#include "scopes.h"
4758-
4759-// Local
4760-#include "scope.h"
4761-
4762-// Qt
4763-#include <QDebug>
4764-#include <QtCore/QStringList>
4765-#include <QtGui/QKeySequence>
4766-
4767-Scopes::Scopes(QObject *parent)
4768- : QAbstractListModel(parent)
4769- , m_unityScopes(std::make_shared<unity::dash::GSettingsScopes>())
4770- , m_loaded(false)
4771-{
4772- m_roles[Scopes::RoleScope] = "scope";
4773- m_roles[Scopes::RoleId] = "id";
4774- m_roles[Scopes::RoleVisible] = "visible";
4775- m_roles[Scopes::RoleTitle] = "title";
4776-
4777- m_unityScopes->scope_added.connect(sigc::mem_fun(this, &Scopes::onScopeAdded));
4778- m_unityScopes->scope_removed.connect(sigc::mem_fun(this, &Scopes::onScopeRemoved));
4779- m_unityScopes->scopes_reordered.connect(sigc::mem_fun(this, &Scopes::onScopesReordered));
4780- m_unityScopes->LoadScopes();
4781-}
4782-
4783-QHash<int, QByteArray> Scopes::roleNames() const
4784-{
4785- return m_roles;
4786-}
4787-
4788-int Scopes::rowCount(const QModelIndex& parent) const
4789-{
4790- Q_UNUSED(parent)
4791-
4792- return m_scopes.count();
4793-}
4794-
4795-QVariant Scopes::data(const QModelIndex& index, int role) const
4796-{
4797- Q_UNUSED(role)
4798-
4799- if (!index.isValid()) {
4800- return QVariant();
4801- }
4802-
4803- Scope* scope = m_scopes.at(index.row());
4804-
4805- if (role == Scopes::RoleScope) {
4806- return QVariant::fromValue(scope);
4807- } else if (role == Scopes::RoleId) {
4808- return QVariant::fromValue(scope->id());
4809- } else if (role == Scopes::RoleVisible) {
4810- return QVariant::fromValue(scope->visible());
4811- } else if (role == Scopes::RoleTitle) {
4812- return QVariant::fromValue(scope->name());
4813- } else {
4814- return QVariant();
4815- }
4816-}
4817-
4818-QVariant Scopes::get(int row) const
4819-{
4820- return data(QAbstractListModel::index(row), 0);
4821-}
4822-
4823-QVariant Scopes::get(const QString& scope_id) const
4824-{
4825- Q_FOREACH(Scope* scope, m_scopes) {
4826- if (scope->id() == scope_id) {
4827- return QVariant::fromValue(scope);
4828- }
4829- }
4830-
4831- return QVariant();
4832-}
4833-
4834-bool Scopes::loaded() const
4835-{
4836- return m_loaded;
4837-}
4838-
4839-void Scopes::onScopeAdded(const unity::dash::Scope::Ptr& scope, int /*position*/)
4840-{
4841- int index = m_scopes.count();
4842- beginInsertRows(QModelIndex(), index, index);
4843- addUnityScope(scope);
4844- endInsertRows();
4845-
4846- // FIXME: do only once after all loaded?
4847- m_loaded = true;
4848- Q_EMIT loadedChanged(m_loaded);
4849-}
4850-
4851-void Scopes::onScopesLoaded()
4852-{
4853-}
4854-
4855-void Scopes::onScopeRemoved(const unity::dash::Scope::Ptr& scope)
4856-{
4857- auto id = QString::fromStdString(scope->id);
4858- auto index = findScopeById(id);
4859- if (index >= 0) {
4860- beginRemoveRows(QModelIndex(), index, index);
4861- removeUnityScope(index);
4862- endRemoveRows();
4863-
4864- Q_EMIT scopeRemoved(id, index);
4865- }
4866-}
4867-
4868-void Scopes::onScopesReordered(const unity::dash::Scopes::ScopeList& scopes)
4869-{
4870- // FIXME Should use beginMoveRows()/endMoveRows() to not recreate the UI for every scope.
4871- beginResetModel();
4872-
4873- // remove existing scopes
4874- for (auto i=m_scopes.count()-1; i>=0; i--) {
4875- removeUnityScope(i);
4876- }
4877-
4878- // re-create scopes
4879- for (uint i=0; i<scopes.size(); i++) {
4880- addUnityScope(scopes[i]);
4881- }
4882- endResetModel();
4883-}
4884-
4885-void Scopes::onScopePropertyChanged()
4886-{
4887- QModelIndex scopeIndex = index(m_scopes.indexOf(qobject_cast<Scope*>(sender())));
4888- Q_EMIT dataChanged(scopeIndex, scopeIndex);
4889-}
4890-
4891-void Scopes::addUnityScope(const unity::dash::Scope::Ptr& unity_scope)
4892-{
4893- Scope* scope = new Scope(this);
4894- scope->setUnityScope(unity_scope);
4895- /* DOCME */
4896- QObject::connect(scope, SIGNAL(visibleChanged(bool)), this, SLOT(onScopePropertyChanged()));
4897- m_scopes.append(scope);
4898-}
4899-
4900-void Scopes::removeUnityScope(int index)
4901-{
4902- Scope* scope = m_scopes.takeAt(index);
4903-
4904- delete scope;
4905-}
4906-
4907-int Scopes::findScopeById(const QString& scope_id)
4908-{
4909- for (int i=0; i<m_scopes.count(); i++) {
4910- if (m_scopes[i]->id() == scope_id) {
4911- return i;
4912- }
4913- }
4914- return -1;
4915-}
4916
4917=== renamed file 'src/Unity/scopes-ng/scopes.h' => 'src/Unity/scopes.h'
4918=== removed file 'src/Unity/scopes.h'
4919--- src/Unity/scopes.h 2013-11-25 10:38:12 +0000
4920+++ src/Unity/scopes.h 1970-01-01 00:00:00 +0000
4921@@ -1,95 +0,0 @@
4922-/*
4923- * Copyright (C) 2011 Canonical, Ltd.
4924- *
4925- * Authors:
4926- * Florian Boucault <florian.boucault@canonical.com>
4927- *
4928- * This program is free software; you can redistribute it and/or modify
4929- * it under the terms of the GNU General Public License as published by
4930- * the Free Software Foundation; version 3.
4931- *
4932- * This program is distributed in the hope that it will be useful,
4933- * but WITHOUT ANY WARRANTY; without even the implied warranty of
4934- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4935- * GNU General Public License for more details.
4936- *
4937- * You should have received a copy of the GNU General Public License
4938- * along with this program. If not, see <http://www.gnu.org/licenses/>.
4939- */
4940-
4941-#ifndef SCOPES_H
4942-#define SCOPES_H
4943-
4944-// Qt
4945-#include <QAbstractListModel>
4946-#include <QList>
4947-
4948-// libunity-core
4949-#include <UnityCore/Scope.h>
4950-#include <UnityCore/GSettingsScopes.h>
4951-
4952-namespace unity
4953-{
4954-namespace dash
4955-{
4956-class Scopes;
4957-}
4958-}
4959-
4960-class Hotkey;
4961-class Scope;
4962-
4963-class Scopes : public QAbstractListModel
4964-{
4965- Q_OBJECT
4966-
4967- Q_ENUMS(Roles)
4968-
4969- Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
4970-
4971-public:
4972- explicit Scopes(QObject *parent = 0);
4973- ~Scopes() = default;
4974-
4975- enum Roles {
4976- RoleScope,
4977- RoleId,
4978- RoleVisible,
4979- RoleTitle
4980- };
4981-
4982- QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
4983- Q_INVOKABLE int rowCount(const QModelIndex& parent = QModelIndex()) const;
4984-
4985- Q_INVOKABLE QVariant get(int row) const;
4986- Q_INVOKABLE QVariant get(const QString& scope_id) const;
4987-
4988- QHash<int, QByteArray> roleNames() const;
4989-
4990- bool loaded() const;
4991-
4992-Q_SIGNALS:
4993- void activateScopeRequested(const QString& scope_id);
4994- void loadedChanged(bool loaded);
4995- void scopeRemoved(const QString& scope_id, int index);
4996-
4997-private Q_SLOTS:
4998- void onScopesLoaded();
4999- void onScopeAdded(const unity::dash::Scope::Ptr& scope, int position);
5000- void onScopeRemoved(const unity::dash::Scope::Ptr& scope);
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: