| 362 | } |
| 363 | |
| 364 | QMenu* GrepDialog::createSyncButtonMenu() |
| 365 | { |
| 366 | auto* ret = new QMenu(this); |
| 367 | |
| 368 | QSet<Path> hadUrls; |
| 369 | |
| 370 | IDocument *doc = m_plugin->core()->documentController()->activeDocument(); |
| 371 | if ( doc ) |
| 372 | { |
| 373 | Path url = Path(doc->url()).parent(); |
| 374 | |
| 375 | // always add the current file's parent directory |
| 376 | hadUrls.insert(url); |
| 377 | addUrlToMenu(ret, url.toUrl()); |
| 378 | |
| 379 | url = url.parent(); |
| 380 | |
| 381 | while(m_plugin->core()->projectController()->findProjectForUrl(url.toUrl())) |
| 382 | { |
| 383 | if (!Algorithm::insert(hadUrls, url).inserted) { |
| 384 | break; |
| 385 | } |
| 386 | addUrlToMenu(ret, url.toUrl()); |
| 387 | url = url.parent(); |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | QVector<QUrl> otherProjectUrls; |
| 392 | const auto projects = m_plugin->core()->projectController()->projects(); |
| 393 | for (IProject* project : projects) { |
| 394 | if (!hadUrls.contains(project->path())) { |
| 395 | otherProjectUrls.append(project->path().toUrl()); |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | // sort the remaining project URLs alphabetically |
| 400 | std::sort(otherProjectUrls.begin(), otherProjectUrls.end()); |
| 401 | for (const QUrl& url : std::as_const(otherProjectUrls)) { |
| 402 | addUrlToMenu(ret, url); |
| 403 | } |
| 404 | |
| 405 | ret->addSeparator(); |
| 406 | addStringToMenu(ret, allOpenFilesString()); |
| 407 | addStringToMenu(ret, allOpenProjectsString()); |
| 408 | return ret; |
| 409 | } |
| 410 | |
| 411 | GrepDialog::~GrepDialog() |
| 412 | { |
nothing calls this directly
no test coverage detected