aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/projectexplorer/projectfilewizardextension.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/projectexplorer/projectfilewizardextension.cpp')
-rw-r--r--src/plugins/projectexplorer/projectfilewizardextension.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/plugins/projectexplorer/projectfilewizardextension.cpp b/src/plugins/projectexplorer/projectfilewizardextension.cpp
index c7bf50e246..e6bf826e7b 100644
--- a/src/plugins/projectexplorer/projectfilewizardextension.cpp
+++ b/src/plugins/projectexplorer/projectfilewizardextension.cpp
@@ -41,6 +41,7 @@
#include <texteditor/tabsettings.h>
#include <texteditor/storagesettings.h>
#include <projectexplorer/project.h>
+#include <projectexplorer/projecttree.h>
#include <projectexplorer/editorconfiguration.h>
#include <utils/mimetypes/mimedatabase.h>
#
@@ -120,7 +121,8 @@ void ProjectFileWizardExtension::firstExtensionPageShown(
QStringList filePaths;
ProjectAction projectAction;
- if (m_context->wizard->kind()== IWizardFactory::ProjectWizard) {
+ const IWizardFactory::WizardKind kind = m_context->wizard->kind();
+ if (kind == IWizardFactory::ProjectWizard) {
projectAction = AddSubProject;
filePaths << generatedProjectFilePath(files);
} else {
@@ -128,13 +130,38 @@ void ProjectFileWizardExtension::firstExtensionPageShown(
filePaths = Utils::transform(files, &GeneratedFile::path);
}
- Node *contextNode = extraValues.value(QLatin1String(Constants::PREFERRED_PROJECT_NODE)).value<Node *>();
+ // Static cast from void * to avoid qobject_cast (which needs a valid object) in value().
+ auto contextNode = static_cast<Node *>(extraValues.value(QLatin1String(Constants::PREFERRED_PROJECT_NODE)).value<void *>());
+ auto project = static_cast<Project *>(extraValues.value(Constants::PROJECT_POINTER).value<void *>());
+ const QString path = extraValues.value(Constants::PREFERRED_PROJECT_NODE_PATH).toString();
- m_context->page->initializeProjectTree(contextNode, filePaths, m_context->wizard->kind(),
+ m_context->page->initializeProjectTree(findWizardContextNode(contextNode, project, path),
+ filePaths, m_context->wizard->kind(),
projectAction);
+ // Refresh combobox on project tree changes:
+ connect(ProjectTree::instance(), &ProjectTree::treeChanged,
+ m_context->page, [this, project, path, filePaths, kind, projectAction]() {
+ m_context->page->initializeProjectTree(
+ findWizardContextNode(m_context->page->currentNode(), project, path), filePaths,
+ kind, projectAction);
+ });
+
m_context->page->initializeVersionControls();
}
+Node *ProjectFileWizardExtension::findWizardContextNode(Node *contextNode, Project *project,
+ const QString &path)
+{
+ if (contextNode && !ProjectTree::hasNode(contextNode)) {
+ if (SessionManager::projects().contains(project) && project->rootProjectNode()) {
+ contextNode = project->rootProjectNode()->findNode([path](const Node *n) {
+ return path == n->filePath().toString();
+ });
+ }
+ }
+ return contextNode;
+}
+
QList<QWizardPage *> ProjectFileWizardExtension::extensionPages(const IWizardFactory *wizard)
{
if (!m_context)