From fa6235d03510558ab381d57e771ad59d7e4769e1 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Wed, 21 Oct 2020 23:20:46 +0200 Subject: cleanup: remove MainWindow::unsavedChanges() function This function was used to unify both methods of checking for unsaved changes: the global unsaved_changes() flag and the Command::clean() function of the undo-system. However, all desktop functions are now undoable and therefore the function is not needed and can be replaced by calls to !Command::clean(). Signed-off-by: Berthold Stoeger --- desktop-widgets/mainwindow.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 74dd166e6..29cc2c1e4 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -570,14 +570,6 @@ void MainWindow::on_actionCloudstoragesave_triggered() setFileClean(); } -// Currently we have two markers for unsaved changes: -// 1) unsaved_changes() returns true for non-undoable changes. -// 2) Command::isClean() returns false for undoable changes. -static bool unsavedChanges() -{ - return unsaved_changes() || !Command::isClean(); -} - void MainWindow::on_actionCloudOnline_triggered() { bool isOffline = !ui.actionCloudOnline->isChecked(); @@ -597,7 +589,7 @@ void MainWindow::on_actionCloudOnline_triggered() git_local_only = isOffline; if (!isOffline) { // User requests to go online. Try to sync cloud storage - if (unsavedChanges()) { + if (!Command::isClean()) { // If there are unsaved changes, ask the user if they want to save them. // If they don't, they have to sync manually. if (QMessageBox::warning(this, tr("Save changes?"), @@ -625,7 +617,7 @@ bool MainWindow::okToClose(QString message) QMessageBox::warning(this, tr("Warning"), message); return false; } - if (unsavedChanges() && askSaveChanges() == false) + if (!Command::isClean() && askSaveChanges() == false) return false; return true; @@ -1303,7 +1295,7 @@ void MainWindow::closeEvent(QCloseEvent *event) return; } - if (unsavedChanges() && (askSaveChanges() == false)) { + if (!Command::isClean() && (askSaveChanges() == false)) { event->ignore(); return; } @@ -1528,7 +1520,7 @@ void MainWindow::setTitle() return; } - QString unsaved = (unsavedChanges() ? " *" : ""); + QString unsaved = (!Command::isClean() ? " *" : ""); QString shown = QString(" (%1)").arg(DiveFilter::instance()->shownText()); setWindowTitle("Subsurface: " + displayedFilename(existing_filename) + unsaved + shown); } -- cgit v1.2.3-70-g09d2