MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / find

Method find

launcher/ui/pages/instance/LogPage.cpp:91–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89 }
90
91 QModelIndex find(const QModelIndex &start, const QString &value, bool reverse) const
92 {
93 QModelIndex parentIndex = parent(start);
94 auto compare = [&](int r) -> QModelIndex
95 {
96 QModelIndex idx = index(r, start.column(), parentIndex);
97 if (!idx.isValid() || idx == start)
98 {
99 return QModelIndex();
100 }
101 QVariant v = data(idx, Qt::DisplayRole);
102 QString t = v.toString();
103 if (t.contains(value, Qt::CaseInsensitive))
104 return idx;
105 return QModelIndex();
106 };
107 if(reverse)
108 {
109 int from = start.row();
110 int to = 0;
111
112 for (int i = 0; i < 2; ++i)
113 {
114 for (int r = from; (r >= to); --r)
115 {
116 auto idx = compare(r);
117 if(idx.isValid())
118 return idx;
119 }
120 // prepare for the next iteration
121 from = rowCount() - 1;
122 to = start.row();
123 }
124 }
125 else
126 {
127 int from = start.row();
128 int to = rowCount(parentIndex);
129
130 for (int i = 0; i < 2; ++i)
131 {
132 for (int r = from; (r < to); ++r)
133 {
134 auto idx = compare(r);
135 if(idx.isValid())
136 return idx;
137 }
138 // prepare for the next iteration
139 from = 0;
140 to = start.row();
141 }
142 }
143 return QModelIndex();
144 }
145private:
146 QFont m_font;
147 std::unique_ptr<LogColorCache> m_colors;

Callers 15

modrinthVersionsTaskMethod · 0.45
modrinthProjectsTaskMethod · 0.45
flameVersionsTaskMethod · 0.45
flameProjectsTaskMethod · 0.45
updateInstanceMethod · 0.45
executeTaskMethod · 0.45
translateMethod · 0.45
reloadLocalFilesMethod · 0.45
resolveMethod · 0.45
getFrontMethod · 0.45
getBackMethod · 0.45
~ListModelMethod · 0.45

Calls 5

QModelIndexClass · 0.85
dataFunction · 0.85
isValidMethod · 0.45
toStringMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected