Merge lp:~uriboni/unity-2d/dash-use-search-hint into lp:unity-2d/3.0

Proposed by Ugo Riboni
Status: Merged
Approved by: Aurélien Gâteau
Approved revision: 464
Merged at revision: 472
Proposed branch: lp:~uriboni/unity-2d/dash-use-search-hint
Merge into: lp:unity-2d/3.0
Diff against target: 115 lines (+26/-3)
4 files modified
launcher/UnityApplications/place.cpp (+1/-0)
launcher/UnityApplications/placeentry.cpp (+15/-0)
launcher/UnityApplications/placeentry.h (+7/-0)
places/SearchEntry.qml (+3/-3)
To merge this branch: bzr merge lp:~uriboni/unity-2d/dash-use-search-hint
Reviewer Review Type Date Requested Status
Aurélien Gâteau (community) Approve
Review via email: mp+54322@code.launchpad.net

Description of the change

[dash] Use the SearchHint from the .place file to choose what to display in the search box for a place entry.

To post a comment you must log in.
Revision history for this message
Aurélien Gâteau (agateau) wrote :

Looks good. Just a minor coding style nitpick: setSearchHint argument should be "const QString&", same for searchHintChanged(), that's slightly more efficient. Feel free to mark the MR as approved when this is fixed.

review: Needs Fixing
Revision history for this message
Ugo Riboni (uriboni) wrote :

Let's take care of that in a separate review. All the other set* methods in that class that are of type QString are not using const QString&, so let's keep it consistent for now and fix it later all in one go. I added a FIXME.

463. By Ugo Riboni

Add FIXME to suggest possible optimization later

464. By Ugo Riboni

Optimize property setter

Revision history for this message
Aurélien Gâteau (agateau) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/UnityApplications/place.cpp'
2--- launcher/UnityApplications/place.cpp 2011-03-11 09:16:42 +0000
3+++ launcher/UnityApplications/place.cpp 2011-03-22 15:21:51 +0000
4@@ -98,6 +98,7 @@
5 // FIXME: extract localized name
6 entry->setName(m_file->value("Name").toString());
7 entry->setIcon(m_file->value("Icon").toString());
8+ entry->setSearchHint(m_file->value("SearchHint").toString());
9 m_file->endGroup();
10 entry->setPosition(i++);
11 connect(entry, SIGNAL(positionChanged(uint)),
12
13=== modified file 'launcher/UnityApplications/placeentry.cpp'
14--- launcher/UnityApplications/placeentry.cpp 2011-03-17 10:42:46 +0000
15+++ launcher/UnityApplications/placeentry.cpp 2011-03-22 15:21:51 +0000
16@@ -347,6 +347,12 @@
17 return m_hints;
18 }
19
20+QString
21+PlaceEntry::searchHint() const
22+{
23+ return m_searchHint;
24+}
25+
26 int
27 PlaceEntry::activeSection() const
28 {
29@@ -531,6 +537,15 @@
30 }
31
32 void
33+PlaceEntry::setSearchHint(const QString& searchHint)
34+{
35+ if (m_searchHint != searchHint) {
36+ m_searchHint = searchHint;
37+ Q_EMIT searchHintChanged(m_searchHint);
38+ }
39+}
40+
41+void
42 PlaceEntry::setActiveSection(int activeSection)
43 {
44 if (activeSection != m_activeSection) {
45
46=== modified file 'launcher/UnityApplications/placeentry.h'
47--- launcher/UnityApplications/placeentry.h 2011-03-17 10:03:05 +0000
48+++ launcher/UnityApplications/placeentry.h 2011-03-22 15:21:51 +0000
49@@ -79,6 +79,7 @@
50 Q_PROPERTY(bool sensitive READ sensitive WRITE setSensitive NOTIFY sensitiveChanged)
51 Q_PROPERTY(DeeListModel* sections READ sections WRITE setSections NOTIFY sectionsChanged)
52 Q_PROPERTY(QMap hints READ hints WRITE setHints NOTIFY hintsChanged)
53+ Q_PROPERTY(QString searchHint READ searchHint WRITE setSearchHint NOTIFY searchHintChanged)
54 Q_PROPERTY(int activeSection READ activeSection WRITE setActiveSection NOTIFY activeSectionChanged)
55 Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
56 Q_PROPERTY(Place* place READ place)
57@@ -123,6 +124,7 @@
58 bool sensitive() const;
59 DeeListModel* sections() const;
60 QMap<QString, QVariant> hints() const;
61+ QString searchHint() const;
62 int activeSection() const;
63 Place* place() const;
64
65@@ -143,6 +145,8 @@
66 QMap<QString, QVariant> globalRendererHints() const;
67
68 /* setters */
69+ /* FIXME: all setters of type QString should be optimized
70+ by having the argument as cont QString& */
71 void setName(QString);
72 void setIcon(QString);
73 void setFileName(QString);
74@@ -154,6 +158,7 @@
75 void setSensitive(bool);
76 void setSections(DeeListModel*);
77 void setHints(QMap<QString, QVariant>);
78+ void setSearchHint(const QString&);
79 void setActiveSection(int);
80 void setActive(bool);
81
82@@ -189,6 +194,7 @@
83 void sensitiveChanged(bool);
84 void sectionsChanged();
85 void hintsChanged();
86+ void searchHintChanged(QString);
87 void activeSectionChanged();
88 void activeChanged();
89
90@@ -226,6 +232,7 @@
91 QVariant values in order to allow exposing it as a property (see
92 http://doc.trolltech.com/properties.html#requirements-for-declaring-properties). */
93 QMap<QString, QVariant> m_hints;
94+ QString m_searchHint;
95 int m_activeSection;
96 bool m_active;
97 Place* m_place;
98
99=== modified file 'places/SearchEntry.qml'
100--- places/SearchEntry.qml 2011-03-22 06:15:19 +0000
101+++ places/SearchEntry.qml 2011-03-22 15:21:51 +0000
102@@ -157,10 +157,10 @@
103 text: {
104 if(search_input.text)
105 return ""
106- else if(dash.currentPage != undefined && dash.currentPage.model.name)
107- return u2d.tr("Search for %1").arg(dash.currentPage.model.name)
108+ else if(dash.currentPage != undefined && dash.currentPage.model.searchHint)
109+ return dash.currentPage.model.searchHint
110 else
111- return u2d.tr("Search")
112+ return ""
113 }
114 }
115 }

Subscribers

People subscribed via source and target branches

to all changes: