From bb06ab41ee2f2108af104407f325050168cf3ef1 Mon Sep 17 00:00:00 2001 From: cristian64 Date: Sun, 26 May 2024 21:35:34 +0100 Subject: [PATCH 1/2] Mark session with unsaved changes when labels are edited directly inline in the table. Previously, if the user edited a node's label by right-clicking on the label cell and entering a different label, the session was not marked as dirty. --- Source/GUI/MemWatcher/MemWatchModel.cpp | 2 ++ Source/GUI/MemWatcher/MemWatchWidget.cpp | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Source/GUI/MemWatcher/MemWatchModel.cpp b/Source/GUI/MemWatcher/MemWatchModel.cpp index ee6b677d..bbe5004a 100644 --- a/Source/GUI/MemWatcher/MemWatchModel.cpp +++ b/Source/GUI/MemWatcher/MemWatchModel.cpp @@ -368,6 +368,8 @@ bool MemWatchModel::editData(const QModelIndex& index, const QVariant& value, co { entry->setLabel(value.toString()); emit dataChanged(index, index); + if (emitEdit) + emit dataEdited(index, value, role); return true; } case WATCH_COL_VALUE: diff --git a/Source/GUI/MemWatcher/MemWatchWidget.cpp b/Source/GUI/MemWatcher/MemWatchWidget.cpp index 30d08634..2c915cde 100644 --- a/Source/GUI/MemWatcher/MemWatchWidget.cpp +++ b/Source/GUI/MemWatcher/MemWatchWidget.cpp @@ -417,12 +417,18 @@ void MemWatchWidget::onWatchDoubleClicked(const QModelIndex& index) void MemWatchWidget::onDataEdited(const QModelIndex& index, const QVariant& value, const int role) { - MemWatchTreeNode* const node{static_cast(index.internalPointer())}; - if (node->isGroup()) + if (role != Qt::EditRole) return; - if (role == Qt::EditRole && index.column() == MemWatchModel::WATCH_COL_VALUE) + const int column{index.column()}; + if (column == MemWatchModel::WATCH_COL_LABEL || column == MemWatchModel::WATCH_COL_TYPE || + column == MemWatchModel::WATCH_COL_ADDRESS) { + m_hasUnsavedChanges = true; + } + else if (column == MemWatchModel::WATCH_COL_VALUE) + { + MemWatchTreeNode* const node{static_cast(index.internalPointer())}; MemWatchEntry* const entry{node->getEntry()}; const Common::MemType entryType{entry->getType()}; From d6c2b8c96c71ac4fdc4a4de810c9d0f2ad28b962 Mon Sep 17 00:00:00 2001 From: cristian64 Date: Sun, 26 May 2024 21:39:07 +0100 Subject: [PATCH 2/2] Mark session with unsaved changes when current selection is grouped. This was an oversight in the recent grouping functionality (introduced in e162fbe7e18434e), where it was overlooked to invalidate the document after the select was moved into a new group. --- Source/GUI/MemWatcher/MemWatchWidget.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/GUI/MemWatcher/MemWatchWidget.cpp b/Source/GUI/MemWatcher/MemWatchWidget.cpp index 2c915cde..0c5bb742 100644 --- a/Source/GUI/MemWatcher/MemWatchWidget.cpp +++ b/Source/GUI/MemWatcher/MemWatchWidget.cpp @@ -312,7 +312,13 @@ void MemWatchWidget::setSelectedWatchesBase(MemWatchEntry* entry, Common::MemBas void MemWatchWidget::groupCurrentSelection() { - m_watchModel->groupSelection(simplifySelection()); + const QModelIndexList indexes{simplifySelection()}; + if (indexes.isEmpty()) + return; + + m_watchModel->groupSelection(indexes); + + m_hasUnsavedChanges = true; } void MemWatchWidget::cutSelectedWatchesToClipBoard()