1
0
Fork 0
mirror of https://github.com/subsurface/subsurface.git synced 2025-02-19 22:16:15 +00:00

Minor coding style cleanups - and use core logic function

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2013-04-27 20:47:47 -07:00
parent 89f02c42aa
commit 4bb0cd8cef

View file

@ -44,9 +44,8 @@ void MainWindow::on_actionNew_triggered()
void MainWindow::on_actionOpen_triggered() void MainWindow::on_actionOpen_triggered()
{ {
QString filename = QFileDialog::getOpenFileName(this, tr("Open File"), QDir::homePath(), filter()); QString filename = QFileDialog::getOpenFileName(this, tr("Open File"), QDir::homePath(), filter());
if (filename.isEmpty()) { if (filename.isEmpty())
return; return;
}
// Needed to convert to char* // Needed to convert to char*
QByteArray fileNamePtr = filename.toLocal8Bit(); QByteArray fileNamePtr = filename.toLocal8Bit();
@ -57,15 +56,13 @@ void MainWindow::on_actionOpen_triggered()
parse_file(fileNamePtr.data(), &error); parse_file(fileNamePtr.data(), &error);
set_filename(fileNamePtr.data(), TRUE); set_filename(fileNamePtr.data(), TRUE);
if (error != NULL) if (error != NULL) {
{
QMessageBox::warning(this, "Error", error->message); QMessageBox::warning(this, "Error", error->message);
g_error_free(error); g_error_free(error);
error = NULL; error = NULL;
} }
//WARNING: Port This method to Qt process_dives(FALSE, FALSE);
report_dives(FALSE, FALSE);
ui->InfoWidget->reload(); ui->InfoWidget->reload();
@ -86,15 +83,12 @@ void MainWindow::on_actionSaveAs_triggered()
void MainWindow::on_actionClose_triggered() void MainWindow::on_actionClose_triggered()
{ {
if (unsaved_changes() && (askSaveChanges() == FALSE)) if (unsaved_changes() && (askSaveChanges() == FALSE))
{
return; return;
}
/* free the dives and trips */ /* free the dives and trips */
while (dive_table.nr) while (dive_table.nr)
{
delete_single_dive(0); delete_single_dive(0);
}
mark_divelist_changed(FALSE); mark_divelist_changed(FALSE);
/* clear the selection and the statistics */ /* clear the selection and the statistics */
@ -142,10 +136,7 @@ void MainWindow::on_actionQuit_triggered()
{ {
qDebug("actionQuit"); qDebug("actionQuit");
if (unsaved_changes() && (askSaveChanges() == FALSE)) if (unsaved_changes() && (askSaveChanges() == FALSE))
{
return; return;
}
} }
void MainWindow::on_actionDownloadDC_triggered() void MainWindow::on_actionDownloadDC_triggered()
@ -313,11 +304,10 @@ void MainWindow::writeSettings()
void MainWindow::closeEvent(QCloseEvent *event) void MainWindow::closeEvent(QCloseEvent *event)
{ {
if (unsaved_changes() && (askSaveChanges() == FALSE)) if (unsaved_changes() && (askSaveChanges() == FALSE)) {
{
event->ignore(); event->ignore();
return; return;
} }
event->accept(); event->accept();
writeSettings(); writeSettings();
} }