on d83cab9 help sign in
135 lines 4.6 kB history raw
1/*
2 * Copyright (C) 2011 Canonical, Ltd.
3 *
4 * Authors:
5 * Florian Boucault <florian.boucault@canonical.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
20#ifndef SCOPE_H
21#define SCOPE_H
23// Qt
24#include <QObject>
25#include <QString>
26#include <QMetaType>
28// libunity-core
29#include <UnityCore/Scope.h>
30#include <UnityCore/Variant.h>
31#include <UnityCore/Results.h>
33// dee-qt
34#include "deelistmodel.h"
36class Categories;
38class Scope : public QObject
40 Q_OBJECT
41 Q_ENUMS(ViewType)
43 Q_PROPERTY(QString id READ id NOTIFY idChanged)
44 Q_PROPERTY(QString name READ name NOTIFY nameChanged)
45 Q_PROPERTY(QString iconHint READ iconHint NOTIFY iconHintChanged)
46 Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
47 Q_PROPERTY(QString searchHint READ searchHint NOTIFY searchHintChanged)
48 Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged)
49 Q_PROPERTY(QString shortcut READ shortcut NOTIFY shortcutChanged)
50 Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)
51 Q_PROPERTY(DeeListModel* results READ results NOTIFY resultsChanged)
52 Q_PROPERTY(Categories* categories READ categories NOTIFY categoriesChanged)
53 Q_PROPERTY(ViewType viewType READ viewType WRITE setViewType NOTIFY viewTypeChanged)
55 Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
56 Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
58public:
59 explicit Scope(QObject *parent = 0);
61 enum ViewType {
62 Hidden,
63 HomeView,
64 LensView
65 };
67 /* getters */
68 QString id() const;
69 QString name() const;
70 QString iconHint() const;
71 QString description() const;
72 QString searchHint() const;
73 bool visible() const;
74 QString shortcut() const;
75 bool connected() const;
76 DeeListModel* results() const;
77 DeeListModel* globalResults() const;
78 Categories* categories() const;
79 ViewType viewType() const;
80 QString searchQuery() const;
81 QString noResultsHint() const;
83 /* setters */
84 void setViewType(const ViewType& viewType);
85 void setSearchQuery(const QString& search_query);
86 void setNoResultsHint(const QString& hint);
88 Q_INVOKABLE void activate(const QString& uri);
89 void setUnityScope(const unity::dash::Scope::Ptr& scope);
90 unity::dash::Scope::Ptr unityScope() const;
92Q_SIGNALS:
93 void idChanged(const std::string&);
94 void dbusNameChanged(const std::string&);
95 void dbusPathChanged(const std::string&);
96 void nameChanged(const std::string&);
97 void iconHintChanged(const std::string&);
98 void descriptionChanged(const std::string&);
99 void searchHintChanged(const std::string&);
100 void visibleChanged(bool);
101 void shortcutChanged(const std::string&);
102 void connectedChanged(bool);
103 void resultsChanged();
104 void categoriesChanged();
105 void viewTypeChanged(ViewType);
106 void searchFinished(const std::string&, unity::glib::HintsMap const&, unity::glib::Error const&);
107 void searchQueryChanged();
108 void noResultsHintChanged();
110private Q_SLOTS:
111 void synchronizeStates();
112 void onSearchFinished(const std::string &, unity::glib::HintsMap const &);
114private:
115 void onResultsSwarmNameChanged(const std::string&);
116 void onResultsChanged(const unity::dash::Results::Ptr&);
117 void onResultsModelChanged(unity::glib::Object<DeeModel>);
118 void onCategoriesSwarmNameChanged(const std::string&);
119 void onCategoriesModelChanged(unity::glib::Object<DeeModel>);
120 void onCategoriesChanged(const unity::dash::Categories::Ptr&);
121 void onViewTypeChanged(unity::dash::ScopeViewType);
123 void onActivated(unity::dash::LocalResult const& result, unity::dash::ScopeHandledType type, unity::glib::HintsMap const&);
124 void fallbackActivate(const QString& uri);
126 unity::dash::Scope::Ptr m_unityScope;
127 DeeListModel* m_results;
128 Categories* m_categories;
129 QString m_searchQuery;
130 QString m_noResultsHint;
131};
133Q_DECLARE_METATYPE(Scope*)
135#endif // SCOPE_H