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

Method buildFolderItem

plugins/qmakemanager/qmakemanager.cpp:175–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173}
174
175ProjectFolderItem* QMakeProjectManager::buildFolderItem(IProject* project, const Path& path, ProjectBaseItem* parent)
176{
177 // find .pro or .pri files in dir
178 QDir dir(path.toLocalFile());
179 const QStringList projectFiles = dir.entryList(QStringList{QStringLiteral("*.pro"), QStringLiteral("*.pri")},
180 QDir::Files);
181 if (projectFiles.isEmpty()) {
182 return nullptr;
183 }
184
185 auto folderItem = new QMakeFolderItem(project, path, parent);
186
187 // TODO: included by not-parent file (in a nother file-tree-branch).
188 QMakeFolderItem* qmakeParent = findQMakeFolderParent(parent);
189 if (!qmakeParent) {
190 // happens for bad qmake configurations
191 return nullptr;
192 }
193
194 for (const QString& file : projectFiles) {
195 const QString absFile = dir.absoluteFilePath(file);
196
197 // TODO: multiple includes by different .pro's
198 QMakeProjectFile* parentPro = nullptr;
199 const auto proFiles = qmakeParent->projectFiles();
200 for (QMakeProjectFile* p : proFiles) {
201 if (p->hasSubProject(absFile)) {
202 parentPro = p;
203 break;
204 }
205 }
206 if (!parentPro && file.endsWith(QLatin1String(".pri"))) {
207 continue;
208 }
209 qCDebug(KDEV_QMAKE) << "add project file:" << absFile;
210 if (parentPro) {
211 qCDebug(KDEV_QMAKE) << "parent:" << parentPro->absoluteFile();
212 } else {
213 qCDebug(KDEV_QMAKE) << "no parent, assume project root";
214 }
215
216 auto qmscope = new QMakeProjectFile(absFile);
217 qmscope->setProject(project);
218
219 const QFileInfo info(absFile);
220 const QDir d = info.dir();
221 /// TODO: cleanup
222 if (parentPro) {
223 // subdir
224 if (QMakeCache* cache = findQMakeCache(project, Path(d.canonicalPath()))) {
225 cache->setMkSpecs(parentPro->mkSpecs());
226 cache->read();
227 qmscope->setQMakeCache(cache);
228 } else {
229 qmscope->setQMakeCache(parentPro->qmakeCache());
230 }
231
232 qmscope->setMkSpecs(parentPro->mkSpecs());

Callers

nothing calls this directly

Calls 15

findQMakeFolderParentFunction · 0.85
toLocalFileMethod · 0.80
projectFilesMethod · 0.80
hasSubProjectMethod · 0.80
endsWithMethod · 0.80
absoluteFileMethod · 0.80
canonicalPathMethod · 0.80
mkSpecsMethod · 0.80
setQMakeCacheMethod · 0.80
qmakeCacheMethod · 0.80
addProjectFileMethod · 0.80
PathClass · 0.70

Tested by

no test coverage detected