Merge lp:~fboucault/unity-2d/dash_home_shortcuts_filter into lp:unity-2d

Proposed by Florian Boucault on 2011-08-31
Status: Merged
Approved by: Gerry Boland on 2011-08-31
Approved revision: 681
Merged at revision: 685
Proposed branch: lp:~fboucault/unity-2d/dash_home_shortcuts_filter
Merge into: lp:unity-2d
Diff against target: 152 lines (+52/-7)
7 files modified
libunity-2d-private/src/filters.cpp (+10/-0)
libunity-2d-private/src/filters.h (+2/-0)
libunity-2d-private/src/listmodelwrapper.h (+8/-0)
libunity-2d-private/src/radiooptionfilter.cpp (+10/-0)
libunity-2d-private/src/radiooptionfilter.h (+2/-0)
places/HomeShortcuts.qml (+3/-7)
places/dash.qml (+17/-0)
To merge this branch: bzr merge lp:~fboucault/unity-2d/dash_home_shortcuts_filter
Reviewer Review Type Date Requested Status
Gerry Boland 2011-08-31 Pending
Review via email: mp+73506@code.launchpad.net

Description of the change

[dash] Home buttons 'Media' and 'Internet' apps now also activate the right filter and open up the 'Filter results' pane.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libunity-2d-private/src/filters.cpp'
2--- libunity-2d-private/src/filters.cpp 2011-08-24 08:36:07 +0000
3+++ libunity-2d-private/src/filters.cpp 2011-08-31 10:59:42 +0000
4@@ -76,6 +76,16 @@
5 }
6 }
7
8+Filter* Filters::getFilter(const QString& id) const
9+{
10+ Q_FOREACH (Filter* filter, m_filters) {
11+ if (filter->id() == id) {
12+ return filter;
13+ }
14+ }
15+ return NULL;
16+}
17+
18 void Filters::onFilterAdded(unity::dash::Filter::Ptr unityFilter)
19 {
20 if (unityFilter == NULL) {
21
22=== modified file 'libunity-2d-private/src/filters.h'
23--- libunity-2d-private/src/filters.h 2011-08-19 17:12:24 +0000
24+++ libunity-2d-private/src/filters.h 2011-08-31 10:59:42 +0000
25@@ -48,6 +48,8 @@
26 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
27 int rowCount(const QModelIndex& parent = QModelIndex()) const;
28
29+ Q_INVOKABLE Filter* getFilter(const QString& id) const;
30+
31 private:
32 unity::dash::Filters::Ptr m_unityFilters;
33 QList<Filter*> m_filters;
34
35=== modified file 'libunity-2d-private/src/listmodelwrapper.h'
36--- libunity-2d-private/src/listmodelwrapper.h 2011-08-25 12:41:57 +0000
37+++ libunity-2d-private/src/listmodelwrapper.h 2011-08-31 10:59:42 +0000
38@@ -46,6 +46,8 @@
39 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
40 int rowCount(const QModelIndex& parent = QModelIndex()) const;
41
42+ const QList<WrapperItem*>& rawList() const;
43+
44 private:
45 void onItemAdded(ItemClass item);
46 void onItemRemoved(ItemClass item);
47@@ -95,6 +97,12 @@
48 }
49
50 template <class WrapperItem, class ItemClass>
51+const QList<WrapperItem*>& ListModelWrapper<WrapperItem, ItemClass>::rawList() const
52+{
53+ return m_list;
54+}
55+
56+template <class WrapperItem, class ItemClass>
57 QVariant ListModelWrapper<WrapperItem, ItemClass>::data(const QModelIndex& index, int role) const
58 {
59 if (!index.isValid()) {
60
61=== modified file 'libunity-2d-private/src/radiooptionfilter.cpp'
62--- libunity-2d-private/src/radiooptionfilter.cpp 2011-08-24 12:24:38 +0000
63+++ libunity-2d-private/src/radiooptionfilter.cpp 2011-08-31 10:59:42 +0000
64@@ -30,6 +30,16 @@
65 return m_options;
66 }
67
68+FilterOption* RadioOptionFilter::getOption(const QString& id) const
69+{
70+ Q_FOREACH (FilterOption* option, m_options->rawList()) {
71+ if (option->id() == id) {
72+ return option;
73+ }
74+ }
75+ return NULL;
76+}
77+
78 void RadioOptionFilter::setUnityFilter(unity::dash::Filter::Ptr filter)
79 {
80 Filter::setUnityFilter(filter);
81
82=== modified file 'libunity-2d-private/src/radiooptionfilter.h'
83--- libunity-2d-private/src/radiooptionfilter.h 2011-08-24 12:36:27 +0000
84+++ libunity-2d-private/src/radiooptionfilter.h 2011-08-31 10:59:42 +0000
85@@ -43,6 +43,8 @@
86 /* getters */
87 FilterOptions* options() const;
88
89+ Q_INVOKABLE FilterOption* getOption(const QString& id) const;
90+
91 Q_SIGNALS:
92 void optionsChanged();
93
94
95=== modified file 'places/HomeShortcuts.qml'
96--- places/HomeShortcuts.qml 2011-08-11 16:12:07 +0000
97+++ places/HomeShortcuts.qml 2011-08-31 10:59:42 +0000
98@@ -55,23 +55,19 @@
99 focus: true
100 label: u2d.tr("Media Apps")
101 icon: "artwork/find_media_apps.png"
102- /* FIXME: this should not only activate the applications lens but also
103- activate the types filter. */
104- onClicked: activateLens("applications.lens")
105+ onClicked: activateLensWithOptionFilter("applications.lens", "type", "media")
106 }
107
108 HomeButton {
109 label: u2d.tr("Internet Apps")
110 icon: "artwork/find_internet_apps.png"
111- /* FIXME: this should not only activate the applications lens but also
112- activate the types filter. */
113- onClicked: activateLens("applications.lens")
114+ onClicked: activateLensWithOptionFilter("applications.lens", "type", "internet")
115 }
116
117 HomeButton {
118 label: u2d.tr("More Apps")
119 icon: "artwork/find_more_apps.png"
120- onClicked: activateLens("applications.lens")
121+ onClicked: activateLensAndClearFilter("applications.lens", "type")
122 }
123
124 HomeButton {
125
126=== modified file 'places/dash.qml'
127--- places/dash.qml 2011-08-23 22:16:05 +0000
128+++ places/dash.qml 2011-08-31 10:59:42 +0000
129@@ -104,6 +104,23 @@
130 dashView.activeLens = ""
131 }
132
133+ function activateLensWithOptionFilter(lensId, filterId, optionId) {
134+ var lens = lenses.get(lensId)
135+ var filter = lens.filters.getFilter(filterId)
136+ var option = filter.getOption(optionId)
137+ filter.clear()
138+ option.active = true
139+ filterPane.folded = false
140+ activateLens(lensId)
141+ }
142+
143+ function activateLensAndClearFilter(lensId, filterId) {
144+ var lens = lenses.get(lensId)
145+ var filter = lens.filters.getFilter(filterId)
146+ filter.clear()
147+ activateLens(lensId)
148+ }
149+
150 property variant lenses: Lenses {}
151
152 Item {

Subscribers

People subscribed via source and target branches