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

Method createSyncButtonMenu

plugins/grepview/grepdialog.cpp:364–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

362}
363
364QMenu* 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
411GrepDialog::~GrepDialog()
412{

Callers

nothing calls this directly

Calls 15

insertFunction · 0.85
sortFunction · 0.85
allOpenFilesStringFunction · 0.85
allOpenProjectsStringFunction · 0.85
activeDocumentMethod · 0.80
documentControllerMethod · 0.80
findProjectForUrlMethod · 0.80
projectControllerMethod · 0.80
projectsMethod · 0.80
PathClass · 0.50
coreMethod · 0.45
parentMethod · 0.45

Tested by

no test coverage detected