on f2c2cdb help sign in
unity8/plugins/Unity/categories.h
80 lines 1.9 kB history raw
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * Authors:
5 * Michał Sawicz <michal.sawicz@canonical.com>
6 * Michal Hruby <michal.hruby@canonical.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 3.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
22#ifndef CATEGORIES_H
23#define CATEGORIES_H
25// unity-core
26#include <UnityCore/Scope.h>
28// dee-qt
29#include "deelistmodel.h"
31#include <QPointer>
32#include <QSet>
33#include <QTimer>
35class Categories : public DeeListModel
37 Q_OBJECT
39 Q_ENUMS(Roles)
41public:
42 explicit Categories(QObject* parent = 0);
44 enum Roles {
45 RoleId,
46 RoleName,
47 RoleIcon,
48 RoleRenderer,
49 RoleContentType,
50 RoleHints,
51 RoleResults,
52 RoleCount,
53 RoleCategoryIndex
54 };
56 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
58 QHash<int, QByteArray> roleNames() const;
60 /* setters */
61 void setUnityScope(const unity::dash::Scope::Ptr& scope);
63private Q_SLOTS:
64 void onCountChanged();
65 void onEmitCountChanged();
67private:
68 void onCategoriesModelChanged(unity::glib::Object<DeeModel> model);
70 DeeListModel* getResults(int index) const;
72 unity::dash::Scope::Ptr m_unityScope;
73 QTimer m_timer;
74 QSet<int> m_updatedCategories;
75 QHash<int, QByteArray> m_roles;
76 mutable QMap<int, DeeListModel*> m_results;
77 sigc::connection m_categoriesChangedConnection;
78};
80#endif // CATEGORIES_H