on 6ca9421 help sign in
unity8/tests/mocks/Unity/fake_scopes.h
83 lines 2.6 kB history raw
1/*
2 * Copyright (C) 2013 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 *
16 * Author: Nick Dedekind <nick.dedekind@canonical.com>
17 */
19#ifndef FAKE_SCOPES_H
20#define FAKE_SCOPES_H
22#include <unity/shell/scopes/ScopesInterface.h>
24// Local
25#include "fake_scope.h"
27// Qt
28#include <QList>
29#include <QSet>
30#include <QTimer>
32class ScopesOverview;
34class Scopes : public unity::shell::scopes::ScopesInterface
36 Q_OBJECT
38public:
39 explicit Scopes(QObject *parent = 0);
40 ~Scopes();
42 Q_INVOKABLE int rowCount(const QModelIndex& parent = QModelIndex()) const override;
44 Q_INVOKABLE unity::shell::scopes::ScopeInterface* getScope(int row) const override;
45 Q_INVOKABLE unity::shell::scopes::ScopeInterface* getScope(const QString& scope_id) const override;
47 Q_INVOKABLE void addScope(Scope* scope);
49 Q_INVOKABLE void clear();
50 Q_INVOKABLE void clearFavorites();
51 Q_INVOKABLE void load();
53 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
54 QModelIndex parent ( const QModelIndex & index ) const override;
56 bool loaded() const override;
57 int count() const override;
58 unity::shell::scopes::ScopeInterface* overviewScope() const override;
60 Q_INVOKABLE void setFavorite(const QString& scopeId, bool favorite) override;
61 Q_INVOKABLE void moveFavoriteTo(const QString& scopeId, int index) override;
63 void addTempScope(unity::shell::scopes::ScopeInterface* scope);
64 Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface* scope) override;
66 // This is used as part of implementation of the other C++ code, not API
67 QList<Scope*> favScopes() const;
68 QList<Scope*> nonFavScopes() const;
69 Q_INVOKABLE Scope* getScopeFromAll(const QString& scope_id) const;
71private Q_SLOTS:
72 void updateScopes();
74private:
75 QList<Scope*> m_scopes; // the favorite ones
76 QList<Scope*> m_allScopes;
77 QSet<unity::shell::scopes::ScopeInterface*> m_tempScopes;
78 ScopesOverview *m_scopesOverview;
79 bool m_loaded;
80 QTimer timer;
81};
83#endif // SCOPES_H