File indexing completed on 2024-12-01 07:40:36
0001 // SPDX-FileCopyrightText: 2022 James Graham <james.h.graham@protonmail.com> 0002 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0003 0004 #pragma once 0005 0006 #include <QQmlEngine> 0007 #include <QSortFilterProxyModel> 0008 0009 /** 0010 * @class StateFilterModel 0011 * 0012 * This class creates a custom QSortFilterProxyModel for filtering a list of state events. 0013 * Event types can be filtered out by adding them to m_stateEventTypesFiltered. 0014 */ 0015 class StateFilterModel : public QSortFilterProxyModel 0016 { 0017 Q_OBJECT 0018 QML_ELEMENT 0019 0020 public: 0021 /** 0022 * @brief Custom filter function checking if an event type has been filtered out. 0023 * 0024 * The filter rejects a row if the state event type has been added to m_stateEventTypesFiltered. 0025 * 0026 * @sa m_stateEventTypesFiltered 0027 */ 0028 bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; 0029 0030 /** 0031 * @brief Add an event type to m_stateEventTypesFiltered. 0032 * 0033 * @sa m_stateEventTypesFiltered 0034 */ 0035 Q_INVOKABLE void addStateEventTypeFiltered(const QString &stateEventType); 0036 0037 /** 0038 * @brief Remove an event type from m_stateEventTypesFiltered. 0039 * 0040 * @sa m_stateEventTypesFiltered 0041 */ 0042 Q_INVOKABLE void removeStateEventTypeFiltered(const QString &stateEventType); 0043 0044 private: 0045 QStringList m_stateEventTypesFiltered; 0046 };