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();
146void Scope::setSearchInProgress(const bool inProg)
148 if (inProg != m_searching) {
149 m_searching = inProg;
150 Q_EMIT searchInProgressChanged();
154void Scope::setNoResultsHint(const QString& str)
156 if (str != m_noResultsHint) {
157 m_noResultsHint = str;
158 Q_EMIT noResultsHintChanged();
162void Scope::activate(QVariant const& result)
164 qDebug() << "Called activate on scope" << m_id << "with result" << result;
165 if (result.toString() == "Result.2.2") {
166 Scopes *scopes = dynamic_cast<Scopes*>(parent());
167 m_openScope = scopes->getScopeFromAll("MockScope9");
168 Q_EMIT openScope(m_openScope);
172PreviewStack* Scope::preview(QVariant const& result)
176 // This probably leaks, do we don't care
177 // it's a test after all
178 return new PreviewStack;
181void Scope::cancelActivation()
185void Scope::closeScope(unity::shell::scopes::ScopeInterface* scope)
187 if (scope != m_openScope) {
188 qDebug() << scope << m_openScope;
189 qFatal("Scope::closeScope got wrong scope in closeScope");
191 m_openScope = nullptr;
194QString Scope::currentNavigationId() const
196 return m_currentNavigationId;
199bool Scope::hasNavigation() const
204QString Scope::currentAltNavigationId() const
206 return m_currentAltNavigationId;
209bool Scope::hasAltNavigation() const
214Scope::Status Scope::status() const
219QVariantMap Scope::customizations() const
222 if (m_id == "clickscope") {
223 h["foreground-color"] = "yellow";
224 m["background-color"] = "red";
225 m["foreground-color"] = "blue";
226 m["page-header"] = h;
227 } else if (m_id == "MockScope5") {
228 h["background"] = "gradient:///lightgrey/grey";
229 h["logo"] = QUrl("../../../tests/qmltests/Dash/tst_PageHeader/logo-ubuntu-orange.svg");
230 h["divider-color"] = "red";
231 h["navigation-background"] = "color:///black";
232 m["page-header"] = h;
239 qDebug() << "Scope::refresh is currently not implmented in the fake scopes plugin";
242unity::shell::scopes::NavigationInterface* Scope::getNavigation(const QString& id)
249 if (id.startsWith("middle")) {
251 parentLabel = "root";
252 } else if (id.startsWith("child")) {
253 parentId = id.mid(5, 7);
254 parentLabel = parentId;
256 return new Navigation(id, id, "all"+id, parentId, parentLabel, this);
259unity::shell::scopes::NavigationInterface* Scope::getAltNavigation(QString const& id)
266 if (id.startsWith("altmiddle")) {
267 parentId = "altroot";
268 parentLabel = "altroot";
270 return new Navigation(id, id, "all"+id, parentId, parentLabel, this);
273void Scope::setNavigationState(const QString &navigationId, bool isAltNavigation)
275 if (isAltNavigation) {
276 m_currentAltNavigationId = navigationId;
277 Q_EMIT currentAltNavigationIdChanged();
279 m_currentNavigationId = navigationId;
280 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