| 156 | } |
| 157 | |
| 158 | void QuickFindWidget::navigateToNextMatch(bool skipCurrent) |
| 159 | { |
| 160 | qInfo(Q_FUNC_INFO); |
| 161 | |
| 162 | // Early out if there are no matches |
| 163 | if (matches.length() == 0) { |
| 164 | ui->lblInfo->hide(); |
| 165 | return; |
| 166 | } |
| 167 | |
| 168 | if (currentMatchIndex != -1) { |
| 169 | currentMatchIndex++; |
| 170 | if (currentMatchIndex >= matches.length()) { |
| 171 | currentMatchIndex = 0; |
| 172 | } |
| 173 | } |
| 174 | else { |
| 175 | int startPos = INVALID_POSITION; |
| 176 | if (skipCurrent) { |
| 177 | startPos = editor->selectionEnd(); |
| 178 | } |
| 179 | else { |
| 180 | startPos = editor->selectionStart(); |
| 181 | } |
| 182 | |
| 183 | auto it = std::lower_bound(matches.begin(), matches.end(), startPos, [](const QPair<int, int>& pair, int value) { |
| 184 | return pair.first < value; |
| 185 | }); |
| 186 | |
| 187 | if (it != matches.end()) { |
| 188 | currentMatchIndex = std::distance(matches.begin(), it); |
| 189 | } else { |
| 190 | // Wrap back around |
| 191 | currentMatchIndex = 0; |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | // Search wrapped around |
| 196 | if (currentMatchIndex == 0) { |
| 197 | showWrapIndicator(); |
| 198 | } |
| 199 | |
| 200 | goToCurrentMatch(); |
| 201 | } |
| 202 | |
| 203 | void QuickFindWidget::navigateToPrevMatch() |
| 204 | { |