Commit 1e46cb42 authored by dt's avatar dt
Browse files

Rework connections on the project pane for Qt4Projects.

Should fix a lot of corner cases, might introduce a few bugs.
Also rename functions/slots to be better named.

Generic Project Manager and CMake Project Manager are missing from this
patch.
parent 429a5274
......@@ -85,13 +85,12 @@ signals:
void displayNameChanged();
protected:
BuildConfiguration(Project * project);
BuildConfiguration(Project *project);
BuildConfiguration(BuildConfiguration *source);
private:
QList<BuildStep *> m_buildSteps;
QList<BuildStep *> m_cleanSteps;
QHash<QString, QVariant> m_values;
Project *m_project;
};
......
......@@ -124,7 +124,7 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
<< tr("Build Environment"));
m_baseEnvironmentComboBox->setCurrentIndex(rc->baseEnvironmentBase());
connect(m_baseEnvironmentComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(baseEnvironmentComboBoxChanged(int)));
this, SLOT(baseEnvironmentSelected(int)));
baseEnvironmentLayout->addWidget(m_baseEnvironmentComboBox);
baseEnvironmentLayout->addStretch(10);
......@@ -136,20 +136,20 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
changed();
connect(m_userName, SIGNAL(textEdited(QString)),
this, SLOT(setUserName(QString)));
this, SLOT(userNameEdited(QString)));
connect(m_executableChooser, SIGNAL(changed(QString)),
this, SLOT(setExecutable()));
this, SLOT(executableEdited()));
connect(m_commandLineArgumentsLineEdit, SIGNAL(textEdited(const QString&)),
this, SLOT(setCommandLineArguments(const QString&)));
this, SLOT(argumentsEdited(const QString&)));
connect(m_workingDirectory, SIGNAL(changed(QString)),
this, SLOT(setWorkingDirectory()));
this, SLOT(workingDirectoryEdited()));
connect(m_useTerminalCheck, SIGNAL(toggled(bool)),
this, SLOT(termToggled(bool)));
connect(m_runConfiguration, SIGNAL(changed()), this, SLOT(changed()));
connect(m_environmentWidget, SIGNAL(userChangesUpdated()),
this, SLOT(userChangesUpdated()));
connect(m_environmentWidget, SIGNAL(userChangesChanged()),
this, SLOT(userChangesChanged()));
connect(m_runConfiguration, SIGNAL(baseEnvironmentChanged()),
this, SLOT(baseEnvironmentChanged()));
......@@ -157,12 +157,12 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
this, SLOT(userEnvironmentChangesChanged()));
}
void CustomExecutableConfigurationWidget::userChangesUpdated()
void CustomExecutableConfigurationWidget::userChangesChanged()
{
m_runConfiguration->setUserEnvironmentChanges(m_environmentWidget->userChanges());
}
void CustomExecutableConfigurationWidget::baseEnvironmentComboBoxChanged(int index)
void CustomExecutableConfigurationWidget::baseEnvironmentSelected(int index)
{
m_ignoreChange = true;
m_runConfiguration->setBaseEnvironmentBase(CustomExecutableRunConfiguration::BaseEnvironmentBase(index));
......@@ -176,7 +176,9 @@ void CustomExecutableConfigurationWidget::baseEnvironmentChanged()
if (m_ignoreChange)
return;
m_baseEnvironmentComboBox->setCurrentIndex(CustomExecutableRunConfiguration::BaseEnvironmentBase(m_runConfiguration->baseEnvironmentBase()));
int index = CustomExecutableRunConfiguration::BaseEnvironmentBase(
m_runConfiguration->baseEnvironmentBase());
m_baseEnvironmentComboBox->setCurrentIndex(index);
m_environmentWidget->setBaseEnvironment(m_runConfiguration->baseEnvironment());
}
......@@ -186,26 +188,26 @@ void CustomExecutableConfigurationWidget::userEnvironmentChangesChanged()
}
void CustomExecutableConfigurationWidget::setExecutable()
void CustomExecutableConfigurationWidget::executableEdited()
{
m_ignoreChange = true;
m_runConfiguration->setExecutable(m_executableChooser->path());
m_ignoreChange = false;
}
void CustomExecutableConfigurationWidget::setCommandLineArguments(const QString &commandLineArguments)
void CustomExecutableConfigurationWidget::argumentsEdited(const QString &arguments)
{
m_ignoreChange = true;
m_runConfiguration->setCommandLineArguments(commandLineArguments);
m_runConfiguration->setCommandLineArguments(arguments);
m_ignoreChange = false;
}
void CustomExecutableConfigurationWidget::setWorkingDirectory()
void CustomExecutableConfigurationWidget::workingDirectoryEdited()
{
m_ignoreChange = true;
m_runConfiguration->setWorkingDirectory(m_workingDirectory->path());
m_ignoreChange = false;
}
void CustomExecutableConfigurationWidget::setUserName(const QString &name)
void CustomExecutableConfigurationWidget::userNameEdited(const QString &name)
{
m_ignoreChange = true;
m_runConfiguration->setUserName(name);
......@@ -250,18 +252,33 @@ CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Project *pro)
setName(tr("Custom Executable"));
connect(pro, SIGNAL(activeBuildConfigurationChanged()),
this, SIGNAL(baseEnvironmentChanged()));
this, SLOT(activeBuildConfigurationChanged()));
// TODO
// connect(pro, SIGNAL(environmentChanged(ProjectExplorer::BuildConfiguration *)),
// this, SIGNAL(baseEnvironmentChanged()));
m_lastActiveBuildConfiguration = pro->activeBuildConfiguration();
if (m_lastActiveBuildConfiguration) {
connect(m_lastActiveBuildConfiguration, SIGNAL(environmentChanged()),
this, SIGNAL(baseEnvironmentChanged()));
}
}
CustomExecutableRunConfiguration::~CustomExecutableRunConfiguration()
{
}
void CustomExecutableRunConfiguration::activeBuildConfigurationChanged()
{
if (m_lastActiveBuildConfiguration) {
disconnect(m_lastActiveBuildConfiguration, SIGNAL(environmentChanged()),
this, SIGNAL(baseEnvironmentChanged()));
}
m_lastActiveBuildConfiguration = project()->activeBuildConfiguration();
if (m_lastActiveBuildConfiguration) {
connect(m_lastActiveBuildConfiguration, SIGNAL(environmentChanged()),
this, SIGNAL(baseEnvironmentChanged()));
}
}
QString CustomExecutableRunConfiguration::type() const
{
return "ProjectExplorer.CustomExecutableRunConfiguration";
......
......@@ -102,6 +102,8 @@ signals:
void baseEnvironmentChanged();
void userEnvironmentChangesChanged(const QList<ProjectExplorer::EnvironmentItem> &diff);
private slots:
void activeBuildConfigurationChanged();
private:
enum BaseEnvironmentBase { CleanEnvironmentBase = 0,
......@@ -126,6 +128,7 @@ private:
QString m_userName;
QList<ProjectExplorer::EnvironmentItem> m_userEnvironmentChanges;
BaseEnvironmentBase m_baseEnvironmentBase;
ProjectExplorer::BuildConfiguration *m_lastActiveBuildConfiguration;
};
class CustomExecutableRunConfigurationFactory : public IRunConfigurationFactory
......@@ -154,16 +157,16 @@ public:
private slots:
void changed();
void setExecutable();
void setCommandLineArguments(const QString &commandLineArguments);
void setUserName(const QString &name);
void setWorkingDirectory();
void executableEdited();
void argumentsEdited(const QString &arguments);
void userNameEdited(const QString &name);
void workingDirectoryEdited();
void termToggled(bool);
void userChangesUpdated();
void userChangesChanged();
void baseEnvironmentChanged();
void userEnvironmentChangesChanged();
void baseEnvironmentComboBoxChanged(int index);
void baseEnvironmentSelected(int index);
private:
bool m_ignoreChange;
CustomExecutableRunConfiguration *m_runConfiguration;
......
......@@ -277,7 +277,7 @@ bool EnvironmentModel::setData(const QModelIndex &index, const QVariant &value,
m_items[pos].unset = false;
updateResultEnvironment();
emit dataChanged(index, index);
emit userChangesUpdated();
emit userChangesChanged();
return true;
}
// not found in m_items, so add it as a new variable
......@@ -287,7 +287,7 @@ bool EnvironmentModel::setData(const QModelIndex &index, const QVariant &value,
m_items[index.row()].value = value.toString();
m_items[index.row()].unset = false;
emit dataChanged(index, index);
emit userChangesUpdated();
emit userChangesChanged();
return true;
}
}
......@@ -328,14 +328,14 @@ QModelIndex EnvironmentModel::addVariable(const EnvironmentItem &item)
m_items.insert(rowInChanges, item);
updateResultEnvironment();
emit dataChanged(index(rowInResult, 0, QModelIndex()), index(rowInResult, 1, QModelIndex()));
emit userChangesUpdated();
emit userChangesChanged();
return index(rowInResult, 0, QModelIndex());
} else {
beginInsertRows(QModelIndex(), rowInResult, rowInResult);
m_items.insert(rowInChanges, item);
updateResultEnvironment();
endInsertRows();
emit userChangesUpdated();
emit userChangesChanged();
return index(rowInResult, 0, QModelIndex());
}
} else {
......@@ -343,7 +343,7 @@ QModelIndex EnvironmentModel::addVariable(const EnvironmentItem &item)
beginInsertRows(QModelIndex(), newPos, newPos);
m_items.insert(newPos, item);
endInsertRows();
emit userChangesUpdated();
emit userChangesChanged();
return index(newPos, 0, QModelIndex());
}
}
......@@ -358,13 +358,13 @@ void EnvironmentModel::removeVariable(const QString &name)
m_items.removeAt(rowInChanges);
updateResultEnvironment();
emit dataChanged(index(rowInResult, 0, QModelIndex()), index(rowInResult, 1, QModelIndex()));
emit userChangesUpdated();
emit userChangesChanged();
} else {
beginRemoveRows(QModelIndex(), rowInResult, rowInResult);
m_items.removeAt(rowInChanges);
updateResultEnvironment();
endRemoveRows();
emit userChangesUpdated();
emit userChangesChanged();
}
} else {
int removePos = findInChanges(name);
......@@ -372,7 +372,7 @@ void EnvironmentModel::removeVariable(const QString &name)
m_items.removeAt(removePos);
updateResultEnvironment();
endRemoveRows();
emit userChangesUpdated();
emit userChangesChanged();
}
}
......@@ -386,7 +386,7 @@ void EnvironmentModel::unset(const QString &name)
m_items[pos].unset = true;
updateResultEnvironment();
emit dataChanged(index(row, 0, QModelIndex()), index(row, 1, QModelIndex()));
emit userChangesUpdated();
emit userChangesChanged();
return;
}
pos = findInChangesInsertPosition(name);
......@@ -394,13 +394,13 @@ void EnvironmentModel::unset(const QString &name)
m_items[pos].unset = true;
updateResultEnvironment();
emit dataChanged(index(row, 0, QModelIndex()), index(row, 1, QModelIndex()));
emit userChangesUpdated();
emit userChangesChanged();
return;
} else {
int pos = findInChanges(name);
m_items[pos].unset = true;
emit dataChanged(index(pos, 1, QModelIndex()), index(pos, 1, QModelIndex()));
emit userChangesUpdated();
emit userChangesChanged();
return;
}
}
......@@ -440,8 +440,8 @@ EnvironmentWidget::EnvironmentWidget(QWidget *parent, QWidget *additionalDetails
{
m_model = new EnvironmentModel();
m_model->setMergedEnvironments(true);
connect(m_model, SIGNAL(userChangesUpdated()),
this, SIGNAL(userChangesUpdated()));
connect(m_model, SIGNAL(userChangesChanged()),
this, SIGNAL(userChangesChanged()));
QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->setContentsMargins(0, 0, 0, 0);
......@@ -509,7 +509,7 @@ EnvironmentWidget::EnvironmentWidget(QWidget *parent, QWidget *additionalDetails
connect(m_environmentTreeView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)),
this, SLOT(environmentCurrentIndexChanged(QModelIndex, QModelIndex)));
connect(m_model, SIGNAL(userChangesUpdated()), this, SLOT(updateSummaryText()));
connect(m_model, SIGNAL(userChangesChanged()), this, SLOT(updateSummaryText()));
}
EnvironmentWidget::~EnvironmentWidget()
......
......@@ -82,7 +82,7 @@ public:
QList<EnvironmentItem> userChanges() const;
void setUserChanges(QList<EnvironmentItem> list);
signals:
void userChangesUpdated();
void userChangesChanged();
private:
void updateResultEnvironment();
int findInChanges(const QString &name) const;
......@@ -115,7 +115,7 @@ public slots:
void updateButtons();
signals:
void userChangesUpdated();
void userChangesChanged();
void detailsVisibleChanged(bool visible);
private slots:
......
......@@ -212,9 +212,9 @@ MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep)
{
m_ui.setupUi(this);
connect(m_ui.makeLineEdit, SIGNAL(textEdited(QString)),
this, SLOT(makeLineEditTextEdited()));
this, SLOT(makeEdited()));
connect(m_ui.makeArgumentsLineEdit, SIGNAL(textEdited(QString)),
this, SLOT(makeArgumentsLineEditTextEdited()));
this, SLOT(makeArgumentsLineEdited()));
connect(makeStep, SIGNAL(userArgumentsChanged()),
this, SLOT(userArgumentsChanged()));
......@@ -300,13 +300,13 @@ void MakeStepConfigWidget::init()
updateDetails();
}
void MakeStepConfigWidget::makeLineEditTextEdited()
void MakeStepConfigWidget::makeEdited()
{
m_makeStep->m_makeCmd = m_ui.makeLineEdit->text();
updateDetails();
}
void MakeStepConfigWidget::makeArgumentsLineEditTextEdited()
void MakeStepConfigWidget::makeArgumentsLineEdited()
{
m_ignoreChange = true;
m_makeStep->setUserArguments(
......
......@@ -82,11 +82,10 @@ public:
virtual bool immutable() const;
QStringList userArguments();
void setUserArguments(const QStringList &arguments);
void setClean(bool clean);
virtual void restoreFromGlobalMap(const QMap<QString, QVariant> &map);
void setClean(bool clean);
virtual void restoreFromLocalMap(const QMap<QString, QVariant> &map);
virtual void storeIntoLocalMap(QMap<QString, QVariant> &map);
......@@ -107,8 +106,10 @@ public:
void init();
QString summaryText() const;
private slots:
void makeLineEditTextEdited();
void makeArgumentsLineEditTextEdited();
// User changes to our widgets
void makeEdited();
void makeArgumentsLineEdited();
void updateMakeOverrideLabel();
void updateDetails();
void userArgumentsChanged();
......
......@@ -99,7 +99,6 @@ QStringList QMakeStep::allArguments()
foreach (const QString &addedConfig, addedUserConfigArguments)
arguments.append("CONFIG+=" + addedConfig);
}
if (!additonalArguments.isEmpty())
arguments << additonalArguments;
......@@ -232,17 +231,35 @@ void QMakeStep::storeIntoLocalMap(QMap<QString, QVariant> &map)
AbstractProcessStep::storeIntoLocalMap(map);
}
////
// QMakeStepConfigWidget
////
QMakeStepConfigWidget::QMakeStepConfigWidget(QMakeStep *step)
: BuildStepConfigWidget(), m_step(step), m_ignoreChange(false)
{
m_ui.setupUi(this);
connect(m_ui.qmakeAdditonalArgumentsLineEdit, SIGNAL(textEdited(const QString&)),
this, SLOT(qmakeArgumentsLineEditTextEdited()));
connect(m_ui.buildConfigurationComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(buildConfigurationChanged()));
this, SLOT(qmakeArgumentsLineEdited()));
connect(m_ui.buildConfigurationComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(buildConfigurationSelected()));
connect(step, SIGNAL(userArgumentsChanged()),
this, SLOT(userArgumentsChanged()));
connect(step->buildConfiguration(), SIGNAL(qtVersionChanged()),
connect(step->qt4BuildConfiguration(), SIGNAL(qtVersionChanged()),
this, SLOT(qtVersionChanged()));
connect(step->qt4BuildConfiguration(), SIGNAL(qmakeBuildConfigurationChanged()),
this, SLOT(qmakeBuildConfigChanged()));
}
void QMakeStepConfigWidget::init()
{
QString qmakeArgs = ProjectExplorer::Environment::joinArgumentList(m_step->userArguments());
m_ui.qmakeAdditonalArgumentsLineEdit->setText(qmakeArgs);
qmakeBuildConfigChanged();
updateSummaryLabel();
updateEffectiveQMakeCall();
}
QString QMakeStepConfigWidget::summaryText() const
......@@ -250,91 +267,90 @@ QString QMakeStepConfigWidget::summaryText() const
return m_summaryText;
}
QString QMakeStepConfigWidget::displayName() const
{
return m_step->displayName();
}
void QMakeStepConfigWidget::qtVersionChanged()
{
updateTitleLabel();
updateSummaryLabel();
updateEffectiveQMakeCall();
}
void QMakeStepConfigWidget::updateTitleLabel()
void QMakeStepConfigWidget::qmakeBuildConfigChanged()
{
Qt4BuildConfiguration *qt4bc = m_step->qt4BuildConfiguration();
const QtVersion *qtVersion = qt4bc->qtVersion();
if (!qtVersion) {
m_summaryText = tr("<b>QMake:</b> No Qt version set. QMake can not be run.");
emit updateSummary();
return;
}
QStringList args = m_step->allArguments();
// We don't want the full path to the .pro file
const QString projectFileName = m_step->buildConfiguration()->project()->file()->fileName();
int index = args.indexOf(projectFileName);
if (index != -1)
args[index] = QFileInfo(projectFileName).fileName();
// And we only use the .pro filename not the full path
QString program = QFileInfo(qtVersion->qmakeCommand()).fileName();
m_summaryText = tr("<b>QMake:</b> %1 %2").arg(program, args.join(QString(QLatin1Char(' '))));
emit updateSummary();
Qt4BuildConfiguration *bc = m_step->qt4BuildConfiguration();
bool debug = bc->qmakeBuildConfiguration() & QtVersion::DebugBuild;
m_ignoreChange = true;
m_ui.buildConfigurationComboBox->setCurrentIndex(debug? 0 : 1);
m_ignoreChange = false;
updateSummaryLabel();
updateEffectiveQMakeCall();
}
void QMakeStepConfigWidget::userArgumentsChanged()
{
if (m_ignoreChange)
return;
QString qmakeArgs = ProjectExplorer::Environment::joinArgumentList(m_step->userArguments());
m_ui.qmakeAdditonalArgumentsLineEdit->setText(qmakeArgs);
updateSummaryLabel();
updateEffectiveQMakeCall();
}
void QMakeStepConfigWidget::qmakeArgumentsLineEditTextEdited()
void QMakeStepConfigWidget::qmakeArgumentsLineEdited()
{
m_ignoreChange = true;
m_step->setUserArguments(
ProjectExplorer::Environment::parseCombinedArgString(m_ui.qmakeAdditonalArgumentsLineEdit->text()));
m_ignoreChange = false;
m_step->qt4BuildConfiguration()->qt4Project()->invalidateCachedTargetInformation();
updateTitleLabel();
updateSummaryLabel();
updateEffectiveQMakeCall();
}
void QMakeStepConfigWidget::buildConfigurationChanged()
void QMakeStepConfigWidget::buildConfigurationSelected()
{
ProjectExplorer::BuildConfiguration *bc = m_step->buildConfiguration();
QtVersion::QmakeBuildConfigs buildConfiguration = QtVersion::QmakeBuildConfig(bc->value("buildConfiguration").toInt());
if (m_ui.buildConfigurationComboBox->currentIndex() == 0) {
// debug
if (m_ignoreChange)
return;
Qt4BuildConfiguration *bc = m_step->qt4BuildConfiguration();
QtVersion::QmakeBuildConfigs buildConfiguration = bc->qmakeBuildConfiguration();
if (m_ui.buildConfigurationComboBox->currentIndex() == 0) { // debug
buildConfiguration = buildConfiguration | QtVersion::DebugBuild;
} else {
buildConfiguration = buildConfiguration & ~QtVersion::DebugBuild;
}
bc->setValue("buildConfiguration", int(buildConfiguration));
m_step->qt4BuildConfiguration()->qt4Project()->invalidateCachedTargetInformation();
updateTitleLabel();
updateEffectiveQMakeCall();
// TODO if exact parsing is the default, we need to update the code model
// and all the Qt4ProFileNodes
// m_step->qt4Project()->update();
}
m_ignoreChange = true;
bc->setQMakeBuildConfiguration(buildConfiguration);
m_ignoreChange = false;
QString QMakeStepConfigWidget::displayName() const
{
return m_step->displayName();
updateSummaryLabel();
updateEffectiveQMakeCall();
}
void QMakeStepConfigWidget::userArgumentsChanged()
void QMakeStepConfigWidget::updateSummaryLabel()
{
if (m_ignoreChange)
Qt4BuildConfiguration *qt4bc = m_step->qt4BuildConfiguration();
const QtVersion *qtVersion = qt4bc->qtVersion();
if (!qtVersion) {
m_summaryText = tr("<b>QMake:</b> No Qt version set. QMake can not be run.");
emit updateSummary();
return;
QString qmakeArgs = ProjectExplorer::Environment::joinArgumentList(m_step->userArguments());
m_ui.qmakeAdditonalArgumentsLineEdit->setText(qmakeArgs);
updateTitleLabel();
updateEffectiveQMakeCall();
}
}
QStringList args = m_step->allArguments();
// We don't want the full path to the .pro file
const QString projectFileName = m_step->buildConfiguration()->project()->file()->fileName();
int index = args.indexOf(projectFileName);
if (index != -1)
args[index] = QFileInfo(projectFileName).fileName();
// And we only use the .pro filename not the full path
QString program = QFileInfo(qtVersion->qmakeCommand()).fileName();
m_summaryText = tr("<b>QMake:</b> %1 %2").arg(program, args.join(QString(QLatin1Char(' '))));
emit updateSummary();
void QMakeStepConfigWidget::init()
{
QString qmakeArgs = ProjectExplorer::Environment::joinArgumentList(m_step->userArguments());
m_ui.qmakeAdditonalArgumentsLineEdit->setText(qmakeArgs);
ProjectExplorer::BuildConfiguration *bc = m_step->buildConfiguration();
bool debug = QtVersion::QmakeBuildConfig(bc->value("buildConfiguration").toInt()) & QtVersion::DebugBuild;
m_ui.buildConfigurationComboBox->setCurrentIndex(debug? 0 : 1);
updateTitleLabel();
updateEffectiveQMakeCall();
}
void QMakeStepConfigWidget::updateEffectiveQMakeCall()
......
......@@ -109,16 +109,20 @@ class QMakeStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget
Q_OBJECT
public:
QMakeStepConfigWidget(QMakeStep *step);
QString displayName() const;
void init();
QString summaryText() const;
QString displayName() const;
private slots:
void qmakeArgumentsLineEditTextEdited();
void buildConfigurationChanged();
void userArgumentsChanged();
// slots for handling buildconfiguration/step signals
void qtVersionChanged();
void qmakeBuildConfigChanged();
void userArgumentsChanged();
// slots for dealing with user changes in our UI
void qmakeArgumentsLineEdited();
void buildConfigurationSelected();
private:
void updateTitleLabel();
void updateSummaryLabel();
void updateEffectiveQMakeCall();
Ui::QMakeStep m_ui;
QMakeStep *m_step;
......
......@@ -268,10 +268,14 @@ MaemoRunConfiguration::MaemoRunConfiguration(Project *project,
connect(&MaemoDeviceConfigurations::instance(), SIGNAL(updated()),
this, SLOT(updateDeviceConf