on 73354fd help sign in
unity8/plugins/Unity/categories.h
82 lines 1.9 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)
40public:
41 explicit Categories(QObject* parent = 0);
42 ~Categories();
44 enum Roles {
45 RoleId,
46 RoleName,
47 RoleIcon,
48 RoleRenderer,
49 RoleContentType,
50 RoleHints,
51 RoleResults,
52 RoleCount
53 };
55 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
57 QHash<int, QByteArray> roleNames() const;
59 /* getters */
60 DeeListModel* resultModel() { return m_resultModel; }
62 /* setters */
63 void setResultModel(DeeListModel*);
65Q_SIGNALS:
66 void resultModelChanged(DeeListModel*);
68private Q_SLOTS:
69 void onCountChanged();
70 void onEmitCountChanged();
72private:
73 CategoryFilter* getFilter(int index) const;
75 QTimer m_timer;
76 QSet<CategoryFilter*> m_timerFilters;
77 QHash<int, QByteArray> m_roles;
78 DeeListModel* m_resultModel;
79 mutable QMap<int, CategoryFilter*> m_filters;
80};
82#endif // CATEGORIES_H