From 981846726b6824f420ed09012724f0d1a2caba9d Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 6 Mar 2018 15:28:06 +0100 Subject: [PATCH] PythonEditor: Model RunConfiguration according to RemoteLinux setup Change-Id: I9733dbb72dd4483dd06865ea8174fbe6a9934338 Reviewed-by: Christian Kandeler --- .../pythoneditor/pythoneditorplugin.cpp | 45 +++++++++++-------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/src/plugins/pythoneditor/pythoneditorplugin.cpp b/src/plugins/pythoneditor/pythoneditorplugin.cpp index dac41d3fd46..939946c859a 100644 --- a/src/plugins/pythoneditor/pythoneditorplugin.cpp +++ b/src/plugins/pythoneditor/pythoneditorplugin.cpp @@ -38,6 +38,7 @@ #include #include +#include #include #include #include @@ -56,8 +57,8 @@ #include #include -#include #include +#include #include #include @@ -88,10 +89,15 @@ public: bool removeFiles(const QStringList &filePaths); bool setFiles(const QStringList &filePaths); bool renameFile(const QString &filePath, const QString &newFilePath); - void refresh(); + void refresh(Target *target = nullptr); private: RestoreResult fromMap(const QVariantMap &map, QString *errorMessage) override; + bool setupTarget(Target *t) + { + refresh(t); + return Project::setupTarget(t); + } bool saveRawFileList(const QStringList &rawFileList); bool saveRawList(const QStringList &rawList, const QString &fileName); @@ -258,6 +264,10 @@ PythonRunConfigurationWidget::PythonRunConfigurationWidget(PythonRunConfiguratio auto vbx = new QVBoxLayout(this); vbx->setMargin(0); vbx->addWidget(m_detailsContainer); + + connect(runConfiguration->target(), &Target::applicationTargetsChanged, this, [this] { + m_scriptLabel->setText(QDir::toNativeSeparators(m_runConfiguration->mainScript())); + }); } class PythonRunConfigurationFactory : public IRunConfigurationFactory @@ -269,22 +279,6 @@ public: registerRunConfiguration(PythonRunConfigurationPrefix); addSupportedProjectType(PythonProjectId); } - - QList availableCreators(Target *parent) const override - { - return Utils::transform(parent->project()->files(Project::AllFiles),[this](const FileName &fn) { - return convert(fn.toString(), fn.toString()); - }); - } - - bool canCreateHelper(Target *parent, const QString &buildTarget) const override - { - PythonProject *project = static_cast(parent->project()); - const QString script = buildTarget; - if (script.endsWith(".pyqtc")) - return false; - return project->files(ProjectExplorer::Project::AllFiles).contains(FileName::fromString(script)); - } }; PythonProject::PythonProject(const FileName &fileName) : @@ -423,20 +417,33 @@ private: QString m_displayName; }; -void PythonProject::refresh() +void PythonProject::refresh(Target *target) { emitParsingStarted(); parseProject(); QDir baseDir(projectDirectory().toString()); + BuildTargetInfoList appTargets; auto newRoot = new PythonProjectNode(this); for (const QString &f : m_files) { const QString displayName = baseDir.relativeFilePath(f); FileType fileType = f.endsWith(".pyqtc") ? FileType::Project : FileType::Source; newRoot->addNestedNode(new PythonFileNode(FileName::fromString(f), displayName, fileType)); + if (fileType == FileType::Source) { + BuildTargetInfo bti; + bti.targetName = f; + bti.targetFilePath = FileName::fromString(f); + bti.projectFilePath = projectFilePath(); + appTargets.list.append(bti); + } } setRootProjectNode(newRoot); + if (!target) + target = activeTarget(); + if (target) + target->setApplicationTargets(appTargets); + emitParsingFinished(true); }