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"
25#include "fake_settingsmodel.h"
27Scope::Scope(Scopes* parent) : Scope("MockScope5", "Mock Scope", false, parent)
31Scope::Scope(QString const& id, QString const& name, bool favorite, Scopes* parent, int categories, bool returnNullPreview)
32 : unity::shell::scopes::ScopeInterface(parent)
36 , m_favorite(favorite)
38 , m_currentNavigationId("root")
39 , m_currentAltNavigationId("altrootChild1")
40 , m_previewRendererName("preview-generic")
41 , m_categories(new Categories(categories, this))
42 , m_openScope(nullptr)
43 , m_settings(new SettingsModel(this))
44 , m_returnNullPreview(returnNullPreview)
48QString Scope::id() const
53QString Scope::name() const
58QString Scope::searchQuery() const
63QString Scope::iconHint() const
68QString Scope::description() const
73QString Scope::searchHint() const
75 return QString("Search %1").arg(m_name);
78QString Scope::shortcut() const
83bool Scope::searchInProgress() const
88bool Scope::favorite() const
93unity::shell::scopes::CategoriesInterface* Scope::categories() const
98unity::shell::scopes::SettingsModelInterface* Scope::settings() const
103QString Scope::noResultsHint() const
105 return m_noResultsHint;
108QString Scope::formFactor() const
113bool Scope::isActive() const
118void Scope::setSearchQuery(const QString &str)
120 if (str != m_searchQuery) {
122 Q_EMIT searchQueryChanged();
126void Scope::setFormFactor(const QString &str)
128 if (str != m_formFactor) {
130 Q_EMIT formFactorChanged();
134void Scope::setActive(const bool active)
136 if (active != m_isActive) {
138 Q_EMIT isActiveChanged();
142void Scope::setFavorite(const bool favorite)
144 if (favorite != m_favorite) {
145 m_favorite = favorite;
146 Q_EMIT favoriteChanged();
150void Scope::setId(const QString &id)
158void Scope::setName(const QString &name)
160 if (name != m_name) {
162 Q_EMIT nameChanged();
166void Scope::setSearchInProgress(const bool inProg)
168 if (inProg != m_searching) {
169 m_searching = inProg;
170 Q_EMIT searchInProgressChanged();
174void Scope::setNoResultsHint(const QString& str)
176 if (str != m_noResultsHint) {
177 m_noResultsHint = str;
178 Q_EMIT noResultsHintChanged();
182void Scope::activate(QVariant const& result)
184 qDebug() << "Called activate on scope" << m_id << "with result" << result;
185 if (result.toString() == "Result.2.2") {
186 Scopes *scopes = dynamic_cast<Scopes*>(parent());
187 m_openScope = scopes->getScopeFromAll("MockScope9");
188 scopes->addTempScope(m_openScope);
189 Q_EMIT openScope(m_openScope);
193PreviewStack* Scope::preview(QVariant const& result)
197 if (m_returnNullPreview) {
200 // This probably leaks, do we don't care
201 // it's a test after all
202 return new PreviewStack(this, this);
206void Scope::cancelActivation()
210void Scope::closeScope(unity::shell::scopes::ScopeInterface* scope)
212 Scopes *scopes = dynamic_cast<Scopes*>(parent());
214 return scopes->closeScope(scope);
218QString Scope::currentNavigationId() const
220 return m_currentNavigationId;
223bool Scope::hasNavigation() const
228QString Scope::currentAltNavigationId() const
230 return m_currentAltNavigationId;
233bool Scope::hasAltNavigation() const
238Scope::Status Scope::status() const
243QVariantMap Scope::customizations() const
246 if (m_id == "clickscope") {
247 h["foreground-color"] = "yellow";
248 m["background-color"] = "red";
249 m["foreground-color"] = "blue";
250 m["page-header"] = h;
251 } else if (m_id == "MockScope4") {
252 h["navigation-background"] = QUrl("../../../tests/qmltests/Dash/artwork/background.png");
253 m["page-header"] = h;
254 } else if (m_id == "MockScope5") {
255 h["background"] = "gradient:///lightgrey/grey";
256 h["logo"] = QUrl("../../../tests/qmltests/Dash/tst_PageHeader/logo-ubuntu-orange.svg");
257 h["divider-color"] = "red";
258 h["navigation-background"] = "color:///black";
259 m["page-header"] = h;
260 } else if (m_id == "MockScope6") {
261 h["navigation-background"] = "gradient:///blue/red";
262 m["page-header"] = h;
272unity::shell::scopes::NavigationInterface* Scope::getNavigation(const QString& id)
279 if (id.startsWith("middle")) {
281 parentLabel = "root";
282 } else if (id.startsWith("child")) {
283 parentId = id.mid(5, 7);
284 parentLabel = parentId;
286 return new Navigation(id, id, "all"+id, parentId, parentLabel, this);
289unity::shell::scopes::NavigationInterface* Scope::getAltNavigation(QString const& id)
296 if (id != "altroot") {
297 parentId = "altroot";
298 parentLabel = "altroot";
300 return new Navigation(id, id, "all"+id, parentId, parentLabel, this);
303void Scope::setNavigationState(const QString &navigationId, bool isAltNavigation)
305 if (isAltNavigation) {
306 m_currentAltNavigationId = navigationId;
307 Q_EMIT currentAltNavigationIdChanged();
309 m_currentNavigationId = navigationId;
310 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