Commit 089e5d38 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Cleanup EnvironmentEditModel

 * Remove now unused code
 * Make updateButtons private
 * Remove unnecessary calls to update Button

Reviewed-by: dt
parent 878f4655
......@@ -85,7 +85,6 @@ void BuildEnvironmentWidget::init(BuildConfiguration *bc)
m_buildEnvironmentWidget->setBaseEnvironment(m_buildConfiguration->baseEnvironment());
m_buildEnvironmentWidget->setBaseEnvironmentText(m_buildConfiguration->baseEnvironmentText());
m_buildEnvironmentWidget->setUserChanges(m_buildConfiguration->userEnvironmentChanges());
m_buildEnvironmentWidget->updateButtons();
}
void BuildEnvironmentWidget::environmentModelUserChangesChanged()
......
......@@ -152,14 +152,6 @@ int EnvironmentModel::findInChanges(const QString &name) const
return -1;
}
int EnvironmentModel::findInChangesInsertPosition(const QString &name) const
{
for (int i=0; i<m_items.size(); ++i)
if (m_items.at(i).name > name)
return i;
return m_items.size();
}
QModelIndex EnvironmentModel::variableToIndex(const QString &name) const
{
int row = findInResult(name);
......@@ -380,8 +372,6 @@ EnvironmentWidget::EnvironmentWidget(QWidget *parent, QWidget *additionalDetails
connect(m_model, SIGNAL(modelReset()),
this, SLOT(invalidateCurrentIndex()));
connect(m_model, SIGNAL(renamedVariable(QString)),
this, SLOT(renamedVariable(QString)));
connect(m_model, SIGNAL(focusIndex(QModelIndex)),
this, SLOT(focusIndex(QModelIndex)));
......@@ -460,13 +450,6 @@ EnvironmentWidget::~EnvironmentWidget()
m_model = 0;
}
void EnvironmentWidget::renamedVariable(const QString &name)
{
QModelIndex index = m_model->variableToIndex(name);
m_environmentTreeView->setCurrentIndex(index);
m_environmentTreeView->setFocus();
}
void EnvironmentWidget::focusIndex(const QModelIndex &index)
{
m_environmentTreeView->setCurrentIndex(index);
......@@ -532,14 +515,12 @@ void EnvironmentWidget::addEnvironmentButtonClicked()
QModelIndex index = m_model->addVariable();
m_environmentTreeView->setCurrentIndex(index);
m_environmentTreeView->edit(index);
updateButtons();
}
void EnvironmentWidget::removeEnvironmentButtonClicked()
{
const QString &name = m_model->indexToVariable(m_environmentTreeView->currentIndex());
m_model->resetVariable(name);
updateButtons();
}
// unset in Merged Environment Mode means, unset if it comes from the base environment
......@@ -551,7 +532,6 @@ void EnvironmentWidget::unsetEnvironmentButtonClicked()
m_model->resetVariable(name);
else
m_model->unsetVariable(name);
updateButtons();
}
void EnvironmentWidget::environmentCurrentIndexChanged(const QModelIndex &current)
......
......@@ -76,21 +76,14 @@ public:
signals:
void userChangesChanged();
/// Strictly speaking this is a hack to work around
/// the problem that we don't emit the right signals
/// on editing a variable
/// Don't try to fix that with out consulting me
/// In short it's impossible to emit the right signals
/// and to ensure that the model is in a consistent
/// state at each signal emission
void renamedVariable(const QString &newName);
/// Hint to the view where it should make sense to focus on next
// This is a hack since there is no way for a model to suggest
// the next interesting place to focus on to the view.
void focusIndex(const QModelIndex &index);
private:
void updateResultEnvironment();
int findInChanges(const QString &name) const;
int findInChangesInsertPosition(const QString &name) const;
int findInResultInsertPosition(const QString &name) const;
int findInResult(const QString &name) const;
......@@ -112,8 +105,6 @@ public:
QList<EnvironmentItem> userChanges() const;
void setUserChanges(QList<EnvironmentItem> list);
public slots:
void updateButtons();
signals:
void userChangesChanged();
......@@ -127,8 +118,8 @@ private slots:
void environmentCurrentIndexChanged(const QModelIndex &current);
void invalidateCurrentIndex();
void updateSummaryText();
void renamedVariable(const QString &name);
void focusIndex(const QModelIndex &index);
void updateButtons();
private:
EnvironmentModel *m_model;
......
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