on xenial help sign in
Add Scope::isActive.
9942542Michał Sawicz
plugins/Unity/scope.cpp+12
@@ -103,6 +103,11 @@ QString Scope::formFactor() const
103 return m_formFactor;
103 return m_formFactor;
104}
104}
105
105
106+bool Scope::isActive() const
107+{
108+ return m_isActive;
109+}
110+
106Filters* Scope::filters() const
111Filters* Scope::filters() const
107{
112{
108 return m_filters.get();
113 return m_filters.get();
@@ -140,6 +145,13 @@ void Scope::setFormFactor(const QString& form_factor) {
140 }
145 }
141}
146}
142
147
148+void Scope::setActive(const bool active) {
149+ if (active != m_isActive) {
150+ m_isActive = active;
151+ Q_EMIT isActiveChanged(m_isActive);
152+ }
153+}
154+
143unity::dash::LocalResult Scope::createLocalResult(const QVariant &uri, const QVariant &icon_hint,
155unity::dash::LocalResult Scope::createLocalResult(const QVariant &uri, const QVariant &icon_hint,
144 const QVariant &category, const QVariant &result_type,
156 const QVariant &category, const QVariant &result_type,
145 const QVariant &mimetype, const QVariant &title,
157 const QVariant &mimetype, const QVariant &title,
plugins/Unity/scope.h+5
@@ -52,6 +52,7 @@ class Scope : public QObject
52 Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
52 Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
53 Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
53 Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
54 Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
54 Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
55+ Q_PROPERTY(bool isActive READ isActive WRITE setActive NOTIFY isActiveChanged)
55
56
56public:
57public:
57 explicit Scope(QObject *parent = 0);
58 explicit Scope(QObject *parent = 0);
@@ -70,11 +71,13 @@ public:
70 QString searchQuery() const;
71 QString searchQuery() const;
71 QString noResultsHint() const;
72 QString noResultsHint() const;
72 QString formFactor() const;
73 QString formFactor() const;
74+ bool isActive() const;
73
75
74 /* setters */
76 /* setters */
75 void setSearchQuery(const QString& search_query);
77 void setSearchQuery(const QString& search_query);
76 void setNoResultsHint(const QString& hint);
78 void setNoResultsHint(const QString& hint);
77 void setFormFactor(const QString& form_factor);
79 void setFormFactor(const QString& form_factor);
80+ void setActive(const bool);
78
81
79 Q_INVOKABLE void activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
82 Q_INVOKABLE void activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
80 const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
83 const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
@@ -101,6 +104,7 @@ Q_SIGNALS:
101 void searchQueryChanged();
104 void searchQueryChanged();
102 void noResultsHintChanged();
105 void noResultsHintChanged();
103 void formFactorChanged();
106 void formFactorChanged();
107+ void isActiveChanged(bool);
104 void filtersChanged();
108 void filtersChanged();
105
109
106 // signals triggered by activate(..) or preview(..) requests.
110 // signals triggered by activate(..) or preview(..) requests.
@@ -131,6 +135,7 @@ private:
131 QString m_searchQuery;
135 QString m_searchQuery;
132 QString m_noResultsHint;
136 QString m_noResultsHint;
133 QString m_formFactor;
137 QString m_formFactor;
138+ bool m_isActive;
134};
139};
135
140
136Q_DECLARE_METATYPE(Scope*)
141Q_DECLARE_METATYPE(Scope*)
tests/mocks/Unity/fake_scope.cpp+13
@@ -30,6 +30,7 @@ static DeeModel* create_results_model(unsigned category_count, unsigned result_c
30Scope::Scope(QObject* parent)
30Scope::Scope(QObject* parent)
31 : QObject(parent)
31 : QObject(parent)
32 , m_visible(false)
32 , m_visible(false)
33+ , m_isActive(false)
33 , m_categories(new Categories(this))
34 , m_categories(new Categories(this))
34 , m_results(new DeeListModel(this))
35 , m_results(new DeeListModel(this))
35{
36{
@@ -44,6 +45,7 @@ Scope::Scope(QString const& id, QString const& name, bool visible, QObject* pare
44 , m_id(id)
45 , m_id(id)
45 , m_name(name)
46 , m_name(name)
46 , m_visible(visible)
47 , m_visible(visible)
48+ , m_isActive(false)
47 , m_categories(new Categories(this))
49 , m_categories(new Categories(this))
48 , m_results(new DeeListModel(this))
50 , m_results(new DeeListModel(this))
49{
51{
@@ -101,6 +103,10 @@ bool Scope::visible() const {
101 return m_visible;
103 return m_visible;
102}
104}
103
105
106+bool Scope::isActive() const {
107+ return m_isActive;
108+}
109+
104void Scope::setName(const QString &str) {
110void Scope::setName(const QString &str) {
105 if (str != m_name) {
111 if (str != m_name) {
106 m_name = str;
112 m_name = str;
@@ -122,6 +128,13 @@ void Scope::setFormFactor(const QString &str) {
122 }
128 }
123}
129}
124
130
131+void Scope::setActive(const bool active) {
132+ if (active != m_isActive) {
133+ m_isActive = active;
134+ Q_EMIT isActiveChanged();
135+ }
136+}
137+
125void Scope::setNoResultsHint(const QString& str) {
138void Scope::setNoResultsHint(const QString& str) {
126 if (str != m_noResultsHint) {
139 if (str != m_noResultsHint) {
127 m_noResultsHint = str;
140 m_noResultsHint = str;
tests/mocks/Unity/fake_scope.h+5
@@ -40,6 +40,7 @@ class Scope : public QObject
40 Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
40 Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
41 Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
41 Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
42 Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
42 Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
43+ Q_PROPERTY(bool isActive READ isActive WRITE setActive NOTIFY isActiveChanged)
43
44
44public:
45public:
45 Scope(QObject* parent = 0);
46 Scope(QObject* parent = 0);
@@ -58,12 +59,14 @@ public:
58 QString searchQuery() const;
59 QString searchQuery() const;
59 QString noResultsHint() const;
60 QString noResultsHint() const;
60 QString formFactor() const;
61 QString formFactor() const;
62+ bool isActive() const;
61
63
62 /* setters */
64 /* setters */
63 void setName(const QString& name);
65 void setName(const QString& name);
64 void setSearchQuery(const QString& search_query);
66 void setSearchQuery(const QString& search_query);
65 void setNoResultsHint(const QString& hint);
67 void setNoResultsHint(const QString& hint);
66 void setFormFactor(const QString& form_factor);
68 void setFormFactor(const QString& form_factor);
69+ void setActive(const bool);
67
70
68 Q_INVOKABLE void activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
71 Q_INVOKABLE void activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
69 const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
72 const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
@@ -86,6 +89,7 @@ Q_SIGNALS:
86 void searchQueryChanged();
89 void searchQueryChanged();
87 void noResultsHintChanged();
90 void noResultsHintChanged();
88 void formFactorChanged();
91 void formFactorChanged();
92+ void isActiveChanged();
89
93
90 // signals triggered by activate(..) or preview(..) requests.
94 // signals triggered by activate(..) or preview(..) requests.
91 void previewReady(Preview *preview);
95 void previewReady(Preview *preview);
@@ -101,6 +105,7 @@ protected:
101 QString m_noResultsHint;
105 QString m_noResultsHint;
102 QString m_formFactor;
106 QString m_formFactor;
103 bool m_visible;
107 bool m_visible;
108+ bool m_isActive;
104
109
105 Categories* m_categories;
110 Categories* m_categories;
106 DeeListModel* m_results;
111 DeeListModel* m_results;