summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/mainwindow.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2017-12-11 17:43:53 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-12-11 23:10:09 -0600
commit4ac5b9c9654e6d561c05451888f337de2d1b7cf7 (patch)
tree726d480ed8ca854b6d98e068fb04db0a0038a4fd /desktop-widgets/mainwindow.cpp
parent931bcc196644c79e1064a9cb1b9c80e82fe0ed06 (diff)
downloadsubsurface-4ac5b9c9654e6d561c05451888f337de2d1b7cf7.tar.gz
Simplify mainwindow title logic: remove MainWindowTitleFormat enum
The MainWindow::setTitle() function was passed an enum, which depended on whether existing_file is set or not. The check can be (and was!) done directly in setTitle(). Therefore, remove the whole enum. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/mainwindow.cpp')
-rw-r--r--desktop-widgets/mainwindow.cpp28
1 files changed, 11 insertions, 17 deletions
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp
index 76e9b0615..7e608427c 100644
--- a/desktop-widgets/mainwindow.cpp
+++ b/desktop-widgets/mainwindow.cpp
@@ -610,7 +610,7 @@ void MainWindow::on_actionCloudstorageopen_triggered()
QByteArray fileNamePtr = QFile::encodeName(filename);
if (!parse_file(fileNamePtr.data())) {
set_filename(fileNamePtr.data());
- setTitle(MWTF_FILENAME);
+ setTitle();
}
getNotificationWidget()->hideNotification();
process_dives(false, false);
@@ -641,7 +641,7 @@ void MainWindow::on_actionCloudstoragesave_triggered()
return;
set_filename(filename.toUtf8().data());
- setTitle(MWTF_FILENAME);
+ setTitle();
mark_divelist_changed(false);
}
@@ -692,7 +692,7 @@ void MainWindow::cleanUpEmpty()
dive_list()->reload(DiveTripModel::TREE);
MapWidget::instance()->reload();
if (!existing_filename)
- setTitle(MWTF_DEFAULT);
+ setTitle();
disableShortcuts();
}
@@ -1654,7 +1654,7 @@ int MainWindow::file_save_as(void)
return -1;
set_filename(filename.toUtf8().data());
- setTitle(MWTF_FILENAME);
+ setTitle();
mark_divelist_changed(false);
addRecentFile(filename, true);
return 0;
@@ -1725,21 +1725,15 @@ void MainWindow::setAutomaticTitle()
setTitle();
}
-void MainWindow::setTitle(enum MainWindowTitleFormat format)
+void MainWindow::setTitle()
{
- switch (format) {
- case MWTF_DEFAULT:
+ if (!existing_filename || !existing_filename[0]) {
setWindowTitle("Subsurface");
- break;
- case MWTF_FILENAME:
- if (!existing_filename) {
- setTitle(MWTF_DEFAULT);
- return;
- }
- QString unsaved = (unsaved_changes() ? " *" : "");
- setWindowTitle("Subsurface: " + displayedFilename(existing_filename) + unsaved);
- break;
+ return;
}
+
+ QString unsaved = (unsaved_changes() ? " *" : "");
+ setWindowTitle("Subsurface: " + displayedFilename(existing_filename) + unsaved);
}
void MainWindow::importFiles(const QStringList fileNames)
@@ -1801,7 +1795,7 @@ void MainWindow::loadFiles(const QStringList fileNames)
if (!parse_file(fileNamePtr.data())) {
set_filename(fileNamePtr.data());
addRecentFile(fileNamePtr, false);
- setTitle(MWTF_FILENAME);
+ setTitle();
}
}
hideProgressBar();