| 131 | } |
| 132 | |
| 133 | bool ArrayGroupModel::setData(const QModelIndex& index, const QVariant& value, int role) |
| 134 | { |
| 135 | if (role != Qt::EditRole) |
| 136 | { |
| 137 | return false; |
| 138 | } |
| 139 | if (index.row() < 0 || index.column() < 0 || index.row() >= this->rowCount(index.parent()) || |
| 140 | index.column() >= this->columnCount(index.parent())) |
| 141 | { |
| 142 | return false; |
| 143 | } |
| 144 | // TODO: Record edit to a journal of edits, then update the output cell-grid. |
| 145 | auto& colData(this->ColumnToArrayComponent[index.column()]); |
| 146 | auto* array = colData.Array; |
| 147 | if (auto* dataArray = vtkDataArray::SafeDownCast(array)) |
| 148 | { |
| 149 | if (value.isNull() || value.toString().isEmpty()) |
| 150 | { |
| 151 | return false; |
| 152 | } |
| 153 | std::vector<double> tuple; |
| 154 | tuple.resize(dataArray->GetNumberOfComponents()); |
| 155 | dataArray->GetTuple(index.row(), tuple.data()); |
| 156 | tuple[colData.Component] = value.toDouble(); |
| 157 | dataArray->SetTuple(index.row(), tuple.data()); |
| 158 | this->Data->Modified(); |
| 159 | Q_EMIT dataChanged(index, index); |
| 160 | return true; |
| 161 | } |
| 162 | else if (auto* stringArray = vtkStringArray::SafeDownCast(array)) |
| 163 | { |
| 164 | stringArray->SetValue(stringArray->GetNumberOfComponents() * index.row() + colData.Component, |
| 165 | value.toString().toStdString()); |
| 166 | this->Data->Modified(); |
| 167 | Q_EMIT dataChanged(index, index); |
| 168 | return true; |
| 169 | } |
| 170 | return false; |
| 171 | } |
| 172 | |
| 173 | Qt::ItemFlags ArrayGroupModel::flags(const QModelIndex& index) const |
| 174 | { |
nothing calls this directly
no test coverage detected