| 1515 | } |
| 1516 | |
| 1517 | void QmitkMultiLabelInspector::OnRenameGroup() |
| 1518 | { |
| 1519 | if (!m_AllowLabelModification) |
| 1520 | mitkThrow() << "QmitkMultiLabelInspector is configured incorrectly. Set AllowLabelModification to true to allow the usage of RenameGroup."; |
| 1521 | |
| 1522 | if (m_Segmentation.IsNull()) |
| 1523 | return; |
| 1524 | |
| 1525 | auto currentIndex = this->m_Controls->view->currentIndex(); |
| 1526 | auto groupIDVariant = currentIndex.data(QmitkMultiLabelTreeModel::ItemModelRole::GroupIDRole); |
| 1527 | |
| 1528 | if (groupIDVariant.isValid()) |
| 1529 | { |
| 1530 | auto groupID = groupIDVariant.value<mitk::MultiLabelSegmentation::GroupIndexType>(); |
| 1531 | |
| 1532 | bool dlgOK; |
| 1533 | auto groupName = mitk::LabelSetImageHelper::CreateDisplayGroupName(m_Segmentation, groupID); |
| 1534 | auto newName = QInputDialog::getText(this, "Change name of the group", "Group name:", QLineEdit::Normal, QString::fromStdString(groupName), &dlgOK); |
| 1535 | if (dlgOK) |
| 1536 | { |
| 1537 | mitk::SegGroupModifyUndoRedoHelper undoRedoGenerator(m_Segmentation, { groupID }, true, 0, true, true); |
| 1538 | |
| 1539 | m_Segmentation->SetGroupName(groupID, newName.toStdString()); |
| 1540 | // this is needed as workaround for (T27307). It circumvents the fact that modifications |
| 1541 | // of data (here the segmentation) does not directly trigger the modification of the |
| 1542 | // owning node (see T27307). Therefore other code (like renderers or model views) that e.g. |
| 1543 | // listens to the datastorage for modification would not get notified. |
| 1544 | |
| 1545 | undoRedoGenerator.RegisterUndoRedoOperationEvent("Rename group #" + std::to_string(groupID)); |
| 1546 | |
| 1547 | if (m_SegmentationNode.IsNotNull()) |
| 1548 | { |
| 1549 | m_SegmentationNode->Modified(); |
| 1550 | } |
| 1551 | |
| 1552 | } |
| 1553 | } |
| 1554 | } |
| 1555 | |
| 1556 | void QmitkMultiLabelInspector::OnRenameLabel(bool /*value*/) |
| 1557 | { |
nothing calls this directly
no test coverage detected