~aacid/unity8/dash_overview

« back to all changes in this revision

Viewing changes to tests/mocks/Unity/fake_scope.cpp

  • Committer: Albert Astals
  • Date: 2014-08-07 15:27:32 UTC
  • mfrom: (1155.1.29 do_merged)
  • Revision ID: albert.astals@canonical.com-20140807152732-0zf22298f1lsxrz8
Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
#include "fake_scope.h"
21
21
 
22
 
#include "fake_department.h"
 
22
#include "fake_navigation.h"
23
23
#include "fake_resultsmodel.h"
24
24
#include "fake_scopes.h"
25
25
 
27
27
{
28
28
}
29
29
 
30
 
Scope::Scope(QString const& id, QString const& name, bool visible, Scopes* parent, int categories)
 
30
Scope::Scope(QString const& id, QString const& name, bool favorite, Scopes* parent, int categories)
31
31
    : unity::shell::scopes::ScopeInterface(parent)
32
32
    , m_id(id)
33
33
    , m_name(name)
34
 
    , m_visible(visible)
35
34
    , m_searching(false)
 
35
    , m_favorite(favorite)
36
36
    , m_isActive(false)
37
 
    , m_currentDeparment("root")
 
37
    , m_currentNavigationId("root")
 
38
    , m_currentAltNavigationId("altroot")
38
39
    , m_previewRendererName("preview-generic")
39
40
    , m_categories(new Categories(categories, this))
40
41
    , m_openScope(nullptr)
81
82
    return m_searching;
82
83
}
83
84
 
 
85
bool Scope::favorite() const
 
86
{
 
87
    return m_favorite;
 
88
}
 
89
 
84
90
unity::shell::scopes::CategoriesInterface* Scope::categories() const
85
91
{
86
92
    return m_categories;
101
107
    return m_formFactor;
102
108
}
103
109
 
104
 
bool Scope::visible() const
105
 
{
106
 
    return m_visible;
107
 
}
108
 
 
109
110
bool Scope::isActive() const
110
111
{
111
112
    return m_isActive;
135
136
    }
136
137
}
137
138
 
 
139
void Scope::setFavorite(const bool favorite)
 
140
{
 
141
    if (favorite != m_favorite) {
 
142
        m_favorite = favorite;
 
143
        Q_EMIT favoriteChanged();
 
144
    }
 
145
}
138
146
void Scope::setSearchInProgress(const bool inProg)
139
147
{
140
148
    if (inProg != m_searching) {
183
191
    m_openScope = nullptr;
184
192
}
185
193
 
186
 
QString Scope::currentDepartmentId() const
187
 
{
188
 
    return m_currentDeparment;
189
 
}
190
 
 
191
 
bool Scope::hasDepartments() const
192
 
{
193
 
    return true;
 
194
QString Scope::currentNavigationId() const
 
195
{
 
196
    return m_currentNavigationId;
 
197
}
 
198
 
 
199
bool Scope::hasNavigation() const
 
200
{
 
201
    return true;
 
202
}
 
203
 
 
204
QString Scope::currentAltNavigationId() const
 
205
{
 
206
    return m_currentAltNavigationId;
 
207
}
 
208
 
 
209
bool Scope::hasAltNavigation() const
 
210
{
 
211
    return true;
 
212
}
 
213
 
 
214
Scope::Status Scope::status() const
 
215
{
 
216
    return Status::Okay;
194
217
}
195
218
 
196
219
QVariantMap Scope::customizations() const
209
232
    return m;
210
233
}
211
234
 
212
 
unity::shell::scopes::DepartmentInterface* Scope::getDepartment(const QString& id)
 
235
void Scope::refresh()
 
236
{
 
237
    qDebug() << "Scope::refresh is currently not implmented in the fake scopes plugin";
 
238
}
 
239
 
 
240
unity::shell::scopes::NavigationInterface* Scope::getNavigation(const QString& id)
213
241
{
214
242
    if (id.isEmpty())
215
243
        return nullptr;
223
251
        parentId = id.mid(5, 7);
224
252
        parentLabel = parentId;
225
253
    }
226
 
    return new Department(id, id, "all"+id, parentId, parentLabel, this);
227
 
}
228
 
 
229
 
void Scope::loadDepartment(const QString& id)
230
 
{
231
 
    m_currentDeparment = id;
232
 
    Q_EMIT currentDepartmentIdChanged();
 
254
    return new Navigation(id, id, "all"+id, parentId, parentLabel, this);
 
255
}
 
256
 
 
257
unity::shell::scopes::NavigationInterface* Scope::getAltNavigation(QString const& id)
 
258
{
 
259
    if (id.isEmpty())
 
260
        return nullptr;
 
261
 
 
262
    QString parentId;
 
263
    QString parentLabel;
 
264
    if (id.startsWith("altmiddle")) {
 
265
        parentId = "altroot";
 
266
        parentLabel = "altroot";
 
267
    }
 
268
    return new Navigation(id, id, "all"+id, parentId, parentLabel, this);
 
269
}
 
270
 
 
271
void Scope::setNavigationState(const QString &navigationId, bool isAltNavigation)
 
272
{
 
273
    if (isAltNavigation) {
 
274
        m_currentAltNavigationId = navigationId;
 
275
        Q_EMIT currentAltNavigationIdChanged();
 
276
    } else {
 
277
        m_currentNavigationId = navigationId;
 
278
        Q_EMIT currentNavigationIdChanged();
 
279
    }
233
280
}