summary refs log tree commit diff
path: root/src/ui/HiddenEvents.h
blob: 4f0d23b4241a839b0c7640274d336c3dbbebcf2b (plain) (blame)
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
// SPDX-FileCopyrightText: Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later

#pragma once

#include <QObject>
#include <QQmlEngine>
#include <QString>
#include <QVariantList>

#include <mtx/events/event_type.hpp>

class HiddenEvents : public QObject
{
    Q_OBJECT
    QML_ELEMENT
    Q_PROPERTY(QString roomid READ roomid WRITE setRoomid NOTIFY roomidChanged REQUIRED)
    Q_PROPERTY(QVariantList hiddenEvents READ hiddenEvents NOTIFY hiddenEventsChanged)
public:
    explicit HiddenEvents(QObject *p = nullptr)
      : QObject(p)
    {
    }

    Q_INVOKABLE void toggle(int type);
    Q_INVOKABLE void save();

    [[nodiscard]] QString roomid() const { return roomid_; }
    void setRoomid(const QString &r)
    {
        roomid_ = r;
        emit roomidChanged();

        load();
    }

    [[nodiscard]] QVariantList hiddenEvents() const;

signals:
    void roomidChanged();
    void hiddenEventsChanged();

private:
    QString roomid_;
    std::vector<mtx::events::EventType> hiddenEvents_;

    void load();
};