2 * Copyright (C) 2013, 2014, 2015 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/>.
20#include "fake_scope.h"
22#include "fake_filters.h"
23#include "fake_navigation.h"
24#include "fake_resultsmodel.h"
25#include "fake_scopes.h"
26#include "fake_settingsmodel.h"
28#include <paths.h> // from unity8/include
30Scope::Scope(Scopes* parent) : Scope("MockScope5", "Mock Scope", false, parent)
34Scope::Scope(QString const& id, QString const& name, bool favorite, Scopes* parent, int categories, bool returnNullPreview)
35 : unity::shell::scopes::ScopeInterface(parent)
39 , m_favorite(favorite)
41 , m_currentNavigationId("root")
42 , m_previewRendererName("preview-generic")
43 , m_categories(new Categories(categories, this))
44 , m_openScope(nullptr)
45 , m_settings(new SettingsModel(this))
46 , m_filters(new Filters(this))
47 , m_returnNullPreview(returnNullPreview)
51QString Scope::id() const
56QString Scope::name() const
61QString Scope::searchQuery() const
66QString Scope::iconHint() const
71QString Scope::description() const
76QString Scope::searchHint() const
78 return QString("Search %1").arg(m_name);
81QString Scope::shortcut() const
86bool Scope::searchInProgress() const
91bool Scope::favorite() const
96unity::shell::scopes::CategoriesInterface* Scope::categories() const
101unity::shell::scopes::SettingsModelInterface* Scope::settings() const
106QString Scope::noResultsHint() const
108 return m_noResultsHint;
111QString Scope::formFactor() const
116bool Scope::isActive() const
121void Scope::setSearchQuery(const QString &str)
123 if (str != m_searchQuery) {
125 Q_EMIT searchQueryChanged();
129void Scope::setFormFactor(const QString &str)
131 if (str != m_formFactor) {
133 Q_EMIT formFactorChanged();
137void Scope::setActive(const bool active)
139 if (active != m_isActive) {
141 Q_EMIT isActiveChanged();
145void Scope::setFavorite(const bool favorite)
147 if (favorite != m_favorite) {
148 m_favorite = favorite;
149 Q_EMIT favoriteChanged();
153void Scope::setId(const QString &id)
161void Scope::setName(const QString &name)
163 if (name != m_name) {
165 Q_EMIT nameChanged();
169void Scope::setSearchInProgress(const bool inProg)
171 if (inProg != m_searching) {
172 m_searching = inProg;
173 Q_EMIT searchInProgressChanged();
177void Scope::setNoResultsHint(const QString& str)
179 if (str != m_noResultsHint) {
180 m_noResultsHint = str;
181 Q_EMIT noResultsHintChanged();
185void Scope::activate(QVariant const& result, QString const& categoryId)
187 qDebug() << "Called activate on scope" << m_id << "with result" << result << "and category" << categoryId;
188 if (result.toString() == "Result.2.2") {
189 Scopes *scopes = dynamic_cast<Scopes*>(parent());
190 m_openScope = scopes->getScopeFromAll("MockScope9");
191 scopes->addTempScope(m_openScope);
192 Q_EMIT openScope(m_openScope);
194 Q_EMIT previewRequested(result);
198PreviewStack* Scope::preview(QVariant const& result, QString const& /*categoryId*/)
202 if (m_returnNullPreview) {
205 return new PreviewStack(this);
209void Scope::cancelActivation()
213void Scope::closeScope(unity::shell::scopes::ScopeInterface* scope)
215 Scopes *scopes = dynamic_cast<Scopes*>(parent());
217 return scopes->closeScope(scope);
221QString Scope::currentNavigationId() const
223 return m_currentNavigationId;
226bool Scope::hasNavigation() const
231Scope::Status Scope::status() const
236QVariantMap Scope::customizations() const
239 if (m_id == "clickscope") {
240 h["foreground-color"] = "yellow";
241 m["background-color"] = "red";
242 m["foreground-color"] = "blue";
243 m["page-header"] = h;
244 } else if (m_id == "MockScope4") {
245 h["navigation-background"] = QUrl(sourceDirectory() + "/tests/qmltests/Dash/artwork/background.png");
246 m["page-header"] = h;
247 } else if (m_id == "MockScope5") {
248 h["background"] = "gradient:///lightgrey/grey";
249 h["logo"] = QUrl(sourceDirectory() + "/tests/qmltests/Dash/tst_PageHeader/logo-ubuntu-orange.svg");
250 h["divider-color"] = "red";
251 h["navigation-background"] = "color:///black";
252 m["page-header"] = h;
253 } else if (m_id == "MockScope6") {
254 h["navigation-background"] = "gradient:///blue/red";
255 m["page-header"] = h;
265void Scope::resetFilters()
267 qWarning() << "Scope::resetFilters is unimplemented";
270void Scope::activateAction(QVariant const& /*result*/, QString const& /*categoryId*/, QString const& /*actionId*/)
272 qFatal("Using Scope::activateAction");
275unity::shell::scopes::NavigationInterface* Scope::getNavigation(const QString& id)
282 if (id.startsWith("middle")) {
284 parentLabel = "root";
285 } else if (id.startsWith("child")) {
286 parentId = id.mid(5, 7);
287 parentLabel = parentId;
289 return new Navigation(id, id, "all"+id, parentId, parentLabel, this);
292void Scope::setNavigationState(const QString &navigationId)
294 m_currentNavigationId = navigationId;
295 Q_EMIT currentNavigationIdChanged();
298unity::shell::scopes::FilterBaseInterface* Scope::primaryNavigationFilter() const
303unity::shell::scopes::FiltersInterface* Scope::filters() const
308QString Scope::primaryNavigationTag() const
314int Scope::activeFiltersCount() const
320void Scope::resetPrimaryNavigationTag()
324void Scope::performQuery(const QString& query)
326 Q_EMIT queryPerformed(query);
327 if (query.startsWith("scopes://")) {
328 QString scopeId = query.mid(9);
329 Q_EMIT gotoScope(scopeId);
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