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

Method prettyFilePath

kdevplatform/shell/projectcontroller.cpp:1157–1192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1155}
1156
1157QString ProjectController::prettyFilePath(const QUrl& url, FormattingOptions format) const
1158{
1159 IProject* project = Core::self()->projectController()->findProjectForUrl(url);
1160
1161 if(!project)
1162 {
1163 // Find a project with the correct base directory at least
1164 const auto projects = Core::self()->projectController()->projects();
1165 auto it = std::find_if(projects.begin(), projects.end(), [&](IProject* candidateProject) {
1166 return (candidateProject->path().toUrl().isParentOf(url));
1167 });
1168 if (it != projects.end()) {
1169 project = *it;
1170 }
1171 }
1172
1173 Path parent = Path(url).parent();
1174 QString prefixText;
1175 if (project) {
1176 if (format == FormatHtml) {
1177 prefixText = QLatin1String("<i>") + project->name() + QLatin1String("</i>/");
1178 } else {
1179 prefixText = project->name() + QLatin1Char(':');
1180 }
1181 QString relativePath = project->path().relativePath(parent);
1182 if(relativePath.startsWith(QLatin1String("./"))) {
1183 relativePath.remove(0, 2);
1184 }
1185 if (!relativePath.isEmpty()) {
1186 prefixText += relativePath + QLatin1Char('/');
1187 }
1188 } else {
1189 prefixText = parent.pathOrUrl() + QLatin1Char('/');
1190 }
1191 return prefixText;
1192}
1193
1194QString ProjectController::prettyFileName(const QUrl& url, FormattingOptions format) const
1195{

Callers 2

DocumentSwitcherItemMethod · 0.80
updateCategoryItemMethod · 0.80

Calls 15

findProjectForUrlMethod · 0.80
projectControllerMethod · 0.80
projectsMethod · 0.80
isParentOfMethod · 0.80
relativePathMethod · 0.80
pathOrUrlMethod · 0.80
PathClass · 0.70
beginMethod · 0.45
endMethod · 0.45
toUrlMethod · 0.45
pathMethod · 0.45
parentMethod · 0.45

Tested by

no test coverage detected