MCPcopy Create free account
hub / github.com/KDE/kdevelop / setData

Method setData

kdevplatform/shell/settings/environmentprofilemodel.cpp:96–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96bool 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
121void EnvironmentProfileModel::addVariable(const QString& variableName, const QString& value)
122{

Callers

nothing calls this directly

Calls 8

QModelIndexClass · 0.70
isValidMethod · 0.45
rowMethod · 0.45
columnMethod · 0.45
isEmptyMethod · 0.45
variablesMethod · 0.45
toStringMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected