Commit a7557176 authored by dt's avatar dt
Browse files

In the EnvironmentWidget show which environment is the base.

Task-Nr: QTCREATORBUG-277
parent dde46ec1
......@@ -95,6 +95,14 @@ ProjectExplorer::Environment CMakeBuildConfiguration::baseEnvironment() const
return env;
}
QString CMakeBuildConfiguration::baseEnvironmentText() const
{
if (useSystemEnvironment())
return tr("System Environment");
else
return tr("Clear Environment");
}
ProjectExplorer::Environment CMakeBuildConfiguration::environment() const
{
ProjectExplorer::Environment env = baseEnvironment();
......
......@@ -51,6 +51,7 @@ public:
ProjectExplorer::Environment environment() const;
ProjectExplorer::Environment baseEnvironment() const;
QString baseEnvironmentText() const;
void setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff);
QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges() const;
bool useSystemEnvironment() const;
......
......@@ -80,6 +80,7 @@ void CMakeBuildEnvironmentWidget::init(ProjectExplorer::BuildConfiguration *bc)
m_clearSystemEnvironmentCheckBox->setChecked(!m_buildConfiguration->useSystemEnvironment());
m_buildEnvironmentWidget->setBaseEnvironment(m_buildConfiguration->baseEnvironment());
m_buildEnvironmentWidget->setBaseEnvironmentText(m_buildConfiguration->baseEnvironmentText());
m_buildEnvironmentWidget->setUserChanges(m_buildConfiguration->userEnvironmentChanges());
m_buildEnvironmentWidget->updateButtons();
}
......@@ -93,9 +94,11 @@ void CMakeBuildEnvironmentWidget::clearSystemEnvironmentCheckBoxClicked(bool che
{
m_buildConfiguration->setUseSystemEnvironment(!checked);
m_buildEnvironmentWidget->setBaseEnvironment(m_buildConfiguration->baseEnvironment());
m_buildEnvironmentWidget->setBaseEnvironmentText(m_buildConfiguration->baseEnvironmentText());
}
void CMakeBuildEnvironmentWidget::environmentChanged()
{
m_buildEnvironmentWidget->setBaseEnvironment(m_buildConfiguration->baseEnvironment());
m_buildEnvironmentWidget->setBaseEnvironmentText(m_buildConfiguration->baseEnvironmentText());
}
......@@ -195,6 +195,18 @@ ProjectExplorer::Environment CMakeRunConfiguration::baseEnvironment() const
return env;
}
QString CMakeRunConfiguration::baseEnvironmentText() const
{
if (m_baseEnvironmentBase == CMakeRunConfiguration::CleanEnvironmentBase) {
return tr("Clean Environment");
} else if (m_baseEnvironmentBase == CMakeRunConfiguration::SystemEnvironmentBase) {
return tr("System Environment");
} else if (m_baseEnvironmentBase == CMakeRunConfiguration::BuildEnvironmentBase) {
return tr("Build Environment");
}
return QString();
}
void CMakeRunConfiguration::setBaseEnvironmentBase(BaseEnvironmentBase env)
{
if (m_baseEnvironmentBase == env)
......@@ -301,6 +313,7 @@ CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *
m_environmentWidget = new ProjectExplorer::EnvironmentWidget(this, baseEnvironmentWidget);
m_environmentWidget->setBaseEnvironment(m_cmakeRunConfiguration->baseEnvironment());
m_environmentWidget->setBaseEnvironmentText(m_cmakeRunConfiguration->baseEnvironmentText());
m_environmentWidget->setUserChanges(m_cmakeRunConfiguration->userEnvironmentChanges());
vbx->addWidget(m_environmentWidget);
......@@ -358,6 +371,7 @@ void CMakeRunConfigurationWidget::baseEnvironmentComboBoxChanged(int index)
m_cmakeRunConfiguration->setBaseEnvironmentBase(CMakeRunConfiguration::BaseEnvironmentBase(index));
m_environmentWidget->setBaseEnvironment(m_cmakeRunConfiguration->baseEnvironment());
m_environmentWidget->setBaseEnvironmentText(m_cmakeRunConfiguration->baseEnvironmentText());
m_ignoreChange = false;
}
......@@ -368,6 +382,7 @@ void CMakeRunConfigurationWidget::baseEnvironmentChanged()
m_baseEnvironmentComboBox->setCurrentIndex(m_cmakeRunConfiguration->baseEnvironmentBase());
m_environmentWidget->setBaseEnvironment(m_cmakeRunConfiguration->baseEnvironment());
m_environmentWidget->setBaseEnvironmentText(m_cmakeRunConfiguration->baseEnvironmentText());
}
void CMakeRunConfigurationWidget::userEnvironmentChangesChanged()
......
......@@ -90,6 +90,8 @@ private:
void setBaseEnvironmentBase(BaseEnvironmentBase env);
BaseEnvironmentBase baseEnvironmentBase() const;
ProjectExplorer::Environment baseEnvironment() const;
QString baseEnvironmentText() const;
void setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff);
QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges() const;
......
......@@ -130,6 +130,7 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
m_environmentWidget = new EnvironmentWidget(this, baseEnvironmentWidget);
m_environmentWidget->setBaseEnvironment(rc->baseEnvironment());
m_environmentWidget->setBaseEnvironmentText(rc->baseEnvironmentText());
m_environmentWidget->setUserChanges(rc->userEnvironmentChanges());
vbox->addWidget(m_environmentWidget);
......@@ -168,6 +169,7 @@ void CustomExecutableConfigurationWidget::baseEnvironmentSelected(int index)
m_runConfiguration->setBaseEnvironmentBase(CustomExecutableRunConfiguration::BaseEnvironmentBase(index));
m_environmentWidget->setBaseEnvironment(m_runConfiguration->baseEnvironment());
m_environmentWidget->setBaseEnvironmentText(m_runConfiguration->baseEnvironmentText());
m_ignoreChange = false;
}
......@@ -180,6 +182,7 @@ void CustomExecutableConfigurationWidget::baseEnvironmentChanged()
m_runConfiguration->baseEnvironmentBase());
m_baseEnvironmentComboBox->setCurrentIndex(index);
m_environmentWidget->setBaseEnvironment(m_runConfiguration->baseEnvironment());
m_environmentWidget->setBaseEnvironmentText(m_runConfiguration->baseEnvironmentText());
}
void CustomExecutableConfigurationWidget::userEnvironmentChangesChanged()
......@@ -358,6 +361,18 @@ QStringList CustomExecutableRunConfiguration::commandLineArguments() const
return m_cmdArguments;
}
QString CustomExecutableRunConfiguration::baseEnvironmentText() const
{
if (m_baseEnvironmentBase == CustomExecutableRunConfiguration::CleanEnvironmentBase) {
return tr("Clean Environment");
} else if (m_baseEnvironmentBase == CustomExecutableRunConfiguration::SystemEnvironmentBase) {
return tr("System Environment");
} else if (m_baseEnvironmentBase == CustomExecutableRunConfiguration::BuildEnvironmentBase) {
return tr("Build Environment");
}
return QString::null;
}
ProjectExplorer::Environment CustomExecutableRunConfiguration::baseEnvironment() const
{
ProjectExplorer::Environment env;
......
......@@ -112,6 +112,7 @@ private:
void setBaseEnvironmentBase(BaseEnvironmentBase env);
BaseEnvironmentBase baseEnvironmentBase() const;
ProjectExplorer::Environment baseEnvironment() const;
QString baseEnvironmentText() const;
void setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff);
QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges() const;
......
......@@ -273,4 +273,3 @@ QStringList DebuggingHelperLibrary::possibleQMakeCommands()
return result;
#endif
}
......@@ -463,6 +463,12 @@ void EnvironmentWidget::setBaseEnvironment(const ProjectExplorer::Environment &e
m_model->setBaseEnvironment(env);
}
void EnvironmentWidget::setBaseEnvironmentText(const QString &text)
{
m_baseEnvironmentText = text;
updateSummaryText();
}
QList<EnvironmentItem> EnvironmentWidget::userChanges() const
{
return m_model->userChanges();
......@@ -479,17 +485,20 @@ void EnvironmentWidget::updateSummaryText()
QString text;
const QList<EnvironmentItem> &list = m_model->userChanges();
foreach (const EnvironmentItem &item, list) {
if (!text.isEmpty())
if (item.name != EnvironmentModel::tr("<VARIABLE>")) {
text.append("<br>");
if (item.name != EnvironmentModel::tr("<VARIABLE>")) {
if (item.unset)
text.append(tr("Unset <b>%1</b>").arg(item.name));
else
text.append(tr("Set <b>%1</b> to <b>%2</b>").arg(item.name, item.value));
}
}
if (text.isEmpty())
text = tr("Summary: No changes to Environment");
text.prepend(tr("Using <b>%1</b>").arg(m_baseEnvironmentText));
else
text.prepend(tr("Using <b>%1</b> and").arg(m_baseEnvironmentText));
m_detailsContainer->setSummaryText(text);
}
......
......@@ -109,6 +109,7 @@ public:
EnvironmentWidget(QWidget *parent, QWidget *additionalDetailsWidget = 0);
~EnvironmentWidget();
void setBaseEnvironmentText(const QString &text);
void setBaseEnvironment(const ProjectExplorer::Environment &env);
QList<EnvironmentItem> userChanges() const;
......@@ -132,6 +133,7 @@ private slots:
private:
EnvironmentModel *m_model;
QString m_baseEnvironmentText;
Utils::DetailsWidget *m_detailsContainer;
QTreeView *m_environmentTreeView;
QPushButton *m_editButton;
......
......@@ -114,6 +114,15 @@ Qt4Project *Qt4BuildConfiguration::qt4Project() const
return static_cast<Qt4Project *>(project());
}
QString Qt4BuildConfiguration::baseEnvironmentText() const
{
if (useSystemEnvironment())
return tr("System Environment");
else
return tr("Clean Environment");
return QString::null;
}
ProjectExplorer::Environment Qt4BuildConfiguration::baseEnvironment() const
{
Environment env = useSystemEnvironment() ? Environment::systemEnvironment() : Environment();
......
......@@ -60,6 +60,7 @@ public:
ProjectExplorer::Environment environment() const;
ProjectExplorer::Environment baseEnvironment() const;
QString baseEnvironmentText() const;
void setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff);
QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges() const;
bool useSystemEnvironment() const;
......
......@@ -82,6 +82,7 @@ void Qt4BuildEnvironmentWidget::init(ProjectExplorer::BuildConfiguration *bc)
m_clearSystemEnvironmentCheckBox->setChecked(!m_buildConfiguration->useSystemEnvironment());
m_buildEnvironmentWidget->setBaseEnvironment(m_buildConfiguration->baseEnvironment());
m_buildEnvironmentWidget->setBaseEnvironmentText(m_buildConfiguration->baseEnvironmentText());
m_buildEnvironmentWidget->setUserChanges(m_buildConfiguration->userEnvironmentChanges());
m_buildEnvironmentWidget->updateButtons();
}
......@@ -95,9 +96,11 @@ void Qt4BuildEnvironmentWidget::clearSystemEnvironmentCheckBoxClicked(bool check
{
m_buildConfiguration->setUseSystemEnvironment(!checked);
m_buildEnvironmentWidget->setBaseEnvironment(m_buildConfiguration->baseEnvironment());
m_buildEnvironmentWidget->setBaseEnvironmentText(m_buildConfiguration->baseEnvironmentText());
}
void Qt4BuildEnvironmentWidget::environmentChanged()
{
m_buildEnvironmentWidget->setBaseEnvironment(m_buildConfiguration->baseEnvironment());
m_buildEnvironmentWidget->setBaseEnvironmentText(m_buildConfiguration->baseEnvironmentText());
}
......@@ -213,6 +213,7 @@ Qt4RunConfigurationWidget::Qt4RunConfigurationWidget(Qt4RunConfiguration *qt4Run
m_environmentWidget = new ProjectExplorer::EnvironmentWidget(this, baseEnvironmentWidget);
m_environmentWidget->setBaseEnvironment(m_qt4RunConfiguration->baseEnvironment());
m_environmentWidget->setBaseEnvironmentText(m_qt4RunConfiguration->baseEnvironmentText());
m_environmentWidget->setUserChanges(m_qt4RunConfiguration->userEnvironmentChanges());
m_environmentWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
vboxTopLayout->addWidget(m_environmentWidget);
......@@ -271,6 +272,7 @@ void Qt4RunConfigurationWidget::baseEnvironmentSelected(int index)
m_qt4RunConfiguration->setBaseEnvironmentBase(Qt4RunConfiguration::BaseEnvironmentBase(index));
m_environmentWidget->setBaseEnvironment(m_qt4RunConfiguration->baseEnvironment());
m_environmentWidget->setBaseEnvironmentText(m_qt4RunConfiguration->baseEnvironmentText());
m_ignoreChange = false;
}
......@@ -281,6 +283,7 @@ void Qt4RunConfigurationWidget::baseEnvironmentChanged()
m_baseEnvironmentComboBox->setCurrentIndex(m_qt4RunConfiguration->baseEnvironmentBase());
m_environmentWidget->setBaseEnvironment(m_qt4RunConfiguration->baseEnvironment());
m_environmentWidget->setBaseEnvironmentText(m_qt4RunConfiguration->baseEnvironmentText());
}
void Qt4RunConfigurationWidget::userEnvironmentChangesChanged(const QList<ProjectExplorer::EnvironmentItem> &userChanges)
......@@ -480,6 +483,17 @@ QStringList Qt4RunConfiguration::commandLineArguments() const
return m_commandLineArguments;
}
QString Qt4RunConfiguration::baseEnvironmentText() const
{
if (m_baseEnvironmentBase == Qt4RunConfiguration::CleanEnvironmentBase)
return tr("Clean Environment");
else if (m_baseEnvironmentBase == Qt4RunConfiguration::SystemEnvironmentBase)
return tr("System Environment");
else if (m_baseEnvironmentBase == Qt4RunConfiguration::BuildEnvironmentBase)
return tr("Build Environment");
return QString::null;
}
ProjectExplorer::Environment Qt4RunConfiguration::baseEnvironment() const
{
ProjectExplorer::Environment env;
......
......@@ -123,6 +123,7 @@ private:
BaseEnvironmentBase baseEnvironmentBase() const;
ProjectExplorer::Environment baseEnvironment() const;
QString baseEnvironmentText() const;
void setUserEnvironmentChanges(const QList<ProjectExplorer::EnvironmentItem> &diff);
QList<ProjectExplorer::EnvironmentItem> userEnvironmentChanges() const;
......
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