File indexing completed on 2024-05-19 05:06:58
0001 /* 0002 SPDX-FileCopyrightText: 2020 Thomas Baumgart <tbaumgart@kde.org> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #ifndef LEDGERFILTER_H 0007 #define LEDGERFILTER_H 0008 0009 #include "kmm_models_export.h" 0010 0011 // ---------------------------------------------------------------------------- 0012 // QT Includes 0013 0014 class QComboBox; 0015 class QLineEdit; 0016 0017 // ---------------------------------------------------------------------------- 0018 // KDE Includes 0019 0020 // ---------------------------------------------------------------------------- 0021 // Project Includes 0022 0023 #include "ledgersortproxymodel.h" 0024 0025 class LedgerFilterPrivate; 0026 class KMM_MODELS_EXPORT LedgerFilter : public LedgerSortProxyModel 0027 { 0028 Q_OBJECT 0029 Q_DECLARE_PRIVATE(LedgerFilter) 0030 Q_DISABLE_COPY(LedgerFilter) 0031 0032 public: 0033 enum class State { 0034 Any, 0035 Imported, 0036 Matched, 0037 Erroneous, 0038 NotMarked, 0039 NotReconciled, 0040 Cleared, 0041 Scheduled, 0042 }; 0043 0044 explicit LedgerFilter(QObject* parent); 0045 0046 void setComboBox(QComboBox* filterBox); 0047 void setLineEdit(QLineEdit* lineEdit); 0048 0049 /** 0050 * Clear all filter settings. This will cause the 0051 * pattern of the filterFixedString to be cleared, 0052 * the stateFilter to be set to State::Any and the 0053 * endDate to be set to QDate(). 0054 */ 0055 void clearFilter(); 0056 0057 void setStateFilter(LedgerFilter::State state); 0058 void setFilterFixedString(const QString &pattern); 0059 0060 /** 0061 * Set the end date of the state filter for transactions. 0062 * Transactions with a postdate after @a date will not be filtered. 0063 * When the object is created, the setting is QDate() which 0064 * causes the filter to be applied to all transactions. 0065 */ 0066 void setEndDate(const QDate& endDate); 0067 0068 /** 0069 * This method returns information about an active 0070 * filter (@c true or @c false) when @a role is 0071 * @c ActiveFilterRole. Otherwise it returns the 0072 * return value of the base class implementation. 0073 */ 0074 QVariant data(const QModelIndex& index, int role) const override; 0075 0076 protected: 0077 /** 0078 * @note Does not call base class implementation 0079 */ 0080 bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override; 0081 0082 // prohibit usage of these methods as we internally rely on setFilterFixedString 0083 void setFilterRegularExpression(const QString& pattern); 0084 void setFilterRegExp(const QString &pattern); 0085 }; 0086 0087 Q_DECLARE_METATYPE(LedgerFilter::State) 0088 0089 #endif // LEDGERFILTER_H 0090