Merge lp:~fboucault/unity-2d/backend_filters into lp:unity-2d
- backend_filters
- Merge into trunk
Proposed by
Florian Boucault
Status: | Merged |
---|---|
Approved by: | Florian Boucault |
Approved revision: | 694 |
Merge reported by: | Florian Boucault |
Merged at revision: | not available |
Proposed branch: | lp:~fboucault/unity-2d/backend_filters |
Merge into: | lp:unity-2d |
Diff against target: |
2240 lines (+1661/-84) 34 files modified
libunity-2d-private/Unity2d/plugin.cpp (+16/-0) libunity-2d-private/src/CMakeLists.txt (+6/-1) libunity-2d-private/src/checkoptionfilter.cpp (+57/-0) libunity-2d-private/src/checkoptionfilter.h (+61/-0) libunity-2d-private/src/filter.cpp (+43/-2) libunity-2d-private/src/filter.h (+5/-2) libunity-2d-private/src/filteroption.cpp (+72/-0) libunity-2d-private/src/filteroption.h (+71/-0) libunity-2d-private/src/filters.cpp (+134/-0) libunity-2d-private/src/filters.h (+67/-0) libunity-2d-private/src/lens.cpp (+12/-3) libunity-2d-private/src/lens.h (+7/-0) libunity-2d-private/src/listmodelwrapper.h (+153/-0) libunity-2d-private/src/multirangefilter.cpp (+57/-0) libunity-2d-private/src/multirangefilter.h (+61/-0) libunity-2d-private/src/radiooptionfilter.cpp (+57/-0) libunity-2d-private/src/radiooptionfilter.h (+61/-0) libunity-2d-private/src/ratingsfilter.cpp (+6/-1) libunity-2d-private/src/ratingsfilter.h (+6/-2) places/ButtonBackground.qml (+18/-0) places/Filter.qml (+3/-2) places/FilterCheckoption.qml (+12/-39) places/FilterLoader.qml (+117/-0) places/FilterMultirange.qml (+37/-0) places/FilterPane.qml (+17/-14) places/FilterRadiooption.qml (+22/-0) places/FilterRatings.qml (+47/-0) places/MultiRangeButton.qml (+65/-0) places/MultiRangeSelectionBar.qml (+64/-0) places/MultiRangeView.qml (+97/-0) places/RatingStars.qml (+129/-0) places/Star.qml (+59/-0) places/TickBox.qml (+12/-3) places/dash.qml (+10/-15) |
To merge this branch: | bzr merge lp:~fboucault/unity-2d/backend_filters |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gerry Boland | Pending | ||
Review via email: mp+72894@code.launchpad.net |
Commit message
Description of the change
[dash] New filters pane on the right hand side of the search results.
Implemented filters:
- multirange
- checkoption
- ratings
To post a comment you must log in.
Revision history for this message
Bob The Builder (bobthebuilder-deactivatedaccount) wrote : | # |
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'libunity-2d-private/Unity2d/plugin.cpp' |
2 | --- libunity-2d-private/Unity2d/plugin.cpp 2011-08-23 17:46:06 +0000 |
3 | +++ libunity-2d-private/Unity2d/plugin.cpp 2011-08-25 14:16:01 +0000 |
4 | @@ -61,6 +61,13 @@ |
5 | #include "lenses.h" |
6 | #include "lens.h" |
7 | |
8 | +#include "filter.h" |
9 | +#include "filters.h" |
10 | +#include "ratingsfilter.h" |
11 | +#include "radiooptionfilter.h" |
12 | +#include "checkoptionfilter.h" |
13 | +#include "multirangefilter.h" |
14 | + |
15 | #include <QtDeclarative/qdeclarative.h> |
16 | #include <QDeclarativeEngine> |
17 | #include <QDeclarativeContext> |
18 | @@ -139,6 +146,15 @@ |
19 | |
20 | qmlRegisterType<Lenses>(uri, 1, 0, "Lenses"); |
21 | qmlRegisterType<Lens>(uri, 1, 0, "Lens"); |
22 | + |
23 | + qmlRegisterType<Filter>(); |
24 | + qmlRegisterType<Filters>(); |
25 | + qmlRegisterType<RatingsFilter>(); |
26 | + qmlRegisterType<RadioOptionFilter>(); |
27 | + qmlRegisterType<CheckOptionFilter>(); |
28 | + qmlRegisterType<MultiRangeFilter>(); |
29 | + qmlRegisterType<FilterOption>(); |
30 | + qmlRegisterType<FilterOptions>(); |
31 | } |
32 | |
33 | void Unity2dPlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri) |
34 | |
35 | === modified file 'libunity-2d-private/src/CMakeLists.txt' |
36 | --- libunity-2d-private/src/CMakeLists.txt 2011-08-22 09:17:03 +0000 |
37 | +++ libunity-2d-private/src/CMakeLists.txt 2011-08-25 14:16:01 +0000 |
38 | @@ -60,7 +60,12 @@ |
39 | lenses.cpp |
40 | lens.cpp |
41 | filter.cpp |
42 | + filteroption.cpp |
43 | ratingsfilter.cpp |
44 | + radiooptionfilter.cpp |
45 | + checkoptionfilter.cpp |
46 | + multirangefilter.cpp |
47 | + filters.cpp |
48 | cairoutils.cpp |
49 | indicatorentrywidget.cpp |
50 | indicatorsmanager.cpp |
51 | @@ -96,7 +101,7 @@ |
52 | ${DEE_INCLUDE_DIRS} |
53 | ) |
54 | |
55 | -add_library(${LIB_NAME} SHARED ${libunity-2d-private_SRCS}) |
56 | +add_library(${LIB_NAME} SHARED ${libunity-2d-private_SRCS} listmodelwrapper.h) |
57 | set_target_properties(${LIB_NAME} PROPERTIES |
58 | VERSION ${libunity-2d-private_VERSION} |
59 | SOVERSION ${libunity-2d-private_SOVERSION} |
60 | |
61 | === added file 'libunity-2d-private/src/checkoptionfilter.cpp' |
62 | --- libunity-2d-private/src/checkoptionfilter.cpp 1970-01-01 00:00:00 +0000 |
63 | +++ libunity-2d-private/src/checkoptionfilter.cpp 2011-08-25 14:16:01 +0000 |
64 | @@ -0,0 +1,57 @@ |
65 | +/* |
66 | + * Copyright (C) 2011 Canonical, Ltd. |
67 | + * |
68 | + * Authors: |
69 | + * Florian Boucault <florian.boucault@canonical.com> |
70 | + * |
71 | + * This program is free software; you can redistribute it and/or modify |
72 | + * it under the terms of the GNU General Public License as published by |
73 | + * the Free Software Foundation; version 3. |
74 | + * |
75 | + * This program is distributed in the hope that it will be useful, |
76 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
77 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
78 | + * GNU General Public License for more details. |
79 | + * |
80 | + * You should have received a copy of the GNU General Public License |
81 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
82 | + */ |
83 | + |
84 | +// Self |
85 | +#include "checkoptionfilter.h" |
86 | + |
87 | +CheckOptionFilter::CheckOptionFilter(QObject *parent) : |
88 | + Filter(parent), m_unityCheckOptionFilter(NULL), m_options(NULL) |
89 | +{ |
90 | +} |
91 | + |
92 | +FilterOptions* CheckOptionFilter::options() const |
93 | +{ |
94 | + return m_options; |
95 | +} |
96 | + |
97 | +void CheckOptionFilter::setUnityFilter(unity::dash::Filter::Ptr filter) |
98 | +{ |
99 | + Filter::setUnityFilter(filter); |
100 | + m_unityCheckOptionFilter = std::dynamic_pointer_cast<unity::dash::CheckOptionFilter>(m_unityFilter); |
101 | + |
102 | + onOptionsChanged(m_unityCheckOptionFilter->options); |
103 | +} |
104 | + |
105 | +void CheckOptionFilter::onOptionsChanged(unity::dash::CheckOptionFilter::CheckOptions options) |
106 | +{ |
107 | + if (m_options != NULL) { |
108 | + // FIXME: should disconnect from m_unityFilter's signals |
109 | + delete m_options; |
110 | + m_options = NULL; |
111 | + } |
112 | + m_options = new FilterOptions(m_unityCheckOptionFilter->options, |
113 | + m_unityCheckOptionFilter->option_added, |
114 | + m_unityCheckOptionFilter->option_removed); |
115 | + /* Property change signals */ |
116 | + m_unityCheckOptionFilter->options.changed.connect(sigc::mem_fun(this, &CheckOptionFilter::onOptionsChanged)); |
117 | + |
118 | + Q_EMIT optionsChanged(); |
119 | +} |
120 | + |
121 | +#include "checkoptionfilter.moc" |
122 | |
123 | === added file 'libunity-2d-private/src/checkoptionfilter.h' |
124 | --- libunity-2d-private/src/checkoptionfilter.h 1970-01-01 00:00:00 +0000 |
125 | +++ libunity-2d-private/src/checkoptionfilter.h 2011-08-25 14:16:01 +0000 |
126 | @@ -0,0 +1,61 @@ |
127 | +/* |
128 | + * Copyright (C) 2011 Canonical, Ltd. |
129 | + * |
130 | + * Authors: |
131 | + * Florian Boucault <florian.boucault@canonical.com> |
132 | + * |
133 | + * This program is free software; you can redistribute it and/or modify |
134 | + * it under the terms of the GNU General Public License as published by |
135 | + * the Free Software Foundation; version 3. |
136 | + * |
137 | + * This program is distributed in the hope that it will be useful, |
138 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
139 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
140 | + * GNU General Public License for more details. |
141 | + * |
142 | + * You should have received a copy of the GNU General Public License |
143 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
144 | + */ |
145 | + |
146 | +#ifndef CHECKOPTIONFILTER_H |
147 | +#define CHECKOPTIONFILTER_H |
148 | + |
149 | +// Qt |
150 | +#include <QObject> |
151 | +#include <QMetaType> |
152 | + |
153 | +// libunity-core |
154 | +#include <UnityCore/CheckOptionFilter.h> |
155 | + |
156 | +// Local |
157 | +#include "filter.h" |
158 | +#include "filteroption.h" |
159 | + |
160 | +class CheckOptionFilter : public Filter |
161 | +{ |
162 | + Q_OBJECT |
163 | + |
164 | + Q_PROPERTY(FilterOptions* options READ options NOTIFY optionsChanged) |
165 | + |
166 | +public: |
167 | + explicit CheckOptionFilter(QObject *parent = 0); |
168 | + |
169 | + /* getters */ |
170 | + FilterOptions* options() const; |
171 | + |
172 | +Q_SIGNALS: |
173 | + void optionsChanged(); |
174 | + |
175 | +protected: |
176 | + virtual void setUnityFilter(unity::dash::Filter::Ptr filter); |
177 | + |
178 | +private: |
179 | + unity::dash::CheckOptionFilter::Ptr m_unityCheckOptionFilter; |
180 | + FilterOptions* m_options; |
181 | + |
182 | + void onOptionsChanged(unity::dash::CheckOptionFilter::CheckOptions); |
183 | +}; |
184 | + |
185 | +Q_DECLARE_METATYPE(CheckOptionFilter*) |
186 | + |
187 | +#endif // CHECKOPTIONFILTER_H |
188 | |
189 | === modified file 'libunity-2d-private/src/filter.cpp' |
190 | --- libunity-2d-private/src/filter.cpp 2011-08-02 15:10:09 +0000 |
191 | +++ libunity-2d-private/src/filter.cpp 2011-08-25 14:16:01 +0000 |
192 | @@ -20,6 +20,22 @@ |
193 | // Self |
194 | #include "filter.h" |
195 | |
196 | +// local |
197 | +#include "ratingsfilter.h" |
198 | +#include "radiooptionfilter.h" |
199 | +#include "checkoptionfilter.h" |
200 | +#include "multirangefilter.h" |
201 | + |
202 | +// libunity-core |
203 | +#include <UnityCore/Filter.h> |
204 | +#include <UnityCore/RatingsFilter.h> |
205 | +#include <UnityCore/RadioOptionFilter.h> |
206 | +#include <UnityCore/CheckOptionFilter.h> |
207 | +#include <UnityCore/MultiRangeFilter.h> |
208 | + |
209 | +// Qt |
210 | +#include <QDebug> |
211 | + |
212 | Filter::Filter(QObject *parent) : |
213 | QObject(parent) |
214 | { |
215 | @@ -67,13 +83,13 @@ |
216 | } |
217 | |
218 | |
219 | -void Filter::setUnityFilter(unity::dash::Filter::Ptr filter) |
220 | +void Filter::setUnityFilter(unity::dash::Filter::Ptr unityFilter) |
221 | { |
222 | if (m_unityFilter != NULL) { |
223 | // FIXME: should disconnect from m_unityFilter's signals |
224 | } |
225 | |
226 | - m_unityFilter = filter; |
227 | + m_unityFilter = unityFilter; |
228 | |
229 | /* Property change signals */ |
230 | m_unityFilter->id.changed.connect(sigc::mem_fun(this, &Filter::idChanged)); |
231 | @@ -88,5 +104,30 @@ |
232 | m_unityFilter->removed.connect(sigc::mem_fun(this, &Filter::removed)); |
233 | } |
234 | |
235 | +Filter* Filter::newFromUnityFilter(unity::dash::Filter::Ptr unityFilter) |
236 | +{ |
237 | + Filter* filter; |
238 | + |
239 | + if (typeid(*unityFilter) == typeid(unity::dash::RatingsFilter)) { |
240 | + filter = new RatingsFilter; |
241 | + } else if (typeid(*unityFilter) == typeid(unity::dash::CheckOptionFilter)) { |
242 | + filter = new CheckOptionFilter; |
243 | + } else if (typeid(*unityFilter) == typeid(unity::dash::RadioOptionFilter)) { |
244 | + filter = new RadioOptionFilter; |
245 | + } else if (typeid(*unityFilter) == typeid(unity::dash::MultiRangeFilter)) { |
246 | + filter = new MultiRangeFilter; |
247 | + } else { |
248 | + qWarning() << "Filter of unknown type: " << typeid(*unityFilter).name(); |
249 | + filter = new Filter; |
250 | + } |
251 | + |
252 | + filter->setUnityFilter(unityFilter); |
253 | + return filter; |
254 | +} |
255 | + |
256 | +bool Filter::hasUnityFilter(unity::dash::Filter::Ptr unityFilter) const |
257 | +{ |
258 | + return m_unityFilter == unityFilter; |
259 | +} |
260 | |
261 | #include "filter.moc" |
262 | |
263 | === modified file 'libunity-2d-private/src/filter.h' |
264 | --- libunity-2d-private/src/filter.h 2011-08-02 15:10:09 +0000 |
265 | +++ libunity-2d-private/src/filter.h 2011-08-25 14:16:01 +0000 |
266 | @@ -51,8 +51,10 @@ |
267 | bool collapsed() const; |
268 | bool filtering() const; |
269 | |
270 | - void clear(); |
271 | - virtual void setUnityFilter(unity::dash::Filter::Ptr filter); |
272 | + Q_INVOKABLE void clear(); |
273 | + |
274 | + static Filter* newFromUnityFilter(unity::dash::Filter::Ptr unityFilter); |
275 | + bool hasUnityFilter(unity::dash::Filter::Ptr unityFilter) const; |
276 | |
277 | Q_SIGNALS: |
278 | void idChanged(std::string); |
279 | @@ -67,6 +69,7 @@ |
280 | |
281 | protected: |
282 | unity::dash::Filter::Ptr m_unityFilter; |
283 | + virtual void setUnityFilter(unity::dash::Filter::Ptr unityFilter); |
284 | }; |
285 | |
286 | Q_DECLARE_METATYPE(Filter*) |
287 | |
288 | === added file 'libunity-2d-private/src/filteroption.cpp' |
289 | --- libunity-2d-private/src/filteroption.cpp 1970-01-01 00:00:00 +0000 |
290 | +++ libunity-2d-private/src/filteroption.cpp 2011-08-25 14:16:01 +0000 |
291 | @@ -0,0 +1,72 @@ |
292 | +/* |
293 | + * Copyright (C) 2011 Canonical, Ltd. |
294 | + * |
295 | + * Authors: |
296 | + * Florian Boucault <florian.boucault@canonical.com> |
297 | + * |
298 | + * This program is free software; you can redistribute it and/or modify |
299 | + * it under the terms of the GNU General Public License as published by |
300 | + * the Free Software Foundation; version 3. |
301 | + * |
302 | + * This program is distributed in the hope that it will be useful, |
303 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
304 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
305 | + * GNU General Public License for more details. |
306 | + * |
307 | + * You should have received a copy of the GNU General Public License |
308 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
309 | + */ |
310 | + |
311 | +// Self |
312 | +#include "filteroption.h" |
313 | + |
314 | +// libunity-core |
315 | +#include <UnityCore/Filter.h> |
316 | + |
317 | +FilterOption::FilterOption(unity::dash::FilterOption::Ptr unityFilterOption, QObject *parent) : |
318 | + QObject(parent), m_unityFilterOption(NULL) |
319 | +{ |
320 | + setUnityFilterOption(unityFilterOption); |
321 | +} |
322 | + |
323 | +QString FilterOption::id() const |
324 | +{ |
325 | + return QString::fromStdString(m_unityFilterOption->id()); |
326 | +} |
327 | + |
328 | +QString FilterOption::name() const |
329 | +{ |
330 | + return QString::fromStdString(m_unityFilterOption->name()); |
331 | +} |
332 | + |
333 | +QString FilterOption::iconHint() const |
334 | +{ |
335 | + return QString::fromStdString(m_unityFilterOption->icon_hint()); |
336 | +} |
337 | + |
338 | +bool FilterOption::active() const |
339 | +{ |
340 | + return m_unityFilterOption->active(); |
341 | +} |
342 | + |
343 | +void FilterOption::setActive(bool active) |
344 | +{ |
345 | + m_unityFilterOption->active = active; |
346 | +} |
347 | + |
348 | +void FilterOption::setUnityFilterOption(unity::dash::FilterOption::Ptr unityFilterOption) |
349 | +{ |
350 | + if (m_unityFilterOption != NULL) { |
351 | + // FIXME: should disconnect from m_unityFilterOption's signals |
352 | + } |
353 | + |
354 | + m_unityFilterOption = unityFilterOption; |
355 | + |
356 | + /* Property change signals */ |
357 | + m_unityFilterOption->id.changed.connect(sigc::mem_fun(this, &FilterOption::idChanged)); |
358 | + m_unityFilterOption->name.changed.connect(sigc::mem_fun(this, &FilterOption::nameChanged)); |
359 | + m_unityFilterOption->icon_hint.changed.connect(sigc::mem_fun(this, &FilterOption::iconHintChanged)); |
360 | + m_unityFilterOption->active.changed.connect(sigc::mem_fun(this, &FilterOption::activeChanged)); |
361 | +} |
362 | + |
363 | +#include "filteroption.moc" |
364 | |
365 | === added file 'libunity-2d-private/src/filteroption.h' |
366 | --- libunity-2d-private/src/filteroption.h 1970-01-01 00:00:00 +0000 |
367 | +++ libunity-2d-private/src/filteroption.h 2011-08-25 14:16:01 +0000 |
368 | @@ -0,0 +1,71 @@ |
369 | +/* |
370 | + * Copyright (C) 2011 Canonical, Ltd. |
371 | + * |
372 | + * Authors: |
373 | + * Florian Boucault <florian.boucault@canonical.com> |
374 | + * |
375 | + * This program is free software; you can redistribute it and/or modify |
376 | + * it under the terms of the GNU General Public License as published by |
377 | + * the Free Software Foundation; version 3. |
378 | + * |
379 | + * This program is distributed in the hope that it will be useful, |
380 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
381 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
382 | + * GNU General Public License for more details. |
383 | + * |
384 | + * You should have received a copy of the GNU General Public License |
385 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
386 | + */ |
387 | + |
388 | +#ifndef FILTEROPTION_H |
389 | +#define FILTEROPTION_H |
390 | + |
391 | +// Local |
392 | +#include "listmodelwrapper.h" |
393 | + |
394 | +// Qt |
395 | +#include <QObject> |
396 | +#include <QMetaType> |
397 | + |
398 | +// libunity-core |
399 | +#include <UnityCore/Filter.h> |
400 | + |
401 | +class FilterOption : public QObject |
402 | +{ |
403 | + Q_OBJECT |
404 | + |
405 | + Q_PROPERTY(QString id READ id NOTIFY idChanged) |
406 | + Q_PROPERTY(QString name READ name NOTIFY nameChanged) |
407 | + Q_PROPERTY(QString iconHint READ iconHint NOTIFY iconHintChanged) |
408 | + Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged) |
409 | + |
410 | +public: |
411 | + explicit FilterOption(unity::dash::FilterOption::Ptr unityFilterOption, QObject *parent = 0); |
412 | + |
413 | + /* getters */ |
414 | + QString id() const; |
415 | + QString name() const; |
416 | + QString iconHint() const; |
417 | + bool active() const; |
418 | + |
419 | + /* setters */ |
420 | + void setActive(bool active); |
421 | + |
422 | +Q_SIGNALS: |
423 | + void idChanged(std::string); |
424 | + void nameChanged(std::string); |
425 | + void iconHintChanged(std::string); |
426 | + void activeChanged(bool); |
427 | + |
428 | +private: |
429 | + void setUnityFilterOption(unity::dash::FilterOption::Ptr unityFilterOption); |
430 | + |
431 | + unity::dash::FilterOption::Ptr m_unityFilterOption; |
432 | +}; |
433 | + |
434 | +Q_DECLARE_METATYPE(FilterOption*) |
435 | + |
436 | +typedef ListModelWrapper<FilterOption, unity::dash::FilterOption::Ptr> FilterOptions; |
437 | +Q_DECLARE_METATYPE(FilterOptions*) |
438 | + |
439 | +#endif // FILTEROPTION_H |
440 | |
441 | === added file 'libunity-2d-private/src/filters.cpp' |
442 | --- libunity-2d-private/src/filters.cpp 1970-01-01 00:00:00 +0000 |
443 | +++ libunity-2d-private/src/filters.cpp 2011-08-25 14:16:01 +0000 |
444 | @@ -0,0 +1,134 @@ |
445 | +/* |
446 | + * Copyright (C) 2011 Canonical, Ltd. |
447 | + * |
448 | + * Authors: |
449 | + * Florian Boucault <florian.boucault@canonical.com> |
450 | + * |
451 | + * This program is free software; you can redistribute it and/or modify |
452 | + * it under the terms of the GNU General Public License as published by |
453 | + * the Free Software Foundation; version 3. |
454 | + * |
455 | + * This program is distributed in the hope that it will be useful, |
456 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
457 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
458 | + * GNU General Public License for more details. |
459 | + * |
460 | + * You should have received a copy of the GNU General Public License |
461 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
462 | + */ |
463 | + |
464 | +// Self |
465 | +#include "filters.h" |
466 | + |
467 | +// Local |
468 | +#include "filter.h" |
469 | + |
470 | +// Qt |
471 | +#include <QDebug> |
472 | + |
473 | +// libunity-core |
474 | +#include <UnityCore/Filters.h> |
475 | + |
476 | +Filters::Filters(unity::dash::Filters::Ptr unityFilters, QObject *parent) : |
477 | + QAbstractListModel(parent), m_unityFilters(unityFilters) |
478 | +{ |
479 | + QHash<int, QByteArray> roles; |
480 | + roles[Filters::RoleFilter] = "filter"; |
481 | + setRoleNames(roles); |
482 | + |
483 | + for (unsigned int i=0; i<m_unityFilters->count(); i++) { |
484 | + unity::dash::Filter::Ptr unityFilter = m_unityFilters->FilterAtIndex(i); |
485 | + addFilter(unityFilter, i); |
486 | + } |
487 | + m_unityFilters->filter_added.connect(sigc::mem_fun(this, &Filters::onFilterAdded)); |
488 | + m_unityFilters->filter_changed.connect(sigc::mem_fun(this, &Filters::onFilterChanged)); |
489 | + m_unityFilters->filter_removed.connect(sigc::mem_fun(this, &Filters::onFilterRemoved)); |
490 | +} |
491 | + |
492 | +Filters::~Filters() |
493 | +{ |
494 | + while (!m_filters.isEmpty()) { |
495 | + delete m_filters.takeFirst(); |
496 | + } |
497 | +} |
498 | + |
499 | +int Filters::rowCount(const QModelIndex& parent) const |
500 | +{ |
501 | + Q_UNUSED(parent) |
502 | + |
503 | + return m_unityFilters->count(); |
504 | +} |
505 | + |
506 | +QVariant Filters::data(const QModelIndex& index, int role) const |
507 | +{ |
508 | + Q_UNUSED(role) |
509 | + |
510 | + if (!index.isValid()) { |
511 | + return QVariant(); |
512 | + } |
513 | + |
514 | + Filter* filter = m_filters.at(index.row()); |
515 | + |
516 | + if (role == Filters::RoleFilter) { |
517 | + return QVariant::fromValue(filter); |
518 | + } else { |
519 | + return QVariant(); |
520 | + } |
521 | +} |
522 | + |
523 | +void Filters::onFilterAdded(unity::dash::Filter::Ptr unityFilter) |
524 | +{ |
525 | + if (unityFilter == NULL) { |
526 | + return; |
527 | + } |
528 | + |
529 | + /* FIXME: figure out actual index of unityFilter; for now filters are appended */ |
530 | + int index = m_filters.count(); |
531 | + addFilter(unityFilter, index); |
532 | +} |
533 | + |
534 | +void Filters::onFilterChanged(unity::dash::Filter::Ptr unityFilter) |
535 | +{ |
536 | + if (unityFilter == NULL) { |
537 | + return; |
538 | + } |
539 | + |
540 | + QModelIndex filterIndex = index(indexForFilter(unityFilter)); |
541 | + Q_EMIT dataChanged(filterIndex, filterIndex); |
542 | +} |
543 | + |
544 | +void Filters::onFilterRemoved(unity::dash::Filter::Ptr unityFilter) |
545 | +{ |
546 | + removeFilter(indexForFilter(unityFilter)); |
547 | +} |
548 | + |
549 | +void Filters::addFilter(unity::dash::Filter::Ptr unityFilter, int index) |
550 | +{ |
551 | + beginInsertRows(QModelIndex(), index, index); |
552 | + Filter* filter = Filter::newFromUnityFilter(unityFilter); |
553 | + m_filters.insert(index, filter); |
554 | + endInsertRows(); |
555 | +} |
556 | + |
557 | +void Filters::removeFilter(int index) |
558 | +{ |
559 | + beginRemoveRows(QModelIndex(), index, index); |
560 | + Filter* filter = m_filters.takeAt(index); |
561 | + delete filter; |
562 | + endRemoveRows(); |
563 | +} |
564 | + |
565 | +int Filters::indexForFilter(unity::dash::Filter::Ptr unityFilter) |
566 | +{ |
567 | + int index; |
568 | + for (index=0; index<m_filters.count(); index++) { |
569 | + if (m_filters[index]->hasUnityFilter(unityFilter)) { |
570 | + return index; |
571 | + } |
572 | + } |
573 | + qWarning() << "Filter" << QString::fromStdString(unityFilter->name()) << "not found in local cache."; |
574 | + return -1; |
575 | +} |
576 | + |
577 | + |
578 | +#include "filters.moc" |
579 | |
580 | === added file 'libunity-2d-private/src/filters.h' |
581 | --- libunity-2d-private/src/filters.h 1970-01-01 00:00:00 +0000 |
582 | +++ libunity-2d-private/src/filters.h 2011-08-25 14:16:01 +0000 |
583 | @@ -0,0 +1,67 @@ |
584 | +/* |
585 | + * Copyright (C) 2011 Canonical, Ltd. |
586 | + * |
587 | + * Authors: |
588 | + * Florian Boucault <florian.boucault@canonical.com> |
589 | + * |
590 | + * This program is free software; you can redistribute it and/or modify |
591 | + * it under the terms of the GNU General Public License as published by |
592 | + * the Free Software Foundation; version 3. |
593 | + * |
594 | + * This program is distributed in the hope that it will be useful, |
595 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
596 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
597 | + * GNU General Public License for more details. |
598 | + * |
599 | + * You should have received a copy of the GNU General Public License |
600 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
601 | + */ |
602 | + |
603 | +#ifndef FILTERS_H |
604 | +#define FILTERS_H |
605 | + |
606 | +// Qt |
607 | +#include <QAbstractListModel> |
608 | +#include <QList> |
609 | + |
610 | +// libunity-core |
611 | +#include <UnityCore/Filters.h> |
612 | +#include <UnityCore/Filter.h> |
613 | + |
614 | + |
615 | +class Filter; |
616 | + |
617 | +class Filters : public QAbstractListModel |
618 | +{ |
619 | + Q_OBJECT |
620 | + |
621 | + Q_ENUMS(Roles) |
622 | + |
623 | +public: |
624 | + explicit Filters(unity::dash::Filters::Ptr unityFilters, QObject *parent = 0); |
625 | + ~Filters(); |
626 | + |
627 | + enum Roles { |
628 | + RoleFilter |
629 | + }; |
630 | + |
631 | + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; |
632 | + int rowCount(const QModelIndex& parent = QModelIndex()) const; |
633 | + |
634 | +private: |
635 | + unity::dash::Filters::Ptr m_unityFilters; |
636 | + QList<Filter*> m_filters; |
637 | + |
638 | + void onFilterAdded(unity::dash::Filter::Ptr unityFilter); |
639 | + void onFilterChanged(unity::dash::Filter::Ptr unityFilter); |
640 | + void onFilterRemoved(unity::dash::Filter::Ptr unityFilter); |
641 | + |
642 | + void addFilter(unity::dash::Filter::Ptr unityFilter, int index); |
643 | + void removeFilter(int index); |
644 | + |
645 | + int indexForFilter(unity::dash::Filter::Ptr unityFilter); |
646 | +}; |
647 | + |
648 | +Q_DECLARE_METATYPE(Filters*) |
649 | + |
650 | +#endif // FILTERS_H |
651 | |
652 | === modified file 'libunity-2d-private/src/lens.cpp' |
653 | --- libunity-2d-private/src/lens.cpp 2011-08-11 17:11:58 +0000 |
654 | +++ libunity-2d-private/src/lens.cpp 2011-08-25 14:16:01 +0000 |
655 | @@ -23,6 +23,7 @@ |
656 | // libunity-2d |
657 | #include <debug_p.h> |
658 | #include "launcherapplication.h" |
659 | +#include "filters.h" |
660 | |
661 | // Qt |
662 | #include <QUrl> |
663 | @@ -31,9 +32,9 @@ |
664 | Lens::Lens(QObject *parent) : |
665 | QObject(parent) |
666 | { |
667 | - m_results = new DeeListModel; |
668 | - m_globalResults = new DeeListModel; |
669 | - m_categories = new DeeListModel; |
670 | + m_results = new DeeListModel(this); |
671 | + m_globalResults = new DeeListModel(this); |
672 | + m_categories = new DeeListModel(this); |
673 | } |
674 | |
675 | QString Lens::id() const |
676 | @@ -111,6 +112,11 @@ |
677 | return m_unityLens->active(); |
678 | } |
679 | |
680 | +Filters* Lens::filters() const |
681 | +{ |
682 | + return m_filters; |
683 | +} |
684 | + |
685 | QString Lens::searchQuery() const |
686 | { |
687 | return m_searchQuery; |
688 | @@ -201,12 +207,15 @@ |
689 | { |
690 | if (m_unityLens != NULL) { |
691 | // FIXME: should disconnect from m_unityLens's signals |
692 | + delete m_filters; |
693 | } |
694 | |
695 | // FIXME: should emit change notification signals for all properties |
696 | |
697 | m_unityLens = lens; |
698 | |
699 | + m_filters = new Filters(m_unityLens->filters, this); |
700 | + |
701 | m_results->setName(QString::fromStdString(m_unityLens->results()->swarm_name)); |
702 | m_globalResults->setName(QString::fromStdString(m_unityLens->global_results()->swarm_name)); |
703 | m_categories->setName(QString::fromStdString(m_unityLens->categories()->swarm_name)); |
704 | |
705 | === modified file 'libunity-2d-private/src/lens.h' |
706 | --- libunity-2d-private/src/lens.h 2011-08-11 17:11:58 +0000 |
707 | +++ libunity-2d-private/src/lens.h 2011-08-25 14:16:01 +0000 |
708 | @@ -20,6 +20,8 @@ |
709 | #ifndef LENS_H |
710 | #define LENS_H |
711 | |
712 | +// Local |
713 | + |
714 | // Qt |
715 | #include <QObject> |
716 | #include <QString> |
717 | @@ -31,6 +33,7 @@ |
718 | // dee-qt |
719 | #include "deelistmodel.h" |
720 | |
721 | +class Filters; |
722 | |
723 | class Lens : public QObject |
724 | { |
725 | @@ -51,6 +54,7 @@ |
726 | Q_PROPERTY(DeeListModel* globalResults READ globalResults NOTIFY globalResultsChanged) |
727 | Q_PROPERTY(DeeListModel* categories READ categories NOTIFY categoriesChanged) |
728 | Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged) |
729 | + Q_PROPERTY(Filters* filters READ filters NOTIFY filtersChanged) |
730 | |
731 | Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged) |
732 | Q_PROPERTY(QString globalSearchQuery READ globalSearchQuery WRITE setGlobalSearchQuery NOTIFY globalSearchQueryChanged) |
733 | @@ -74,6 +78,7 @@ |
734 | DeeListModel* globalResults() const; |
735 | DeeListModel* categories() const; |
736 | bool active() const; |
737 | + Filters* filters() const; |
738 | QString searchQuery() const; |
739 | QString globalSearchQuery() const; |
740 | |
741 | @@ -101,6 +106,7 @@ |
742 | void globalResultsChanged(); |
743 | void categoriesChanged(); |
744 | void activeChanged(bool); |
745 | + void filtersChanged(); |
746 | void searchFinished(std::string const&); |
747 | void globalSearchFinished(std::string const&); |
748 | void searchQueryChanged(); |
749 | @@ -123,6 +129,7 @@ |
750 | DeeListModel* m_categories; |
751 | QString m_searchQuery; |
752 | QString m_globalSearchQuery; |
753 | + Filters* m_filters; |
754 | }; |
755 | |
756 | Q_DECLARE_METATYPE(Lens*) |
757 | |
758 | === added file 'libunity-2d-private/src/listmodelwrapper.h' |
759 | --- libunity-2d-private/src/listmodelwrapper.h 1970-01-01 00:00:00 +0000 |
760 | +++ libunity-2d-private/src/listmodelwrapper.h 2011-08-25 14:16:01 +0000 |
761 | @@ -0,0 +1,153 @@ |
762 | +/* |
763 | + * Copyright (C) 2011 Canonical, Ltd. |
764 | + * |
765 | + * Authors: |
766 | + * Florian Boucault <florian.boucault@canonical.com> |
767 | + * |
768 | + * This program is free software; you can redistribute it and/or modify |
769 | + * it under the terms of the GNU General Public License as published by |
770 | + * the Free Software Foundation; version 3. |
771 | + * |
772 | + * This program is distributed in the hope that it will be useful, |
773 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
774 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
775 | + * GNU General Public License for more details. |
776 | + * |
777 | + * You should have received a copy of the GNU General Public License |
778 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
779 | + */ |
780 | + |
781 | +#ifndef LISTMODELWRAPPER_H |
782 | +#define LISTMODELWRAPPER_H |
783 | + |
784 | +// Qt |
785 | +#include <QAbstractListModel> |
786 | +#include <QList> |
787 | + |
788 | +#include <sigc++/signal.h> |
789 | +#include <vector> |
790 | + |
791 | +template <class WrapperItem, class ItemClass> |
792 | +class ListModelWrapper : public QAbstractListModel |
793 | +{ |
794 | + Q_ENUMS(Roles) |
795 | + |
796 | +public: |
797 | + explicit ListModelWrapper(const std::vector<ItemClass>& list, |
798 | + sigc::signal<void, ItemClass> itemAddedSignal, |
799 | + sigc::signal<void, ItemClass> itemRemovedSignal, |
800 | + QObject *parent = 0); |
801 | + ~ListModelWrapper(); |
802 | + |
803 | + enum Roles { |
804 | + RoleItem |
805 | + }; |
806 | + |
807 | + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; |
808 | + int rowCount(const QModelIndex& parent = QModelIndex()) const; |
809 | + |
810 | +private: |
811 | + void onItemAdded(ItemClass item); |
812 | + void onItemRemoved(ItemClass item); |
813 | + void onItemChanged(ItemClass item); |
814 | + |
815 | + QList<WrapperItem*> m_list; |
816 | + QMap<ItemClass, int> m_indexes; |
817 | + |
818 | + void addItem(ItemClass item, int index); |
819 | + void removeItem(ItemClass item, int index); |
820 | +}; |
821 | + |
822 | + |
823 | +template <class WrapperItem, class ItemClass> |
824 | +ListModelWrapper<WrapperItem, ItemClass>::ListModelWrapper(const std::vector<ItemClass>& list, |
825 | + sigc::signal<void, ItemClass> itemAddedSignal, |
826 | + sigc::signal<void, ItemClass> itemRemovedSignal, |
827 | + QObject *parent) : |
828 | + QAbstractListModel(parent) |
829 | +{ |
830 | + QHash<int, QByteArray> roles; |
831 | + roles[ListModelWrapper::RoleItem] = "item"; |
832 | + setRoleNames(roles); |
833 | + |
834 | + for (unsigned int i=0; i<list.size(); i++) { |
835 | + addItem(list[i], i); |
836 | + } |
837 | + itemAddedSignal.connect(sigc::mem_fun(this, &ListModelWrapper::onItemAdded)); |
838 | + itemRemovedSignal.connect(sigc::mem_fun(this, &ListModelWrapper::onItemRemoved)); |
839 | +} |
840 | + |
841 | +template <class WrapperItem, class ItemClass> |
842 | +ListModelWrapper<WrapperItem, ItemClass>::~ListModelWrapper() |
843 | +{ |
844 | + m_indexes.clear(); |
845 | + while (!m_list.isEmpty()) { |
846 | + delete m_list.takeFirst(); |
847 | + } |
848 | +} |
849 | + |
850 | +template <class WrapperItem, class ItemClass> |
851 | +int ListModelWrapper<WrapperItem, ItemClass>::rowCount(const QModelIndex& parent) const |
852 | +{ |
853 | + Q_UNUSED(parent) |
854 | + |
855 | + return m_list.count(); |
856 | +} |
857 | + |
858 | +template <class WrapperItem, class ItemClass> |
859 | +QVariant ListModelWrapper<WrapperItem, ItemClass>::data(const QModelIndex& index, int role) const |
860 | +{ |
861 | + if (!index.isValid()) { |
862 | + return QVariant(); |
863 | + } |
864 | + |
865 | + WrapperItem* item = m_list.at(index.row()); |
866 | + |
867 | + if (role == ListModelWrapper::RoleItem) { |
868 | + return QVariant::fromValue(item); |
869 | + } else { |
870 | + return QVariant(); |
871 | + } |
872 | +} |
873 | + |
874 | +template <class WrapperItem, class ItemClass> |
875 | +void ListModelWrapper<WrapperItem, ItemClass>::onItemAdded(ItemClass item) |
876 | +{ |
877 | + /* FIXME: figure out actual index of item; for now items are appended */ |
878 | + int index = m_list.count(); |
879 | + beginInsertRows(QModelIndex(), index, index); |
880 | + addItem(item, index); |
881 | + endInsertRows(); |
882 | +} |
883 | + |
884 | +template <class WrapperItem, class ItemClass> |
885 | +void ListModelWrapper<WrapperItem, ItemClass>::onItemRemoved(ItemClass item) |
886 | +{ |
887 | + int index = m_indexes[item]; |
888 | + beginInsertRows(QModelIndex(), index, index); |
889 | + removeItem(item, index); |
890 | + endInsertRows(); |
891 | +} |
892 | + |
893 | +template <class WrapperItem, class ItemClass> |
894 | +void ListModelWrapper<WrapperItem, ItemClass>::onItemChanged(ItemClass item) |
895 | +{ |
896 | + QModelIndex itemIndex = index(m_indexes[item]); |
897 | + Q_EMIT dataChanged(itemIndex, itemIndex); |
898 | +} |
899 | + |
900 | +template <class WrapperItem, class ItemClass> |
901 | +void ListModelWrapper<WrapperItem, ItemClass>::addItem(ItemClass item, int index) |
902 | +{ |
903 | + m_indexes.insert(item, index); |
904 | + m_list.insert(index, new WrapperItem(item)); |
905 | +} |
906 | + |
907 | +template <class WrapperItem, class ItemClass> |
908 | +void ListModelWrapper<WrapperItem, ItemClass>::removeItem(ItemClass item, int index) |
909 | +{ |
910 | + m_indexes.remove(item); |
911 | + delete m_list.takeAt(index); |
912 | +} |
913 | + |
914 | +#endif // LISTMODELWRAPPER_H |
915 | |
916 | === added file 'libunity-2d-private/src/multirangefilter.cpp' |
917 | --- libunity-2d-private/src/multirangefilter.cpp 1970-01-01 00:00:00 +0000 |
918 | +++ libunity-2d-private/src/multirangefilter.cpp 2011-08-25 14:16:01 +0000 |
919 | @@ -0,0 +1,57 @@ |
920 | +/* |
921 | + * Copyright (C) 2011 Canonical, Ltd. |
922 | + * |
923 | + * Authors: |
924 | + * Florian Boucault <florian.boucault@canonical.com> |
925 | + * |
926 | + * This program is free software; you can redistribute it and/or modify |
927 | + * it under the terms of the GNU General Public License as published by |
928 | + * the Free Software Foundation; version 3. |
929 | + * |
930 | + * This program is distributed in the hope that it will be useful, |
931 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
932 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
933 | + * GNU General Public License for more details. |
934 | + * |
935 | + * You should have received a copy of the GNU General Public License |
936 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
937 | + */ |
938 | + |
939 | +// Self |
940 | +#include "multirangefilter.h" |
941 | + |
942 | +MultiRangeFilter::MultiRangeFilter(QObject *parent) : |
943 | + Filter(parent), m_unityMultiRangeFilter(NULL), m_options(NULL) |
944 | +{ |
945 | +} |
946 | + |
947 | +FilterOptions* MultiRangeFilter::options() const |
948 | +{ |
949 | + return m_options; |
950 | +} |
951 | + |
952 | +void MultiRangeFilter::setUnityFilter(unity::dash::Filter::Ptr filter) |
953 | +{ |
954 | + Filter::setUnityFilter(filter); |
955 | + m_unityMultiRangeFilter = std::dynamic_pointer_cast<unity::dash::MultiRangeFilter>(m_unityFilter); |
956 | + |
957 | + onOptionsChanged(m_unityMultiRangeFilter->options); |
958 | +} |
959 | + |
960 | +void MultiRangeFilter::onOptionsChanged(unity::dash::MultiRangeFilter::Options options) |
961 | +{ |
962 | + if (m_options != NULL) { |
963 | + // FIXME: should disconnect from m_unityFilter's signals |
964 | + delete m_options; |
965 | + m_options = NULL; |
966 | + } |
967 | + m_options = new FilterOptions(m_unityMultiRangeFilter->options, |
968 | + m_unityMultiRangeFilter->option_added, |
969 | + m_unityMultiRangeFilter->option_removed); |
970 | + /* Property change signals */ |
971 | + m_unityMultiRangeFilter->options.changed.connect(sigc::mem_fun(this, &MultiRangeFilter::onOptionsChanged)); |
972 | + |
973 | + Q_EMIT optionsChanged(); |
974 | +} |
975 | + |
976 | +#include "multirangefilter.moc" |
977 | |
978 | === added file 'libunity-2d-private/src/multirangefilter.h' |
979 | --- libunity-2d-private/src/multirangefilter.h 1970-01-01 00:00:00 +0000 |
980 | +++ libunity-2d-private/src/multirangefilter.h 2011-08-25 14:16:01 +0000 |
981 | @@ -0,0 +1,61 @@ |
982 | +/* |
983 | + * Copyright (C) 2011 Canonical, Ltd. |
984 | + * |
985 | + * Authors: |
986 | + * Florian Boucault <florian.boucault@canonical.com> |
987 | + * |
988 | + * This program is free software; you can redistribute it and/or modify |
989 | + * it under the terms of the GNU General Public License as published by |
990 | + * the Free Software Foundation; version 3. |
991 | + * |
992 | + * This program is distributed in the hope that it will be useful, |
993 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
994 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
995 | + * GNU General Public License for more details. |
996 | + * |
997 | + * You should have received a copy of the GNU General Public License |
998 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
999 | + */ |
1000 | + |
1001 | +#ifndef MULTIRANGEFILTER_H |
1002 | +#define MULTIRANGEFILTER_H |
1003 | + |
1004 | +// Qt |
1005 | +#include <QObject> |
1006 | +#include <QMetaType> |
1007 | + |
1008 | +// libunity-core |
1009 | +#include <UnityCore/MultiRangeFilter.h> |
1010 | + |
1011 | +// Local |
1012 | +#include "filter.h" |
1013 | +#include "filteroption.h" |
1014 | + |
1015 | +class MultiRangeFilter : public Filter |
1016 | +{ |
1017 | + Q_OBJECT |
1018 | + |
1019 | + Q_PROPERTY(FilterOptions* options READ options NOTIFY optionsChanged) |
1020 | + |
1021 | +public: |
1022 | + explicit MultiRangeFilter(QObject *parent = 0); |
1023 | + |
1024 | + /* getters */ |
1025 | + FilterOptions* options() const; |
1026 | + |
1027 | +Q_SIGNALS: |
1028 | + void optionsChanged(); |
1029 | + |
1030 | +protected: |
1031 | + virtual void setUnityFilter(unity::dash::Filter::Ptr filter); |
1032 | + |
1033 | +private: |
1034 | + unity::dash::MultiRangeFilter::Ptr m_unityMultiRangeFilter; |
1035 | + FilterOptions* m_options; |
1036 | + |
1037 | + void onOptionsChanged(unity::dash::MultiRangeFilter::Options); |
1038 | +}; |
1039 | + |
1040 | +Q_DECLARE_METATYPE(MultiRangeFilter*) |
1041 | + |
1042 | +#endif // MULTIRANGEFILTER_H |
1043 | |
1044 | === added file 'libunity-2d-private/src/radiooptionfilter.cpp' |
1045 | --- libunity-2d-private/src/radiooptionfilter.cpp 1970-01-01 00:00:00 +0000 |
1046 | +++ libunity-2d-private/src/radiooptionfilter.cpp 2011-08-25 14:16:01 +0000 |
1047 | @@ -0,0 +1,57 @@ |
1048 | +/* |
1049 | + * Copyright (C) 2011 Canonical, Ltd. |
1050 | + * |
1051 | + * Authors: |
1052 | + * Florian Boucault <florian.boucault@canonical.com> |
1053 | + * |
1054 | + * This program is free software; you can redistribute it and/or modify |
1055 | + * it under the terms of the GNU General Public License as published by |
1056 | + * the Free Software Foundation; version 3. |
1057 | + * |
1058 | + * This program is distributed in the hope that it will be useful, |
1059 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1060 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1061 | + * GNU General Public License for more details. |
1062 | + * |
1063 | + * You should have received a copy of the GNU General Public License |
1064 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1065 | + */ |
1066 | + |
1067 | +// Self |
1068 | +#include "radiooptionfilter.h" |
1069 | + |
1070 | +RadioOptionFilter::RadioOptionFilter(QObject *parent) : |
1071 | + Filter(parent), m_unityRadioOptionFilter(NULL), m_options(NULL) |
1072 | +{ |
1073 | +} |
1074 | + |
1075 | +FilterOptions* RadioOptionFilter::options() const |
1076 | +{ |
1077 | + return m_options; |
1078 | +} |
1079 | + |
1080 | +void RadioOptionFilter::setUnityFilter(unity::dash::Filter::Ptr filter) |
1081 | +{ |
1082 | + Filter::setUnityFilter(filter); |
1083 | + m_unityRadioOptionFilter = std::dynamic_pointer_cast<unity::dash::RadioOptionFilter>(m_unityFilter); |
1084 | + |
1085 | + onOptionsChanged(m_unityRadioOptionFilter->options); |
1086 | +} |
1087 | + |
1088 | +void RadioOptionFilter::onOptionsChanged(unity::dash::RadioOptionFilter::RadioOptions options) |
1089 | +{ |
1090 | + if (m_options != NULL) { |
1091 | + // FIXME: should disconnect from m_unityFilter's signals |
1092 | + delete m_options; |
1093 | + m_options = NULL; |
1094 | + } |
1095 | + m_options = new FilterOptions(m_unityRadioOptionFilter->options, |
1096 | + m_unityRadioOptionFilter->option_added, |
1097 | + m_unityRadioOptionFilter->option_removed); |
1098 | + /* Property change signals */ |
1099 | + m_unityRadioOptionFilter->options.changed.connect(sigc::mem_fun(this, &RadioOptionFilter::onOptionsChanged)); |
1100 | + |
1101 | + Q_EMIT optionsChanged(); |
1102 | +} |
1103 | + |
1104 | +#include "radiooptionfilter.moc" |
1105 | |
1106 | === added file 'libunity-2d-private/src/radiooptionfilter.h' |
1107 | --- libunity-2d-private/src/radiooptionfilter.h 1970-01-01 00:00:00 +0000 |
1108 | +++ libunity-2d-private/src/radiooptionfilter.h 2011-08-25 14:16:01 +0000 |
1109 | @@ -0,0 +1,61 @@ |
1110 | +/* |
1111 | + * Copyright (C) 2011 Canonical, Ltd. |
1112 | + * |
1113 | + * Authors: |
1114 | + * Florian Boucault <florian.boucault@canonical.com> |
1115 | + * |
1116 | + * This program is free software; you can redistribute it and/or modify |
1117 | + * it under the terms of the GNU General Public License as published by |
1118 | + * the Free Software Foundation; version 3. |
1119 | + * |
1120 | + * This program is distributed in the hope that it will be useful, |
1121 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1122 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1123 | + * GNU General Public License for more details. |
1124 | + * |
1125 | + * You should have received a copy of the GNU General Public License |
1126 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1127 | + */ |
1128 | + |
1129 | +#ifndef RADIOOPTIONFILTER_H |
1130 | +#define RADIOOPTIONFILTER_H |
1131 | + |
1132 | +// Qt |
1133 | +#include <QObject> |
1134 | +#include <QMetaType> |
1135 | + |
1136 | +// libunity-core |
1137 | +#include <UnityCore/RadioOptionFilter.h> |
1138 | + |
1139 | +// Local |
1140 | +#include "filter.h" |
1141 | +#include "filteroption.h" |
1142 | + |
1143 | +class RadioOptionFilter : public Filter |
1144 | +{ |
1145 | + Q_OBJECT |
1146 | + |
1147 | + Q_PROPERTY(FilterOptions* options READ options NOTIFY optionsChanged) |
1148 | + |
1149 | +public: |
1150 | + explicit RadioOptionFilter(QObject *parent = 0); |
1151 | + |
1152 | + /* getters */ |
1153 | + FilterOptions* options() const; |
1154 | + |
1155 | +Q_SIGNALS: |
1156 | + void optionsChanged(); |
1157 | + |
1158 | +protected: |
1159 | + virtual void setUnityFilter(unity::dash::Filter::Ptr filter); |
1160 | + |
1161 | +private: |
1162 | + unity::dash::RadioOptionFilter::Ptr m_unityRadioOptionFilter; |
1163 | + FilterOptions* m_options; |
1164 | + |
1165 | + void onOptionsChanged(unity::dash::RadioOptionFilter::RadioOptions); |
1166 | +}; |
1167 | + |
1168 | +Q_DECLARE_METATYPE(RadioOptionFilter*) |
1169 | + |
1170 | +#endif // RADIOOPTIONFILTER_H |
1171 | |
1172 | === modified file 'libunity-2d-private/src/ratingsfilter.cpp' |
1173 | --- libunity-2d-private/src/ratingsfilter.cpp 2011-08-02 15:10:09 +0000 |
1174 | +++ libunity-2d-private/src/ratingsfilter.cpp 2011-08-25 14:16:01 +0000 |
1175 | @@ -21,7 +21,7 @@ |
1176 | #include "ratingsfilter.h" |
1177 | |
1178 | RatingsFilter::RatingsFilter(QObject *parent) : |
1179 | - Filter(parent) |
1180 | + Filter(parent), m_unityRatingsFilter(NULL) |
1181 | { |
1182 | } |
1183 | |
1184 | @@ -30,6 +30,11 @@ |
1185 | return m_unityRatingsFilter->rating(); |
1186 | } |
1187 | |
1188 | +void RatingsFilter::setRating(float rating) |
1189 | +{ |
1190 | + m_unityRatingsFilter->rating = rating; |
1191 | +} |
1192 | + |
1193 | void RatingsFilter::setUnityFilter(unity::dash::Filter::Ptr filter) |
1194 | { |
1195 | if (m_unityFilter != NULL) { |
1196 | |
1197 | === modified file 'libunity-2d-private/src/ratingsfilter.h' |
1198 | --- libunity-2d-private/src/ratingsfilter.h 2011-08-02 15:10:09 +0000 |
1199 | +++ libunity-2d-private/src/ratingsfilter.h 2011-08-25 14:16:01 +0000 |
1200 | @@ -34,7 +34,7 @@ |
1201 | { |
1202 | Q_OBJECT |
1203 | |
1204 | - Q_PROPERTY(float rating READ rating NOTIFY ratingChanged) |
1205 | + Q_PROPERTY(float rating READ rating WRITE setRating NOTIFY ratingChanged) |
1206 | |
1207 | public: |
1208 | explicit RatingsFilter(QObject *parent = 0); |
1209 | @@ -42,11 +42,15 @@ |
1210 | /* getters */ |
1211 | float rating() const; |
1212 | |
1213 | - virtual void setUnityFilter(unity::dash::Filter::Ptr filter); |
1214 | + /* setters */ |
1215 | + void setRating(float rating); |
1216 | |
1217 | Q_SIGNALS: |
1218 | void ratingChanged(float); |
1219 | |
1220 | +protected: |
1221 | + virtual void setUnityFilter(unity::dash::Filter::Ptr filter); |
1222 | + |
1223 | private: |
1224 | unity::dash::RatingsFilter::Ptr m_unityRatingsFilter; |
1225 | }; |
1226 | |
1227 | === modified file 'places/ButtonBackground.qml' |
1228 | --- places/ButtonBackground.qml 2011-08-23 17:34:44 +0000 |
1229 | +++ places/ButtonBackground.qml 2011-08-25 14:16:01 +0000 |
1230 | @@ -1,3 +1,21 @@ |
1231 | +/* |
1232 | + * This file is part of unity-2d |
1233 | + * |
1234 | + * Copyright 2010-2011 Canonical Ltd. |
1235 | + * |
1236 | + * This program is free software; you can redistribute it and/or modify |
1237 | + * it under the terms of the GNU General Public License as published by |
1238 | + * the Free Software Foundation; version 3. |
1239 | + * |
1240 | + * This program is distributed in the hope that it will be useful, |
1241 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1242 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1243 | + * GNU General Public License for more details. |
1244 | + * |
1245 | + * You should have received a copy of the GNU General Public License |
1246 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1247 | + */ |
1248 | + |
1249 | import QtQuick 1.0 |
1250 | |
1251 | Item { |
1252 | |
1253 | === renamed file 'places/SearchRefineOption.qml' => 'places/Filter.qml' |
1254 | --- places/SearchRefineOption.qml 2011-08-11 08:17:14 +0000 |
1255 | +++ places/Filter.qml 2011-08-25 14:16:01 +0000 |
1256 | @@ -19,9 +19,10 @@ |
1257 | import QtQuick 1.0 |
1258 | |
1259 | FocusScope { |
1260 | - property string title |
1261 | + id: filterView |
1262 | + |
1263 | property variant lens |
1264 | + property variant filterModel |
1265 | |
1266 | - width: parent.width |
1267 | height: childrenRect.height |
1268 | } |
1269 | |
1270 | === renamed file 'places/SearchRefineOptionType.qml' => 'places/FilterCheckoption.qml' |
1271 | --- places/SearchRefineOptionType.qml 2011-08-25 13:08:52 +0000 |
1272 | +++ places/FilterCheckoption.qml 2011-08-25 14:16:01 +0000 |
1273 | @@ -18,39 +18,16 @@ |
1274 | |
1275 | import QtQuick 1.0 |
1276 | |
1277 | -SearchRefineOption { |
1278 | - id: searchRefineOption |
1279 | - |
1280 | - Item { |
1281 | - id: header |
1282 | - |
1283 | - Accessible.name: searchRefineOption.title |
1284 | - |
1285 | - KeyNavigation.down: filters |
1286 | - |
1287 | - focus: true |
1288 | - anchors.top: parent.top |
1289 | - anchors.left: parent.left |
1290 | - anchors.right: parent.right |
1291 | - height: childrenRect.height |
1292 | - |
1293 | - TextCustom { |
1294 | - id: title |
1295 | - |
1296 | - anchors.top: parent.top |
1297 | - anchors.left: parent.left |
1298 | - |
1299 | - text: searchRefineOption.title |
1300 | - fontSize: "large" |
1301 | - font.bold: true |
1302 | - font.underline: ( parent.state == "selected" || parent.state == "hovered" ) |
1303 | - } |
1304 | - } |
1305 | +Filter { |
1306 | + id: filterView |
1307 | + |
1308 | + height: filters.height |
1309 | |
1310 | GridViewWithSpacing { |
1311 | id: filters |
1312 | |
1313 | - columns: 2 |
1314 | + columns: ( filterView.filterModel.id == "genre" |
1315 | + || filterView.filterModel.id == "modified" ) ? 3 : 2 |
1316 | rows: Math.ceil(count/columns) |
1317 | |
1318 | horizontalSpacing: 10 |
1319 | @@ -59,17 +36,16 @@ |
1320 | cellWidth: width/columns |
1321 | delegateHeight: 30 |
1322 | |
1323 | - anchors.top: header.bottom |
1324 | - anchors.topMargin: 15 |
1325 | height: cellHeight * rows |
1326 | boundsBehavior: Flickable.StopAtBounds |
1327 | |
1328 | + focus: true |
1329 | anchors.left: parent.left |
1330 | anchors.right: parent.right |
1331 | + anchors.top: parent.top |
1332 | |
1333 | /* Make sure the first item is selected when getting the focus for the first time */ |
1334 | currentIndex: 0 |
1335 | - KeyNavigation.up: header |
1336 | |
1337 | delegate: FocusScope { |
1338 | TickBox { |
1339 | @@ -77,15 +53,12 @@ |
1340 | width: filters.delegateWidth |
1341 | height: filters.delegateHeight |
1342 | x: filters.delegateX(model.index % filters.columns) |
1343 | - /* Not checking for lens != undefined leads to a segfault |
1344 | - when switching lenses */ |
1345 | - text: lens != undefined ? column_0 : "" |
1346 | - checked: dash.currentPage.model.activeSection == model.index |
1347 | - |
1348 | - onClicked: lens.activeSection = model.index |
1349 | + text: item.name |
1350 | + checked: item.active |
1351 | + onClicked: item.active = !item.active |
1352 | } |
1353 | } |
1354 | |
1355 | - model: lens != undefined ? lens.sections : undefined |
1356 | + model: filterView.filterModel.options |
1357 | } |
1358 | } |
1359 | |
1360 | === added file 'places/FilterLoader.qml' |
1361 | --- places/FilterLoader.qml 1970-01-01 00:00:00 +0000 |
1362 | +++ places/FilterLoader.qml 2011-08-25 14:16:01 +0000 |
1363 | @@ -0,0 +1,117 @@ |
1364 | +/* |
1365 | + * This file is part of unity-2d |
1366 | + * |
1367 | + * Copyright 2010-2011 Canonical Ltd. |
1368 | + * |
1369 | + * This program is free software; you can redistribute it and/or modify |
1370 | + * it under the terms of the GNU General Public License as published by |
1371 | + * the Free Software Foundation; version 3. |
1372 | + * |
1373 | + * This program is distributed in the hope that it will be useful, |
1374 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1375 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1376 | + * GNU General Public License for more details. |
1377 | + * |
1378 | + * You should have received a copy of the GNU General Public License |
1379 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1380 | + */ |
1381 | + |
1382 | +import QtQuick 1.0 |
1383 | +import "utils.js" as Utils |
1384 | + |
1385 | +FocusScope { |
1386 | + id: filterLoader |
1387 | + |
1388 | + property variant lens |
1389 | + property variant filterModel |
1390 | + property bool isFirst |
1391 | + |
1392 | + height: childrenRect.height |
1393 | + |
1394 | + FocusScope { |
1395 | + id: header |
1396 | + |
1397 | + function accessibleDescription() { |
1398 | + if (filterModel.filtering) { |
1399 | + return u2d.tr("Filter %1 active").arg(filterModel.name) |
1400 | + } else { |
1401 | + return u2d.tr("Filter %1 inactive").arg(filterModel.name) |
1402 | + } |
1403 | + } |
1404 | + |
1405 | + Accessible.name: accessibleDescription() |
1406 | + |
1407 | + KeyNavigation.down: filterView |
1408 | + |
1409 | + focus: true |
1410 | + anchors.top: parent.top |
1411 | + anchors.left: parent.left |
1412 | + anchors.right: parent.right |
1413 | + height: childrenRect.height |
1414 | + |
1415 | + Rectangle { |
1416 | + id: separatorLine |
1417 | + |
1418 | + color: "#21ffffff" |
1419 | + |
1420 | + height: 1 |
1421 | + visible: !isFirst |
1422 | + anchors.top: parent.top |
1423 | + anchors.left: parent.left |
1424 | + anchors.right: parent.right |
1425 | + } |
1426 | + |
1427 | + TextCustom { |
1428 | + id: title |
1429 | + |
1430 | + anchors.verticalCenter: clearButton.verticalCenter |
1431 | + anchors.topMargin: isFirst ? 0 : 13 |
1432 | + anchors.left: parent.left |
1433 | + |
1434 | + text: u2d.tr(filterModel.name) |
1435 | + fontSize: "large" |
1436 | + font.bold: true |
1437 | + font.underline: ( parent.state == "selected" || parent.state == "hovered" ) |
1438 | + } |
1439 | + |
1440 | + TickBox { |
1441 | + id: clearButton |
1442 | + |
1443 | + focus: true |
1444 | + |
1445 | + /* FIXME: should be 48px wide in English but made bigger to |
1446 | + accomodate for more verbose languages */ |
1447 | + width: 55 |
1448 | + height: 30 |
1449 | + anchors.top: parent.top |
1450 | + anchors.topMargin: isFirst ? 0 : 13 |
1451 | + anchors.right: parent.right |
1452 | + |
1453 | + text: u2d.tr("All") |
1454 | + checked: !filterModel.filtering |
1455 | + onClicked: filterModel.clear() |
1456 | + } |
1457 | + } |
1458 | + |
1459 | + Loader { |
1460 | + id: filterView |
1461 | + |
1462 | + KeyNavigation.up: header |
1463 | + anchors.top: header.bottom |
1464 | + anchors.topMargin: 15 |
1465 | + anchors.left: parent.left |
1466 | + anchors.right: parent.right |
1467 | + |
1468 | + source: Utils.convertToCamelCase(filterModel.rendererName) + ".qml" |
1469 | + onStatusChanged: { |
1470 | + if (status == Loader.Error) { |
1471 | + console.log("Failed to load filter renderer", filterModel.rendererName) |
1472 | + } |
1473 | + } |
1474 | + |
1475 | + Binding { target: filterView.item; property: "lens"; value: filterLoader.lens } |
1476 | + Binding { target: filterView.item; property: "filterModel"; value: filterLoader.filterModel } |
1477 | + |
1478 | + onLoaded: item.focus = true |
1479 | + } |
1480 | +} |
1481 | |
1482 | === added file 'places/FilterMultirange.qml' |
1483 | --- places/FilterMultirange.qml 1970-01-01 00:00:00 +0000 |
1484 | +++ places/FilterMultirange.qml 2011-08-25 14:16:01 +0000 |
1485 | @@ -0,0 +1,37 @@ |
1486 | +/* |
1487 | + * This file is part of unity-2d |
1488 | + * |
1489 | + * Copyright 2010-2011 Canonical Ltd. |
1490 | + * |
1491 | + * This program is free software; you can redistribute it and/or modify |
1492 | + * it under the terms of the GNU General Public License as published by |
1493 | + * the Free Software Foundation; version 3. |
1494 | + * |
1495 | + * This program is distributed in the hope that it will be useful, |
1496 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1497 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1498 | + * GNU General Public License for more details. |
1499 | + * |
1500 | + * You should have received a copy of the GNU General Public License |
1501 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1502 | + */ |
1503 | + |
1504 | +import QtQuick 1.0 |
1505 | + |
1506 | +Filter { |
1507 | + id: filterView |
1508 | + |
1509 | + height: filters.height |
1510 | + |
1511 | + MultiRangeView { |
1512 | + id: filters |
1513 | + |
1514 | + focus: true |
1515 | + anchors.left: parent.left |
1516 | + anchors.right: parent.right |
1517 | + anchors.top: parent.top |
1518 | + height: 30 |
1519 | + |
1520 | + model: filterView.filterModel.options |
1521 | + } |
1522 | +} |
1523 | |
1524 | === renamed file 'places/SearchRefine.qml' => 'places/FilterPane.qml' |
1525 | --- places/SearchRefine.qml 2011-08-25 13:08:52 +0000 |
1526 | +++ places/FilterPane.qml 2011-08-25 14:16:01 +0000 |
1527 | @@ -20,7 +20,7 @@ |
1528 | import Effects 1.0 |
1529 | |
1530 | FocusScope { |
1531 | - id: searchRefine |
1532 | + id: filterPane |
1533 | |
1534 | property bool folded: true |
1535 | property int headerHeight |
1536 | @@ -51,12 +51,12 @@ |
1537 | color: "white" |
1538 | } |
1539 | |
1540 | - onClicked: searchRefine.folded = !searchRefine.folded |
1541 | + onClicked: filterPane.folded = !filterPane.folded |
1542 | |
1543 | focus: true |
1544 | |
1545 | /* Do not navigate down to the options if they are folded */ |
1546 | - KeyNavigation.down: !searchRefine.folded ? options : header |
1547 | + KeyNavigation.down: !filterPane.folded ? options : header |
1548 | |
1549 | anchors.left: parent.left |
1550 | anchors.right: parent.right |
1551 | @@ -79,25 +79,17 @@ |
1552 | FoldingArrow { |
1553 | id: arrow |
1554 | |
1555 | - folded: searchRefine.folded |
1556 | + folded: filterPane.folded |
1557 | |
1558 | anchors.verticalCenter: title.verticalCenter |
1559 | anchors.right: parent.right |
1560 | } |
1561 | } |
1562 | |
1563 | - VisualItemModel { |
1564 | - id: optionsModel |
1565 | - |
1566 | - SearchRefineOptionType { |
1567 | - title: u2d.tr("Type") |
1568 | - lens: searchRefine.lens |
1569 | - } |
1570 | - } |
1571 | - |
1572 | ListView { |
1573 | id: options |
1574 | |
1575 | + clip: true |
1576 | opacity: folded ? 0.0 : 1.0 |
1577 | Behavior on opacity {NumberAnimation {duration: 100; easing.type: Easing.InOutQuad}} |
1578 | |
1579 | @@ -109,6 +101,7 @@ |
1580 | anchors.topMargin: 7 |
1581 | anchors.bottom: parent.bottom |
1582 | orientation: ListView.Vertical |
1583 | + spacing: 12 |
1584 | |
1585 | /* Make sure the first section is selected when getting the focus */ |
1586 | currentIndex: 0 |
1587 | @@ -123,6 +116,16 @@ |
1588 | /* Non-draggable when all items are visible */ |
1589 | boundsBehavior: Flickable.StopAtBounds |
1590 | |
1591 | - model: optionsModel |
1592 | + model: filterPane.lens != undefined ? filterPane.lens.filters : undefined |
1593 | + /* Dynamically load the QML file corresponding to filter.rendererName. |
1594 | + For example, if filter.rendererName == "filter-checkoption" then |
1595 | + load "FilterCheckoption.qml". |
1596 | + */ |
1597 | + delegate: FilterLoader { |
1598 | + width: ListView.view.width |
1599 | + lens: filterPane.lens |
1600 | + filterModel: filter |
1601 | + isFirst: index == 0 |
1602 | + } |
1603 | } |
1604 | } |
1605 | |
1606 | === added file 'places/FilterRadiooption.qml' |
1607 | --- places/FilterRadiooption.qml 1970-01-01 00:00:00 +0000 |
1608 | +++ places/FilterRadiooption.qml 2011-08-25 14:16:01 +0000 |
1609 | @@ -0,0 +1,22 @@ |
1610 | +/* |
1611 | + * This file is part of unity-2d |
1612 | + * |
1613 | + * Copyright 2010-2011 Canonical Ltd. |
1614 | + * |
1615 | + * This program is free software; you can redistribute it and/or modify |
1616 | + * it under the terms of the GNU General Public License as published by |
1617 | + * the Free Software Foundation; version 3. |
1618 | + * |
1619 | + * This program is distributed in the hope that it will be useful, |
1620 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1621 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1622 | + * GNU General Public License for more details. |
1623 | + * |
1624 | + * You should have received a copy of the GNU General Public License |
1625 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1626 | + */ |
1627 | + |
1628 | +import QtQuick 1.0 |
1629 | + |
1630 | +FilterCheckoption { |
1631 | +} |
1632 | |
1633 | === added file 'places/FilterRatings.qml' |
1634 | --- places/FilterRatings.qml 1970-01-01 00:00:00 +0000 |
1635 | +++ places/FilterRatings.qml 2011-08-25 14:16:01 +0000 |
1636 | @@ -0,0 +1,47 @@ |
1637 | +/* |
1638 | + * This file is part of unity-2d |
1639 | + * |
1640 | + * Copyright 2010-2011 Canonical Ltd. |
1641 | + * |
1642 | + * This program is free software; you can redistribute it and/or modify |
1643 | + * it under the terms of the GNU General Public License as published by |
1644 | + * the Free Software Foundation; version 3. |
1645 | + * |
1646 | + * This program is distributed in the hope that it will be useful, |
1647 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1648 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1649 | + * GNU General Public License for more details. |
1650 | + * |
1651 | + * You should have received a copy of the GNU General Public License |
1652 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1653 | + */ |
1654 | + |
1655 | +import QtQuick 1.0 |
1656 | + |
1657 | +Filter { |
1658 | + id: filterView |
1659 | + |
1660 | + height: rating.height |
1661 | + |
1662 | + RatingStars { |
1663 | + id: rating |
1664 | + |
1665 | + height: childrenRect.height |
1666 | + |
1667 | + focus: true |
1668 | + anchors.left: parent.left |
1669 | + anchors.right: parent.right |
1670 | + anchors.top: parent.top |
1671 | + |
1672 | + size: 5 |
1673 | + spacing: 7 |
1674 | + rating: filterView.filterModel.rating |
1675 | + Binding { |
1676 | + target: filterView.filterModel |
1677 | + property: "rating" |
1678 | + value: rating.rating |
1679 | + } |
1680 | + |
1681 | + enabled: true |
1682 | + } |
1683 | +} |
1684 | |
1685 | === added file 'places/MultiRangeButton.qml' |
1686 | --- places/MultiRangeButton.qml 1970-01-01 00:00:00 +0000 |
1687 | +++ places/MultiRangeButton.qml 2011-08-25 14:16:01 +0000 |
1688 | @@ -0,0 +1,65 @@ |
1689 | +/* |
1690 | + * This file is part of unity-2d |
1691 | + * |
1692 | + * Copyright 2010-2011 Canonical Ltd. |
1693 | + * |
1694 | + * This program is free software; you can redistribute it and/or modify |
1695 | + * it under the terms of the GNU General Public License as published by |
1696 | + * the Free Software Foundation; version 3. |
1697 | + * |
1698 | + * This program is distributed in the hope that it will be useful, |
1699 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1700 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1701 | + * GNU General Public License for more details. |
1702 | + * |
1703 | + * You should have received a copy of the GNU General Public License |
1704 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1705 | + */ |
1706 | + |
1707 | +import QtQuick 1.0 |
1708 | +import Effects 1.0 |
1709 | + |
1710 | +AbstractButton { |
1711 | + id: multiRangeButton |
1712 | + |
1713 | + property string text |
1714 | + property bool checked: false |
1715 | + property bool isLast: false |
1716 | + |
1717 | + Accessible.name: text |
1718 | + |
1719 | + TextCustom { |
1720 | + id: label |
1721 | + anchors.top: parent.top |
1722 | + anchors.bottom: parent.bottom |
1723 | + anchors.left: parent.left |
1724 | + anchors.leftMargin: 1 |
1725 | + width: parent.width-1 |
1726 | + horizontalAlignment: Text.AlignHCenter |
1727 | + verticalAlignment: Text.AlignVCenter |
1728 | + fontSize: "small" |
1729 | + color: "white" |
1730 | + text: multiRangeButton.text |
1731 | + elide: Text.ElideRight |
1732 | + |
1733 | + effect: DropShadow { |
1734 | + blurRadius: 8 |
1735 | + color: "white" |
1736 | + offset.x: 0 |
1737 | + offset.y: 0 |
1738 | + enabled: ( multiRangeButton.state == "selected" ) |
1739 | + } |
1740 | + } |
1741 | + |
1742 | + Rectangle { |
1743 | + id: separatorLine |
1744 | + |
1745 | + color: "#21ffffff" |
1746 | + |
1747 | + width: 1 |
1748 | + visible: ( !isLast ) |
1749 | + anchors.top: parent.top |
1750 | + anchors.bottom: parent.bottom |
1751 | + anchors.left: parent.right |
1752 | + } |
1753 | +} |
1754 | |
1755 | === added file 'places/MultiRangeSelectionBar.qml' |
1756 | --- places/MultiRangeSelectionBar.qml 1970-01-01 00:00:00 +0000 |
1757 | +++ places/MultiRangeSelectionBar.qml 2011-08-25 14:16:01 +0000 |
1758 | @@ -0,0 +1,64 @@ |
1759 | +/* |
1760 | + * This file is part of unity-2d |
1761 | + * |
1762 | + * Copyright 2010-2011 Canonical Ltd. |
1763 | + * |
1764 | + * This program is free software; you can redistribute it and/or modify |
1765 | + * it under the terms of the GNU General Public License as published by |
1766 | + * the Free Software Foundation; version 3. |
1767 | + * |
1768 | + * This program is distributed in the hope that it will be useful, |
1769 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1770 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1771 | + * GNU General Public License for more details. |
1772 | + * |
1773 | + * You should have received a copy of the GNU General Public License |
1774 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1775 | + */ |
1776 | + |
1777 | +import QtQuick 1.0 |
1778 | + |
1779 | +Item { |
1780 | + id: multiRangeSelectionBar |
1781 | + |
1782 | + property bool isFirst: true |
1783 | + property bool isLast: false |
1784 | + property int leftPos: 0 |
1785 | + property int rightPos: 100 |
1786 | + |
1787 | + x: leftPos |
1788 | + width: rightPos - leftPos |
1789 | + height: childrenRect.height |
1790 | + |
1791 | + Image { |
1792 | + id: leftBorder |
1793 | + source: (isFirst) ? "artwork/multirange_selection_left_first.png" |
1794 | + : "artwork/multirange_selection_left.png" |
1795 | + width: sourceSize.width |
1796 | + height: sourceSize.height |
1797 | + anchors.left: parent.left |
1798 | + anchors.top: parent.top |
1799 | + } |
1800 | + |
1801 | + Image { |
1802 | + id: background |
1803 | + source: "artwork/multirange_selection_middle.png" |
1804 | + width: sourceSize.width |
1805 | + height: sourceSize.height |
1806 | + anchors.top: parent.top |
1807 | + anchors.left: leftBorder.right |
1808 | + anchors.right: rightBorder.left |
1809 | + fillMode: Image.TileHorizontally |
1810 | + } |
1811 | + |
1812 | + Image { |
1813 | + id: rightBorder |
1814 | + source: (isLast) ? "artwork/multirange_selection_right_last.png" |
1815 | + : "artwork/multirange_selection_right.png" |
1816 | + width: sourceSize.width |
1817 | + height: sourceSize.height |
1818 | + anchors.top: parent.top |
1819 | + anchors.right: parent.right |
1820 | + } |
1821 | + |
1822 | +} |
1823 | |
1824 | === added file 'places/MultiRangeView.qml' |
1825 | --- places/MultiRangeView.qml 1970-01-01 00:00:00 +0000 |
1826 | +++ places/MultiRangeView.qml 2011-08-25 14:16:01 +0000 |
1827 | @@ -0,0 +1,97 @@ |
1828 | +/* |
1829 | + * This file is part of unity-2d |
1830 | + * |
1831 | + * Copyright 2010-2011 Canonical Ltd. |
1832 | + * |
1833 | + * This program is free software; you can redistribute it and/or modify |
1834 | + * it under the terms of the GNU General Public License as published by |
1835 | + * the Free Software Foundation; version 3. |
1836 | + * |
1837 | + * This program is distributed in the hope that it will be useful, |
1838 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1839 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1840 | + * GNU General Public License for more details. |
1841 | + * |
1842 | + * You should have received a copy of the GNU General Public License |
1843 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1844 | + */ |
1845 | + |
1846 | +import QtQuick 1.0 |
1847 | + |
1848 | +FocusScope { |
1849 | + id: multiRangeView |
1850 | + |
1851 | + property alias model: list.model |
1852 | + property alias count: list.count |
1853 | + property int cellWidth: Math.floor(width / count) |
1854 | + |
1855 | + /* Keep track of active cells with array, from which determine index |
1856 | + of leftmost and rightmost active cells.*/ |
1857 | + property variant activeCells: Array(count) |
1858 | + property int leftActiveCell: -1 |
1859 | + property int rightActiveCell: -1 |
1860 | + |
1861 | + function cellActivationChanged(cellId, state) { |
1862 | + var tmp = activeCells |
1863 | + tmp[cellId] = state |
1864 | + activeCells = tmp |
1865 | + setSelectionBarPosition() |
1866 | + } |
1867 | + |
1868 | + function setSelectionBarPosition() { |
1869 | + leftActiveCell = activeCells.indexOf(true) |
1870 | + rightActiveCell = activeCells.lastIndexOf(true); |
1871 | + } |
1872 | + |
1873 | + Rectangle { |
1874 | + id: container |
1875 | + |
1876 | + /* FIXME: Rectangle's borders grow half inside and half outside of the |
1877 | + rectangle. In order to avoid it being clipped, we adjust its size |
1878 | + and position depending on its border's width. |
1879 | + |
1880 | + Ref.: http://lists.qt.nokia.com/pipermail/qt-qml/2010-May/000264.html |
1881 | + */ |
1882 | + x: Math.floor(border.width / 2) |
1883 | + y: Math.floor(border.width / 2) |
1884 | + width: parent.width - border.width |
1885 | + height: parent.height - border.width |
1886 | + |
1887 | + border.color: "#21ffffff" // 80% opaque white |
1888 | + border.width: 1 |
1889 | + color: "transparent" |
1890 | + radius: 5 |
1891 | + } |
1892 | + |
1893 | + ListView { |
1894 | + id: list |
1895 | + |
1896 | + anchors.fill: parent |
1897 | + orientation: ListView.Horizontal |
1898 | + focus: true |
1899 | + boundsBehavior: Flickable.StopAtBounds |
1900 | + |
1901 | + delegate: MultiRangeButton { |
1902 | + height: ListView.view.height |
1903 | + width: cellWidth |
1904 | + text: item.name |
1905 | + checked: item.active |
1906 | + onClicked: item.active = !item.active |
1907 | + onCheckedChanged: cellActivationChanged(model.index, checked) |
1908 | + isLast: ( model.index == count-1 ) |
1909 | + Component.onCompleted: cellActivationChanged(model.index, item.active) |
1910 | + } |
1911 | + } |
1912 | + |
1913 | + MultiRangeSelectionBar { |
1914 | + id: selectionBar |
1915 | + |
1916 | + visible: ( leftActiveCell != -1 && rightActiveCell != -1 ) |
1917 | + isFirst: ( leftActiveCell == 0 ) |
1918 | + isLast: ( rightActiveCell == count-1 ) |
1919 | + leftPos: ( leftActiveCell == 0 ) ? 0 : leftActiveCell*cellWidth-2 |
1920 | + /* Hack: Rounding errors can mean the right of the selectionBar fails |
1921 | + to wholly cover the container Rectangle (and its border) */ |
1922 | + rightPos: ( rightActiveCell == count-1 ) ? parent.width : (rightActiveCell+1)*cellWidth+3 |
1923 | + } |
1924 | +} |
1925 | |
1926 | === added file 'places/RatingStars.qml' |
1927 | --- places/RatingStars.qml 1970-01-01 00:00:00 +0000 |
1928 | +++ places/RatingStars.qml 2011-08-25 14:16:01 +0000 |
1929 | @@ -0,0 +1,129 @@ |
1930 | +/* |
1931 | + * This file is part of unity-2d |
1932 | + * |
1933 | + * Copyright 2010-2011 Canonical Ltd. |
1934 | + * |
1935 | + * This program is free software; you can redistribute it and/or modify |
1936 | + * it under the terms of the GNU General Public License as published by |
1937 | + * the Free Software Foundation; version 3. |
1938 | + * |
1939 | + * This program is distributed in the hope that it will be useful, |
1940 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1941 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1942 | + * GNU General Public License for more details. |
1943 | + * |
1944 | + * You should have received a copy of the GNU General Public License |
1945 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1946 | + */ |
1947 | + |
1948 | +import QtQuick 1.0 |
1949 | + |
1950 | +Item { |
1951 | + id: ratingStars |
1952 | + |
1953 | + property real rating: 3.7 |
1954 | + property int size: 5 /* Number of stars */ |
1955 | + property alias enabled: starsMouseArea.enabled |
1956 | + property alias spacing: stars.spacing |
1957 | + |
1958 | + /* Configure icon size to use. Requires icon files named: |
1959 | + - artwork/star_empty-${starIconSize}.png |
1960 | + - artwork/star_full-${starIconSize}.png |
1961 | + */ |
1962 | + property int starIconSize: 32 |
1963 | + |
1964 | + width: stars.width |
1965 | + height: stars.height |
1966 | + |
1967 | + function clamp(x, min, max) { |
1968 | + return Math.max(Math.min(x, max), min) |
1969 | + } |
1970 | + |
1971 | + function incrementRating() { |
1972 | + /* Make math easier since half rating accepted */ |
1973 | + var double_rating = rating * 2 |
1974 | + |
1975 | + if ( double_rating % 1 > 0){ /* if non-integer, round up */ |
1976 | + double_rating = Math.ceil(double_rating) |
1977 | + } |
1978 | + else { |
1979 | + double_rating = clamp(double_rating+1, 0, size * 2) |
1980 | + } |
1981 | + rating = double_rating / 2 |
1982 | + } |
1983 | + |
1984 | + function decrementRating() { |
1985 | + var double_rating = rating * 2 |
1986 | + |
1987 | + if ( double_rating % 1 > 0){ /* if non-integer, round down */ |
1988 | + double_rating = Math.ceil(double_rating) |
1989 | + } |
1990 | + else { |
1991 | + double_rating = clamp(double_rating-1, 0, size * 2) |
1992 | + } |
1993 | + rating = double_rating / 2 |
1994 | + } |
1995 | + |
1996 | + Keys.onPressed: if (handleKeyPress(event.key)) event.accepted = true |
1997 | + function handleKeyPress(key) { |
1998 | + switch (key) { |
1999 | + case Qt.Key_Right: |
2000 | + incrementRating() |
2001 | + return true |
2002 | + case Qt.Key_Left: |
2003 | + decrementRating() |
2004 | + return true |
2005 | + } |
2006 | + return false |
2007 | + } |
2008 | + |
2009 | + Row { |
2010 | + id: stars |
2011 | + |
2012 | + Repeater { |
2013 | + model: size |
2014 | + Star { |
2015 | + fill: clamp(rating - index, 0, 1) |
2016 | + iconSize: starIconSize |
2017 | + selected: ( ratingStars.activeFocus ) |
2018 | + } |
2019 | + } |
2020 | + } |
2021 | + |
2022 | + MouseArea { |
2023 | + id: starsMouseArea |
2024 | + |
2025 | + /* Calculating Star Rating incorporating inter-star spacing/gap. |
2026 | + |
2027 | + Consider each star+gap as a "unit". Determine what unit the mouse is over, |
2028 | + and remove the width of the gaps to the left from the reported mouse position. |
2029 | + */ |
2030 | + |
2031 | + /* Width of each unit */ |
2032 | + property int unitWidth: starIconSize + stars.spacing |
2033 | + |
2034 | + function calculateRating( posX ){ |
2035 | + /* Small left-hand edge to set zero rating */ |
2036 | + if( posX < 4 ) return 0 |
2037 | + |
2038 | + /* Mouse X coordinate over one unit, relative to that unit's left edge*/ |
2039 | + var posXOverUnit = posX % unitWidth |
2040 | + |
2041 | + /* What unit is the mouse over? This is the integer part of the rating (plus one)*/ |
2042 | + var rating = (posX - posXOverUnit) / unitWidth + 1 |
2043 | + |
2044 | + /* If posX under half the star's width, remove 0.5 from the rating */ |
2045 | + if( posXOverUnit <= (starIconSize/2) ){ |
2046 | + rating = rating - 0.5 |
2047 | + } |
2048 | + return clamp( rating, 0, size ) |
2049 | + } |
2050 | + |
2051 | + anchors.fill: stars |
2052 | + |
2053 | + onPressed: rating = calculateRating(mouseX) |
2054 | + onPositionChanged: { |
2055 | + if (pressed) rating = calculateRating(mouseX) |
2056 | + } |
2057 | + } |
2058 | +} |
2059 | |
2060 | === added file 'places/Star.qml' |
2061 | --- places/Star.qml 1970-01-01 00:00:00 +0000 |
2062 | +++ places/Star.qml 2011-08-25 14:16:01 +0000 |
2063 | @@ -0,0 +1,59 @@ |
2064 | +/* |
2065 | + * This file is part of unity-2d |
2066 | + * |
2067 | + * Copyright 2010-2011 Canonical Ltd. |
2068 | + * |
2069 | + * This program is free software; you can redistribute it and/or modify |
2070 | + * it under the terms of the GNU General Public License as published by |
2071 | + * the Free Software Foundation; version 3. |
2072 | + * |
2073 | + * This program is distributed in the hope that it will be useful, |
2074 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2075 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2076 | + * GNU General Public License for more details. |
2077 | + * |
2078 | + * You should have received a copy of the GNU General Public License |
2079 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2080 | + */ |
2081 | + |
2082 | +import QtQuick 1.0 |
2083 | +import Effects 1.0 |
2084 | + |
2085 | +Item { |
2086 | + /* Fill is between 0 and 1 */ |
2087 | + property real fill: 0 |
2088 | + property int iconSize: 32 |
2089 | + property bool selected: false |
2090 | + |
2091 | + width: childrenRect.width |
2092 | + height: childrenRect.height |
2093 | + |
2094 | + effect: DropShadow { |
2095 | + blurRadius: 8 |
2096 | + color: "white" |
2097 | + offset.x: 0 |
2098 | + offset.y: 0 |
2099 | + } |
2100 | + |
2101 | + Image { |
2102 | + width: sourceSize.width |
2103 | + height: sourceSize.height |
2104 | + |
2105 | + source: ("artwork/star_empty-%1.png").arg(iconSize) |
2106 | + opacity: ( selected ) ? 0.8 : 0.3 |
2107 | + asynchronous: true |
2108 | + } |
2109 | + |
2110 | + Image { |
2111 | + width: Math.ceil(sourceSize.width * fill) |
2112 | + height: sourceSize.height |
2113 | + |
2114 | + source: ("artwork/star_full-%1.png").arg(iconSize) |
2115 | + fillMode: Image.TileHorizontally |
2116 | + asynchronous: true |
2117 | + opacity: ( selected ) ? 1 : 0.8 |
2118 | + clip: true |
2119 | + } |
2120 | +} |
2121 | + |
2122 | + |
2123 | |
2124 | === modified file 'places/TickBox.qml' |
2125 | --- places/TickBox.qml 2011-08-25 13:08:52 +0000 |
2126 | +++ places/TickBox.qml 2011-08-25 14:16:01 +0000 |
2127 | @@ -42,8 +42,17 @@ |
2128 | |
2129 | Rectangle { |
2130 | id: container |
2131 | - width: parent.width |
2132 | - height: parent.height |
2133 | + |
2134 | + /* FIXME: Rectangle's borders grow half inside and half outside of the |
2135 | + rectangle. In order to avoid it being clipped, we adjust its size |
2136 | + and position depending on its border's width. |
2137 | + |
2138 | + Ref.: http://lists.qt.nokia.com/pipermail/qt-qml/2010-May/000264.html |
2139 | + */ |
2140 | + x: Math.floor(border.width / 2) |
2141 | + y: Math.floor(border.width / 2) |
2142 | + width: parent.width - border.width |
2143 | + height: parent.height - border.width |
2144 | border.color: if ( parent.state == "selected") return "white" |
2145 | else if ( checked ) return "#cdffffff" // 13% opaque |
2146 | else return "#21ffffff" // 80% opaque |
2147 | @@ -54,7 +63,7 @@ |
2148 | |
2149 | TextCustom { |
2150 | id: label |
2151 | - anchors.fill: container |
2152 | + anchors.fill: parent |
2153 | width: parent.width |
2154 | horizontalAlignment: Text.AlignHCenter |
2155 | verticalAlignment: Text.AlignVCenter |
2156 | |
2157 | === added file 'places/artwork/multirange_selection_left.png' |
2158 | Binary files places/artwork/multirange_selection_left.png 1970-01-01 00:00:00 +0000 and places/artwork/multirange_selection_left.png 2011-08-25 14:16:01 +0000 differ |
2159 | === added file 'places/artwork/multirange_selection_left_first.png' |
2160 | Binary files places/artwork/multirange_selection_left_first.png 1970-01-01 00:00:00 +0000 and places/artwork/multirange_selection_left_first.png 2011-08-25 14:16:01 +0000 differ |
2161 | === added file 'places/artwork/multirange_selection_middle.png' |
2162 | Binary files places/artwork/multirange_selection_middle.png 1970-01-01 00:00:00 +0000 and places/artwork/multirange_selection_middle.png 2011-08-25 14:16:01 +0000 differ |
2163 | === added file 'places/artwork/multirange_selection_right.png' |
2164 | Binary files places/artwork/multirange_selection_right.png 1970-01-01 00:00:00 +0000 and places/artwork/multirange_selection_right.png 2011-08-25 14:16:01 +0000 differ |
2165 | === added file 'places/artwork/multirange_selection_right_last.png' |
2166 | Binary files places/artwork/multirange_selection_right_last.png 1970-01-01 00:00:00 +0000 and places/artwork/multirange_selection_right_last.png 2011-08-25 14:16:01 +0000 differ |
2167 | === added file 'places/artwork/star_empty-32.png' |
2168 | Binary files places/artwork/star_empty-32.png 1970-01-01 00:00:00 +0000 and places/artwork/star_empty-32.png 2011-08-25 14:16:01 +0000 differ |
2169 | === added file 'places/artwork/star_empty.png' |
2170 | Binary files places/artwork/star_empty.png 1970-01-01 00:00:00 +0000 and places/artwork/star_empty.png 2011-08-25 14:16:01 +0000 differ |
2171 | === added file 'places/artwork/star_full-32.png' |
2172 | Binary files places/artwork/star_full-32.png 1970-01-01 00:00:00 +0000 and places/artwork/star_full-32.png 2011-08-25 14:16:01 +0000 differ |
2173 | === added file 'places/artwork/star_full.png' |
2174 | Binary files places/artwork/star_full.png 1970-01-01 00:00:00 +0000 and places/artwork/star_full.png 2011-08-25 14:16:01 +0000 differ |
2175 | === modified file 'places/dash.qml' |
2176 | --- places/dash.qml 2011-08-23 17:51:00 +0000 |
2177 | +++ places/dash.qml 2011-08-25 14:16:01 +0000 |
2178 | @@ -191,36 +191,31 @@ |
2179 | /* FIXME: check on visible necessary; fixed in Qt Quick 1.1 |
2180 | ref: http://bugreports.qt.nokia.com/browse/QTBUG-15862 |
2181 | */ |
2182 | - KeyNavigation.right: refine_search.visible ? refine_search : search_entry |
2183 | + KeyNavigation.right: filterPane.visible ? filterPane : search_entry |
2184 | KeyNavigation.down: pageLoader |
2185 | |
2186 | anchors.top: parent.top |
2187 | anchors.topMargin: 10 |
2188 | anchors.left: parent.left |
2189 | anchors.leftMargin: 16 |
2190 | - anchors.right: refine_search.left |
2191 | + anchors.right: filterPane.left |
2192 | anchors.rightMargin: 10 |
2193 | |
2194 | height: 53 |
2195 | } |
2196 | |
2197 | - SearchRefine { |
2198 | - id: refine_search |
2199 | + FilterPane { |
2200 | + id: filterPane |
2201 | |
2202 | KeyNavigation.left: search_entry |
2203 | |
2204 | - /* SearchRefine is only to be displayed for lenses, not in the home page */ |
2205 | - /* FIXME: deactivated for now as the Qt bindings for the filters |
2206 | - backend are not ready. Code should be: |
2207 | - |
2208 | - visible: dashView.activeLens != "" |
2209 | - */ |
2210 | - visible: false |
2211 | + /* FilterPane is only to be displayed for lenses, not in the home page */ |
2212 | + visible: dashView.activeLens != "" |
2213 | lens: visible && currentPage != undefined ? currentPage.model : undefined |
2214 | |
2215 | anchors.top: search_entry.anchors.top |
2216 | anchors.topMargin: search_entry.anchors.topMargin |
2217 | - height: parent.height |
2218 | + anchors.bottom: lensBar.top |
2219 | headerHeight: search_entry.height |
2220 | width: 310 |
2221 | anchors.right: parent.right |
2222 | @@ -234,7 +229,7 @@ |
2223 | /* FIXME: check on visible necessary; fixed in Qt Quick 1.1 |
2224 | ref: http://bugreports.qt.nokia.com/browse/QTBUG-15862 |
2225 | */ |
2226 | - KeyNavigation.right: refine_search.visible && !refine_search.folded ? refine_search : pageLoader |
2227 | + KeyNavigation.right: filterPane.visible && !filterPane.folded ? filterPane : pageLoader |
2228 | KeyNavigation.up: search_entry |
2229 | KeyNavigation.down: lensBar |
2230 | |
2231 | @@ -242,8 +237,8 @@ |
2232 | anchors.topMargin: 2 |
2233 | anchors.bottom: lensBar.top |
2234 | anchors.left: parent.left |
2235 | - anchors.right: !refine_search.visible || refine_search.folded ? parent.right : refine_search.left |
2236 | - anchors.rightMargin: !refine_search.visible || refine_search.folded ? 0 : 15 |
2237 | + anchors.right: !filterPane.visible || filterPane.folded ? parent.right : filterPane.left |
2238 | + anchors.rightMargin: !filterPane.visible || filterPane.folded ? 0 : 15 |
2239 | onLoaded: item.focus = true |
2240 | } |
2241 |
There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.