Commit de0b0706 authored by hjk's avatar hjk

QmakeProjectManager: Code cosmetics

Qt 5 connects, remove no-op function, add a few 'overload', use a few 'auto',
put common code with ugly cast in function, ...

Change-Id: I242aea07356bf535ba9ae11235de4a2a2c1f1d04
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent 99b98f28
...@@ -37,25 +37,18 @@ ...@@ -37,25 +37,18 @@
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <QStringList>
#include <QLabel>
#include <QWidget> #include <QWidget>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QCheckBox; class QCheckBox;
class QLabel;
class QLineEdit; class QLineEdit;
class QRadioButton;
class QComboBox;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace Utils {
class PathChooser;
class DetailsWidget;
}
namespace QmakeProjectManager { namespace QmakeProjectManager {
class QmakeProFileNode; class QmakeProFileNode;
class QmakeProject;
namespace Internal { namespace Internal {
class DesktopQmakeRunConfigurationFactory; class DesktopQmakeRunConfigurationFactory;
...@@ -113,6 +106,7 @@ private: ...@@ -113,6 +106,7 @@ private:
QPair<QString, QString> extractWorkingDirAndExecutable(const QmakeProFileNode *node) const; QPair<QString, QString> extractWorkingDirAndExecutable(const QmakeProFileNode *node) const;
QString baseWorkingDirectory() const; QString baseWorkingDirectory() const;
QString defaultDisplayName(); QString defaultDisplayName();
QmakeProject *qmakeProject() const;
void ctor(); void ctor();
...@@ -131,14 +125,11 @@ class DesktopQmakeRunConfigurationWidget : public QWidget ...@@ -131,14 +125,11 @@ class DesktopQmakeRunConfigurationWidget : public QWidget
Q_OBJECT Q_OBJECT
public: public:
DesktopQmakeRunConfigurationWidget(DesktopQmakeRunConfiguration *qmakeRunConfiguration, QWidget *parent); explicit DesktopQmakeRunConfigurationWidget(DesktopQmakeRunConfiguration *qmakeRunConfiguration);
~DesktopQmakeRunConfigurationWidget();
private slots: private:
void runConfigurationEnabledChange(); void runConfigurationEnabledChange();
void effectiveTargetInformationChanged(); void effectiveTargetInformationChanged();
void qvfbToggled(bool);
void usingDyldImageSuffixToggled(bool); void usingDyldImageSuffixToggled(bool);
void usingDyldImageSuffixChanged(bool); void usingDyldImageSuffixChanged(bool);
void usingLibrarySearchPathToggled(bool state); void usingLibrarySearchPathToggled(bool state);
...@@ -154,7 +145,6 @@ private: ...@@ -154,7 +145,6 @@ private:
QCheckBox *m_usingDyldImageSuffix = nullptr; QCheckBox *m_usingDyldImageSuffix = nullptr;
QCheckBox *m_usingLibrarySearchPath = nullptr; QCheckBox *m_usingLibrarySearchPath = nullptr;
QLineEdit *m_qmlDebugPort = nullptr; QLineEdit *m_qmlDebugPort = nullptr;
Utils::DetailsWidget *m_detailsContainer = nullptr;
}; };
class DesktopQmakeRunConfigurationFactory : public QmakeRunConfigurationFactory class DesktopQmakeRunConfigurationFactory : public QmakeRunConfigurationFactory
...@@ -163,25 +153,25 @@ class DesktopQmakeRunConfigurationFactory : public QmakeRunConfigurationFactory ...@@ -163,25 +153,25 @@ class DesktopQmakeRunConfigurationFactory : public QmakeRunConfigurationFactory
public: public:
explicit DesktopQmakeRunConfigurationFactory(QObject *parent = 0); explicit DesktopQmakeRunConfigurationFactory(QObject *parent = 0);
~DesktopQmakeRunConfigurationFactory();
bool canCreate(ProjectExplorer::Target *parent, Core::Id id) const; bool canCreate(ProjectExplorer::Target *parent, Core::Id id) const override;
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const; bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const override;
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const; bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const override;
ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source); ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent,
ProjectExplorer::RunConfiguration *source) override;
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent, CreationMode mode) const; QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent, CreationMode mode) const override;
QString displayNameForId(Core::Id id) const; QString displayNameForId(Core::Id id) const override;
QList<ProjectExplorer::RunConfiguration *> runConfigurationsForNode(ProjectExplorer::Target *t, QList<ProjectExplorer::RunConfiguration *> runConfigurationsForNode(ProjectExplorer::Target *t,
const ProjectExplorer::Node *n); const ProjectExplorer::Node *n) override;
private: private:
bool canHandle(ProjectExplorer::Target *t) const; bool canHandle(ProjectExplorer::Target *t) const override;
ProjectExplorer::RunConfiguration *doCreate(ProjectExplorer::Target *parent, Core::Id id); ProjectExplorer::RunConfiguration *doCreate(ProjectExplorer::Target *parent, Core::Id id) override;
ProjectExplorer::RunConfiguration *doRestore(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *doRestore(ProjectExplorer::Target *parent,
const QVariantMap &map); const QVariantMap &map) override;
}; };
} // namespace Internal } // namespace Internal
......
...@@ -33,10 +33,9 @@ ...@@ -33,10 +33,9 @@
#include <coreplugin/variablechooser.h> #include <coreplugin/variablechooser.h>
#include <projectexplorer/environmentaspect.h> #include <projectexplorer/environmentaspect.h>
#include <projectexplorer/runconfigurationaspects.h>
#include <projectexplorer/target.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
#include <projectexplorer/runconfigurationaspects.h> #include <projectexplorer/runconfigurationaspects.h>
#include <projectexplorer/target.h>
#include <utils/detailswidget.h> #include <utils/detailswidget.h>
#include <utils/pathchooser.h> #include <utils/pathchooser.h>
...@@ -48,26 +47,24 @@ ...@@ -48,26 +47,24 @@
#include <QLineEdit> #include <QLineEdit>
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils;
namespace QtSupport { namespace QtSupport {
namespace Internal { namespace Internal {
CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomExecutableRunConfiguration *rc, ApplyMode mode) CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomExecutableRunConfiguration *rc, ApplyMode mode)
: m_ignoreChange(false), : m_runConfiguration(rc)
m_runConfiguration(rc),
m_temporaryArgumentsAspect(0),
m_temporaryTerminalAspect(0)
{ {
QFormLayout *layout = new QFormLayout; auto layout = new QFormLayout;
layout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); layout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
layout->setMargin(0); layout->setMargin(0);
m_executableChooser = new Utils::PathChooser(this); m_executableChooser = new PathChooser(this);
m_executableChooser->setHistoryCompleter(QLatin1String("Qt.CustomExecutable.History")); m_executableChooser->setHistoryCompleter(QLatin1String("Qt.CustomExecutable.History"));
m_executableChooser->setExpectedKind(Utils::PathChooser::Command); m_executableChooser->setExpectedKind(PathChooser::Command);
layout->addRow(tr("Executable:"), m_executableChooser); layout->addRow(tr("Executable:"), m_executableChooser);
ArgumentsAspect *argumentsAspect = rc->extraAspect<ArgumentsAspect>(); auto argumentsAspect = rc->extraAspect<ArgumentsAspect>();
if (mode == InstantApply) { if (mode == InstantApply) {
argumentsAspect->addToMainConfigurationWidget(this, layout); argumentsAspect->addToMainConfigurationWidget(this, layout);
} else { } else {
...@@ -77,14 +74,14 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE ...@@ -77,14 +74,14 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
this, &CustomExecutableConfigurationWidget::validChanged); this, &CustomExecutableConfigurationWidget::validChanged);
} }
m_workingDirectory = new Utils::PathChooser(this); m_workingDirectory = new PathChooser(this);
m_workingDirectory->setHistoryCompleter(QLatin1String("Qt.WorkingDir.History")); m_workingDirectory->setHistoryCompleter(QLatin1String("Qt.WorkingDir.History"));
m_workingDirectory->setExpectedKind(Utils::PathChooser::Directory); m_workingDirectory->setExpectedKind(PathChooser::Directory);
m_workingDirectory->setBaseFileName(rc->target()->project()->projectDirectory()); m_workingDirectory->setBaseFileName(rc->target()->project()->projectDirectory());
layout->addRow(tr("Working directory:"), m_workingDirectory); layout->addRow(tr("Working directory:"), m_workingDirectory);
TerminalAspect *terminalAspect = rc->extraAspect<TerminalAspect>(); auto terminalAspect = rc->extraAspect<TerminalAspect>();
if (mode == InstantApply) { if (mode == InstantApply) {
terminalAspect->addToMainConfigurationWidget(this, layout); terminalAspect->addToMainConfigurationWidget(this, layout);
} else { } else {
...@@ -94,42 +91,43 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE ...@@ -94,42 +91,43 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
this, &CustomExecutableConfigurationWidget::validChanged); this, &CustomExecutableConfigurationWidget::validChanged);
} }
QVBoxLayout *vbox = new QVBoxLayout(this); auto vbox = new QVBoxLayout(this);
vbox->setMargin(0); vbox->setMargin(0);
m_detailsContainer = new Utils::DetailsWidget(this); m_detailsContainer = new DetailsWidget(this);
m_detailsContainer->setState(Utils::DetailsWidget::NoSummary); m_detailsContainer->setState(DetailsWidget::NoSummary);
vbox->addWidget(m_detailsContainer); vbox->addWidget(m_detailsContainer);
QWidget *detailsWidget = new QWidget(m_detailsContainer); auto detailsWidget = new QWidget(m_detailsContainer);
m_detailsContainer->setWidget(detailsWidget); m_detailsContainer->setWidget(detailsWidget);
detailsWidget->setLayout(layout); detailsWidget->setLayout(layout);
changed(); changed();
if (mode == InstantApply) { if (mode == InstantApply) {
connect(m_executableChooser, SIGNAL(rawPathChanged(QString)), connect(m_executableChooser, &PathChooser::rawPathChanged,
this, SLOT(executableEdited())); this, &CustomExecutableConfigurationWidget::executableEdited);
connect(m_workingDirectory, SIGNAL(rawPathChanged(QString)), connect(m_workingDirectory, &PathChooser::rawPathChanged,
this, SLOT(workingDirectoryEdited())); this, &CustomExecutableConfigurationWidget::workingDirectoryEdited);
} else { } else {
connect(m_executableChooser, SIGNAL(rawPathChanged(QString)), connect(m_executableChooser, &PathChooser::rawPathChanged,
this, SIGNAL(validChanged())); this, &CustomExecutableConfigurationWidget::validChanged);
connect(m_workingDirectory, SIGNAL(rawPathChanged(QString)), connect(m_workingDirectory, &PathChooser::rawPathChanged,
this, SIGNAL(validChanged())); this, &CustomExecutableConfigurationWidget::validChanged);
} }
ProjectExplorer::EnvironmentAspect *aspect = rc->extraAspect<ProjectExplorer::EnvironmentAspect>(); auto enviromentAspect = rc->extraAspect<EnvironmentAspect>();
if (aspect) { connect(enviromentAspect, &EnvironmentAspect::environmentChanged,
connect(aspect, SIGNAL(environmentChanged()), this, SLOT(environmentWasChanged())); this, &CustomExecutableConfigurationWidget::environmentWasChanged);
environmentWasChanged(); environmentWasChanged();
}
// If we are in mode InstantApply, we keep us in sync with the rc // If we are in InstantApply mode, we keep us in sync with the rc
// otherwise we ignore changes to the rc and override them on apply, // otherwise we ignore changes to the rc and override them on apply,
// or keep them on cancel // or keep them on cancel
if (mode == InstantApply) if (mode == InstantApply) {
connect(m_runConfiguration, SIGNAL(changed()), this, SLOT(changed())); connect(m_runConfiguration, &CustomExecutableRunConfiguration::changed,
this, &CustomExecutableConfigurationWidget::changed);
}
Core::VariableChooser::addSupportForChildWidgets(this, m_runConfiguration->macroExpander()); Core::VariableChooser::addSupportForChildWidgets(this, m_runConfiguration->macroExpander());
} }
...@@ -142,8 +140,7 @@ CustomExecutableConfigurationWidget::~CustomExecutableConfigurationWidget() ...@@ -142,8 +140,7 @@ CustomExecutableConfigurationWidget::~CustomExecutableConfigurationWidget()
void CustomExecutableConfigurationWidget::environmentWasChanged() void CustomExecutableConfigurationWidget::environmentWasChanged()
{ {
ProjectExplorer::EnvironmentAspect *aspect auto aspect = m_runConfiguration->extraAspect<EnvironmentAspect>();
= m_runConfiguration->extraAspect<ProjectExplorer::EnvironmentAspect>();
QTC_ASSERT(aspect, return); QTC_ASSERT(aspect, return);
m_workingDirectory->setEnvironment(aspect->environment()); m_workingDirectory->setEnvironment(aspect->environment());
m_executableChooser->setEnvironment(aspect->environment()); m_executableChooser->setEnvironment(aspect->environment());
......
...@@ -66,26 +66,24 @@ public: ...@@ -66,26 +66,24 @@ public:
~CustomExecutableConfigurationWidget(); ~CustomExecutableConfigurationWidget();
void apply(); // only used for DelayedApply void apply(); // only used for DelayedApply
bool isValid() const; bool isValid() const;
signals: signals:
void validChanged(); void validChanged();
private slots: private:
void changed(); void changed();
void executableEdited(); void executableEdited();
void workingDirectoryEdited(); void workingDirectoryEdited();
void environmentWasChanged(); void environmentWasChanged();
private: bool m_ignoreChange = false;
bool m_ignoreChange; CustomExecutableRunConfiguration *m_runConfiguration = 0;
CustomExecutableRunConfiguration *m_runConfiguration; ProjectExplorer::ArgumentsAspect *m_temporaryArgumentsAspect = 0;
ProjectExplorer::ArgumentsAspect *m_temporaryArgumentsAspect; ProjectExplorer::TerminalAspect *m_temporaryTerminalAspect = 0;
ProjectExplorer::TerminalAspect *m_temporaryTerminalAspect; Utils::PathChooser *m_executableChooser = 0;
Utils::PathChooser *m_executableChooser; Utils::PathChooser *m_workingDirectory = 0;
Utils::PathChooser *m_workingDirectory; Utils::DetailsWidget *m_detailsContainer = 0;
Utils::DetailsWidget *m_detailsContainer;
}; };
} // namespace Internal } // namespace Internal
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment