Debian Codegraph @

settingsdialog/optioncategoryfiltermodel.cpp

raw symbols SCIP
1 #include "./optioncategoryfiltermodel.h"
2 #include "./optioncategory.h"
3 #include "./optioncategorymodel.h"
4
5 namespace QtUtilities {
6
7 /*!
8 * \class OptionCategoryFilterModel
9 * \brief The OptionCategoryFilterModel class is used by SettingsDialog to
10 * filter option categories.
11 */
12
13 /*!
14 * \brief Constructs an option category filter model.
15 */
16 OptionCategoryFilterModel::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