diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2020-04-17 15:30:05 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2020-04-20 10:05:24 +0000 |
commit | 5350288e45d26b3e14ffb99d7f0b342fe5f2076a (patch) | |
tree | 8a0ffc34cf79cbbe863b060b8bf1379c7d18e407 /src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp | |
parent | 9f981e7e239c1b188b320017f064c633795714ae (diff) | |
download | qt-creator-5350288e45d26b3e14ffb99d7f0b342fe5f2076a.tar.gz |
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 <eike.ziller@qt.io>
Diffstat (limited to 'src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp')
-rw-r--r-- | src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp | 106 |
1 files changed, 1 insertions, 105 deletions
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 <android/androidconstants.h> - #include <coreplugin/fileiconprovider.h> -#include <coreplugin/icore.h> -#include <cpptools/cpptoolsconstants.h> - #include <projectexplorer/target.h> -#include <utils/algorithm.h> -#include <utils/checkablemessagebox.h> -#include <utils/mimetypes/mimedatabase.h> -#include <utils/optional.h> #include <utils/qtcassert.h> -#include <QClipboard> -#include <QDir> -#include <QGuiApplication> -#include <QMessageBox> - using namespace ProjectExplorer; namespace CMakeProjectManager { namespace Internal { -namespace { -void copySourcePathToClipboard(Utils::optional<QString> 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<QString> 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<CMakeProjectNode *>(context)) { - noAutoAdditionNotify(filePaths, n); - return true; // Return always true as autoadd is not supported! - } - - if (auto n = dynamic_cast<CMakeTargetNode *>(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<CMakeTargetNode *>(context)) - return action == ProjectAction::AddNewFile; - - if (dynamic_cast<CMakeListsNode *>(context)) - return action == ProjectAction::AddNewFile; - - return BuildSystem::supportsAction(context, action, node); -} - Utils::optional<Utils::FilePath> CMakeTargetNode::visibleAfterAddFileAction() const { return filePath().pathAppended("CMakeLists.txt"); |