on d854340 help sign in
134 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/Results.h>
32// dee-qt
33#include "deelistmodel.h"
35class Categories;
37class Scope : public QObject
39 Q_OBJECT
40 Q_ENUMS(ViewType)
42 Q_PROPERTY(QString id READ id NOTIFY idChanged)
43 Q_PROPERTY(QString name READ name NOTIFY nameChanged)
44 Q_PROPERTY(QString iconHint READ iconHint NOTIFY iconHintChanged)
45 Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
46 Q_PROPERTY(QString searchHint READ searchHint NOTIFY searchHintChanged)
47 Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged)
48 Q_PROPERTY(QString shortcut READ shortcut NOTIFY shortcutChanged)
49 Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)
50 Q_PROPERTY(DeeListModel* results READ results NOTIFY resultsChanged)
51 Q_PROPERTY(Categories* categories READ categories NOTIFY categoriesChanged)
52 Q_PROPERTY(ViewType viewType READ viewType WRITE setViewType NOTIFY viewTypeChanged)
54 Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
55 Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
57public:
58 explicit Scope(QObject *parent = 0);
60 enum ViewType {
61 Hidden,
62 HomeView,
63 ScopeView
64 };
66 /* getters */
67 QString id() const;
68 QString name() const;
69 QString iconHint() const;
70 QString description() const;
71 QString searchHint() const;
72 bool visible() const;
73 QString shortcut() const;
74 bool connected() const;
75 DeeListModel* results() const;
76 DeeListModel* globalResults() const;
77 Categories* categories() const;
78 ViewType viewType() const;
79 QString searchQuery() const;
80 QString noResultsHint() const;
82 /* setters */
83 void setViewType(const ViewType& viewType);
84 void setSearchQuery(const QString& search_query);
85 void setNoResultsHint(const QString& hint);
87 Q_INVOKABLE void activate(const QString& uri);
88 void setUnityScope(const unity::dash::Scope::Ptr& scope);
89 unity::dash::Scope::Ptr unityScope() const;
91Q_SIGNALS:
92 void idChanged(const std::string&);
93 void dbusNameChanged(const std::string&);
94 void dbusPathChanged(const std::string&);
95 void nameChanged(const std::string&);
96 void iconHintChanged(const std::string&);
97 void descriptionChanged(const std::string&);
98 void searchHintChanged(const std::string&);
99 void visibleChanged(bool);
100 void shortcutChanged(const std::string&);
101 void connectedChanged(bool);
102 void resultsChanged();
103 void categoriesChanged();
104 void viewTypeChanged(ViewType);
105 void searchFinished(const std::string&, unity::glib::HintsMap const&, unity::glib::Error const&);
106 void searchQueryChanged();
107 void noResultsHintChanged();
109private Q_SLOTS:
110 void synchronizeStates();
111 void onSearchFinished(const std::string &, unity::glib::HintsMap const &);
113private:
114 void onResultsSwarmNameChanged(const std::string&);
115 void onResultsChanged(const unity::dash::Results::Ptr&);
116 void onResultsModelChanged(unity::glib::Object<DeeModel>);
117 void onCategoriesSwarmNameChanged(const std::string&);
118 void onCategoriesModelChanged(unity::glib::Object<DeeModel>);
119 void onCategoriesChanged(const unity::dash::Categories::Ptr&);
120 void onViewTypeChanged(unity::dash::ScopeViewType);
122 void onActivated(unity::dash::LocalResult const& result, unity::dash::ScopeHandledType type, unity::glib::HintsMap const&);
123 void fallbackActivate(const QString& uri);
125 unity::dash::Scope::Ptr m_unityScope;
126 DeeListModel* m_results;
127 Categories* m_categories;
128 QString m_searchQuery;
129 QString m_noResultsHint;
130};
132Q_DECLARE_METATYPE(Scope*)
134#endif // SCOPE_H