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 @@
#include <utils/fileutils.h>
#include <QStringList>
#include <QLabel>
#include <QWidget>
QT_BEGIN_NAMESPACE
class QCheckBox;
class QLabel;
class QLineEdit;
class QRadioButton;
class QComboBox;
QT_END_NAMESPACE
namespace Utils {
class PathChooser;
class DetailsWidget;
}
namespace QmakeProjectManager {
class QmakeProFileNode;
class QmakeProject;
namespace Internal {
class DesktopQmakeRunConfigurationFactory;
......@@ -113,6 +106,7 @@ private:
QPair<QString, QString> extractWorkingDirAndExecutable(const QmakeProFileNode *node) const;
QString baseWorkingDirectory() const;
QString defaultDisplayName();
QmakeProject *qmakeProject() const;
void ctor();
......@@ -131,14 +125,11 @@ class DesktopQmakeRunConfigurationWidget : public QWidget
Q_OBJECT
public:
DesktopQmakeRunConfigurationWidget(DesktopQmakeRunConfiguration *qmakeRunConfiguration, QWidget *parent);
~DesktopQmakeRunConfigurationWidget();
explicit DesktopQmakeRunConfigurationWidget(DesktopQmakeRunConfiguration *qmakeRunConfiguration);
private slots:
private:
void runConfigurationEnabledChange();
void effectiveTargetInformationChanged();
void qvfbToggled(bool);
void usingDyldImageSuffixToggled(bool);
void usingDyldImageSuffixChanged(bool);
void usingLibrarySearchPathToggled(bool state);
......@@ -154,7 +145,6 @@ private:
QCheckBox *m_usingDyldImageSuffix = nullptr;
QCheckBox *m_usingLibrarySearchPath = nullptr;
QLineEdit *m_qmlDebugPort = nullptr;
Utils::DetailsWidget *m_detailsContainer = nullptr;
};
class DesktopQmakeRunConfigurationFactory : public QmakeRunConfigurationFactory
......@@ -163,25 +153,25 @@ class DesktopQmakeRunConfigurationFactory : public QmakeRunConfigurationFactory
public:
explicit DesktopQmakeRunConfigurationFactory(QObject *parent = 0);
~DesktopQmakeRunConfigurationFactory();
bool canCreate(ProjectExplorer::Target *parent, Core::Id id) const;
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const;
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const;
ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source);
bool canCreate(ProjectExplorer::Target *parent, Core::Id id) const override;
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const override;
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const override;
ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent,
ProjectExplorer::RunConfiguration *source) override;
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent, CreationMode mode) const;
QString displayNameForId(Core::Id id) const;
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent, CreationMode mode) const override;
QString displayNameForId(Core::Id id) const override;
QList<ProjectExplorer::RunConfiguration *> runConfigurationsForNode(ProjectExplorer::Target *t,
const ProjectExplorer::Node *n);
const ProjectExplorer::Node *n) override;
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,
const QVariantMap &map);
const QVariantMap &map) override;
};
} // namespace Internal
......
......@@ -33,10 +33,9 @@
#include <coreplugin/variablechooser.h>
#include <projectexplorer/environmentaspect.h>
#include <projectexplorer/runconfigurationaspects.h>
#include <projectexplorer/target.h>
#include <projectexplorer/project.h>
#include <projectexplorer/runconfigurationaspects.h>
#include <projectexplorer/target.h>
#include <utils/detailswidget.h>
#include <utils/pathchooser.h>
......@@ -48,26 +47,24 @@
#include <QLineEdit>
using namespace ProjectExplorer;
using namespace Utils;
namespace QtSupport {
namespace Internal {
CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomExecutableRunConfiguration *rc, ApplyMode mode)
: m_ignoreChange(false),
m_runConfiguration(rc),
m_temporaryArgumentsAspect(0),
m_temporaryTerminalAspect(0)
: m_runConfiguration(rc)
{
QFormLayout *layout = new QFormLayout;
auto layout = new QFormLayout;
layout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
layout->setMargin(0);
m_executableChooser = new Utils::PathChooser(this);
m_executableChooser = new PathChooser(this);
m_executableChooser->setHistoryCompleter(QLatin1String("Qt.CustomExecutable.History"));
m_executableChooser->setExpectedKind(Utils::PathChooser::Command);
m_executableChooser->setExpectedKind(PathChooser::Command);
layout->addRow(tr("Executable:"), m_executableChooser);
ArgumentsAspect *argumentsAspect = rc->extraAspect<ArgumentsAspect>();
auto argumentsAspect = rc->extraAspect<ArgumentsAspect>();
if (mode == InstantApply) {
argumentsAspect->addToMainConfigurationWidget(this, layout);
} else {
......@@ -77,14 +74,14 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
this, &CustomExecutableConfigurationWidget::validChanged);
}
m_workingDirectory = new Utils::PathChooser(this);
m_workingDirectory = new PathChooser(this);
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());
layout->addRow(tr("Working directory:"), m_workingDirectory);
TerminalAspect *terminalAspect = rc->extraAspect<TerminalAspect>();
auto terminalAspect = rc->extraAspect<TerminalAspect>();
if (mode == InstantApply) {
terminalAspect->addToMainConfigurationWidget(this, layout);
} else {
......@@ -94,42 +91,43 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
this, &CustomExecutableConfigurationWidget::validChanged);
}
QVBoxLayout *vbox = new QVBoxLayout(this);
auto vbox = new QVBoxLayout(this);
vbox->setMargin(0);
m_detailsContainer = new Utils::DetailsWidget(this);
m_detailsContainer->setState(Utils::DetailsWidget::NoSummary);
m_detailsContainer = new DetailsWidget(this);
m_detailsContainer->setState(DetailsWidget::NoSummary);
vbox->addWidget(m_detailsContainer);
QWidget *detailsWidget = new QWidget(m_detailsContainer);
auto detailsWidget = new QWidget(m_detailsContainer);
m_detailsContainer->setWidget(detailsWidget);
detailsWidget->setLayout(layout);
changed();
if (mode == InstantApply) {
connect(m_executableChooser, SIGNAL(rawPathChanged(QString)),
this, SLOT(executableEdited()));
connect(m_workingDirectory, SIGNAL(rawPathChanged(QString)),
this, SLOT(workingDirectoryEdited()));
connect(m_executableChooser, &PathChooser::rawPathChanged,
this, &CustomExecutableConfigurationWidget::executableEdited);
connect(m_workingDirectory, &PathChooser::rawPathChanged,
this, &CustomExecutableConfigurationWidget::workingDirectoryEdited);
} else {
connect(m_executableChooser, SIGNAL(rawPathChanged(QString)),
this, SIGNAL(validChanged()));
connect(m_workingDirectory, SIGNAL(rawPathChanged(QString)),
this, SIGNAL(validChanged()));
connect(m_executableChooser, &PathChooser::rawPathChanged,
this, &CustomExecutableConfigurationWidget::validChanged);
connect(m_workingDirectory, &PathChooser::rawPathChanged,
this, &CustomExecutableConfigurationWidget::validChanged);
}
ProjectExplorer::EnvironmentAspect *aspect = rc->extraAspect<ProjectExplorer::EnvironmentAspect>();
if (aspect) {
connect(aspect, SIGNAL(environmentChanged()), this, SLOT(environmentWasChanged()));
environmentWasChanged();
}
auto enviromentAspect = rc->extraAspect<EnvironmentAspect>();
connect(enviromentAspect, &EnvironmentAspect::environmentChanged,
this, &CustomExecutableConfigurationWidget::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,
// or keep them on cancel
if (mode == InstantApply)
connect(m_runConfiguration, SIGNAL(changed()), this, SLOT(changed()));
if (mode == InstantApply) {
connect(m_runConfiguration, &CustomExecutableRunConfiguration::changed,
this, &CustomExecutableConfigurationWidget::changed);
}
Core::VariableChooser::addSupportForChildWidgets(this, m_runConfiguration->macroExpander());
}
......@@ -142,8 +140,7 @@ CustomExecutableConfigurationWidget::~CustomExecutableConfigurationWidget()
void CustomExecutableConfigurationWidget::environmentWasChanged()
{
ProjectExplorer::EnvironmentAspect *aspect
= m_runConfiguration->extraAspect<ProjectExplorer::EnvironmentAspect>();
auto aspect = m_runConfiguration->extraAspect<EnvironmentAspect>();
QTC_ASSERT(aspect, return);
m_workingDirectory->setEnvironment(aspect->environment());
m_executableChooser->setEnvironment(aspect->environment());
......
......@@ -66,26 +66,24 @@ public:
~CustomExecutableConfigurationWidget();
void apply(); // only used for DelayedApply
bool isValid() const;
signals:
void validChanged();
private slots:
private:
void changed();
void executableEdited();
void workingDirectoryEdited();
void environmentWasChanged();
private:
bool m_ignoreChange;
CustomExecutableRunConfiguration *m_runConfiguration;
ProjectExplorer::ArgumentsAspect *m_temporaryArgumentsAspect;
ProjectExplorer::TerminalAspect *m_temporaryTerminalAspect;
Utils::PathChooser *m_executableChooser;
Utils::PathChooser *m_workingDirectory;
Utils::DetailsWidget *m_detailsContainer;
bool m_ignoreChange = false;
CustomExecutableRunConfiguration *m_runConfiguration = 0;
ProjectExplorer::ArgumentsAspect *m_temporaryArgumentsAspect = 0;
ProjectExplorer::TerminalAspect *m_temporaryTerminalAspect = 0;
Utils::PathChooser *m_executableChooser = 0;
Utils::PathChooser *m_workingDirectory = 0;
Utils::DetailsWidget *m_detailsContainer = 0;
};
} // 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