~dandrader/unity-api/lifecycle

« back to all changes in this revision

Viewing changes to include/unity/shell/scopes/DepartmentInterface.h

  • Committer: CI bot
  • Author(s): Michal Hruby, Albert Astals
  • Date: 2014-06-16 14:45:00 UTC
  • mfrom: (134.3.11 departments)
  • Revision ID: ps-jenkins@lists.canonical.com-20140616144500-xcnt2u2onjgu26si
Add Departments interfaces
 Fixes: 1320847

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 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
 */
 
16
 
 
17
#ifndef UNITY_SHELL_SCOPES_DEPARTMENTINTERFACE_H
 
18
#define UNITY_SHELL_SCOPES_DEPARTMENTINTERFACE_H
 
19
 
 
20
#include <unity/SymbolExport.h>
 
21
 
 
22
#include <QAbstractListModel>
 
23
 
 
24
namespace unity
 
25
{
 
26
namespace shell
 
27
{
 
28
namespace scopes
 
29
{
 
30
 
 
31
/**
 
32
 * @brief Object representing department instance, which exposes model(s) with results.
 
33
 */
 
34
class UNITY_API DepartmentInterface : public QAbstractListModel
 
35
{
 
36
    Q_OBJECT
 
37
 
 
38
    Q_ENUMS(Roles)
 
39
 
 
40
    /**
 
41
     * @brief Id of the department.
 
42
     */
 
43
    Q_PROPERTY(QString departmentId READ departmentId NOTIFY departmentIdChanged)
 
44
 
 
45
    /**
 
46
     * @brief Label of the department.
 
47
     */
 
48
    Q_PROPERTY(QString label READ label NOTIFY labelChanged)
 
49
 
 
50
    /**
 
51
     * @brief Label for "All Button" of the department.
 
52
     */
 
53
    Q_PROPERTY(QString allLabel READ allLabel NOTIFY allLabelChanged)
 
54
 
 
55
    /**
 
56
     * @brief Parent Id of the department.
 
57
     */
 
58
    Q_PROPERTY(QString parentDepartmentId READ parentDepartmentId NOTIFY parentDepartmentIdChanged)
 
59
 
 
60
    /**
 
61
     * @brief Parent label of the department.
 
62
     */
 
63
    Q_PROPERTY(QString parentLabel READ parentLabel NOTIFY parentLabelChanged)
 
64
 
 
65
    /**
 
66
     * @brief Is the model of the deparment completely loaded?
 
67
     */
 
68
    Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
 
69
 
 
70
    /**
 
71
     * @brief Is this deparment the root deparment?
 
72
     */
 
73
    Q_PROPERTY(bool isRoot READ isRoot NOTIFY isRootChanged)
 
74
 
 
75
    /**
 
76
     * @brief Number of items of the deparment.
 
77
     */
 
78
    Q_PROPERTY(int count READ count NOTIFY countChanged)
 
79
 
 
80
protected:
 
81
    /// @cond
 
82
    explicit DepartmentInterface(QObject* parent = 0) : QAbstractListModel(parent) { }
 
83
    /// @endcond
 
84
 
 
85
public:
 
86
    /**
 
87
     * @brief The roles supported by this model.
 
88
     */
 
89
    enum Roles {
 
90
        RoleDepartmentId,
 
91
        RoleLabel,
 
92
        RoleHasChildren,
 
93
        RoleIsActive
 
94
    };
 
95
 
 
96
    // @cond
 
97
    virtual QString departmentId() const = 0;
 
98
    virtual QString label() const = 0;
 
99
    virtual QString allLabel() const = 0;
 
100
    virtual QString parentDepartmentId() const = 0;
 
101
    virtual QString parentLabel() const = 0;
 
102
    virtual bool loaded() const = 0;
 
103
    virtual bool isRoot() const = 0;
 
104
    virtual int count() const = 0;
 
105
    QHash<int, QByteArray> roleNames() const override
 
106
    {
 
107
        QHash<int, QByteArray> roles;
 
108
        roles[RoleDepartmentId] = "departmentId";
 
109
        roles[RoleLabel] = "label";
 
110
        roles[RoleHasChildren] = "hasChildren";
 
111
        roles[RoleIsActive] = "isActive";
 
112
        return roles;
 
113
    }
 
114
    // @endcond
 
115
 
 
116
Q_SIGNALS:
 
117
    // @cond
 
118
    void departmentIdChanged();
 
119
    void labelChanged();
 
120
    void allLabelChanged();
 
121
    void parentDepartmentIdChanged();
 
122
    void parentLabelChanged();
 
123
    void loadedChanged();
 
124
    void isRootChanged();
 
125
    void countChanged();
 
126
    // @endcond
 
127
};
 
128
 
 
129
}
 
130
}
 
131
}
 
132
 
 
133
Q_DECLARE_METATYPE(unity::shell::scopes::DepartmentInterface*)
 
134
 
 
135
#endif