on xenial help sign in
Add Scope::isActive.
commit99425429fe56e4710352b1284d49d10d0f1f1254 authorMichał Sawicz <michal.sawicz@canonical.com> dateTue 24 Sep 2013, 11:51 (13 years ago) parent4bded4d
4 files changed+35
plugins/Unity/scope.cpp+12 plugins/Unity/scope.h+5 tests/mocks/Unity/fake_scope.cpp+13 tests/mocks/Unity/fake_scope.h+5
plugins/Unity/scope.cpp+12
@@ -103,6 +103,11 @@ QString Scope::formFactor() const
103103 return m_formFactor;
104104}
105105
106+bool Scope::isActive() const
107+{
108+ return m_isActive;
109+}
110+
106111Filters* Scope::filters() const
107112{
108113 return m_filters.get();
@@ -140,6 +145,13 @@ void Scope::setFormFactor(const QString& form_factor) {
140145 }
141146}
142147
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+
143155unity::dash::LocalResult Scope::createLocalResult(const QVariant &uri, const QVariant &icon_hint,
144156 const QVariant &category, const QVariant &result_type,
145157 const QVariant &mimetype, const QVariant &title,
plugins/Unity/scope.h+5
@@ -52,6 +52,7 @@ class Scope : public QObject
5252 Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
5353 Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
5454 Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
55+ Q_PROPERTY(bool isActive READ isActive WRITE setActive NOTIFY isActiveChanged)
5556
5657public:
5758 explicit Scope(QObject *parent = 0);
@@ -70,11 +71,13 @@ public:
7071 QString searchQuery() const;
7172 QString noResultsHint() const;
7273 QString formFactor() const;
74+ bool isActive() const;
7375
7476 /* setters */
7577 void setSearchQuery(const QString& search_query);
7678 void setNoResultsHint(const QString& hint);
7779 void setFormFactor(const QString& form_factor);
80+ void setActive(const bool);
7881
7982 Q_INVOKABLE void activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
8083 const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
@@ -101,6 +104,7 @@ Q_SIGNALS:
101104 void searchQueryChanged();
102105 void noResultsHintChanged();
103106 void formFactorChanged();
107+ void isActiveChanged(bool);
104108 void filtersChanged();
105109
106110 // signals triggered by activate(..) or preview(..) requests.
@@ -131,6 +135,7 @@ private:
131135 QString m_searchQuery;
132136 QString m_noResultsHint;
133137 QString m_formFactor;
138+ bool m_isActive;
134139};
135140
136141Q_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
3030Scope::Scope(QObject* parent)
3131 : QObject(parent)
3232 , m_visible(false)
33+ , m_isActive(false)
3334 , m_categories(new Categories(this))
3435 , m_results(new DeeListModel(this))
3536{
@@ -44,6 +45,7 @@ Scope::Scope(QString const& id, QString const& name, bool visible, QObject* pare
4445 , m_id(id)
4546 , m_name(name)
4647 , m_visible(visible)
48+ , m_isActive(false)
4749 , m_categories(new Categories(this))
4850 , m_results(new DeeListModel(this))
4951{
@@ -101,6 +103,10 @@ bool Scope::visible() const {
101103 return m_visible;
102104}
103105
106+bool Scope::isActive() const {
107+ return m_isActive;
108+}
109+
104110void Scope::setName(const QString &str) {
105111 if (str != m_name) {
106112 m_name = str;
@@ -122,6 +128,13 @@ void Scope::setFormFactor(const QString &str) {
122128 }
123129}
124130
131+void Scope::setActive(const bool active) {
132+ if (active != m_isActive) {
133+ m_isActive = active;
134+ Q_EMIT isActiveChanged();
135+ }
136+}
137+
125138void Scope::setNoResultsHint(const QString& str) {
126139 if (str != m_noResultsHint) {
127140 m_noResultsHint = str;
tests/mocks/Unity/fake_scope.h+5
@@ -40,6 +40,7 @@ class Scope : public QObject
4040 Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
4141 Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
4242 Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
43+ Q_PROPERTY(bool isActive READ isActive WRITE setActive NOTIFY isActiveChanged)
4344
4445public:
4546 Scope(QObject* parent = 0);
@@ -58,12 +59,14 @@ public:
5859 QString searchQuery() const;
5960 QString noResultsHint() const;
6061 QString formFactor() const;
62+ bool isActive() const;
6163
6264 /* setters */
6365 void setName(const QString& name);
6466 void setSearchQuery(const QString& search_query);
6567 void setNoResultsHint(const QString& hint);
6668 void setFormFactor(const QString& form_factor);
69+ void setActive(const bool);
6770
6871 Q_INVOKABLE void activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
6972 const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
@@ -86,6 +89,7 @@ Q_SIGNALS:
8689 void searchQueryChanged();
8790 void noResultsHintChanged();
8891 void formFactorChanged();
92+ void isActiveChanged();
8993
9094 // signals triggered by activate(..) or preview(..) requests.
9195 void previewReady(Preview *preview);
@@ -101,6 +105,7 @@ protected:
101105 QString m_noResultsHint;
102106 QString m_formFactor;
103107 bool m_visible;
108+ bool m_isActive;
104109
105110 Categories* m_categories;
106111 DeeListModel* m_results;