| 102 | } |
| 103 | |
| 104 | QVariant ArrayGroupModel::data(const QModelIndex& index, int role) const |
| 105 | { |
| 106 | if (role != Qt::DisplayRole) |
| 107 | { |
| 108 | return QVariant(); |
| 109 | } |
| 110 | if (index.row() < 0 || index.column() < 0 || index.row() >= this->rowCount(index.parent()) || |
| 111 | index.column() >= this->columnCount(index.parent())) |
| 112 | { |
| 113 | return QVariant(); |
| 114 | } |
| 115 | auto& colData(this->ColumnToArrayComponent[index.column()]); |
| 116 | auto* array = colData.Array; |
| 117 | if (auto* dataArray = vtkDataArray::SafeDownCast(array)) |
| 118 | { |
| 119 | std::vector<double> tuple; |
| 120 | tuple.resize(dataArray->GetNumberOfComponents()); |
| 121 | dataArray->GetTuple(index.row(), tuple.data()); |
| 122 | return tuple[colData.Component]; |
| 123 | } |
| 124 | else if (auto* stringArray = vtkStringArray::SafeDownCast(array)) |
| 125 | { |
| 126 | std::string value = |
| 127 | stringArray->GetValue(stringArray->GetNumberOfComponents() * index.row() + colData.Component); |
| 128 | return QString::fromStdString(value); |
| 129 | } |
| 130 | return QVariant(); |
| 131 | } |
| 132 | |
| 133 | bool ArrayGroupModel::setData(const QModelIndex& index, const QVariant& value, int role) |
| 134 | { |
no test coverage detected