2 * Copyright (C) 2013 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18#include "fake_scope.h"
23#include "fake_preview.h"
25static DeeModel* create_categories_model(unsigned category_count);
26static DeeModel* create_results_model(unsigned category_count, unsigned result_count);
28// TODO: Implement remaining pieces
30Scope::Scope(QObject* parent)
34 , m_categories(new Categories(this))
35 , m_results(new DeeListModel(this))
37 DeeModel* results_model = create_results_model(4, 30);
38 m_categories->setResultModel(results_model);
39 m_categories->setModel(create_categories_model(4));
40 m_results->setModel(results_model);
43Scope::Scope(QString const& id, QString const& name, bool visible, QObject* parent)
49 , m_categories(new Categories(this))
50 , m_results(new DeeListModel(this))
52 DeeModel* results_model = create_results_model(4, 30);
53 m_categories->setResultModel(results_model);
54 m_categories->setModel(create_categories_model(4));
55 m_results->setModel(results_model);
58QString Scope::id() const {
62QString Scope::name() const {
66QString Scope::searchQuery() const {
70QString Scope::iconHint() const {
74QString Scope::description() const {
78QString Scope::searchHint() const {
82QString Scope::shortcut() const {
86bool Scope::connected() const {
90bool Scope::searchInProgress() const {
94Categories* Scope::categories() const {
98QString Scope::noResultsHint() const {
99 return m_noResultsHint;
102QString Scope::formFactor() const {
106bool Scope::visible() const {
110void Scope::setName(const QString &str) {
113 Q_EMIT nameChanged(m_name);
117void Scope::setSearchQuery(const QString &str) {
118 if (str != m_searchQuery) {
120 Q_EMIT searchQueryChanged();
124void Scope::setFormFactor(const QString &str) {
125 if (str != m_formFactor) {
127 Q_EMIT formFactorChanged();
131void Scope::setSearchInProgress(const bool inProg) {
132 if (inProg != m_searching) {
133 m_searching = inProg;
134 Q_EMIT searchInProgressChanged();
138void Scope::setNoResultsHint(const QString& str) {
139 if (str != m_noResultsHint) {
140 m_noResultsHint = str;
141 Q_EMIT noResultsHintChanged();
145void Scope::activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
146 const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
147 const QVariant &comment, const QVariant &dnd_uri, const QVariant &metadata)
152 Q_UNUSED(result_type);
160void Scope::preview(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
161 const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
162 const QVariant &comment, const QVariant &dnd_uri, const QVariant &metadata)
167 Q_UNUSED(result_type);
175static const gchar * categories_model_schema[] = {
179 "s", // RENDERER_NAME
184DeeModel* create_categories_model(unsigned category_count) {
185 DeeModel* category_model = dee_sequence_model_new();
186 dee_model_set_schema_full(category_model, categories_model_schema, G_N_ELEMENTS(categories_model_schema));
187 GVariant* hints = g_variant_new_array(g_variant_type_element(G_VARIANT_TYPE_VARDICT), NULL, 0);
189 for(unsigned i = 0; i < category_count; ++i)
191 dee_model_append(category_model,
192 std::to_string(i).c_str(),
193 ("Category "+std::to_string(i)).c_str(),
198 return category_model;
202/* Schema that is used in the DeeModel representing
204static const gchar * results_model_schema[] = {
216DeeModel* create_results_model(unsigned category_count, unsigned result_count) {
217 DeeModel* results_model = dee_sequence_model_new();
218 dee_model_set_schema_full(results_model, results_model_schema, G_N_ELEMENTS(results_model_schema));
219 GVariant* hints = g_variant_new_array(g_variant_type_element(G_VARIANT_TYPE_VARDICT), NULL, 0);
221 for(unsigned i = 0; i < result_count; ++i)
223 unsigned category = i % category_count;
225 dee_model_append(results_model,
226 ("uri://result."+std::to_string(i)).c_str(),
227 (shellAppDirectory() + "graphics/applicationIcons/dash.png").toLatin1().data(),
230 "application/x-desktop",
231 ("Title."+std::to_string(i)).c_str(),
232 ("Comment."+std::to_string(i)).c_str(),
233 ("uri://result."+std::to_string(i)).c_str(),
236 return results_model;
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list