* Generates the base path (without extension) and the file type * for the specified url. * * @returns pair of base path and file type which has been found for @p url. */
| 133 | * @returns pair of base path and file type which has been found for @p url. |
| 134 | */ |
| 135 | QPair<QString,FileType> basePathAndTypeForUrl(const QUrl &url) |
| 136 | { |
| 137 | QString path = url.toLocalFile(); |
| 138 | int idxSlash = path.lastIndexOf(QLatin1Char('/')); |
| 139 | int idxDot = path.lastIndexOf(QLatin1Char('.')); |
| 140 | FileType fileType = Unknown; |
| 141 | QString basePath; |
| 142 | if (idxSlash >= 0 && idxDot >= 0 && idxDot > idxSlash) { |
| 143 | basePath = path.left(idxDot); |
| 144 | if (idxDot + 1 < path.length()) { |
| 145 | QString extension = path.mid(idxDot + 1); |
| 146 | if (ClangHelpers::isHeader(extension)) { |
| 147 | fileType = Header; |
| 148 | } else if (ClangHelpers::isSource(extension)) { |
| 149 | fileType = Source; |
| 150 | } |
| 151 | } |
| 152 | } else { |
| 153 | basePath = path; |
| 154 | } |
| 155 | |
| 156 | return qMakePair(basePath, fileType); |
| 157 | } |
| 158 | |
| 159 | } |
| 160 |
no test coverage detected