on 4787a4f help sign in
unity8/plugins/Unity/categories.h
91 lines 2.4 kB history raw
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 */
21#ifndef CATEGORIES_H
22#define CATEGORIES_H
24// dee-qt
25#include "deelistmodel.h"
27#include <QSet>
28#include <QTimer>
30class CategoryFilter;
32class Categories : public DeeListModel
34 Q_OBJECT
36 Q_ENUMS(Roles)
38 Q_PROPERTY(DeeListModel* resultModel READ resultModel WRITE setResultModel NOTIFY resultModelChanged)
39 Q_PROPERTY(DeeListModel* globalResultModel READ globalResultModel WRITE setResultModel NOTIFY globalResultModelChanged)
41public:
42 explicit Categories(QObject* parent = 0);
43 ~Categories();
45 enum Roles {
46 RoleId,
47 RoleName,
48 RoleIcon,
49 RoleRenderer,
50 RoleHints,
51 RoleResults,
52 RoleGlobalResults,
53 RoleCount,
54 RoleGlobalCount
55 };
57 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
59 QHash<int, QByteArray> roleNames() const;
61 /* getters */
62 DeeListModel* resultModel() { return m_resultModel; }
63 DeeListModel* globalResultModel() { return m_globalResultModel; }
65 /* setters */
66 void setResultModel(DeeListModel*);
67 void setGlobalResultModel(DeeListModel*);
69Q_SIGNALS:
70 void resultModelChanged(DeeListModel*);
71 void globalResultModelChanged(DeeListModel*);
73private Q_SLOTS:
74 void onCountChanged();
75 void onGlobalCountChanged();
76 void onEmitCountChanged();
78private:
79 CategoryFilter* getFilter(int index) const;
80 CategoryFilter* getGlobalFilter(int index) const;
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};
91#endif // CATEGORIES_H