| 252 | } |
| 253 | |
| 254 | bool QmitkRenderWindowDataNodeTableModel::setData(const QModelIndex& index, const QVariant& value, int role) |
| 255 | { |
| 256 | if (!index.isValid() || this != index.model()) |
| 257 | { |
| 258 | return false; |
| 259 | } |
| 260 | |
| 261 | if (index.row() < 0 || index.row() >= static_cast<int>(m_CurrentSelection.size())) |
| 262 | { |
| 263 | return false; |
| 264 | } |
| 265 | |
| 266 | mitk::DataNode* dataNode = m_CurrentSelection.at(index.row()); |
| 267 | |
| 268 | if (index.column() == 0) // data node information column |
| 269 | { |
| 270 | if (role == Qt::EditRole && !value.toString().isEmpty()) |
| 271 | { |
| 272 | dataNode->SetName(value.toString().toStdString()); |
| 273 | emit dataChanged(index, index); |
| 274 | return true; |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | if (index.column() == 1) // data node visibility column |
| 279 | { |
| 280 | if (role == Qt::EditRole) |
| 281 | { |
| 282 | auto baseRenderer = m_BaseRenderer.Lock(); |
| 283 | bool visibility = value.toBool(); |
| 284 | dataNode->SetVisibility(visibility, baseRenderer); |
| 285 | |
| 286 | if (baseRenderer.IsNotNull()) |
| 287 | { |
| 288 | // Explicitly request an update since a renderer-specific property change does not mark the node as modified. |
| 289 | // see https://phabricator.mitk.org/T22322 |
| 290 | mitk::RenderingManager::GetInstance()->RequestUpdate(baseRenderer->GetRenderWindow()); |
| 291 | } |
| 292 | |
| 293 | emit dataChanged(index, index); |
| 294 | return true; |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | return false; |
| 299 | } |
| 300 | |
| 301 | Qt::DropActions QmitkRenderWindowDataNodeTableModel::supportedDropActions() const |
| 302 | { |
no test coverage detected