on 5b03213 help sign in
unity8/plugins/Unity/filters.h
77 lines 2.1 kB history raw
1/*
2 * Copyright (C) 2011, 2013 Canonical, Ltd.
3 *
4 * Authors:
5 * Florian Boucault <florian.boucault@canonical.com>
6 * Pawel Stolowski <pawel.stolowski@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 */
21#ifndef FILTERS_H
22#define FILTERS_H
24// Qt
25#include <QAbstractListModel>
26#include <QList>
28// libunity-core
29#include <UnityCore/Filters.h>
30#include <UnityCore/Filter.h>
32class Filter;
34class Filters : public QAbstractListModel
36 Q_OBJECT
38 Q_ENUMS(Roles)
40public:
41 explicit Filters(unity::dash::Filters::Ptr unityFilters, QObject *parent = nullptr);
42 ~Filters();
44 enum Roles {
45 RoleId = Qt::UserRole,
46 RoleName,
47 RoleIconHint,
48 RoleRendererName,
49 RoleVisible,
50 RoleCollapsed,
51 RoleFiltering,
52 RoleOptions
53 };
55 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
56 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
57 QHash<int, QByteArray> roleNames() const override;
59 Filter* getFilter(const QString& id) const;
61private:
62 void onFilterAdded(unity::dash::Filter::Ptr unityFilter);
63 void onFilterChanged(unity::dash::Filter::Ptr unityFilter);
64 void onFilterRemoved(unity::dash::Filter::Ptr unityFilter);
66 void addFilter(unity::dash::Filter::Ptr unityFilter, int index);
67 void removeFilter(int index);
69 int indexForFilter(unity::dash::Filter::Ptr unityFilter);
71 unity::dash::Filters::Ptr m_unityFilters;
72 QList<Filter*> m_filters;
73};
75Q_DECLARE_METATYPE(Filters*)
77#endif // FILTERS_H