forked from qt-creator/qt-creator
CMakePM: Refactor display of CMakeLists.txt
All CMakeLists.txt from the Project view are marked as generated, except the root one. This means that in normal case they will be hidden. Every CMake Target (except Utility) will get a CMakeLists.txt:<number> entry with the definition line of the target. The CMake Folders will get an entry with the CMakeLists.txt which can be accessed via context menu and "Open...". The CMake Folder that only had a CMakeLists.txt will be removed when the filter "Hide Empty Directories" is checked. This for example makes a reduced plugin Qt Creator only display the enabled plugins, and not all plugins! With this change the "Simplify Tree" view will no longer have many CMakeLists.txt entries, which makes the view more useful. Fixes: QTCREATORBUG-31362 Change-Id: I708171e4b114100fae6fb592044a19fc36239261 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -44,6 +44,8 @@ CMakeListsNode::CMakeListsNode(const FilePath &cmakeListPath) :
|
||||
{
|
||||
setIcon(DirectoryIcon(Constants::Icons::FILE_OVERLAY));
|
||||
setListInProject(false);
|
||||
setLocationInfo(
|
||||
{{Constants::CMAKE_LISTS_TXT, cmakeListPath.pathAppended(Constants::CMAKE_LISTS_TXT)}});
|
||||
}
|
||||
|
||||
bool CMakeListsNode::showInSimpleTree() const
|
||||
|
||||
@@ -112,10 +112,12 @@ static CMakeFileResult extractCMakeFilesData(const QFuture<void> &cancelFuture,
|
||||
}
|
||||
|
||||
auto node = std::make_unique<FileNode>(info.path, FileType::Project);
|
||||
node->setIsGenerated(info.isGenerated
|
||||
&& !info.isCMakeListsDotTxt); // CMakeLists.txt are never
|
||||
// generated, independent
|
||||
// what cmake thinks:-)
|
||||
node->setIsGenerated(info.isGenerated);
|
||||
|
||||
// We will have the CMakeLists.txt file in the Target nodes as a child node.
|
||||
// Except the root CMakeLists.txt file.
|
||||
if (info.isCMakeListsDotTxt && info.path.parentDir() != sourceDirectory)
|
||||
node->setIsGenerated(true);
|
||||
|
||||
if (info.isCMakeListsDotTxt) {
|
||||
result.cmakeListNodes.emplace_back(std::move(node));
|
||||
@@ -938,6 +940,14 @@ static void setupLocationInfoForTargets(const QFuture<void> &cancelFuture,
|
||||
result += dedupMulti(t.installDefinitions);
|
||||
|
||||
folderNode->setLocationInfo(result);
|
||||
|
||||
if (!t.backtrace.isEmpty() && t.targetType != TargetType::UtilityType) {
|
||||
auto cmakeDefinition = std::make_unique<FileNode>(
|
||||
t.backtrace.last().path, Node::fileTypeForFileName(t.backtrace.last().path));
|
||||
cmakeDefinition->setLine(t.backtrace.last().line);
|
||||
cmakeDefinition->setPriority(Node::DefaultProjectFilePriority);
|
||||
folderNode->addNode(std::move(cmakeDefinition));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user