Qt Utilities  6.4.1
Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models
optioncategoryfiltermodel.cpp
Go to the documentation of this file.
2 #include "./optioncategory.h"
4 
5 namespace QtUtilities {
6 
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
OptionCategoryFilterModel(QObject *parent=nullptr)
Constructs an option category filter model.
bool filterAcceptsRow(int source_row, const QModelIndex &sourceParent) const override
The OptionCategory class wraps associated option pages.