2 * Copyright (C) 2013, 2014 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_navigation.h"
23#include "fake_resultsmodel.h"
24#include "fake_scopes.h"
26Scope::Scope(Scopes* parent) : Scope(QString(), QString(), false, parent)
30Scope::Scope(QString const& id, QString const& name, bool favorite, Scopes* parent, int categories)
31 : unity::shell::scopes::ScopeInterface(parent)
35 , m_favorite(favorite)
37 , m_currentNavigationId("root")
38 , m_currentAltNavigationId("altroot")
39 , m_previewRendererName("preview-generic")
40 , m_categories(new Categories(categories, this))
41 , m_openScope(nullptr)
45QString Scope::id() const
50QString Scope::name() const
55QString Scope::searchQuery() const
60QString Scope::iconHint() const
65QString Scope::description() const
70QString Scope::searchHint() const
72 return QString("Search %1").arg(m_name);
75QString Scope::shortcut() const
80bool Scope::searchInProgress() const
85bool Scope::favorite() const
90unity::shell::scopes::CategoriesInterface* Scope::categories() const
95unity::shell::scopes::SettingsModelInterface* Scope::settings() const
100QString Scope::noResultsHint() const
102 return m_noResultsHint;
105QString Scope::formFactor() const
110bool Scope::isActive() const
115void Scope::setSearchQuery(const QString &str)
117 if (str != m_searchQuery) {
119 Q_EMIT searchQueryChanged();
123void Scope::setFormFactor(const QString &str)
125 if (str != m_formFactor) {
127 Q_EMIT formFactorChanged();
131void Scope::setActive(const bool active)
133 if (active != m_isActive) {
135 Q_EMIT isActiveChanged();
139void Scope::setFavorite(const bool favorite)
141 if (favorite != m_favorite) {
142 m_favorite = favorite;
143 Q_EMIT favoriteChanged();
147void Scope::setId(const QString &id)
155void Scope::setName(const QString &name)
157 if (name != m_name) {
159 Q_EMIT nameChanged();
163void Scope::setSearchInProgress(const bool inProg)
165 if (inProg != m_searching) {
166 m_searching = inProg;
167 Q_EMIT searchInProgressChanged();
171void Scope::setNoResultsHint(const QString& str)
173 if (str != m_noResultsHint) {
174 m_noResultsHint = str;
175 Q_EMIT noResultsHintChanged();
179void Scope::activate(QVariant const& result)
181 qDebug() << "Called activate on scope" << m_id << "with result" << result;
182 if (result.toString() == "Result.2.2") {
183 Scopes *scopes = dynamic_cast<Scopes*>(parent());
184 m_openScope = scopes->getScopeFromAll("MockScope9");
185 Q_EMIT openScope(m_openScope);
189PreviewStack* Scope::preview(QVariant const& result)
193 // This probably leaks, do we don't care
194 // it's a test after all
195 return new PreviewStack;
198void Scope::cancelActivation()
202void Scope::closeScope(unity::shell::scopes::ScopeInterface* scope)
204 if (scope != m_openScope) {
205 qDebug() << scope << m_openScope;
206 qFatal("Scope::closeScope got wrong scope in closeScope");
208 m_openScope = nullptr;
211QString Scope::currentNavigationId() const
213 return m_currentNavigationId;
216bool Scope::hasNavigation() const
221QString Scope::currentAltNavigationId() const
223 return m_currentAltNavigationId;
226bool Scope::hasAltNavigation() 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 == "MockScope5") {
245 h["background"] = "gradient:///lightgrey/grey";
246 h["logo"] = QUrl("../../../tests/qmltests/Dash/tst_PageHeader/logo-ubuntu-orange.svg");
247 m["page-header"] = h;
254 qDebug() << "Scope::refresh is currently not implmented in the fake scopes plugin";
257unity::shell::scopes::NavigationInterface* Scope::getNavigation(const QString& id)
264 if (id.startsWith("middle")) {
266 parentLabel = "root";
267 } else if (id.startsWith("child")) {
268 parentId = id.mid(5, 7);
269 parentLabel = parentId;
271 return new Navigation(id, id, "all"+id, parentId, parentLabel, this);
274unity::shell::scopes::NavigationInterface* Scope::getAltNavigation(QString const& id)
281 if (id.startsWith("altmiddle")) {
282 parentId = "altroot";
283 parentLabel = "altroot";
285 return new Navigation(id, id, "all"+id, parentId, parentLabel, this);
288void Scope::setNavigationState(const QString &navigationId, bool isAltNavigation)
290 if (isAltNavigation) {
291 m_currentAltNavigationId = navigationId;
292 Q_EMIT currentAltNavigationIdChanged();
294 m_currentNavigationId = navigationId;
295 Q_EMIT currentNavigationIdChanged();
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