~unity-team/unity8/ota9.5

« back to all changes in this revision

Viewing changes to plugins/Unity/lenses.h

  • Committer: Michał Sawicz
  • Date: 2013-06-05 22:03:08 UTC
  • Revision ID: michal.sawicz@canonical.com-20130605220308-yny8fv3futtr04fg
Inital unity8 commit.

Previous history can be found at https://code.launchpad.net/~unity-team/unity/phablet

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2011 Canonical, Ltd.
 
3
 *
 
4
 * Authors:
 
5
 *  Florian Boucault <florian.boucault@canonical.com>
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation; version 3.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
 
 
20
#ifndef LENSES_H
 
21
#define LENSES_H
 
22
 
 
23
// Qt
 
24
#include <QAbstractListModel>
 
25
#include <QList>
 
26
 
 
27
// libunity-core
 
28
#include <UnityCore/Lens.h>
 
29
#include <UnityCore/HomeLens.h>
 
30
 
 
31
namespace unity
 
32
{
 
33
namespace dash
 
34
{
 
35
class Lenses;
 
36
}
 
37
}
 
38
 
 
39
class Hotkey;
 
40
class Lens;
 
41
 
 
42
class Lenses : public QAbstractListModel
 
43
{
 
44
    Q_OBJECT
 
45
 
 
46
    Q_ENUMS(Roles)
 
47
 
 
48
    Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
 
49
 
 
50
public:
 
51
    explicit Lenses(QObject *parent = 0);
 
52
    ~Lenses() = default;
 
53
 
 
54
    enum Roles {
 
55
        RoleLens,
 
56
        RoleId,
 
57
        RoleVisible
 
58
    };
 
59
 
 
60
    QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
 
61
    Q_INVOKABLE int rowCount(const QModelIndex& parent = QModelIndex()) const;
 
62
 
 
63
    Q_INVOKABLE QVariant get(int row) const;
 
64
    Q_INVOKABLE QVariant get(const QString& lens_id) const;
 
65
 
 
66
    QHash<int, QByteArray> roleNames() const;
 
67
 
 
68
    bool loaded() const;
 
69
 
 
70
Q_SIGNALS:
 
71
    void activateLensRequested(const QString& lens_id);
 
72
    void loadedChanged(bool loaded);
 
73
 
 
74
private Q_SLOTS:
 
75
    void onLensAdded(const unity::dash::Lens::Ptr& lens);
 
76
    void onLensesLoaded();
 
77
    void onLensPropertyChanged();
 
78
 
 
79
private:
 
80
    unity::dash::Lenses::Ptr m_unityLenses;
 
81
    unity::dash::HomeLens::Ptr m_homeLens;
 
82
    QList<Lens*> m_lenses;
 
83
    QHash<int, QByteArray> m_roles;
 
84
    bool m_loaded;
 
85
 
 
86
    void addUnityLens(const unity::dash::Lens::Ptr& unity_lens);
 
87
    void removeUnityLens(int index);
 
88
};
 
89
 
 
90
#endif // LENSES_H