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

Function getDirectoryChoice

plugins/grepview/grepdialog.cpp:198–230  ·  view source on GitHub ↗

Returns the chosen directories or files (only the top directories, not subfiles)

Source from the content-addressed store, hash-verified

196
197///Returns the chosen directories or files (only the top directories, not subfiles)
198QList<QUrl> getDirectoryChoice(const QString& text)
199{
200 QList<QUrl> ret;
201 if (text == allOpenFilesString()) {
202 const auto openDocuments = ICore::self()->documentController()->openDocuments();
203 ret.reserve(openDocuments.size());
204 for (auto* doc : openDocuments) {
205 ret << doc->url();
206 }
207 } else if (text == allOpenProjectsString()) {
208 const auto projects = ICore::self()->projectController()->projects();
209 ret.reserve(projects.size());
210 for (auto* project : projects) {
211 ret << project->path().toUrl();
212 }
213 } else {
214 const QStringList semicolonSeparatedFileList = text.split(pathsSeparator(), Qt::SkipEmptyParts);
215 if (!semicolonSeparatedFileList.isEmpty() && QFileInfo::exists(semicolonSeparatedFileList[0])) {
216 // We use QFileInfo to make sure this is really a semicolon-separated file list, not a file containing
217 // a semicolon in the name.
218 ret.reserve(semicolonSeparatedFileList.size());
219 for (const QString& file : semicolonSeparatedFileList) {
220 ret << QUrl::fromLocalFile(file).adjusted(QUrl::StripTrailingSlash | QUrl::NormalizePathSegments);
221 }
222 } else {
223 auto url = QUrl::fromUserInput(text).adjusted(QUrl::StripTrailingSlash | QUrl::NormalizePathSegments);
224 if (!url.isEmpty()) {
225 ret.push_back(std::move(url));
226 }
227 }
228 }
229 return ret;
230}
231
232///Check if all directories are part of a project
233bool directoriesInProject(const QString& dir)

Callers 3

directoriesInProjectFunction · 0.85
isPartOfChoiceMethod · 0.85
startSearchMethod · 0.85

Calls 15

allOpenFilesStringFunction · 0.85
allOpenProjectsStringFunction · 0.85
pathsSeparatorFunction · 0.85
openDocumentsMethod · 0.80
documentControllerMethod · 0.80
projectsMethod · 0.80
projectControllerMethod · 0.80
reserveMethod · 0.45
sizeMethod · 0.45
urlMethod · 0.45
toUrlMethod · 0.45
pathMethod · 0.45

Tested by

no test coverage detected