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

Method setData

src/backend/matrix/MatrixModel.cpp:171–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169}
170
171bool MatrixModel::setData(const QModelIndex& index, const QVariant& value, int role) {
172 if (!index.isValid())
173 return false;
174
175 int row = index.row();
176 int column = index.column();
177
178 if (role == Qt::EditRole) {
179 const auto mode = m_matrix->mode();
180 switch (mode) {
181 case AbstractColumn::ColumnMode::Double:
182 m_matrix->setCell(row, column, value.toDouble());
183 break;
184 case AbstractColumn::ColumnMode::Integer:
185 m_matrix->setCell(row, column, value.toInt());
186 break;
187 case AbstractColumn::ColumnMode::BigInt:
188 m_matrix->setCell(row, column, value.toLongLong());
189 break;
190 case AbstractColumn::ColumnMode::DateTime:
191 case AbstractColumn::ColumnMode::Month:
192 case AbstractColumn::ColumnMode::Day:
193 DEBUG(" WARNING: DateTime format not supported yet"); // should not happen
194 // TODO: m_matrix->setCell(row, column, value.toDateTime());
195 break;
196 case AbstractColumn::ColumnMode::Text:
197 DEBUG(" WARNING: Text format not supported yet"); // should not happen
198 m_matrix->setCell(row, column, value.toString());
199 break;
200 }
201
202 if (!m_suppressDataChangedSignal)
203 Q_EMIT changed();
204 return true;
205 }
206 return false;
207}
208
209QModelIndex MatrixModel::index(int row, int column, const QModelIndex& /*parent*/) const {
210 return createIndex(row, column);

Callers

nothing calls this directly

Calls 6

modeMethod · 0.80
isValidMethod · 0.45
rowMethod · 0.45
columnMethod · 0.45
setCellMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected