MCPcopy Create free account
hub / github.com/KDE/kdevelop / setFilter

Method setFilter

kdevplatform/language/interfaces/quickopenfilter.h:76–114  ·  view source on GitHub ↗

Changes the filter-text and refilters the data

Source from the content-addressed store, hash-verified

74
75 ///Changes the filter-text and refilters the data
76 void setFilter(const QString& text)
77 {
78 if (m_oldFilterText == text) {
79 return;
80 }
81 if (text.isEmpty()) {
82 clearFilter();
83 return;
84 }
85
86 const QVector<Item> filterBase = text.startsWith(m_oldFilterText) ?
87 m_filtered :
88 m_items; //Start filtering based on the whole data
89
90 m_filtered.clear();
91
92 QStringList typedFragments = text.split(QStringLiteral("::"), Qt::SkipEmptyParts);
93 if (typedFragments.isEmpty()) {
94 clearFilter();
95 return;
96 }
97 if (typedFragments.last().endsWith(QLatin1Char(':'))) {
98 // remove the trailing colon if there's only one; otherwise,
99 // this breaks incremental filtering
100 typedFragments.last().chop(1);
101 }
102 if (typedFragments.size() == 1 && typedFragments.last().isEmpty()) {
103 clearFilter();
104 return;
105 }
106 for (const Item& data : filterBase) {
107 const QString& itemData = itemText(data);
108 if (itemData.contains(text, Qt::CaseInsensitive) || matchesAbbreviationMulti(itemData, typedFragments)) {
109 m_filtered << data;
110 }
111 }
112
113 m_oldFilterText = text;
114 }
115
116protected:
117 ///Should return the text an item should be filtered by.

Callers

nothing calls this directly

Calls 8

matchesAbbreviationMultiFunction · 0.85
endsWithMethod · 0.80
isEmptyMethod · 0.45
clearMethod · 0.45
splitMethod · 0.45
lastMethod · 0.45
sizeMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected