FuzzyFilterProxyModel
Qt Base Class: QSortFilterProxyModel
Signature: QSortFilterProxyModel(self, parent: Optional[PySide6.QtCore.QObject] = None) -> None
Base classes
Name | Children | Inherits |
---|---|---|
SortFilterProxyModel prettyqt.core.sortfilterproxymodel |
⋔ Inheritance diagram
graph TD
1473290728656["itemmodels.FuzzyFilterProxyModel"]
1473299898960["core.SortFilterProxyModel"]
1473299903840["core.AbstractProxyModelMixin"]
1473299890176["core.AbstractItemModelMixin"]
1473299815024["core.ObjectMixin"]
140713234304496["builtins.object"]
1473289062816["QtCore.QSortFilterProxyModel"]
1473289061840["QtCore.QAbstractProxyModel"]
1473289050128["QtCore.QAbstractItemModel"]
1473288842240["QtCore.QObject"]
1473291690208["Shiboken.Object"]
1473299898960 --> 1473290728656
1473299903840 --> 1473299898960
1473299890176 --> 1473299903840
1473299815024 --> 1473299890176
140713234304496 --> 1473299815024
1473289062816 --> 1473299898960
1473289061840 --> 1473289062816
1473289050128 --> 1473289061840
1473288842240 --> 1473289050128
1473291690208 --> 1473288842240
140713234304496 --> 1473291690208
🛈 DocStrings
Bases: SortFilterProxyModel
A FilterProxyModel which sorts the results based on a matching score.
The matching score evaluates metrics like upper/lower casing, distance of filter character to match character and some more. Best matches are shown at the top.
The matching score is exposed as a custom UserRole (FuzzyFilterProxyModel.Roles.SortRole) The proxymodel replaces the text from the display role in the given filter column with HTML code in order to color the letter matches. A backup from the original text is made available in the BackupRole. Based on the original text, the proxy calculates a score for the match and makes it available via the SortRole. To display the html code properly, a HtmlItemDelegate is needed.
Example
proxy = itemmodels.FuzzyFilterProxyModel()
proxy.set_source_model(model)
table.set_model(proxy)
table.show()
Source code in prettyqt\itemmodels\proxies\fuzzyfilterproxymodel.py
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
⌗ Property table
Qt Property | Type | Doc |
---|---|---|
objectName |
QString | |
sourceModel |
QAbstractItemModel | |
filterRegularExpression |
QRegularExpression | |
filterKeyColumn |
int | |
dynamicSortFilter |
bool | |
filterCaseSensitivity |
Qt::CaseSensitivity | |
sortCaseSensitivity |
Qt::CaseSensitivity | |
isSortLocaleAware |
bool | |
sortRole |
int | |
filterRole |
int | |
recursiveFilteringEnabled |
bool | |
autoAcceptChildRows |
bool | |
filterMode |
QString | Mode to use for filtering |
search_term |
QString | Current search term |
match_color |
QColor | Color to use for match coloring |