Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prompt user before destructive operations of great impact. #147

Merged
merged 4 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/GUI/MemWatcher/MemWatchModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ void MemWatchModel::clearRoot()
endResetModel();
}

void MemWatchModel::removeNode(const QModelIndex& index)
void MemWatchModel::deleteNode(const QModelIndex& index)
{
if (index.isValid())
{
Expand Down
5 changes: 3 additions & 2 deletions Source/GUI/MemWatcher/MemWatchModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@ class MemWatchModel : public QAbstractItemModel

void changeType(const QModelIndex& index, Common::MemType type, size_t length);
static MemWatchEntry* getEntryFromIndex(const QModelIndex& index);
void addNodes(const std::vector<MemWatchTreeNode*>& nodes, const QModelIndex& referenceIndex = QModelIndex{});
void addNodes(const std::vector<MemWatchTreeNode*>& nodes,
const QModelIndex& referenceIndex = QModelIndex{});
void addGroup(const QString& name, const QModelIndex& referenceIndex = QModelIndex{});
void addEntry(MemWatchEntry* entry, const QModelIndex& referenceIndex = QModelIndex{});
void editEntry(MemWatchEntry* entry, const QModelIndex& index);
void clearRoot();
void removeNode(const QModelIndex& index);
void deleteNode(const QModelIndex& index);
void onUpdateTimer();
void onFreezeTimer();
void loadRootFromJsonRecursive(const QJsonObject& json);
Expand Down
14 changes: 10 additions & 4 deletions Source/GUI/MemWatcher/MemWatchWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ void MemWatchWidget::cutSelectedWatchesToClipBoard()
if (!cutList.empty())
{
for (const auto& index : cutList)
m_watchModel->removeNode(index);
{
m_watchModel->deleteNode(index);
}

m_hasUnsavedChanges = true;
}
Expand Down Expand Up @@ -585,14 +587,14 @@ void MemWatchWidget::onDeleteSelection()

QMessageBox* confirmationBox =
new QMessageBox(QMessageBox::Question, QString("Deleting confirmation"), confirmationMsg,
QMessageBox::Yes | QMessageBox::No, this);
QMessageBox::Yes | QMessageBox::Cancel, this);
confirmationBox->setDefaultButton(QMessageBox::Yes);
if (confirmationBox->exec() == QMessageBox::Yes)
{
const QModelIndexList toDeleteList{simplifySelection()};
for (const auto& index : toDeleteList)
{
m_watchModel->removeNode(index);
m_watchModel->deleteNode(index);
}

m_hasUnsavedChanges = true;
Expand Down Expand Up @@ -732,7 +734,11 @@ void MemWatchWidget::clearWatchList()
if (!m_watchModel->hasAnyNodes())
return;

if (!warnIfUnsavedChanges())
const QString msg{tr("Are you sure you want to delete these watches and/or groups?")};
QMessageBox box(QMessageBox::Question, tr("Clear watch list confirmation"), msg,
QMessageBox::Yes | QMessageBox::Cancel, this);
box.setDefaultButton(QMessageBox::Yes);
if (box.exec() != QMessageBox::Yes)
return;

m_watchModel->clearRoot();
Expand Down
Loading