From 5350288e45d26b3e14ffb99d7f0b342fe5f2076a Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Fri, 17 Apr 2020 15:30:05 +0200 Subject: CMake: Fix includes all over the CMake plugin Keep internals internal, remove some unnecessary includes, add some that should have been there. This reduces the number of files that get rebuild when working on CMake internals from over 1000 to about 200. This patch also moves some code around that ended up being in the wrong file. Change-Id: Icd7366ac760dc85031040720418fbb16336dce9b Reviewed-by: Eike Ziller --- .../cmakeprojectmanager/cmakeprojectnodes.cpp | 106 +-------------------- 1 file changed, 1 insertion(+), 105 deletions(-) (limited to 'src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp') diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp index fbb5f8deee..6f130f2b1a 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp @@ -25,98 +25,20 @@ #include "cmakeprojectnodes.h" -#include "cmakeconfigitem.h" -#include "cmakeproject.h" +#include "cmakebuildsystem.h" #include "cmakeprojectconstants.h" -#include "cmakeprojectplugin.h" -#include "cmakespecificsettings.h" #include - #include -#include -#include - #include -#include -#include -#include -#include #include -#include -#include -#include -#include - using namespace ProjectExplorer; namespace CMakeProjectManager { namespace Internal { -namespace { -void copySourcePathToClipboard(Utils::optional srcPath, - const ProjectExplorer::ProjectNode *node) -{ - QClipboard *clip = QGuiApplication::clipboard(); - - QDir projDir{node->filePath().toFileInfo().absoluteFilePath()}; - clip->setText(QDir::cleanPath(projDir.relativeFilePath(srcPath.value()))); -} - -void noAutoAdditionNotify(const QStringList &filePaths, const ProjectExplorer::ProjectNode *node) -{ - Utils::optional srcPath{}; - - for (const QString &file : filePaths) { - if (Utils::mimeTypeForFile(file).name() == CppTools::Constants::CPP_SOURCE_MIMETYPE) { - srcPath = file; - break; - } - } - - if (srcPath) { - CMakeSpecificSettings *settings = CMakeProjectPlugin::projectTypeSpecificSettings(); - switch (settings->afterAddFileSetting()) { - case CMakeProjectManager::Internal::ASK_USER: { - bool checkValue{false}; - QDialogButtonBox::StandardButton reply = - Utils::CheckableMessageBox::question(nullptr, - QMessageBox::tr("Copy to Clipboard?"), - QMessageBox::tr("Files are not automatically added to the " - "CMakeLists.txt file of the CMake project." - "\nCopy the path to the source files to the clipboard?"), - "Remember My Choice", &checkValue, QDialogButtonBox::Yes | QDialogButtonBox::No, - QDialogButtonBox::Yes); - if (checkValue) { - if (QDialogButtonBox::Yes == reply) - settings->setAfterAddFileSetting(AfterAddFileAction::COPY_FILE_PATH); - else if (QDialogButtonBox::No == reply) - settings->setAfterAddFileSetting(AfterAddFileAction::NEVER_COPY_FILE_PATH); - - settings->toSettings(Core::ICore::settings()); - } - - if (QDialogButtonBox::Yes == reply) { - copySourcePathToClipboard(srcPath, node); - } - break; - } - - case CMakeProjectManager::Internal::COPY_FILE_PATH: { - copySourcePathToClipboard(srcPath, node); - break; - } - - case CMakeProjectManager::Internal::NEVER_COPY_FILE_PATH: - break; - } - } -} - -} - CMakeInputsNode::CMakeInputsNode(const Utils::FilePath &cmakeLists) : ProjectExplorer::ProjectNode(cmakeLists) { @@ -157,21 +79,6 @@ QString CMakeProjectNode::tooltip() const return QString(); } -bool CMakeBuildSystem::addFiles(Node *context, const QStringList &filePaths, QStringList *notAdded) -{ - if (auto n = dynamic_cast(context)) { - noAutoAdditionNotify(filePaths, n); - return true; // Return always true as autoadd is not supported! - } - - if (auto n = dynamic_cast(context)) { - noAutoAdditionNotify(filePaths, n); - return true; // Return always true as autoadd is not supported! - } - - return BuildSystem::addFiles(context, filePaths, notAdded); -} - CMakeTargetNode::CMakeTargetNode(const Utils::FilePath &directory, const QString &target) : ProjectExplorer::ProjectNode(directory) { @@ -248,17 +155,6 @@ void CMakeTargetNode::setConfig(const CMakeConfig &config) m_config = config; } -bool CMakeBuildSystem::supportsAction(Node *context, ProjectAction action, const Node *node) const -{ - if (dynamic_cast(context)) - return action == ProjectAction::AddNewFile; - - if (dynamic_cast(context)) - return action == ProjectAction::AddNewFile; - - return BuildSystem::supportsAction(context, action, node); -} - Utils::optional CMakeTargetNode::visibleAfterAddFileAction() const { return filePath().pathAppended("CMakeLists.txt"); -- cgit v1.2.1