~ci-train-bot/unity8/unity8-ubuntu-zesty-2167

« back to all changes in this revision

Viewing changes to plugins/Unity/categories.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) 2013 Canonical, Ltd.
 
3
 *
 
4
 * Authors:
 
5
 *  Michał Sawicz <michal.sawicz@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
 
 
21
#ifndef CATEGORIES_H
 
22
#define CATEGORIES_H
 
23
 
 
24
// dee-qt
 
25
#include "deelistmodel.h"
 
26
 
 
27
#include <QSet>
 
28
#include <QTimer>
 
29
 
 
30
class CategoryFilter;
 
31
 
 
32
class Categories : public DeeListModel
 
33
{
 
34
    Q_OBJECT
 
35
 
 
36
    Q_ENUMS(Roles)
 
37
 
 
38
    Q_PROPERTY(DeeListModel* resultModel READ resultModel WRITE setResultModel NOTIFY resultModelChanged)
 
39
    Q_PROPERTY(DeeListModel* globalResultModel READ globalResultModel WRITE setResultModel NOTIFY globalResultModelChanged)
 
40
 
 
41
public:
 
42
    explicit Categories(QObject* parent = 0);
 
43
    ~Categories();
 
44
 
 
45
    enum Roles {
 
46
        RoleId,
 
47
        RoleName,
 
48
        RoleIcon,
 
49
        RoleRenderer,
 
50
        RoleHints,
 
51
        RoleResults,
 
52
        RoleGlobalResults,
 
53
        RoleCount,
 
54
        RoleGlobalCount
 
55
    };
 
56
 
 
57
    QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
 
58
 
 
59
    QHash<int, QByteArray> roleNames() const;
 
60
 
 
61
    /* getters */
 
62
    DeeListModel* resultModel() { return m_resultModel; }
 
63
    DeeListModel* globalResultModel() { return m_globalResultModel; }
 
64
 
 
65
    /* setters */
 
66
    void setResultModel(DeeListModel*);
 
67
    void setGlobalResultModel(DeeListModel*);
 
68
 
 
69
Q_SIGNALS:
 
70
    void resultModelChanged(DeeListModel*);
 
71
    void globalResultModelChanged(DeeListModel*);
 
72
 
 
73
private Q_SLOTS:
 
74
    void onCountChanged();
 
75
    void onGlobalCountChanged();
 
76
    void onEmitCountChanged();
 
77
 
 
78
private:
 
79
    CategoryFilter* getFilter(int index) const;
 
80
    CategoryFilter* getGlobalFilter(int index) const;
 
81
 
 
82
    QTimer m_timer;
 
83
    QSet<CategoryFilter*> m_timerFilters;
 
84
    QHash<int, QByteArray> m_roles;
 
85
    DeeListModel* m_resultModel;
 
86
    DeeListModel* m_globalResultModel;
 
87
    mutable QMap<int, CategoryFilter*> m_filters;
 
88
    mutable QMap<int, CategoryFilter*> m_globalFilters;
 
89
};
 
90
 
 
91
#endif // CATEGORIES_H