forked from qt-creator/qt-creator
Do not mark env vars as modified if not needed.
* Ignore steData calls that do not actually change any data in the EnvironmentEditorModel. This prevents all variables touched from getting marked up as changed. Reviewed-By: con
This commit is contained in:
@@ -234,15 +234,21 @@ int EnvironmentModel::findInResultInsertPosition(const QString &name) const
|
|||||||
bool EnvironmentModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
bool EnvironmentModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||||
{
|
{
|
||||||
if (role == Qt::EditRole && index.isValid()) {
|
if (role == Qt::EditRole && index.isValid()) {
|
||||||
|
// ignore changes to already set values:
|
||||||
|
if (data(index, role) == value)
|
||||||
|
return true;
|
||||||
|
|
||||||
if (index.column() == 0) {
|
if (index.column() == 0) {
|
||||||
//fail if a variable with the same name already exists
|
//fail if a variable with the same name already exists
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
if (findInChanges(value.toString().toUpper()) != -1)
|
const QString &newName = value.toString().toUpper();
|
||||||
return false;
|
|
||||||
#else
|
#else
|
||||||
if (findInChanges(value.toString()) != -1)
|
const QString &newName = value.toString();
|
||||||
return false;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (findInChanges(newName) != -1)
|
||||||
|
return false;
|
||||||
|
|
||||||
EnvironmentItem old("", "");
|
EnvironmentItem old("", "");
|
||||||
if (m_mergedEnvironments) {
|
if (m_mergedEnvironments) {
|
||||||
int pos = findInChanges(indexToVariable(index));
|
int pos = findInChanges(indexToVariable(index));
|
||||||
@@ -256,11 +262,7 @@ bool EnvironmentModel::setData(const QModelIndex &index, const QVariant &value,
|
|||||||
} else {
|
} else {
|
||||||
old = m_items.at(index.row());
|
old = m_items.at(index.row());
|
||||||
}
|
}
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
const QString &newName = value.toString().toUpper();
|
|
||||||
#else
|
|
||||||
const QString &newName = value.toString();
|
|
||||||
#endif
|
|
||||||
if (changes(old.name))
|
if (changes(old.name))
|
||||||
removeVariable(old.name);
|
removeVariable(old.name);
|
||||||
old.name = newName;
|
old.name = newName;
|
||||||
|
Reference in New Issue
Block a user