Qt Utilities: settingsdialog/optioncategoryfiltermodel.cpp Source File

Qt Utilities 6.21.2 Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models

Loading...
Searching...
No Matches
optioncategoryfiltermodel.cpp
Go to the documentation of this file.
1#include "./optioncategoryfiltermodel.h"
2#include "./optioncategory.h"
3#include "./optioncategorymodel.h"
4
5namespace QtUtilities {
6
12
16OptionCategoryFilterModel::OptionCategoryFilterModel(QObject *parent)
17 : QSortFilterProxyModel(parent)
18{
19}
20
21 bool OptionCategoryFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
22{
23 if (QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent))
24 return true;
25 if (auto *const model = qobject_cast<OptionCategoryModel *>(sourceModel())) {
26 if (OptionCategory *category = model->category(sourceRow)) {
27 return category->matches(
28#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
29 filterRegularExpression().pattern()
30#elif (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
31 !filterRegularExpression().pattern().isEmpty() ? filterRegularExpression().pattern() : filterRegExp().pattern()
32#else
33 filterRegExp().pattern()
34#endif
35 );
36 }
37 }
38 return false;
39}
40} // namespace QtUtilities
QtUtilities::OptionCategoryFilterModel::OptionCategoryFilterModel
OptionCategoryFilterModel(QObject *parent=nullptr)
Constructs an option category filter model.
Definition optioncategoryfiltermodel.cpp:16
QtUtilities::OptionCategoryFilterModel::filterAcceptsRow
bool filterAcceptsRow(int source_row, const QModelIndex &sourceParent) const override
Definition optioncategoryfiltermodel.cpp:21
QtUtilities::OptionCategory
The OptionCategory class wraps associated option pages.
Definition optioncategory.h:18
QtUtilities
!
Definition trylocker.h:8
optioncategory.h
optioncategoryfiltermodel.h
optioncategorymodel.h