Returns the chosen directories or files (only the top directories, not subfiles)
| 196 | |
| 197 | ///Returns the chosen directories or files (only the top directories, not subfiles) |
| 198 | QList<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 |
| 233 | bool directoriesInProject(const QString& dir) |
no test coverage detected