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)
35 , m_categories(new Categories(this))
36 , m_results(new DeeListModel(this))
38 DeeModel* results_model = create_results_model(4, 30);
39 m_categories->setResultModel(results_model);
40 m_categories->setModel(create_categories_model(4));
41 m_results->setModel(results_model);
44Scope::Scope(QString const& id, QString const& name, bool visible, QObject* parent)
51 , m_categories(new Categories(this))
52 , m_results(new DeeListModel(this))
54 DeeModel* results_model = create_results_model(4, 30);
55 m_categories->setResultModel(results_model);
56 m_categories->setModel(create_categories_model(4));
57 m_results->setModel(results_model);
60QString Scope::id() const {
64QString Scope::name() const {
68QString Scope::searchQuery() const {
72QString Scope::iconHint() const {
76QString Scope::description() const {
80QString Scope::searchHint() const {
84QString Scope::shortcut() const {
88bool Scope::connected() const {
92bool Scope::searchInProgress() const {
96Categories* Scope::categories() const {
100QString Scope::noResultsHint() const {
101 return m_noResultsHint;
104QString Scope::formFactor() const {
108bool Scope::visible() const {
112bool Scope::isActive() const {
116void Scope::setName(const QString &str) {
119 Q_EMIT nameChanged(m_name);
123void Scope::setSearchQuery(const QString &str) {
124 if (str != m_searchQuery) {
126 Q_EMIT searchQueryChanged();
130void Scope::setFormFactor(const QString &str) {
131 if (str != m_formFactor) {
133 Q_EMIT formFactorChanged();
137void Scope::setActive(const bool active) {
138 if (active != m_isActive) {
140 Q_EMIT isActiveChanged();
144void Scope::setSearchInProgress(const bool inProg) {
145 if (inProg != m_searching) {
146 m_searching = inProg;
147 Q_EMIT searchInProgressChanged();
151void Scope::setNoResultsHint(const QString& str) {
152 if (str != m_noResultsHint) {
153 m_noResultsHint = str;
154 Q_EMIT noResultsHintChanged();
158void Scope::activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
159 const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
160 const QVariant &comment, const QVariant &dnd_uri, const QVariant &metadata)
165 Q_UNUSED(result_type);
173void Scope::preview(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
174 const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
175 const QVariant &comment, const QVariant &dnd_uri, const QVariant &metadata)
180 Q_UNUSED(result_type);
188static const gchar * categories_model_schema[] = {
192 "s", // RENDERER_NAME
197DeeModel* create_categories_model(unsigned category_count) {
198 DeeModel* category_model = dee_sequence_model_new();
199 dee_model_set_schema_full(category_model, categories_model_schema, G_N_ELEMENTS(categories_model_schema));
200 GVariant* hints = g_variant_new_array(g_variant_type_element(G_VARIANT_TYPE_VARDICT), NULL, 0);
202 for(unsigned i = 0; i < category_count; ++i)
204 dee_model_append(category_model,
205 std::to_string(i).c_str(),
206 ("Category "+std::to_string(i)).c_str(),
211 return category_model;
215/* Schema that is used in the DeeModel representing
217static const gchar * results_model_schema[] = {
229DeeModel* create_results_model(unsigned category_count, unsigned result_count) {
230 DeeModel* results_model = dee_sequence_model_new();
231 dee_model_set_schema_full(results_model, results_model_schema, G_N_ELEMENTS(results_model_schema));
232 GVariant* hints = g_variant_new_array(g_variant_type_element(G_VARIANT_TYPE_VARDICT), NULL, 0);
234 for(unsigned i = 0; i < result_count; ++i)
236 unsigned category = i % category_count;
238 dee_model_append(results_model,
239 ("uri://result."+std::to_string(i)).c_str(),
240 (shellAppDirectory() + "graphics/applicationIcons/dash.png").toLatin1().data(),
243 "application/x-desktop",
244 ("Title."+std::to_string(i)).c_str(),
245 ("Comment."+std::to_string(i)).c_str(),
246 ("uri://result."+std::to_string(i)).c_str(),
249 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