| 94 | } |
| 95 | |
| 96 | bool EnvironmentProfileModel::setData(const QModelIndex& index, const QVariant& data, int role) |
| 97 | { |
| 98 | if (!index.isValid() || |
| 99 | index.row() < 0 || index.row() >= rowCount() || |
| 100 | index.column() < 0 || index.column() >= columnCount(QModelIndex()) || |
| 101 | m_currentProfileName.isEmpty()) { |
| 102 | return false; |
| 103 | } |
| 104 | |
| 105 | if (role == Qt::EditRole) { |
| 106 | auto& variables = m_profileListModel->variables(m_currentProfileName); |
| 107 | if (index.column() == VariableColumn) { |
| 108 | const QString oldVariable = m_varsByIndex[index.row()]; |
| 109 | const QString value = variables.take(oldVariable); |
| 110 | const QString newVariable = data.toString(); |
| 111 | variables.insert(newVariable, value); |
| 112 | m_varsByIndex[index.row()] = newVariable; |
| 113 | } else { |
| 114 | variables.insert(m_varsByIndex[index.row()], data.toString()); |
| 115 | } |
| 116 | emit dataChanged(index, index); |
| 117 | } |
| 118 | return true; |
| 119 | } |
| 120 | |
| 121 | void EnvironmentProfileModel::addVariable(const QString& variableName, const QString& value) |
| 122 | { |