Skip to content

Commit

Permalink
Merge pull request #154 from cristian64/revise_unsaved_changes
Browse files Browse the repository at this point in the history
Mark session with unsaved changes during grouping and inline label editing.
  • Loading branch information
dreamsyntax authored May 26, 2024
2 parents 0060c79 + d6c2b8c commit 06616f9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Source/GUI/MemWatcher/MemWatchModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 16 additions & 4 deletions Source/GUI/MemWatcher/MemWatchWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -417,12 +423,18 @@ void MemWatchWidget::onWatchDoubleClicked(const QModelIndex& index)

void MemWatchWidget::onDataEdited(const QModelIndex& index, const QVariant& value, const int role)
{
MemWatchTreeNode* const node{static_cast<MemWatchTreeNode*>(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<MemWatchTreeNode*>(index.internalPointer())};
MemWatchEntry* const entry{node->getEntry()};
const Common::MemType entryType{entry->getType()};

Expand Down

0 comments on commit 06616f9

Please sign in to comment.