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

Class ClosestMatchToText

plugins/quickopen/projectitemquickopen.cpp:71–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69};
70
71struct ClosestMatchToText
72{
73 explicit ClosestMatchToText(const QHash<int, int>& _cache)
74 : cache(_cache)
75 {
76 }
77
78 /** @brief Calculates the distance to two pre-filtered match items
79 *
80 * @param a The CodeModelView witch represents the first item to be tested
81 * @param b The CodeModelView witch represents the second item to be tested
82 *
83 * @b
84 */
85 inline bool operator()(const CodeModelViewItem& a, const CodeModelViewItem& b) const
86 {
87 const int height_a = cache.value(a.m_id.index(), -1);
88 const int height_b = cache.value(b.m_id.index(), -1);
89
90 Q_ASSERT(height_a != -1);
91 Q_ASSERT(height_b != -1);
92
93 if (height_a == height_b) {
94 // stable sorting for equal items based on index
95 // TODO: fast string-based sorting in such cases?
96 return a.m_id.index() < b.m_id.index();
97 }
98
99 return height_a < height_b;
100 }
101private:
102 const QHash<int, int>& cache;
103};
104
105Path findProjectForForPath(const IndexedString& path)
106{

Callers 1

setFilterTextMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected