CMake: Fix several issues with the CMakeBuildStep

- Store the selection of the "Current executable" target again
  (broke apparently with 2c822ae3)
- Display the resolved target of the "Current executable" seletion
  in the command line, instead of the fixed "
   '<Current executable>' text
- Make the "Current executable" translatable
- Add a tooltip explaining what it is
- Use a Utils::TreeModel instead of a QStandardItemModel for the
  target model
- As side-effect, searching in the target view using Ctrl-F seems
  to magically work again.

Change-Id: Ia4d0913f6e586f49f74da66651a9177437dad6d9
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
hjk
2020-09-10 17:01:32 +02:00
parent 512c0381f3
commit d09ea40c25
2 changed files with 203 additions and 219 deletions

View File

@@ -26,19 +26,33 @@
#pragma once
#include <projectexplorer/abstractprocessstep.h>
#include <QRegularExpression>
#include <utils/treemodel.h>
namespace Utils { class CommandLine; }
namespace ProjectExplorer {
class RunConfiguration;
class StringAspect;
} // ProjectExplorer
namespace ProjectExplorer { class StringAspect; }
namespace CMakeProjectManager {
namespace Internal {
class CMakeBuildStep;
class CMakeTargetItem : public Utils::TreeItem
{
public:
CMakeTargetItem() = default;
CMakeTargetItem(const QString &target, CMakeBuildStep *step, bool special);
private:
QVariant data(int column, int role) const final;
bool setData(int column, const QVariant &data, int role) final;
Qt::ItemFlags flags(int column) const final;
QString m_target;
CMakeBuildStep *m_step = nullptr;
bool m_special = false;
};
class CMakeBuildStep : public ProjectExplorer::AbstractProcessStep
{
Q_OBJECT
@@ -47,12 +61,10 @@ public:
CMakeBuildStep(ProjectExplorer::BuildStepList *bsl, Utils::Id id);
QStringList buildTargets() const;
bool buildsBuildTarget(const QString &target) const;
void setBuildTargets(const QStringList &target);
Utils::CommandLine cmakeCommand(ProjectExplorer::RunConfiguration *rc) const;
QStringList knownBuildTargets();
bool buildsBuildTarget(const QString &target) const;
void setBuildsBuildTarget(const QString &target, bool on);
QVariantMap toMap() const override;
@@ -62,16 +74,17 @@ public:
static QString testTarget();
static QStringList specialTargets();
QString activeRunConfigTarget() const;
signals:
void targetsToBuildChanged();
void buildTargetsChanged();
protected:
void processFinished(int exitCode, QProcess::ExitStatus status) override;
private:
Utils::CommandLine cmakeCommand() const;
void processFinished(int exitCode, QProcess::ExitStatus status) override;
bool fromMap(const QVariantMap &map) override;
private:
bool init() override;
void setupOutputFormatter(Utils::OutputFormatter *formatter) override;
void doRun() override;
@@ -83,14 +96,18 @@ private:
void handleProjectWasParsed(bool success);
void handleBuildTargetsChanges(bool success);
void recreateBuildTargetsModel();
void updateBuildTargetsModel();
QMetaObject::Connection m_runTrigger;
friend class CMakeBuildStepConfigWidget;
QStringList m_buildTargets;
QStringList m_buildTargets; // Convention: Empty string member signifies "Current executable"
ProjectExplorer::StringAspect *m_cmakeArguments = nullptr;
ProjectExplorer::StringAspect *m_toolArguments = nullptr;
bool m_waiting = false;
Utils::TreeModel<Utils::TreeItem, CMakeTargetItem> m_buildTargetModel;
};
class CMakeBuildStepFactory : public ProjectExplorer::BuildStepFactory