Changeset View
Changeset View
Standalone View
Standalone View
libnotificationmanager/notificationgroupingproxymodel_p.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright 2016 Eike Hein <hein@kde.org> | ||||
3 | * Copyright 2019 Kai Uwe Broulik <kde@privat.broulik.de> | ||||
4 | * | ||||
5 | * This library is free software; you can redistribute it and/or | ||||
6 | * modify it under the terms of the GNU Lesser General Public | ||||
7 | * License as published by the Free Software Foundation; either | ||||
8 | * version 2.1 of the License, or (at your option) version 3, or any | ||||
9 | * later version accepted by the membership of KDE e.V. (or its | ||||
10 | * successor approved by the membership of KDE e.V.), which shall | ||||
11 | * act as a proxy defined in Section 6 of version 3 of the license. | ||||
12 | * | ||||
13 | * This library is distributed in the hope that it will be useful, | ||||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
16 | * Lesser General Public License for more details. | ||||
17 | * | ||||
18 | * You should have received a copy of the GNU Lesser General Public | ||||
19 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
20 | */ | ||||
21 | | ||||
22 | | ||||
23 | #pragma once | ||||
24 | | ||||
25 | #include <QAbstractProxyModel> | ||||
26 | | ||||
27 | namespace NotificationManager | ||||
28 | { | ||||
29 | | ||||
30 | class NotificationGroupingProxyModel : public QAbstractProxyModel | ||||
31 | { | ||||
32 | Q_OBJECT | ||||
33 | | ||||
34 | public: | ||||
35 | explicit NotificationGroupingProxyModel(QObject *parent = nullptr); | ||||
36 | ~NotificationGroupingProxyModel() override; | ||||
37 | | ||||
38 | void setSourceModel(QAbstractItemModel *sourceModel) override; | ||||
39 | | ||||
40 | QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; | ||||
41 | QModelIndex parent(const QModelIndex &child) const override; | ||||
42 | | ||||
43 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; | ||||
44 | bool hasChildren(const QModelIndex &parent = QModelIndex()) const override; | ||||
45 | int columnCount(const QModelIndex &parent = QModelIndex()) const override; | ||||
46 | | ||||
47 | QVariant data(const QModelIndex &proxyIndex, int role) const override; | ||||
48 | | ||||
49 | QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override; | ||||
50 | QModelIndex mapToSource(const QModelIndex &proxyIndex) const override; | ||||
51 | | ||||
52 | protected: | ||||
53 | //bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override; | ||||
54 | | ||||
55 | private: | ||||
56 | bool appsMatch(const QModelIndex &a, const QModelIndex &b) const; | ||||
57 | bool isGroup(int row) const; | ||||
58 | bool tryToGroup(const QModelIndex &sourceIndex, bool silent = false); | ||||
59 | void adjustMap(int anchor, int delta); | ||||
60 | void rebuildMap(); | ||||
61 | void checkGrouping(bool silent = false); | ||||
62 | void formGroupFor(const QModelIndex &index); | ||||
63 | | ||||
64 | QVector<QVector<int> *> rowMap; | ||||
65 | | ||||
66 | }; | ||||
67 | | ||||
68 | } // namespace NotificationManager |