Qbs, Qmake, Python, Generic: Introduce BuildSystem derived classes

... and move context menu action handling there.

This is a temporary measure to be able to move that functionality
alongside the actual BuildSystem to the BuildConfiguration.

There is a lot to be cleaned up left, to keep the patch small.

Change-Id: If4b0820a13b376fc97b70785052924972ce22705
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2019-10-22 14:55:51 +02:00
parent e1baae2e20
commit 66c7d75dbd
24 changed files with 707 additions and 544 deletions

View File

@@ -55,6 +55,13 @@ protected:
bool validateParsingContext(const ParsingContext &ctx) final;
void parseProject(ParsingContext &&ctx) final;
bool supportsAction(ProjectExplorer::Node *context,
ProjectExplorer::ProjectAction action,
const ProjectExplorer::Node *node) const override;
bool addFiles(ProjectExplorer::Node *context,
const QStringList &filePaths, QStringList *) final;
private:
// Treescanner states:
void handleTreeScanningFinished();

View File

@@ -138,11 +138,6 @@ bool CMakeListsNode::showInSimpleTree() const
return false;
}
bool CMakeListsNode::supportsAction(ProjectExplorer::ProjectAction action, const ProjectExplorer::Node *) const
{
return action == ProjectExplorer::ProjectAction::AddNewFile;
}
Utils::optional<Utils::FilePath> CMakeListsNode::visibleAfterAddFileAction() const
{
return filePath().pathAppended("CMakeLists.txt");
@@ -161,10 +156,19 @@ QString CMakeProjectNode::tooltip() const
return QString();
}
bool CMakeProjectNode::addFiles(const QStringList &filePaths, QStringList *)
bool CMakeBuildSystem::addFiles(Node *context, const QStringList &filePaths, QStringList *notAdded)
{
noAutoAdditionNotify(filePaths, this);
return true; // Return always true as autoadd is not supported!
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) :
@@ -243,16 +247,15 @@ void CMakeTargetNode::setConfig(const CMakeConfig &config)
m_config = config;
}
bool CMakeTargetNode::supportsAction(ProjectExplorer::ProjectAction action,
const ProjectExplorer::Node *) const
bool CMakeBuildSystem::supportsAction(Node *context, ProjectAction action, const Node *node) const
{
return action == ProjectExplorer::ProjectAction::AddNewFile;
}
if (dynamic_cast<CMakeTargetNode *>(context))
return action == ProjectAction::AddNewFile;
bool CMakeTargetNode::addFiles(const QStringList &filePaths, QStringList *)
{
noAutoAdditionNotify(filePaths, this);
return true; // Return always true as autoadd is not supported!
if (dynamic_cast<CMakeListsNode *>(context))
return action == ProjectAction::AddNewFile;
return BuildSystem::supportsAction(context, action, node);
}
Utils::optional<Utils::FilePath> CMakeTargetNode::visibleAfterAddFileAction() const

View File

@@ -44,7 +44,6 @@ public:
CMakeListsNode(const Utils::FilePath &cmakeListPath);
bool showInSimpleTree() const final;
bool supportsAction(ProjectExplorer::ProjectAction action, const Node *node) const override;
Utils::optional<Utils::FilePath> visibleAfterAddFileAction() const override;
};
@@ -54,8 +53,6 @@ public:
CMakeProjectNode(const Utils::FilePath &directory);
QString tooltip() const final;
bool addFiles(const QStringList &filePaths, QStringList *notAdded) override;
};
class CMakeTargetNode : public ProjectExplorer::ProjectNode
@@ -70,8 +67,6 @@ public:
Utils::FilePath buildDirectory() const;
void setBuildDirectory(const Utils::FilePath &directory);
bool supportsAction(ProjectExplorer::ProjectAction action, const Node *node) const override;
bool addFiles(const QStringList &filePaths, QStringList *notAdded) override;
Utils::optional<Utils::FilePath> visibleAfterAddFileAction() const override;
void build() override;