MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / getExistingDirectory

Method getExistingDirectory

gui/projectfiledialog.cpp:561–584  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

559}
560
561QString ProjectFileDialog::getExistingDirectory(const QString &caption, bool trailingSlash)
562{
563 const QFileInfo inf(mProjectFile->getFilename());
564 const QString projectPath = inf.absolutePath();
565 QString selectedDir = QFileDialog::getExistingDirectory(this,
566 caption,
567 projectPath);
568
569 if (selectedDir.isEmpty())
570 return QString();
571
572 // Check if the path is relative to project file's path and if so
573 // make it a relative path instead of absolute path.
574 const QDir dir(projectPath);
575 const QString relpath(dir.relativeFilePath(selectedDir));
576 if (!relpath.startsWith("../.."))
577 selectedDir = relpath;
578
579 // Trailing slash..
580 if (trailingSlash && !selectedDir.endsWith('/'))
581 selectedDir += '/';
582
583 return selectedDir;
584}
585
586void ProjectFileDialog::browseBuildDir()
587{

Callers

nothing calls this directly

Calls 4

isEmptyMethod · 0.80
startsWithMethod · 0.80
endsWithMethod · 0.80
QStringClass · 0.70

Tested by

no test coverage detected