-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActionsFilterModel.h
More file actions
47 lines (37 loc) · 1.17 KB
/
ActionsFilterModel.h
File metadata and controls
47 lines (37 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once
#include <QSortFilterProxyModel>
#include <QVector>
/**
* A QSortFilterProxyModel that filters recursively through all child items.
*
* @author Thomas Kroes
*/
class ActionsFilterModel final : public QSortFilterProxyModel
{
Q_OBJECT
public:
/**
* Construct with optional parent.
* @param parent The parent QObject.
*/
explicit ActionsFilterModel(QObject* parent = nullptr);
// Optional: include tooltips and ids in matching.
void setSearchRoles(QVector<int> roles);
protected:
/**
* Reimplemented to filter recursively.
* @param sourceRow The row in the source model.
* @param sourceParent The parent index in the source model.
* @return True if the row should be included in the filtered model.
*/
bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override;
private:
/**
* Check if a row matches the current filter.
* @param idx The index of the row to check.
* @return True if the row matches the filter, false otherwise.
*/
bool rowMatches(const QModelIndex& idx) const;
private:
QVector<int> searchRoles; /** The roles to search in. */
};