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_hasNavigation(true)
43 , m_hasPrimaryFilter(true)
44 , m_currentNavigationId("root")
45 , m_previewRendererName("preview-generic")
46 , m_categories(new Categories(categories, this))
47 , m_openScope(nullptr)
48 , m_settings(new SettingsModel(this))
49 , m_filters(new Filters(this))
50 , m_returnNullPreview(returnNullPreview)
52 m_primaryNavigationFilter = new FakeOptionSelectorFilter("OSF3", "PFTag", "Which food you like More", false, QStringList() << "meat" << "vegetables", this);
55QString Scope::id() const
60QString Scope::name() const
65QString Scope::searchQuery() const
70QString Scope::iconHint() const
75QString Scope::description() const
80QString Scope::searchHint() const
82 return QString("Search %1").arg(m_name);
85QString Scope::shortcut() const
90bool Scope::searchInProgress() const
95bool Scope::favorite() const
100unity::shell::scopes::CategoriesInterface* Scope::categories() const
105unity::shell::scopes::SettingsModelInterface* Scope::settings() const
110QString Scope::noResultsHint() const
112 return m_noResultsHint;
115QString Scope::formFactor() const
120bool Scope::isActive() const
125void Scope::setSearchQuery(const QString &str)
127 if (str != m_searchQuery) {
129 Q_EMIT searchQueryChanged();
133void Scope::setFormFactor(const QString &str)
135 if (str != m_formFactor) {
137 Q_EMIT formFactorChanged();
141void Scope::setActive(const bool active)
143 if (active != m_isActive) {
145 Q_EMIT isActiveChanged();
149void Scope::setFavorite(const bool favorite)
151 if (favorite != m_favorite) {
152 m_favorite = favorite;
153 Q_EMIT favoriteChanged();
157void Scope::setId(const QString &id)
165void Scope::setName(const QString &name)
167 if (name != m_name) {
169 Q_EMIT nameChanged();
173void Scope::setSearchInProgress(const bool inProg)
175 if (inProg != m_searching) {
176 m_searching = inProg;
177 Q_EMIT searchInProgressChanged();
181void Scope::setNoResultsHint(const QString& str)
183 if (str != m_noResultsHint) {
184 m_noResultsHint = str;
185 Q_EMIT noResultsHintChanged();
189void Scope::activate(QVariant const& result, QString const& categoryId)
191 qDebug() << "Called activate on scope" << m_id << "with result" << result << "and category" << categoryId;
192 if (result.toString() == "Result.2.2") {
193 Scopes *scopes = dynamic_cast<Scopes*>(parent());
194 m_openScope = scopes->getScopeFromAll("MockScope9");
195 scopes->addTempScope(m_openScope);
196 Q_EMIT openScope(m_openScope);
198 Q_EMIT previewRequested(result);
202PreviewStack* Scope::preview(QVariant const& result, QString const& /*categoryId*/)
206 if (m_returnNullPreview) {
209 return new PreviewStack(this);
213void Scope::cancelActivation()
217void Scope::closeScope(unity::shell::scopes::ScopeInterface* scope)
219 Scopes *scopes = dynamic_cast<Scopes*>(parent());
221 return scopes->closeScope(scope);
225QString Scope::currentNavigationId() const
227 return m_currentNavigationId;
230bool Scope::hasNavigation() const
232 return m_hasNavigation;
235void Scope::setHasNavigation(bool hasNavigation)
237 m_hasNavigation = hasNavigation;
238 Q_EMIT hasNavigationChanged();
241Scope::Status Scope::status() const
246QVariantMap Scope::customizations() const
249 if (m_id == "clickscope") {
250 h["foreground-color"] = "yellow";
251 m["background-color"] = "red";
252 m["foreground-color"] = "blue";
253 m["page-header"] = h;
254 } else if (m_id == "MockScope4") {
255 h["navigation-background"] = QUrl(sourceDirectory() + "/tests/qmltests/Dash/artwork/background.png");
256 m["page-header"] = h;
257 } else if (m_id == "MockScope5") {
258 h["background"] = "gradient:///lightgrey/grey";
259 h["logo"] = QUrl(sourceDirectory() + "/tests/qmltests/Dash/tst_PageHeader/logo-ubuntu-orange.svg");
260 h["divider-color"] = "red";
261 h["navigation-background"] = "color:///black";
262 m["page-header"] = h;
263 } else if (m_id == "MockScope6") {
264 h["navigation-background"] = "gradient:///blue/red";
265 m["page-header"] = h;
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();
296 Q_EMIT primaryNavigationTagChanged();
299unity::shell::scopes::FilterBaseInterface* Scope::primaryNavigationFilter() const
301 return m_hasPrimaryFilter ? m_primaryNavigationFilter : nullptr;
304unity::shell::scopes::FiltersInterface* Scope::filters() const
309QString Scope::primaryNavigationTag() const
311 if (m_currentNavigationId == "root")
314 return const_cast<Scope*>(this)->getNavigation(m_currentNavigationId)->label();
317int Scope::activeFiltersCount() const
323void Scope::resetPrimaryNavigationTag()
325 if (m_currentNavigationId != "root") {
326 setNavigationState("root");
330void Scope::setHasPrimaryFilter(bool hasPrimaryFilter)
332 m_hasPrimaryFilter = hasPrimaryFilter;
333 Q_EMIT primaryNavigationFilterChanged();
336void Scope::performQuery(const QString& query)
338 Q_EMIT queryPerformed(query);
339 if (query.startsWith("scopes://")) {
340 QString scopeId = query.mid(9);
341 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