diff options
Diffstat (limited to 'qt-ui/mainwindow.cpp')
-rw-r--r-- | qt-ui/mainwindow.cpp | 93 |
1 files changed, 40 insertions, 53 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 709693c30..19a16a886 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -43,6 +43,7 @@ #include "printdialog.h" #endif #include "divelogimportdialog.h" +#include "divelogexportdialog.h" #ifndef NO_USERMANUAL #include "usermanual.h" #endif @@ -67,13 +68,13 @@ MainWindow::MainWindow() : QMainWindow(), connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.ListWidget, SLOT(update())); connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.ListWidget, SLOT(reloadHeaderActions())); connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.InfoWidget, SLOT(updateDiveInfo())); - connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.divePlanner, SLOT(settingsChanged())); connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.divePlannerWidget, SLOT(settingsChanged())); connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), TankInfoModel::instance(), SLOT(update())); connect(ui.actionRecent1, SIGNAL(triggered(bool)), this, SLOT(recentFileTriggered(bool))); connect(ui.actionRecent2, SIGNAL(triggered(bool)), this, SLOT(recentFileTriggered(bool))); connect(ui.actionRecent3, SIGNAL(triggered(bool)), this, SLOT(recentFileTriggered(bool))); connect(ui.actionRecent4, SIGNAL(triggered(bool)), this, SLOT(recentFileTriggered(bool))); + connect(information(), SIGNAL(addDiveFinished()), ui.newProfile, SLOT(setProfileState())); ui.mainErrorMessage->hide(); initialUiSetup(); @@ -84,10 +85,8 @@ MainWindow::MainWindow() : QMainWindow(), ui.globe->reload(); ui.ListWidget->expand(ui.ListWidget->model()->index(0, 0)); ui.ListWidget->scrollTo(ui.ListWidget->model()->index(0, 0), QAbstractItemView::PositionAtCenter); - ui.divePlanner->settingsChanged(); ui.divePlannerWidget->settingsChanged(); - #ifndef ENABLE_PLANNER ui.menuLog->removeAction(ui.actionDivePlanner); #endif @@ -124,14 +123,14 @@ MainWindow *MainWindow::instance() } // this gets called after we download dives from a divecomputer -void MainWindow::refreshDisplay(bool recreateDiveList) +void MainWindow::refreshDisplay(bool doRecreateDiveList) { showError(get_error_string()); ui.InfoWidget->reload(); TankInfoModel::instance()->update(); ui.globe->reload(); - if (recreateDiveList) - ui.ListWidget->reload(DiveTripModel::CURRENT); + if (doRecreateDiveList) + recreateDiveList(); ui.ListWidget->setFocus(); WSInfoModel::instance()->updateInfo(); // refresh the yearly stats if the window has an instance @@ -143,6 +142,11 @@ void MainWindow::refreshDisplay(bool recreateDiveList) } } +void MainWindow::recreateDiveList() +{ + ui.ListWidget->reload(DiveTripModel::CURRENT); +} + void MainWindow::current_dive_changed(int divenr) { if (divenr >= 0) { @@ -189,7 +193,7 @@ void MainWindow::on_actionSaveAs_triggered() file_save_as(); } -ProfileWidget2* MainWindow::graphics() const +ProfileWidget2 *MainWindow::graphics() const { return ui.newProfile; } @@ -273,34 +277,6 @@ void MainWindow::updateLastUsedDir(const QString &dir) s.setValue("LastDir", dir); } -void MainWindow::on_actionExportUDDF_triggered() -{ - QFileInfo fi(system_default_filename()); - QString filename = QFileDialog::getSaveFileName(this, tr("Export UDDF File as"), fi.absolutePath(), - tr("UDDF files (*.uddf *.UDDF)")); - if (!filename.isNull() && !filename.isEmpty()) - export_dives_xslt(filename.toUtf8(), false, "uddf-export.xslt"); -} - -void MainWindow::on_actionExport_CSV_triggered() -{ - QFileInfo fi(system_default_filename()); - QString filename = QFileDialog::getSaveFileName(this, tr("Export CSV File as"), fi.absolutePath(), - tr("CSV files (*.csv *.CSV)")); - - if (!filename.isNull() && !filename.isEmpty()) - export_dives_xslt(filename.toUtf8(), false, "xml2csv.xslt"); -} - -void MainWindow::on_actionExportHTMLworldmap_triggered() -{ - QFileInfo fi(system_default_filename()); - QString filename = QFileDialog::getSaveFileName(this, tr("Export World Map"), fi.absolutePath(), - tr("HTML files (*.html)")); - if (!filename.isNull() && !filename.isEmpty()) - export_worldmap_HTML(filename.toUtf8().data()); -} - void MainWindow::on_actionPrint_triggered() { #ifndef NO_PRINTING @@ -335,21 +311,23 @@ void MainWindow::on_actionDivePlanner_triggered() DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN); DivePlannerPointsModel::instance()->clear(); CylindersModel::instance()->clear(); - for_each_dive(i,dive) { - if(dive->selected){ + for_each_dive (i, dive) { + if (dive->selected) { DivePlannerPointsModel::instance()->copyCylindersFrom(dive); CylindersModel::instance()->copyFromDive(dive); break; } } - ui.stackedWidget->setCurrentIndex(PLANNERPROFILE); ui.infoPane->setCurrentIndex(PLANNERWIDGET); } void MainWindow::showProfile() { enableDcShortcuts(); - ui.stackedWidget->setCurrentIndex(PROFILE); + //TODO: I BROKE THIS BY COMMENTING THE LINE BELOW + // and I'm sleepy now, so I think I should not try to fix right away. + // we don't setCurrentIndex anymore, we ->setPlanState() or ->setAddState() on the ProfileView. + //ui.stackedWidget->setCurrentIndex(PROFILE); ui.infoPane->setCurrentIndex(MAINTAB); } @@ -430,8 +408,9 @@ void MainWindow::on_actionAddDive_triggered() ui.InfoWidget->setCurrentIndex(0); ui.InfoWidget->updateDiveInfo(selected_dive); ui.InfoWidget->addDiveStarted(); - ui.stackedWidget->setCurrentIndex(PLANNERPROFILE); // Planner. ui.infoPane->setCurrentIndex(MAINTAB); + + ui.newProfile->setAddState(); DivePlannerPointsModel::instance()->clear(); DivePlannerPointsModel::instance()->createSimpleDive(); ui.ListWidget->reload(DiveTripModel::CURRENT); @@ -439,6 +418,7 @@ void MainWindow::on_actionAddDive_triggered() void MainWindow::on_actionRenumber_triggered() { + RenumberDialog::instance()->renumberOnlySelected(false); RenumberDialog::instance()->show(); } @@ -462,11 +442,11 @@ void MainWindow::on_actionYearlyStatistics_triggered() yearlyStats->setMinimumWidth(600); yearlyStats->setWindowTitle(tr("Yearly Statistics")); yearlyStats->setWindowIcon(QIcon(":subsurface-icon")); - QShortcut* closeKey = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), yearlyStats); + QShortcut *closeKey = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), yearlyStats); connect(closeKey, SIGNAL(activated()), yearlyStats, SLOT(close())); closeKey = new QShortcut(QKeySequence(Qt::Key_Escape), yearlyStats); connect(closeKey, SIGNAL(activated()), yearlyStats, SLOT(close())); - QShortcut* quitKey = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), yearlyStats); + QShortcut *quitKey = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), yearlyStats); connect(quitKey, SIGNAL(activated()), this, SLOT(close())); } /* problem here is that without more MainWindow variables or a separate YearlyStatistics @@ -873,7 +853,7 @@ void MainWindow::addRecentFile(const QStringList &newFiles) } } - foreach(const QString & file, newFiles) { + foreach (const QString &file, newFiles) { int index = files.indexOf(file); if (index >= 0) { @@ -881,7 +861,7 @@ void MainWindow::addRecentFile(const QStringList &newFiles) } } - foreach(const QString & file, newFiles) { + foreach (const QString &file, newFiles) { if (QFile::exists(file)) { files.prepend(file); } @@ -929,7 +909,7 @@ void MainWindow::removeRecentFile(QStringList failedFiles) } } - foreach(QString file, failedFiles) + foreach (QString file, failedFiles) files.removeAll(file); for (int c = 1; c <= 4; c++) { @@ -965,12 +945,7 @@ void MainWindow::recentFileTriggered(bool checked) int MainWindow::file_save_as(void) { QString filename; - const char *default_filename; - - if (existing_filename) - default_filename = existing_filename; - else - default_filename = prefs.default_filename; + const char *default_filename = existing_filename; filename = QFileDialog::getSaveFileName(this, tr("Save File as"), default_filename, tr("Subsurface XML files (*.ssrf *.xml *.XML)")); if (filename.isNull() || filename.isEmpty()) @@ -1128,14 +1103,20 @@ void MainWindow::editCurrentDive() if (defaultDC == "manually added dive") { disableDcShortcuts(); DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD); - ui.stackedWidget->setCurrentIndex(PLANNERPROFILE); // Planner. + //TODO: I BROKE THIS BY COMMENTING THE LINE BELOW + // and I'm sleepy now, so I think I should not try to fix right away. + // we don't setCurrentIndex anymore, we ->setPlanState() or ->setAddState() on the ProfileView. + //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") { disableDcShortcuts(); DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN); - ui.stackedWidget->setCurrentIndex(PLANNERPROFILE); // Planner. + //TODO: I BROKE THIS BY COMMENTING THE LINE BELOW + // and I'm sleepy now, so I think I should not try to fix right away. + // we don't setCurrentIndex anymore, we ->setPlanState() or ->setAddState() on the ProfileView. + //ui.stackedWidget->setCurrentIndex(PLANNERPROFILE); // Planner. ui.infoPane->setCurrentIndex(PLANNERWIDGET); DivePlannerPointsModel::instance()->loadFromDive(d); ui.InfoWidget->enableEdition(MainTab::MANUALLY_ADDED_DIVE); @@ -1221,3 +1202,9 @@ void MainWindow::on_profScaled_clicked(bool triggered) } #undef TOOLBOX_PREF_PROFILE + +void MainWindow::on_actionExport_triggered() +{ + DiveLogExportDialog *diveLogExport = new DiveLogExportDialog(this); + diveLogExport->show(); +} |