File indexing completed on 2024-11-24 04:50:39

0001 // SPDX-FileCopyrightText: 2022 Carl Schwan <carl@carlschwan.eu>
0002 // SPDX-License-Identifier: LGPL-2.0-or-later
0003 #pragma once
0004 #include <QObject>
0005 
0006 /**
0007  * This class is used to enable cross-compatible filtering of data in models.
0008  */
0009 class Filter : public QObject
0010 {
0011     Q_OBJECT
0012     Q_PROPERTY(qint64 collectionId READ collectionId WRITE setCollectionId NOTIFY collectionIdChanged)
0013     Q_PROPERTY(QStringList tags READ tags WRITE setTags NOTIFY tagsChanged)
0014     Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
0015 
0016 public:
0017     qint64 collectionId() const;
0018     QStringList tags() const;
0019     QString name() const;
0020 
0021 public Q_SLOTS:
0022     void setCollectionId(const qint64 collectionId);
0023     void setTags(const QStringList tags);
0024     void setName(const QString &name);
0025 
0026     void toggleFilterTag(const QString tagName);
0027     void reset();
0028     void removeTag(const QString &tagName);
0029 
0030 Q_SIGNALS:
0031     void collectionIdChanged();
0032     void tagsChanged();
0033     void nameChanged();
0034 
0035 private:
0036     qint64 m_collectionId = -1;
0037     QStringList m_tags;
0038     QString m_name;
0039 };