Skip to content
Snippets Groups Projects
Commit 12b0933d authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Rename some methods for consistency

Reviewed-by: dt
parent dffb276e
No related branches found
No related tags found
No related merge requests found
...@@ -218,7 +218,7 @@ bool EnvironmentModel::setData(const QModelIndex &index, const QVariant &value, ...@@ -218,7 +218,7 @@ bool EnvironmentModel::setData(const QModelIndex &index, const QVariant &value,
} }
if (changes(old.name)) if (changes(old.name))
removeVariable(old.name); resetVariable(old.name);
old.name = newName; old.name = newName;
addVariable(old); addVariable(old);
emit renamedVariable(newName); emit renamedVariable(newName);
...@@ -280,7 +280,7 @@ QModelIndex EnvironmentModel::addVariable(const EnvironmentItem &item) ...@@ -280,7 +280,7 @@ QModelIndex EnvironmentModel::addVariable(const EnvironmentItem &item)
} }
} }
void EnvironmentModel::removeVariable(const QString &name) void EnvironmentModel::resetVariable(const QString &name)
{ {
int rowInResult = findInResult(name); int rowInResult = findInResult(name);
int rowInChanges = findInChanges(name); int rowInChanges = findInChanges(name);
...@@ -299,7 +299,7 @@ void EnvironmentModel::removeVariable(const QString &name) ...@@ -299,7 +299,7 @@ void EnvironmentModel::removeVariable(const QString &name)
} }
} }
void EnvironmentModel::unset(const QString &name) void EnvironmentModel::unsetVariable(const QString &name)
{ {
int row = findInResult(name); int row = findInResult(name);
// look in m_items for the variable // look in m_items for the variable
...@@ -319,7 +319,7 @@ void EnvironmentModel::unset(const QString &name) ...@@ -319,7 +319,7 @@ void EnvironmentModel::unset(const QString &name)
emit userChangesChanged(); emit userChangesChanged();
} }
bool EnvironmentModel::isUnset(const QString &name) bool EnvironmentModel::canUnset(const QString &name)
{ {
int pos = findInChanges(name); int pos = findInChanges(name);
if (pos != -1) if (pos != -1)
...@@ -328,7 +328,7 @@ bool EnvironmentModel::isUnset(const QString &name) ...@@ -328,7 +328,7 @@ bool EnvironmentModel::isUnset(const QString &name)
return false; return false;
} }
bool EnvironmentModel::isInBaseEnvironment(const QString &name) bool EnvironmentModel::canReset(const QString &name)
{ {
return m_baseEnvironment.hasKey(name); return m_baseEnvironment.hasKey(name);
} }
...@@ -395,10 +395,10 @@ EnvironmentWidget::EnvironmentWidget(QWidget *parent, QWidget *additionalDetails ...@@ -395,10 +395,10 @@ EnvironmentWidget::EnvironmentWidget(QWidget *parent, QWidget *additionalDetails
m_addButton->setText(tr("&Add")); m_addButton->setText(tr("&Add"));
buttonLayout->addWidget(m_addButton); buttonLayout->addWidget(m_addButton);
m_removeButton = new QPushButton(this); m_resetButton = new QPushButton(this);
m_removeButton->setEnabled(false); m_resetButton->setEnabled(false);
m_removeButton->setText(tr("&Reset")); m_resetButton->setText(tr("&Reset"));
buttonLayout->addWidget(m_removeButton); buttonLayout->addWidget(m_resetButton);
m_unsetButton = new QPushButton(this); m_unsetButton = new QPushButton(this);
m_unsetButton->setEnabled(false); m_unsetButton->setEnabled(false);
...@@ -419,7 +419,7 @@ EnvironmentWidget::EnvironmentWidget(QWidget *parent, QWidget *additionalDetails ...@@ -419,7 +419,7 @@ EnvironmentWidget::EnvironmentWidget(QWidget *parent, QWidget *additionalDetails
this, SLOT(editEnvironmentButtonClicked())); this, SLOT(editEnvironmentButtonClicked()));
connect(m_addButton, SIGNAL(clicked(bool)), connect(m_addButton, SIGNAL(clicked(bool)),
this, SLOT(addEnvironmentButtonClicked())); this, SLOT(addEnvironmentButtonClicked()));
connect(m_removeButton, SIGNAL(clicked(bool)), connect(m_resetButton, SIGNAL(clicked(bool)),
this, SLOT(removeEnvironmentButtonClicked())); this, SLOT(removeEnvironmentButtonClicked()));
connect(m_unsetButton, SIGNAL(clicked(bool)), connect(m_unsetButton, SIGNAL(clicked(bool)),
this, SLOT(unsetEnvironmentButtonClicked())); this, SLOT(unsetEnvironmentButtonClicked()));
...@@ -507,7 +507,7 @@ void EnvironmentWidget::addEnvironmentButtonClicked() ...@@ -507,7 +507,7 @@ void EnvironmentWidget::addEnvironmentButtonClicked()
void EnvironmentWidget::removeEnvironmentButtonClicked() void EnvironmentWidget::removeEnvironmentButtonClicked()
{ {
const QString &name = m_model->indexToVariable(m_environmentTreeView->currentIndex()); const QString &name = m_model->indexToVariable(m_environmentTreeView->currentIndex());
m_model->removeVariable(name); m_model->resetVariable(name);
updateButtons(); updateButtons();
} }
...@@ -516,10 +516,10 @@ void EnvironmentWidget::removeEnvironmentButtonClicked() ...@@ -516,10 +516,10 @@ void EnvironmentWidget::removeEnvironmentButtonClicked()
void EnvironmentWidget::unsetEnvironmentButtonClicked() void EnvironmentWidget::unsetEnvironmentButtonClicked()
{ {
const QString &name = m_model->indexToVariable(m_environmentTreeView->currentIndex()); const QString &name = m_model->indexToVariable(m_environmentTreeView->currentIndex());
if (!m_model->isInBaseEnvironment(name)) if (!m_model->canReset(name))
m_model->removeVariable(name); m_model->resetVariable(name);
else else
m_model->unset(name); m_model->unsetVariable(name);
updateButtons(); updateButtons();
} }
...@@ -529,13 +529,13 @@ void EnvironmentWidget::environmentCurrentIndexChanged(const QModelIndex &curren ...@@ -529,13 +529,13 @@ void EnvironmentWidget::environmentCurrentIndexChanged(const QModelIndex &curren
if (current.isValid()) { if (current.isValid()) {
m_editButton->setEnabled(true); m_editButton->setEnabled(true);
const QString &name = m_model->indexToVariable(current); const QString &name = m_model->indexToVariable(current);
bool modified = m_model->isInBaseEnvironment(name) && m_model->changes(name); bool modified = m_model->canReset(name) && m_model->changes(name);
bool unset = m_model->isUnset(name); bool unset = m_model->canUnset(name);
m_removeButton->setEnabled(modified || unset); m_resetButton->setEnabled(modified || unset);
m_unsetButton->setEnabled(!unset); m_unsetButton->setEnabled(!unset);
} else { } else {
m_editButton->setEnabled(false); m_editButton->setEnabled(false);
m_removeButton->setEnabled(false); m_resetButton->setEnabled(false);
m_unsetButton->setEnabled(false); m_unsetButton->setEnabled(false);
} }
} }
...@@ -63,10 +63,10 @@ public: ...@@ -63,10 +63,10 @@ public:
QModelIndex addVariable(); QModelIndex addVariable();
QModelIndex addVariable(const EnvironmentItem &item); QModelIndex addVariable(const EnvironmentItem &item);
void removeVariable(const QString &name); void resetVariable(const QString &name);
void unset(const QString &name); void unsetVariable(const QString &name);
bool isUnset(const QString &name); bool canUnset(const QString &name);
bool isInBaseEnvironment(const QString &name); bool canReset(const QString &name);
QString indexToVariable(const QModelIndex &index) const; QString indexToVariable(const QModelIndex &index) const;
QModelIndex variableToIndex(const QString &name) const; QModelIndex variableToIndex(const QString &name) const;
bool changes(const QString &key) const; bool changes(const QString &key) const;
...@@ -132,7 +132,7 @@ private: ...@@ -132,7 +132,7 @@ private:
QTreeView *m_environmentTreeView; QTreeView *m_environmentTreeView;
QPushButton *m_editButton; QPushButton *m_editButton;
QPushButton *m_addButton; QPushButton *m_addButton;
QPushButton *m_removeButton; QPushButton *m_resetButton;
QPushButton *m_unsetButton; QPushButton *m_unsetButton;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment