on 14ca310 help sign in
unity8/tests/mocks/Unity/fake_scope.cpp
155 lines 3.2 kB history raw
1/*
2 * Copyright (C) 2013, 2014 Canonical, Ltd.
3 *
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.
7 *
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.
12 *
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/>.
15 */
17#include "fake_scope.h"
18#include "fake_resultsmodel.h"
20Scope::Scope(QObject* parent) : Scope(QString(), QString(), false, parent)
24Scope::Scope(QString const& id, QString const& name, bool visible, QObject* parent)
25 : QObject(parent)
26 , m_id(id)
27 , m_name(name)
28 , m_visible(visible)
29 , m_searching(false)
30 , m_isActive(false)
31 , m_previewRendererName("preview-generic")
32 , m_categories(new Categories(20, this))
36QString Scope::id() const {
37 return m_id;
40QString Scope::name() const {
41 return m_name;
44QString Scope::searchQuery() const {
45 return m_searchQuery;
48QString Scope::iconHint() const {
49 return m_iconHint;
52QString Scope::description() const {
53 return m_description;
56QString Scope::searchHint() const {
57 return QString("");
60QString Scope::shortcut() const {
61 return QString("");
64bool Scope::connected() const {
65 return true;
68bool Scope::searchInProgress() const {
69 return m_searching;
72Categories* Scope::categories() const {
73 return m_categories;
76QString Scope::noResultsHint() const {
77 return m_noResultsHint;
80QString Scope::formFactor() const {
81 return m_formFactor;
84bool Scope::visible() const {
85 return m_visible;
88bool Scope::isActive() const {
89 return m_isActive;
92void Scope::setName(const QString &str) {
93 if (str != m_name) {
94 m_name = str;
95 Q_EMIT nameChanged(m_name);
96 }
99void Scope::setSearchQuery(const QString &str) {
100 if (str != m_searchQuery) {
101 m_searchQuery = str;
102 Q_EMIT searchQueryChanged();
103 }
106void Scope::setFormFactor(const QString &str) {
107 if (str != m_formFactor) {
108 m_formFactor = str;
109 Q_EMIT formFactorChanged();
110 }
113void Scope::setActive(const bool active) {
114 if (active != m_isActive) {
115 m_isActive = active;
116 Q_EMIT isActiveChanged(active);
117 }
120void Scope::setSearchInProgress(const bool inProg) {
121 if (inProg != m_searching) {
122 m_searching = inProg;
123 Q_EMIT searchInProgressChanged();
124 }
127void Scope::setNoResultsHint(const QString& str) {
128 if (str != m_noResultsHint) {
129 m_noResultsHint = str;
130 Q_EMIT noResultsHintChanged();
131 }
134void Scope::activate(QVariant const& result)
136 Q_UNUSED(result);
139PreviewStack* Scope::preview(QVariant const& result)
141 Q_UNUSED(result);
143 // This probably leaks, do we don't care
144 // it's a test after all
145 return new PreviewStack;
148void Scope::cancelActivation()
152void Scope::closeScope(Scope* /*scope*/)
154 qFatal("Scope::closeScope is not implemented");