diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-01-16 11:50:56 +0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-01-16 11:50:56 +0700 |
commit | a27f67c02612791fad73b4e0550d942dc3a5a339 (patch) | |
tree | 4417a2be34c8bcd7c03db23ba5f307ad463657a9 /qt-ui/mainwindow.cpp | |
parent | 3387ccc6f676636fe3fb8b11c8c371f627d74551 (diff) | |
download | subsurface-a27f67c02612791fad73b4e0550d942dc3a5a339.tar.gz |
Whitespace and coding style updates
Another futile attempt to cleanup the code and make coding style and
whitespace consistent. I tried to add a file that describes the key points
of our coding style. I have no illusions that this will help the least
bit...
This commit should ONLY change whitespace
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/mainwindow.cpp')
-rw-r--r-- | qt-ui/mainwindow.cpp | 94 |
1 files changed, 46 insertions, 48 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 293bc84be..8ebc67413 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -112,8 +112,8 @@ void MainWindow::on_actionNew_triggered() void MainWindow::on_actionOpen_triggered() { - if(DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING || - ui.InfoWidget->isEditing()) { + if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING || + ui.InfoWidget->isEditing()) { QMessageBox::warning(this, tr("Warning"), tr("Please save or cancel the current dive edit before opening a new file.")); return; } @@ -125,7 +125,8 @@ void MainWindow::on_actionOpen_triggered() loadFiles( QStringList() << filename ); } -QTabWidget *MainWindow::tabWidget(){ +QTabWidget *MainWindow::tabWidget() +{ return ui.tabWidget; } void MainWindow::on_actionSave_triggered() @@ -153,8 +154,8 @@ void MainWindow::cleanUpEmpty() void MainWindow::on_actionClose_triggered() { - if(DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING || - ui.InfoWidget->isEditing()) { + if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING || + ui.InfoWidget->isEditing()) { QMessageBox::warning(this, tr("Warning"), tr("Please save or cancel the current dive edit before closing the file.")); return; } @@ -199,7 +200,7 @@ void MainWindow::on_actionExportUDDF_triggered() { QFileInfo fi(system_default_filename()); QString filename = QFileDialog::getSaveFileName(this, tr("Save File as"), fi.absolutePath(), - tr("UDDF files (*.uddf *.UDDF)")); + tr("UDDF files (*.uddf *.UDDF)")); if (!filename.isNull() && !filename.isEmpty()) export_dives_uddf(filename.toUtf8(), false); } @@ -223,8 +224,8 @@ void MainWindow::enableDcShortcuts() void MainWindow::on_actionDivePlanner_triggered() { - if(DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING || - ui.InfoWidget->isEditing()) { + if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING || + ui.InfoWidget->isEditing()) { QMessageBox::warning(this, tr("Warning"), tr("Please save or cancel the current dive edit before trying to plan a dive.")); return; } @@ -250,8 +251,8 @@ void MainWindow::on_actionPreferences_triggered() void MainWindow::on_actionQuit_triggered() { - if(DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING || - ui.InfoWidget->isEditing()) { + if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING || + ui.InfoWidget->isEditing()) { QMessageBox::warning(this, tr("Warning"), tr("Please save or cancel the current dive edit before closing the file.")); return; } @@ -286,8 +287,8 @@ void MainWindow::on_actionEditDeviceNames_triggered() void MainWindow::on_actionAddDive_triggered() { - if(DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING || - ui.InfoWidget->isEditing()) { + if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING || + ui.InfoWidget->isEditing()) { QMessageBox::warning(this, tr("Warning"), tr("Please save or cancel the current dive edit before trying to add a dive.")); return; } @@ -378,15 +379,15 @@ void MainWindow::on_infoProfileSplitter_splitterMoved(int pos, int idx) void MainWindow::on_actionViewList_triggered() { beginChangeState(LIST_MAXIMIZED); - ui.listGlobeSplitter->setSizes( BEHAVIOR << EXPANDED << COLLAPSED); - ui.mainSplitter->setSizes( BEHAVIOR << COLLAPSED << EXPANDED); + ui.listGlobeSplitter->setSizes(BEHAVIOR << EXPANDED << COLLAPSED); + ui.mainSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED); } void MainWindow::on_actionViewProfile_triggered() { beginChangeState(PROFILE_MAXIMIZED); ui.infoProfileSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED); - ui.mainSplitter->setSizes( BEHAVIOR << EXPANDED << COLLAPSED); + ui.mainSplitter->setSizes(BEHAVIOR << EXPANDED << COLLAPSED); redrawProfile(); } @@ -394,7 +395,7 @@ void MainWindow::on_actionViewInfo_triggered() { beginChangeState(INFO_MAXIMIZED); ui.infoProfileSplitter->setSizes(BEHAVIOR << EXPANDED << COLLAPSED); - ui.mainSplitter->setSizes( BEHAVIOR << EXPANDED << COLLAPSED); + ui.mainSplitter->setSizes(BEHAVIOR << EXPANDED << COLLAPSED); } void MainWindow::on_actionViewGlobe_triggered() @@ -411,51 +412,51 @@ void MainWindow::on_actionViewAll_triggered() static QList<int> mainSizes; const int appH = qApp->desktop()->size().height(); const int appW = qApp->desktop()->size().width(); - if (mainSizes.empty()){ - mainSizes.append( appH * 0.7 ); - mainSizes.append( appH * 0.3 ); + if (mainSizes.empty()) { + mainSizes.append(appH * 0.7); + mainSizes.append(appH * 0.3); } static QList<int> infoProfileSizes; - if (infoProfileSizes.empty()){ - infoProfileSizes.append( appW * 0.3 ); - infoProfileSizes.append( appW * 0.7 ); + if (infoProfileSizes.empty()) { + infoProfileSizes.append(appW * 0.3); + infoProfileSizes.append(appW * 0.7); } static QList<int> listGlobeSizes; - if(listGlobeSizes.empty()){ - listGlobeSizes.append( appW * 0.7 ); - listGlobeSizes.append( appW * 0.3 ); + if (listGlobeSizes.empty()) { + listGlobeSizes.append(appW * 0.7); + listGlobeSizes.append(appW * 0.3); } QSettings settings; settings.beginGroup("MainWindow"); - if (settings.value("mainSplitter").isValid()){ + if (settings.value("mainSplitter").isValid()) { ui.mainSplitter->restoreState(settings.value("mainSplitter").toByteArray()); ui.infoProfileSplitter->restoreState(settings.value("infoProfileSplitter").toByteArray()); ui.listGlobeSplitter->restoreState(settings.value("listGlobeSplitter").toByteArray()); - if(ui.mainSplitter->sizes().first() == 0 || ui.mainSplitter->sizes().last() == 0) + if (ui.mainSplitter->sizes().first() == 0 || ui.mainSplitter->sizes().last() == 0) ui.mainSplitter->setSizes(mainSizes); - if(ui.infoProfileSplitter->sizes().first() == 0 || ui.infoProfileSplitter->sizes().last() == 0) + if (ui.infoProfileSplitter->sizes().first() == 0 || ui.infoProfileSplitter->sizes().last() == 0) ui.infoProfileSplitter->setSizes(infoProfileSizes); - if(ui.listGlobeSplitter->sizes().first() == 0 || ui.listGlobeSplitter->sizes().last() == 0) + if (ui.listGlobeSplitter->sizes().first() == 0 || ui.listGlobeSplitter->sizes().last() == 0) ui.listGlobeSplitter->setSizes(listGlobeSizes); } else { - ui.mainSplitter->setSizes( mainSizes ); + ui.mainSplitter->setSizes(mainSizes); ui.infoProfileSplitter->setSizes(infoProfileSizes); ui.listGlobeSplitter->setSizes(listGlobeSizes); } redrawProfile(); } -void MainWindow::beginChangeState(CurrentState s){ - if (state == VIEWALL && state != s){ +void MainWindow::beginChangeState(CurrentState s) { + if (state == VIEWALL && state != s) { saveSplitterSizes(); } state = s; } -void MainWindow::saveSplitterSizes(){ +void MainWindow::saveSplitterSizes() { QSettings settings; settings.beginGroup("MainWindow"); settings.setValue("mainSplitter", ui.mainSplitter->saveState()); @@ -481,8 +482,7 @@ void MainWindow::on_actionFullScreen_triggered(bool checked) { if (checked) { setWindowState(windowState() | Qt::WindowFullScreen); - } - else { + } else { setWindowState(windowState() & ~Qt::WindowFullScreen); } } @@ -504,7 +504,7 @@ void MainWindow::on_actionAboutSubsurface_triggered() void MainWindow::on_actionUserManual_triggered() { - if(!helpView){ + if (!helpView) { helpView = new UserManual(); } helpView->show(); @@ -613,7 +613,7 @@ void MainWindow::initialUiSetup() resize(sz); state = (CurrentState) settings.value("lastState", 0).toInt(); - switch(state){ + switch (state) { case VIEWALL: on_actionViewAll_triggered(); break; case GLOBE_MAXIMIZED : on_actionViewGlobe_triggered(); break; case INFO_MAXIMIZED : on_actionViewInfo_triggered(); break; @@ -693,22 +693,21 @@ void MainWindow::writeSettings() settings.setValue("maximized", isMaximized()); if (!isMaximized()) settings.setValue("size", size()); - if (state == VIEWALL){ + if (state == VIEWALL) saveSplitterSizes(); - } settings.endGroup(); } void MainWindow::closeEvent(QCloseEvent *event) { - if(DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING || - ui.InfoWidget->isEditing()) { + if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING || + ui.InfoWidget->isEditing()) { QMessageBox::warning(this, tr("Warning"), tr("Please save or cancel the current dive edit before closing the file.")); event->ignore(); return; } - if (helpView && helpView->isVisible()){ + if (helpView && helpView->isVisible()) { helpView->close(); helpView->deleteLater(); } @@ -754,7 +753,7 @@ void MainWindow::file_save_as(void) tr("Subsurface XML files (*.ssrf *.xml *.XML)")); if (!filename.isNull() && !filename.isEmpty()) { - if(ui.InfoWidget->isEditing()) + if (ui.InfoWidget->isEditing()) ui.InfoWidget->acceptChanges(); save_dives(filename.toUtf8().data()); @@ -771,7 +770,7 @@ void MainWindow::file_save(void) if (!existing_filename) return file_save_as(); - if(ui.InfoWidget->isEditing()) + if (ui.InfoWidget->isEditing()) ui.InfoWidget->acceptChanges(); current_default = prefs.default_filename; @@ -885,7 +884,7 @@ void MainWindow::on_actionImportDiveLog_triggered() void MainWindow::editCurrentDive() { - if(information()->isEditing() || DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING){ + if (information()->isEditing() || DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING) { QMessageBox::warning(this, tr("Warning"), tr("First finish the current edition before trying to do another.")); return; } @@ -893,15 +892,14 @@ void MainWindow::editCurrentDive() struct dive *d = current_dive; QString defaultDC(d->dc.model); DivePlannerPointsModel::instance()->clear(); - if (defaultDC == "manually added dive"){ + if (defaultDC == "manually added dive") { disableDcShortcuts(); DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD); ui.stackedWidget->setCurrentIndex(PLANNERPROFILE); // Planner. ui.infoPane->setCurrentIndex(MAINTAB); DivePlannerPointsModel::instance()->loadFromDive(d); ui.InfoWidget->enableEdition(MainTab::MANUALLY_ADDED_DIVE); - } - else if (defaultDC == "planned dive"){ + } else if (defaultDC == "planned dive") { disableDcShortcuts(); DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN); ui.stackedWidget->setCurrentIndex(PLANNERPROFILE); // Planner. |