File: notificationgroupcollapsingproxymodel_p.h

package info (click to toggle)
plasma-workspace 4%3A5.27.5-2%2Bdeb12u2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 102,040 kB
  • sloc: cpp: 121,800; xml: 3,238; python: 645; perl: 586; sh: 254; javascript: 113; ruby: 62; makefile: 15; ansic: 13
file content (58 lines) | stat: -rw-r--r-- 1,447 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
    SPDX-FileCopyrightText: 2019 Kai Uwe Broulik <kde@privat.broulik.de>

    SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/

#pragma once

#include <QDateTime>
#include <QSortFilterProxyModel>

namespace NotificationManager
{
class NotificationGroupCollapsingProxyModel : public QSortFilterProxyModel
{
    Q_OBJECT

public:
    explicit NotificationGroupCollapsingProxyModel(QObject *parent = nullptr);
    ~NotificationGroupCollapsingProxyModel() override;

    void setSourceModel(QAbstractItemModel *sourceModel) override;

    QVariant data(const QModelIndex &index, int role) const override;
    bool setData(const QModelIndex &index, const QVariant &value, int role) override;

    int limit() const;
    void setLimit(int limit);

    QDateTime lastRead() const;
    void setLastRead(const QDateTime &lastRead);

    bool expandUnread() const;
    void setExpandUnread(bool expand);

    void collapseAll();

Q_SIGNALS:
    void limitChanged();
    void lastReadChanged();
    void expandUnreadChanged();

protected:
    bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;

private:
    bool setGroupExpanded(const QModelIndex &idx, bool expanded);

    void invalidateGroupRoles();

    int m_limit = 0;
    QDateTime m_lastRead;
    bool m_expandUnread = false;

    QList<QPersistentModelIndex> m_expandedGroups;
};

} // namespace NotificationManager