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/>.
23static DeeModel* create_categories_model(unsigned category_count);
24static DeeModel* create_results_model(unsigned category_count, unsigned result_count);
26// TODO: Implement remaining pieces
28Lens::Lens(QObject* parent)
31 m_categories(new Categories(this)),
32 m_results(new DeeListModel(this))
34 m_categories->setModel(create_categories_model(4));
35 m_results->setModel(create_results_model(4, 30));
37 m_categories->setResultModel(m_results);
38 m_categories->setGlobalResultModel(m_results);
41Lens::Lens(QString const& id,
49 m_categories(new Categories(this)),
50 m_results(new DeeListModel(this))
52 m_categories->setModel(create_categories_model(4));
53 m_results->setModel(create_results_model(4, 30));
55 m_categories->setResultModel(m_results);
56 m_categories->setGlobalResultModel(m_results);
59QString Lens::id() const {
63QString Lens::name() const {
67QString Lens::searchQuery() const {
71void Lens::setName(const QString &str) {
74 Q_EMIT nameChanged(m_name);
78void Lens::setSearchQuery(const QString &str) {
79 if (str != m_searchQuery) {
81 Q_EMIT searchQueryChanged(m_searchQuery);
85bool Lens::visible() const {
89Categories* Lens::categories() const {
93static const gchar * categories_model_schema[] = {
101DeeModel* create_categories_model(unsigned category_count) {
102 DeeModel* category_model = dee_sequence_model_new();
103 dee_model_set_schema_full(category_model, categories_model_schema, G_N_ELEMENTS(categories_model_schema));
106 g_variant_builder_init(&b, G_VARIANT_TYPE("a{sv}"));
107 GVariant *hints = g_variant_builder_end(&b);
109 for(unsigned i = 0; i < category_count; ++i)
111 dee_model_append(category_model,
112 ("Category "+std::to_string(i)).c_str(),
117 g_variant_unref(hints);
118 return category_model;
122/* Schema that is used in the DeeModel representing
124static const gchar * results_model_schema[] = {
135static const gchar * icons[] = {
143DeeModel* create_results_model(unsigned category_count, unsigned result_count) {
144 DeeModel* results_model = dee_sequence_model_new();
145 dee_model_set_schema_full(results_model, results_model_schema, G_N_ELEMENTS(results_model_schema));
148 g_variant_builder_init(&b, G_VARIANT_TYPE("a{sv}"));
149 GVariant *hints = g_variant_builder_end(&b);
151 for(unsigned i = 0; i < result_count; ++i)
153 unsigned category = i % category_count;
155 dee_model_append(results_model,
156 ("uri://result."+std::to_string(i)).c_str(),
157 (shellAppDirectory() + "Dash/graphics/lensIcons/" + (icons[i%G_N_ELEMENTS(icons)])).toLatin1().data(),
159 "application/x-desktop",
160 ("Title."+std::to_string(i)).c_str(),
161 ("Comment."+std::to_string(i)).c_str(),
162 ("uri://result."+std::to_string(i)).c_str(),
165 g_variant_unref(hints);
166 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