| 1155 | } |
| 1156 | |
| 1157 | QString 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 | |
| 1194 | QString ProjectController::prettyFileName(const QUrl& url, FormattingOptions format) const |
| 1195 | { |
no test coverage detected