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

Method seekFile

plugins/patchreview/patchreviewtoolview.cpp:306–357  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

304}
305
306void PatchReviewToolView::seekFile(bool forwards)
307{
308 if(!m_plugin->patch())
309 return;
310 const QList<QUrl> checkedUrls = m_fileModel->checkedUrls();
311 QList<QUrl> allUrls = m_fileModel->urls();
312 IDocument* current = ICore::self()->documentController()->activeDocument();
313 if(!current || checkedUrls.empty())
314 return;
315 qCDebug(PLUGIN_PATCHREVIEW) << "seeking direction" << forwards;
316 int currentIndex = allUrls.indexOf(current->url());
317 QUrl newUrl;
318 if((forwards && current->url() == checkedUrls.back()) ||
319 (!forwards && current->url() == checkedUrls[0]))
320 {
321 newUrl = m_plugin->patch()->file();
322 qCDebug(PLUGIN_PATCHREVIEW) << "jumping to patch";
323 }
324 else if(current->url() == m_plugin->patch()->file() || currentIndex == -1)
325 {
326 if(forwards)
327 newUrl = checkedUrls[0];
328 else
329 newUrl = checkedUrls.back();
330 qCDebug(PLUGIN_PATCHREVIEW) << "jumping from patch";
331 } else {
332 QSet<QUrl> checkedUrlsSet(checkedUrls.begin(), checkedUrls.end());
333 for(int offset = 1; offset < allUrls.size(); ++offset)
334 {
335 int pos;
336 if(forwards) {
337 pos = (currentIndex + offset) % allUrls.size();
338 }else{
339 pos = currentIndex - offset;
340 if(pos < 0)
341 pos += allUrls.size();
342 }
343 if(checkedUrlsSet.contains(allUrls[pos]))
344 {
345 newUrl = allUrls[pos];
346 break;
347 }
348 }
349 }
350
351 if(newUrl.isValid())
352 {
353 open( newUrl, true );
354 }else{
355 qCDebug(PLUGIN_PATCHREVIEW) << "found no valid target url";
356 }
357}
358
359void PatchReviewToolView::open( const QUrl& url, bool activate ) const
360{

Callers

nothing calls this directly

Calls 15

patchMethod · 0.80
checkedUrlsMethod · 0.80
activeDocumentMethod · 0.80
documentControllerMethod · 0.80
emptyMethod · 0.80
urlsMethod · 0.45
indexOfMethod · 0.45
urlMethod · 0.45
backMethod · 0.45
fileMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected