| 304 | } |
| 305 | |
| 306 | void 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 | |
| 359 | void PatchReviewToolView::open( const QUrl& url, bool activate ) const |
| 360 | { |
nothing calls this directly
no test coverage detected