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_optionselectorfilter.h"
25#include "fake_resultsmodel.h"
26#include "fake_scopes.h"
27#include "fake_settingsmodel.h"
29#include <paths.h> // from unity8/include
31Scope::Scope(Scopes* parent) : Scope("MockScope5", "Mock Scope", false, parent)
35Scope::Scope(QString const& id, QString const& name, bool favorite, Scopes* parent, int categories, bool returnNullPreview)
36 : unity::shell::scopes::ScopeInterface(parent)
40 , m_favorite(favorite)
42 , m_currentNavigationId("root")
43 , m_previewRendererName("preview-generic")
44 , m_categories(new Categories(categories, this))
45 , m_openScope(nullptr)
46 , m_settings(new SettingsModel(this))
47 , m_filters(new Filters(this))
48 , m_returnNullPreview(returnNullPreview)
50 m_primaryNavigationFilter = new FakeOptionSelectorFilter("OSF2", "PFTag", "Which food you like More", false, QStringList() << "meat" << "vegetables", this);
53QString Scope::id() const
58QString Scope::name() const
63QString Scope::searchQuery() const
68QString Scope::iconHint() const
73QString Scope::description() const
78QString Scope::searchHint() const
80 return QString("Search %1").arg(m_name);
83QString Scope::shortcut() const
88bool Scope::searchInProgress() const
93bool Scope::favorite() const
98unity::shell::scopes::CategoriesInterface* Scope::categories() const
103unity::shell::scopes::SettingsModelInterface* Scope::settings() const
108QString Scope::noResultsHint() const
110 return m_noResultsHint;
113QString Scope::formFactor() const
118bool Scope::isActive() const
123void Scope::setSearchQuery(const QString &str)
125 if (str != m_searchQuery) {
127 Q_EMIT searchQueryChanged();
131void Scope::setFormFactor(const QString &str)
133 if (str != m_formFactor) {
135 Q_EMIT formFactorChanged();
139void Scope::setActive(const bool active)
141 if (active != m_isActive) {
143 Q_EMIT isActiveChanged();
147void Scope::setFavorite(const bool favorite)
149 if (favorite != m_favorite) {
150 m_favorite = favorite;
151 Q_EMIT favoriteChanged();
155void Scope::setId(const QString &id)
163void Scope::setName(const QString &name)
165 if (name != m_name) {
167 Q_EMIT nameChanged();
171void Scope::setSearchInProgress(const bool inProg)
173 if (inProg != m_searching) {
174 m_searching = inProg;
175 Q_EMIT searchInProgressChanged();
179void Scope::setNoResultsHint(const QString& str)
181 if (str != m_noResultsHint) {
182 m_noResultsHint = str;
183 Q_EMIT noResultsHintChanged();
187void Scope::activate(QVariant const& result, QString const& categoryId)
189 qDebug() << "Called activate on scope" << m_id << "with result" << result << "and category" << categoryId;
190 if (result.toString() == "Result.2.2") {
191 Scopes *scopes = dynamic_cast<Scopes*>(parent());
192 m_openScope = scopes->getScopeFromAll("MockScope9");
193 scopes->addTempScope(m_openScope);
194 Q_EMIT openScope(m_openScope);
196 Q_EMIT previewRequested(result);
200PreviewStack* Scope::preview(QVariant const& result, QString const& /*categoryId*/)
204 if (m_returnNullPreview) {
207 return new PreviewStack(this);
211void Scope::cancelActivation()
215void Scope::closeScope(unity::shell::scopes::ScopeInterface* scope)
217 Scopes *scopes = dynamic_cast<Scopes*>(parent());
219 return scopes->closeScope(scope);
223QString Scope::currentNavigationId() const
225 return m_currentNavigationId;
228bool Scope::hasNavigation() const
233Scope::Status Scope::status() const
238QVariantMap Scope::customizations() const
241 if (m_id == "clickscope") {
242 h["foreground-color"] = "yellow";
243 m["background-color"] = "red";
244 m["foreground-color"] = "blue";
245 m["page-header"] = h;
246 } else if (m_id == "MockScope4") {
247 h["navigation-background"] = QUrl(sourceDirectory() + "/tests/qmltests/Dash/artwork/background.png");
248 m["page-header"] = h;
249 } else if (m_id == "MockScope5") {
250 h["background"] = "gradient:///lightgrey/grey";
251 h["logo"] = QUrl(sourceDirectory() + "/tests/qmltests/Dash/tst_PageHeader/logo-ubuntu-orange.svg");
252 h["divider-color"] = "red";
253 h["navigation-background"] = "color:///black";
254 m["page-header"] = h;
255 } else if (m_id == "MockScope6") {
256 h["navigation-background"] = "gradient:///blue/red";
257 m["page-header"] = h;
267unity::shell::scopes::NavigationInterface* Scope::getNavigation(const QString& id)
274 if (id.startsWith("middle")) {
276 parentLabel = "root";
277 } else if (id.startsWith("child")) {
278 parentId = id.mid(5, 7);
279 parentLabel = parentId;
281 return new Navigation(id, id, "all"+id, parentId, parentLabel, this);
284void Scope::setNavigationState(const QString &navigationId)
286 m_currentNavigationId = navigationId;
287 Q_EMIT currentNavigationIdChanged();
288 Q_EMIT primaryNavigationTagChanged();
291unity::shell::scopes::FilterBaseInterface* Scope::primaryNavigationFilter() const
293 return m_primaryNavigationFilter;
296unity::shell::scopes::FiltersInterface* Scope::filters() const
301QString Scope::primaryNavigationTag() const
303 if (m_currentNavigationId == "root")
306 return const_cast<Scope*>(this)->getNavigation(m_currentNavigationId)->label();
309int Scope::activeFiltersCount() const
315void Scope::resetPrimaryNavigationTag()
317 if (m_currentNavigationId != "root") {
318 setNavigationState("root");
322void Scope::performQuery(const QString& query)
324 Q_EMIT queryPerformed(query);
325 if (query.startsWith("scopes://")) {
326 QString scopeId = query.mid(9);
327 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