2013-04-14 03:44:02 +00:00
|
|
|
/*
|
|
|
|
* mainwindow.cpp
|
|
|
|
*
|
|
|
|
* classes for the main UI window in Subsurface
|
|
|
|
*/
|
2013-04-07 22:20:43 +00:00
|
|
|
#include "mainwindow.h"
|
|
|
|
|
|
|
|
#include <QVBoxLayout>
|
2013-04-13 13:17:59 +00:00
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QMessageBox>
|
2013-04-09 08:35:44 +00:00
|
|
|
#include <QtDebug>
|
2013-04-18 07:59:32 +00:00
|
|
|
#include <QDateTime>
|
2013-04-27 09:09:57 +00:00
|
|
|
#include <QSettings>
|
|
|
|
#include <QCloseEvent>
|
2013-05-02 21:05:53 +00:00
|
|
|
#include <QApplication>
|
|
|
|
#include <QFontMetrics>
|
2013-06-17 23:02:30 +00:00
|
|
|
#include <QTableView>
|
2013-10-04 15:28:40 +00:00
|
|
|
#include <QDesktopWidget>
|
2013-12-05 12:02:25 +00:00
|
|
|
#include <QDesktopServices>
|
2014-02-13 21:48:07 +00:00
|
|
|
#include <QStringList>
|
|
|
|
#include <QSettings>
|
2014-04-25 04:37:47 +00:00
|
|
|
#include <QShortcut>
|
2014-08-23 01:26:07 +00:00
|
|
|
#include <QToolBar>
|
2014-05-25 18:56:39 +00:00
|
|
|
#include <fcntl.h>
|
2013-04-12 07:24:07 +00:00
|
|
|
#include "divelistview.h"
|
2013-04-22 23:00:27 +00:00
|
|
|
#include "starwidget.h"
|
2014-06-13 17:56:46 +00:00
|
|
|
#include "ssrf-version.h"
|
2014-04-11 08:51:07 +00:00
|
|
|
#include "dive.h"
|
|
|
|
#include "display.h"
|
|
|
|
#include "divelist.h"
|
|
|
|
#include "pref.h"
|
|
|
|
#include "helpers.h"
|
2013-04-27 15:27:27 +00:00
|
|
|
#include "modeldelegates.h"
|
2013-05-02 23:32:57 +00:00
|
|
|
#include "models.h"
|
2013-05-20 19:43:33 +00:00
|
|
|
#include "downloadfromdivecomputer.h"
|
2013-05-24 18:19:48 +00:00
|
|
|
#include "preferences.h"
|
2013-06-06 13:33:15 +00:00
|
|
|
#include "subsurfacewebservices.h"
|
2013-06-07 14:43:45 +00:00
|
|
|
#include "divecomputermanagementdialog.h"
|
2013-06-17 16:41:00 +00:00
|
|
|
#include "simplewidgets.h"
|
2013-06-20 15:33:26 +00:00
|
|
|
#include "diveplanner.h"
|
2013-06-24 11:36:38 +00:00
|
|
|
#include "about.h"
|
2014-03-30 20:14:56 +00:00
|
|
|
#include "worldmap-save.h"
|
2014-04-02 19:41:39 +00:00
|
|
|
#include "updatemanager.h"
|
2014-06-04 21:34:09 +00:00
|
|
|
#include "planner.h"
|
2014-05-29 15:54:19 +00:00
|
|
|
#include "configuredivecomputerdialog.h"
|
2014-08-25 18:46:08 +00:00
|
|
|
#include "statistics/statisticswidget.h"
|
2014-11-13 18:31:03 +00:00
|
|
|
#include "filtermodels.h"
|
2014-03-26 22:36:06 +00:00
|
|
|
#ifndef NO_PRINTING
|
2014-06-23 13:43:51 +00:00
|
|
|
#include <QPrintDialog>
|
2013-07-09 12:37:53 +00:00
|
|
|
#include "printdialog.h"
|
2014-03-26 22:36:06 +00:00
|
|
|
#endif
|
2013-12-29 16:11:20 +00:00
|
|
|
#include "divelogimportdialog.h"
|
2014-05-20 16:33:32 +00:00
|
|
|
#include "divelogexportdialog.h"
|
2014-06-13 17:56:46 +00:00
|
|
|
#include "usersurvey.h"
|
2014-03-26 22:35:24 +00:00
|
|
|
#ifndef NO_USERMANUAL
|
|
|
|
#include "usermanual.h"
|
|
|
|
#endif
|
2014-12-17 03:59:41 +00:00
|
|
|
#ifndef NO_USERSURVEY
|
|
|
|
#include "usersurvey.h"
|
|
|
|
#endif
|
2014-06-26 16:20:34 +00:00
|
|
|
#include <QNetworkProxy>
|
2013-04-13 13:17:59 +00:00
|
|
|
|
2014-02-12 14:22:54 +00:00
|
|
|
MainWindow *MainWindow::m_Instance = NULL;
|
2013-05-19 03:09:36 +00:00
|
|
|
|
2014-02-09 19:04:21 +00:00
|
|
|
MainWindow::MainWindow() : QMainWindow(),
|
|
|
|
actionNextDive(0),
|
|
|
|
actionPreviousDive(0),
|
|
|
|
helpView(0),
|
2014-04-02 19:56:14 +00:00
|
|
|
state(VIEWALL),
|
2014-05-27 22:02:45 +00:00
|
|
|
updateManager(0),
|
2014-06-13 17:56:46 +00:00
|
|
|
survey(0)
|
2013-04-07 22:20:43 +00:00
|
|
|
{
|
2014-02-19 00:47:21 +00:00
|
|
|
Q_ASSERT_X(m_Instance == NULL, "MainWindow", "MainWindow recreated!");
|
2014-02-12 14:22:54 +00:00
|
|
|
m_Instance = this;
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.setupUi(this);
|
2014-10-31 17:22:21 +00:00
|
|
|
ui.multiFilter->hide();
|
2014-08-23 01:26:07 +00:00
|
|
|
profileToolbarActions << ui.profCalcAllTissues << ui.profCalcCeiling << ui.profDcCeiling << ui.profEad <<
|
|
|
|
ui.profHR << ui.profIncrement3m << ui.profMod << ui.profNdl_tts << ui.profNdl_tts <<
|
|
|
|
ui.profPhe << ui.profPn2 << ui.profPO2 << ui.profRuler << ui.profSAC << ui.profScaled <<
|
2014-09-15 12:09:00 +00:00
|
|
|
ui.profTogglePicture << ui.profTankbar << ui.profTissues;
|
2013-04-25 23:44:06 +00:00
|
|
|
setWindowIcon(QIcon(":subsurface-icon"));
|
2014-06-28 08:14:36 +00:00
|
|
|
if (!QIcon::hasThemeIcon("window-close")) {
|
|
|
|
QIcon::setThemeName("subsurface");
|
|
|
|
}
|
2013-10-03 18:54:25 +00:00
|
|
|
connect(ui.ListWidget, SIGNAL(currentDiveChanged(int)), this, SLOT(current_dive_changed(int)));
|
2013-05-26 18:33:45 +00:00
|
|
|
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(readSettings()));
|
2013-10-03 18:54:25 +00:00
|
|
|
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.ListWidget, SLOT(update()));
|
|
|
|
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.ListWidget, SLOT(reloadHeaderActions()));
|
2013-11-20 07:08:20 +00:00
|
|
|
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.InfoWidget, SLOT(updateDiveInfo()));
|
2013-12-09 06:43:00 +00:00
|
|
|
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.divePlannerWidget, SLOT(settingsChanged()));
|
2014-06-27 09:43:11 +00:00
|
|
|
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui.plannerSettingsWidget, SLOT(settingsChanged()));
|
2014-01-11 14:57:06 +00:00
|
|
|
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), TankInfoModel::instance(), SLOT(update()));
|
2014-02-13 21:48:07 +00:00
|
|
|
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)));
|
2014-05-21 23:34:06 +00:00
|
|
|
connect(information(), SIGNAL(addDiveFinished()), ui.newProfile, SLOT(setProfileState()));
|
2014-07-16 22:23:02 +00:00
|
|
|
connect(DivePlannerPointsModel::instance(), SIGNAL(planCreated()), this, SLOT(planCreated()));
|
|
|
|
connect(DivePlannerPointsModel::instance(), SIGNAL(planCanceled()), this, SLOT(planCanceled()));
|
2014-06-26 15:04:39 +00:00
|
|
|
connect(ui.printPlan, SIGNAL(pressed()), ui.divePlannerWidget, SLOT(printDecoPlan()));
|
|
|
|
#ifdef NO_PRINTING
|
|
|
|
ui.printPlan->hide();
|
|
|
|
#endif
|
|
|
|
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.mainErrorMessage->hide();
|
2014-07-10 16:50:49 +00:00
|
|
|
ui.newProfile->setEmptyState();
|
2013-06-04 12:40:09 +00:00
|
|
|
initialUiSetup();
|
2013-05-22 01:29:23 +00:00
|
|
|
readSettings();
|
2013-11-08 22:30:17 +00:00
|
|
|
ui.ListWidget->reload(DiveTripModel::TREE);
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.ListWidget->reloadHeaderActions();
|
|
|
|
ui.ListWidget->setFocus();
|
|
|
|
ui.globe->reload();
|
2014-02-14 06:11:05 +00:00
|
|
|
ui.ListWidget->expand(ui.ListWidget->model()->index(0, 0));
|
|
|
|
ui.ListWidget->scrollTo(ui.ListWidget->model()->index(0, 0), QAbstractItemView::PositionAtCenter);
|
2013-12-09 06:43:00 +00:00
|
|
|
ui.divePlannerWidget->settingsChanged();
|
2014-06-27 09:43:11 +00:00
|
|
|
ui.plannerSettingsWidget->settingsChanged();
|
2014-03-26 22:08:56 +00:00
|
|
|
#ifdef NO_MARBLE
|
2014-06-17 18:01:14 +00:00
|
|
|
ui.globePane->hide();
|
2014-03-26 22:08:56 +00:00
|
|
|
ui.menuView->removeAction(ui.actionViewGlobe);
|
|
|
|
#endif
|
2014-03-26 22:35:24 +00:00
|
|
|
#ifdef NO_USERMANUAL
|
|
|
|
ui.menuHelp->removeAction(ui.actionUserManual);
|
|
|
|
#endif
|
2014-12-17 03:59:41 +00:00
|
|
|
#ifdef NO_USERSURVEY
|
|
|
|
ui.menuHelp->removeAction(ui.actionUserSurvey);
|
|
|
|
#endif
|
|
|
|
|
2014-03-26 22:36:06 +00:00
|
|
|
#ifdef NO_PRINTING
|
|
|
|
ui.menuFile->removeAction(ui.actionPrint);
|
|
|
|
#endif
|
2014-08-16 15:32:23 +00:00
|
|
|
memset(©PasteDive, 0, sizeof(copyPasteDive));
|
|
|
|
memset(&what, 0, sizeof(what));
|
2014-08-23 01:26:07 +00:00
|
|
|
|
|
|
|
QToolBar *toolBar = new QToolBar();
|
2014-09-17 22:39:49 +00:00
|
|
|
Q_FOREACH (QAction *a, profileToolbarActions)
|
2014-08-23 01:26:07 +00:00
|
|
|
toolBar->addAction(a);
|
|
|
|
toolBar->setOrientation(Qt::Vertical);
|
|
|
|
|
|
|
|
// since I'm adding the toolBar by hand, because designer
|
|
|
|
// has no concept of "toolbar" for a non-mainwindow widget (...)
|
|
|
|
// I need to take the current item that's in the toolbar Position
|
|
|
|
// and reposition it alongside the grid layout.
|
|
|
|
QLayoutItem *p = ui.gridLayout->takeAt(0);
|
2014-09-17 22:39:49 +00:00
|
|
|
ui.gridLayout->addWidget(toolBar, 0, 0);
|
2014-08-23 01:26:07 +00:00
|
|
|
ui.gridLayout->addItem(p, 0, 1);
|
2013-05-14 11:18:26 +00:00
|
|
|
}
|
|
|
|
|
2014-02-12 14:22:54 +00:00
|
|
|
MainWindow::~MainWindow()
|
|
|
|
{
|
|
|
|
m_Instance = NULL;
|
|
|
|
}
|
|
|
|
|
2014-03-11 21:54:28 +00:00
|
|
|
void MainWindow::setLoadedWithFiles(bool f)
|
|
|
|
{
|
|
|
|
filesAsArguments = f;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MainWindow::filesFromCommandLine() const
|
|
|
|
{
|
|
|
|
return filesAsArguments;
|
|
|
|
}
|
|
|
|
|
2014-02-12 14:22:54 +00:00
|
|
|
MainWindow *MainWindow::instance()
|
|
|
|
{
|
|
|
|
return m_Instance;
|
|
|
|
}
|
|
|
|
|
2013-05-30 08:58:59 +00:00
|
|
|
// this gets called after we download dives from a divecomputer
|
2014-05-18 10:08:58 +00:00
|
|
|
void MainWindow::refreshDisplay(bool doRecreateDiveList)
|
2013-05-30 08:58:59 +00:00
|
|
|
{
|
2014-03-14 18:26:07 +00:00
|
|
|
showError(get_error_string());
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.InfoWidget->reload();
|
2013-12-28 22:56:01 +00:00
|
|
|
TankInfoModel::instance()->update();
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.globe->reload();
|
2014-05-18 10:08:58 +00:00
|
|
|
if (doRecreateDiveList)
|
|
|
|
recreateDiveList();
|
2014-06-01 03:59:36 +00:00
|
|
|
ui.diveListPane->setCurrentIndex(0); // switch to the dive list
|
2014-06-17 18:01:14 +00:00
|
|
|
#ifdef NO_MARBLE
|
|
|
|
ui.globePane->hide();
|
|
|
|
#endif
|
2014-06-10 15:40:02 +00:00
|
|
|
ui.globePane->setCurrentIndex(0);
|
2014-05-27 22:10:22 +00:00
|
|
|
ui.ListWidget->setEnabled(true);
|
2014-05-27 22:32:45 +00:00
|
|
|
ui.ListWidget->setFocus();
|
2013-11-16 20:58:31 +00:00
|
|
|
WSInfoModel::instance()->updateInfo();
|
2014-05-28 17:14:40 +00:00
|
|
|
if (amount_selected == 0)
|
|
|
|
cleanUpEmpty();
|
2013-05-30 08:58:59 +00:00
|
|
|
}
|
|
|
|
|
2014-05-18 10:08:58 +00:00
|
|
|
void MainWindow::recreateDiveList()
|
|
|
|
{
|
|
|
|
ui.ListWidget->reload(DiveTripModel::CURRENT);
|
2014-09-17 18:45:18 +00:00
|
|
|
TagFilterModel::instance()->repopulate();
|
2014-10-31 18:49:52 +00:00
|
|
|
BuddyFilterModel::instance()->repopulate();
|
2014-10-31 19:42:56 +00:00
|
|
|
LocationFilterModel::instance()->repopulate();
|
2014-11-13 19:32:17 +00:00
|
|
|
SuitsFilterModel::instance()->repopulate();
|
2014-05-18 10:08:58 +00:00
|
|
|
}
|
|
|
|
|
2013-05-14 11:18:26 +00:00
|
|
|
void MainWindow::current_dive_changed(int divenr)
|
|
|
|
{
|
2013-06-05 00:51:40 +00:00
|
|
|
if (divenr >= 0) {
|
2013-05-31 12:05:33 +00:00
|
|
|
select_dive(divenr);
|
2014-05-07 20:58:07 +00:00
|
|
|
ui.globe->centerOnCurrentDive();
|
2013-05-31 12:05:33 +00:00
|
|
|
}
|
2014-07-03 03:00:57 +00:00
|
|
|
ui.newProfile->plotDive();
|
2014-07-02 19:58:41 +00:00
|
|
|
ui.InfoWidget->updateDiveInfo();
|
2014-01-15 20:13:20 +00:00
|
|
|
}
|
|
|
|
|
2013-04-09 08:35:44 +00:00
|
|
|
void MainWindow::on_actionNew_triggered()
|
|
|
|
{
|
2013-06-26 12:07:50 +00:00
|
|
|
on_actionClose_triggered();
|
2013-04-09 08:35:44 +00:00
|
|
|
}
|
2013-04-09 16:26:23 +00:00
|
|
|
|
|
|
|
void MainWindow::on_actionOpen_triggered()
|
|
|
|
{
|
2014-06-09 02:46:43 +00:00
|
|
|
if (!okToClose(tr("Please save or cancel the current dive edit before opening a new file.")))
|
2013-11-15 21:42:49 +00:00
|
|
|
return;
|
2014-06-09 02:46:43 +00:00
|
|
|
|
2014-11-21 17:46:24 +00:00
|
|
|
// yes, this look wrong to use getSaveFileName() for the open dialog, but we need to be able
|
|
|
|
// to enter file names that don't exist in order to use our git syntax /path/to/dir[branch]
|
|
|
|
// with is a potentially valid input, but of course won't exist. So getOpenFileName() wouldn't work
|
2014-11-23 00:06:01 +00:00
|
|
|
QFileDialog dialog(this, tr("Open file"), lastUsedDir(), filter());
|
|
|
|
dialog.setFileMode(QFileDialog::AnyFile);
|
|
|
|
dialog.setViewMode(QFileDialog::Detail);
|
|
|
|
dialog.setLabelText(QFileDialog::Accept, tr("Open"));
|
|
|
|
dialog.setLabelText(QFileDialog::Reject, tr("Cancel"));
|
|
|
|
QStringList filenames;
|
|
|
|
if (dialog.exec())
|
|
|
|
filenames = dialog.selectedFiles();
|
|
|
|
if (filenames.isEmpty())
|
2013-04-13 13:17:59 +00:00
|
|
|
return;
|
2014-11-23 00:06:01 +00:00
|
|
|
updateLastUsedDir(QFileInfo(filenames.first()).dir().path());
|
2014-06-09 02:46:43 +00:00
|
|
|
closeCurrentFile();
|
2014-11-23 00:06:01 +00:00
|
|
|
loadFiles(filenames);
|
2013-04-09 16:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionSave_triggered()
|
|
|
|
{
|
2013-05-19 22:25:47 +00:00
|
|
|
file_save();
|
2013-04-09 16:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionSaveAs_triggered()
|
|
|
|
{
|
2013-05-19 22:25:47 +00:00
|
|
|
file_save_as();
|
2013-04-09 16:26:23 +00:00
|
|
|
}
|
2013-09-23 05:24:28 +00:00
|
|
|
|
2014-05-22 18:40:22 +00:00
|
|
|
ProfileWidget2 *MainWindow::graphics() const
|
2014-03-07 15:42:13 +00:00
|
|
|
{
|
|
|
|
return ui.newProfile;
|
|
|
|
}
|
|
|
|
|
2013-09-23 05:24:28 +00:00
|
|
|
void MainWindow::cleanUpEmpty()
|
|
|
|
{
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.InfoWidget->clearStats();
|
|
|
|
ui.InfoWidget->clearInfo();
|
|
|
|
ui.InfoWidget->clearEquipment();
|
2014-07-02 21:15:17 +00:00
|
|
|
ui.InfoWidget->updateDiveInfo(true);
|
2014-03-07 15:42:13 +00:00
|
|
|
ui.newProfile->setEmptyState();
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.ListWidget->reload(DiveTripModel::TREE);
|
|
|
|
ui.globe->reload();
|
2013-12-05 12:38:12 +00:00
|
|
|
if (!existing_filename)
|
|
|
|
setTitle(MWTF_DEFAULT);
|
2014-07-16 09:09:14 +00:00
|
|
|
disableDcShortcuts();
|
2013-09-23 05:24:28 +00:00
|
|
|
}
|
|
|
|
|
2014-06-09 02:46:43 +00:00
|
|
|
bool MainWindow::okToClose(QString message)
|
2013-04-09 16:26:23 +00:00
|
|
|
{
|
2014-01-16 04:50:56 +00:00
|
|
|
if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING ||
|
|
|
|
ui.InfoWidget->isEditing()) {
|
2014-06-09 02:46:43 +00:00
|
|
|
QMessageBox::warning(this, tr("Warning"), message);
|
|
|
|
return false;
|
2013-11-15 21:42:49 +00:00
|
|
|
}
|
2014-06-09 02:46:43 +00:00
|
|
|
if (unsaved_changes() && askSaveChanges() == false)
|
|
|
|
return false;
|
2013-04-13 13:17:59 +00:00
|
|
|
|
2014-06-09 02:46:43 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::closeCurrentFile()
|
|
|
|
{
|
2014-02-11 18:03:08 +00:00
|
|
|
ui.newProfile->setEmptyState();
|
2013-04-13 13:17:59 +00:00
|
|
|
/* free the dives and trips */
|
2014-03-13 22:42:45 +00:00
|
|
|
clear_git_id();
|
2013-04-13 13:17:59 +00:00
|
|
|
while (dive_table.nr)
|
|
|
|
delete_single_dive(0);
|
2013-04-28 03:47:47 +00:00
|
|
|
|
2014-05-12 17:58:15 +00:00
|
|
|
free((void *)existing_filename);
|
|
|
|
existing_filename = NULL;
|
|
|
|
|
2013-09-23 05:24:28 +00:00
|
|
|
cleanUpEmpty();
|
2014-01-15 08:30:42 +00:00
|
|
|
mark_divelist_changed(false);
|
2013-04-13 13:17:59 +00:00
|
|
|
|
|
|
|
clear_events();
|
2013-04-09 16:26:23 +00:00
|
|
|
}
|
|
|
|
|
2014-06-09 02:46:43 +00:00
|
|
|
void MainWindow::on_actionClose_triggered()
|
|
|
|
{
|
2014-12-10 03:16:39 +00:00
|
|
|
if (okToClose(tr("Please save or cancel the current dive edit before closing the file."))) {
|
2014-06-09 02:46:43 +00:00
|
|
|
closeCurrentFile();
|
2014-12-10 04:15:52 +00:00
|
|
|
// hide any pictures and the filter
|
|
|
|
DivePictureModel::instance()->updateDivePictures();
|
2014-12-10 03:16:39 +00:00
|
|
|
ui.multiFilter->closeFilter();
|
|
|
|
recreateDiveList();
|
|
|
|
}
|
2014-06-09 02:46:43 +00:00
|
|
|
}
|
|
|
|
|
2013-11-14 15:42:26 +00:00
|
|
|
QString MainWindow::lastUsedDir()
|
2013-04-09 16:26:23 +00:00
|
|
|
{
|
2013-06-25 10:35:04 +00:00
|
|
|
QSettings settings;
|
|
|
|
QString lastDir = QDir::homePath();
|
|
|
|
|
|
|
|
settings.beginGroup("FileDialog");
|
|
|
|
if (settings.contains("LastDir"))
|
|
|
|
if (QDir::setCurrent(settings.value("LastDir").toString()))
|
|
|
|
lastDir = settings.value("LastDir").toString();
|
2013-11-14 15:42:26 +00:00
|
|
|
return lastDir;
|
|
|
|
}
|
2013-06-25 10:35:04 +00:00
|
|
|
|
2014-02-14 06:11:05 +00:00
|
|
|
void MainWindow::updateLastUsedDir(const QString &dir)
|
2013-11-14 15:42:26 +00:00
|
|
|
{
|
|
|
|
QSettings s;
|
|
|
|
s.beginGroup("FileDialog");
|
|
|
|
s.setValue("LastDir", dir);
|
2013-04-09 16:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionPrint_triggered()
|
|
|
|
{
|
2014-03-26 22:36:06 +00:00
|
|
|
#ifndef NO_PRINTING
|
2014-02-08 19:12:13 +00:00
|
|
|
PrintDialog dlg(this);
|
|
|
|
|
|
|
|
dlg.exec();
|
2014-03-26 22:36:06 +00:00
|
|
|
#endif
|
2013-04-09 16:26:23 +00:00
|
|
|
}
|
|
|
|
|
2013-07-04 15:30:05 +00:00
|
|
|
void MainWindow::disableDcShortcuts()
|
|
|
|
{
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.actionPreviousDC->setShortcut(QKeySequence());
|
|
|
|
ui.actionNextDC->setShortcut(QKeySequence());
|
2013-07-04 15:30:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::enableDcShortcuts()
|
|
|
|
{
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.actionPreviousDC->setShortcut(Qt::Key_Left);
|
|
|
|
ui.actionNextDC->setShortcut(Qt::Key_Right);
|
2013-07-04 15:30:05 +00:00
|
|
|
}
|
|
|
|
|
2013-06-27 17:48:03 +00:00
|
|
|
void MainWindow::showProfile()
|
|
|
|
{
|
2013-07-04 15:30:05 +00:00
|
|
|
enableDcShortcuts();
|
2014-05-27 22:44:47 +00:00
|
|
|
ui.newProfile->setProfileState();
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.infoPane->setCurrentIndex(MAINTAB);
|
2013-06-20 21:48:21 +00:00
|
|
|
}
|
|
|
|
|
2013-04-09 16:26:23 +00:00
|
|
|
void MainWindow::on_actionPreferences_triggered()
|
|
|
|
{
|
2013-05-24 18:19:48 +00:00
|
|
|
PreferencesDialog::instance()->show();
|
2013-04-09 16:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionQuit_triggered()
|
|
|
|
{
|
2014-05-06 13:56:28 +00:00
|
|
|
if (ui.InfoWidget->isEditing()) {
|
2014-06-04 01:17:32 +00:00
|
|
|
ui.InfoWidget->rejectChanges();
|
|
|
|
if (ui.InfoWidget->isEditing())
|
|
|
|
// didn't discard the edits
|
|
|
|
return;
|
2013-11-17 23:46:27 +00:00
|
|
|
}
|
2014-05-06 13:56:28 +00:00
|
|
|
if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING) {
|
|
|
|
DivePlannerPointsModel::instance()->cancelPlan();
|
|
|
|
if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING)
|
|
|
|
// The planned dive was not discarded
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-01-15 08:30:42 +00:00
|
|
|
if (unsaved_changes() && (askSaveChanges() == false))
|
2013-04-27 09:09:57 +00:00
|
|
|
return;
|
2013-05-03 23:30:36 +00:00
|
|
|
writeSettings();
|
|
|
|
QApplication::quit();
|
2013-04-09 16:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionDownloadDC_triggered()
|
|
|
|
{
|
2014-02-08 19:22:09 +00:00
|
|
|
DownloadFromDCWidget dlg(this);
|
|
|
|
|
|
|
|
dlg.exec();
|
2013-04-09 16:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionDownloadWeb_triggered()
|
|
|
|
{
|
2014-02-09 16:51:19 +00:00
|
|
|
SubsurfaceWebServices dlg(this);
|
|
|
|
|
|
|
|
dlg.exec();
|
2013-06-06 13:33:15 +00:00
|
|
|
}
|
2013-04-09 16:26:23 +00:00
|
|
|
|
2013-10-25 01:02:59 +00:00
|
|
|
void MainWindow::on_actionDivelogs_de_triggered()
|
|
|
|
{
|
2013-11-15 02:57:09 +00:00
|
|
|
DivelogsDeWebServices::instance()->downloadDives();
|
2013-10-25 01:02:59 +00:00
|
|
|
}
|
|
|
|
|
2013-04-09 16:26:23 +00:00
|
|
|
void MainWindow::on_actionEditDeviceNames_triggered()
|
|
|
|
{
|
2013-06-17 22:58:26 +00:00
|
|
|
DiveComputerManagementDialog::instance()->init();
|
2013-06-07 14:43:45 +00:00
|
|
|
DiveComputerManagementDialog::instance()->update();
|
|
|
|
DiveComputerManagementDialog::instance()->show();
|
2013-06-10 18:34:57 +00:00
|
|
|
}
|
2013-04-09 16:26:23 +00:00
|
|
|
|
2014-05-25 18:19:36 +00:00
|
|
|
bool MainWindow::plannerStateClean()
|
2014-05-25 18:15:57 +00:00
|
|
|
{
|
|
|
|
if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING ||
|
|
|
|
ui.InfoWidget->isEditing()) {
|
2014-05-25 18:19:36 +00:00
|
|
|
QMessageBox::warning(this, tr("Warning"), tr("Please save or cancel the current dive edit before trying to add a dive."));
|
|
|
|
return false;
|
2014-05-25 18:15:57 +00:00
|
|
|
}
|
2014-05-25 18:19:36 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-05-28 18:43:32 +00:00
|
|
|
void MainWindow::planCanceled()
|
|
|
|
{
|
2014-08-19 20:53:36 +00:00
|
|
|
// while planning we might have modified the displayed_dive
|
|
|
|
// let's refresh what's shown on the profile
|
2014-05-28 18:43:32 +00:00
|
|
|
showProfile();
|
2014-08-19 20:53:36 +00:00
|
|
|
ui.newProfile->replot();
|
2014-07-06 19:36:25 +00:00
|
|
|
refreshDisplay(false);
|
2014-07-16 22:29:01 +00:00
|
|
|
ui.newProfile->plotDive(get_dive(selected_dive));
|
2014-08-02 20:05:52 +00:00
|
|
|
DivePictureModel::instance()->updateDivePictures();
|
2014-05-28 18:43:32 +00:00
|
|
|
}
|
|
|
|
|
2014-05-28 18:54:04 +00:00
|
|
|
void MainWindow::planCreated()
|
|
|
|
{
|
2014-08-18 19:12:05 +00:00
|
|
|
// get the new dive selected and assign a number if reasonable
|
2014-08-20 02:13:09 +00:00
|
|
|
ui.newProfile->setProfileState();
|
2014-08-19 20:03:53 +00:00
|
|
|
if (displayed_dive.id == 0) {
|
|
|
|
// we might have added a new dive (so displayed_dive was cleared out by clone_dive()
|
|
|
|
dive_list()->unselectDives();
|
|
|
|
select_dive(dive_table.nr - 1);
|
|
|
|
dive_list()->selectDive(selected_dive);
|
|
|
|
set_dive_nr_for_current_dive();
|
|
|
|
}
|
2014-10-27 19:35:19 +00:00
|
|
|
// make sure our UI is in a consistent state
|
|
|
|
ui.InfoWidget->updateDiveInfo();
|
2014-05-28 18:54:04 +00:00
|
|
|
showProfile();
|
|
|
|
refreshDisplay();
|
|
|
|
}
|
|
|
|
|
2014-06-01 04:14:44 +00:00
|
|
|
void MainWindow::setPlanNotes(const char *notes)
|
|
|
|
{
|
2014-06-03 07:35:19 +00:00
|
|
|
ui.divePlanOutput->setHtml(notes);
|
2014-06-01 04:14:44 +00:00
|
|
|
}
|
|
|
|
|
2014-06-03 08:06:18 +00:00
|
|
|
void MainWindow::printPlan()
|
|
|
|
{
|
2014-06-23 13:43:51 +00:00
|
|
|
#ifndef NO_PRINTING
|
2014-06-04 21:34:09 +00:00
|
|
|
QString diveplan = ui.divePlanOutput->toHtml();
|
2014-07-01 07:57:54 +00:00
|
|
|
QString withDisclaimer = QString("<img height=50 src=\":subsurface-icon\"> ") + diveplan + QString(disclaimer);
|
2014-06-04 21:34:09 +00:00
|
|
|
|
2014-06-03 08:06:18 +00:00
|
|
|
QPrinter printer;
|
|
|
|
QPrintDialog *dialog = new QPrintDialog(&printer, this);
|
|
|
|
dialog->setWindowTitle(tr("Print runtime table"));
|
|
|
|
if (dialog->exec() != QDialog::Accepted)
|
|
|
|
return;
|
|
|
|
|
2014-06-04 21:34:09 +00:00
|
|
|
ui.divePlanOutput->setHtml(withDisclaimer);
|
2014-06-03 08:06:18 +00:00
|
|
|
ui.divePlanOutput->print(&printer);
|
2014-06-04 21:34:09 +00:00
|
|
|
ui.divePlanOutput->setHtml(diveplan);
|
2014-06-23 13:43:51 +00:00
|
|
|
#endif
|
2014-06-03 08:06:18 +00:00
|
|
|
}
|
|
|
|
|
2014-07-04 14:14:16 +00:00
|
|
|
void MainWindow::setupForAddAndPlan(const char *model)
|
|
|
|
{
|
|
|
|
// clean out the dive and give it an id and the correct dc model
|
|
|
|
clear_dive(&displayed_dive);
|
|
|
|
displayed_dive.id = dive_getUniqID(&displayed_dive);
|
|
|
|
displayed_dive.when = QDateTime::currentMSecsSinceEpoch() / 1000L + gettimezoneoffset() + 3600;
|
|
|
|
displayed_dive.dc.model = model; // don't translate! this is stored in the XML file
|
|
|
|
// setup the dive cylinders
|
|
|
|
DivePlannerPointsModel::instance()->clear();
|
|
|
|
DivePlannerPointsModel::instance()->setupCylinders();
|
|
|
|
}
|
|
|
|
|
2014-08-19 20:03:53 +00:00
|
|
|
void MainWindow::on_actionReplanDive_triggered()
|
|
|
|
{
|
|
|
|
if (!plannerStateClean())
|
|
|
|
return;
|
2014-10-25 08:33:31 +00:00
|
|
|
if (!current_dive || !current_dive->dc.model || strcmp(current_dive->dc.model, "planned dive")) {
|
2014-10-27 19:35:19 +00:00
|
|
|
qDebug() << "trying to replan a dive that's not a planned dive:" << current_dive->dc.model;
|
2014-08-19 20:03:53 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// put us in PLAN mode
|
2014-08-19 20:49:18 +00:00
|
|
|
DivePlannerPointsModel::instance()->clear();
|
2014-08-19 20:03:53 +00:00
|
|
|
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
|
|
|
|
|
|
|
|
ui.newProfile->setPlanState();
|
2014-08-20 02:54:18 +00:00
|
|
|
ui.newProfile->clearHandlers();
|
2014-08-19 20:03:53 +00:00
|
|
|
ui.infoPane->setCurrentIndex(PLANNERWIDGET);
|
2014-11-04 11:15:27 +00:00
|
|
|
ui.divePlannerWidget->setReplanButton(true);
|
2014-08-19 20:03:53 +00:00
|
|
|
DivePlannerPointsModel::instance()->loadFromDive(current_dive);
|
|
|
|
reset_cylinders(&displayed_dive, true);
|
|
|
|
ui.diveListPane->setCurrentIndex(1); // switch to the plan output
|
|
|
|
ui.globePane->setCurrentIndex(1);
|
|
|
|
#ifdef NO_MARBLE
|
|
|
|
ui.globePane->show();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-05-25 18:19:36 +00:00
|
|
|
void MainWindow::on_actionDivePlanner_triggered()
|
|
|
|
{
|
2014-08-19 20:03:53 +00:00
|
|
|
if (!plannerStateClean())
|
2014-05-25 18:19:36 +00:00
|
|
|
return;
|
|
|
|
|
2014-05-27 18:32:18 +00:00
|
|
|
// put us in PLAN mode
|
2014-05-26 20:43:52 +00:00
|
|
|
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
|
2014-07-04 13:53:33 +00:00
|
|
|
|
2014-05-25 18:15:57 +00:00
|
|
|
ui.newProfile->setPlanState();
|
|
|
|
ui.infoPane->setCurrentIndex(PLANNERWIDGET);
|
2014-05-27 18:32:18 +00:00
|
|
|
|
|
|
|
// create a simple starting dive, using the first gas from the just copied cylidners
|
2014-07-04 14:14:16 +00:00
|
|
|
setupForAddAndPlan("planned dive"); // don't translate, stored in XML file
|
2014-06-28 15:07:28 +00:00
|
|
|
DivePlannerPointsModel::instance()->setupStartTime();
|
2014-05-27 18:28:42 +00:00
|
|
|
DivePlannerPointsModel::instance()->createSimpleDive();
|
2014-08-02 20:05:52 +00:00
|
|
|
DivePictureModel::instance()->updateDivePictures();
|
2014-11-04 11:15:27 +00:00
|
|
|
ui.divePlannerWidget->setReplanButton(false);
|
2014-05-27 22:10:22 +00:00
|
|
|
|
2014-06-01 03:59:36 +00:00
|
|
|
ui.diveListPane->setCurrentIndex(1); // switch to the plan output
|
2014-06-10 15:40:02 +00:00
|
|
|
ui.globePane->setCurrentIndex(1);
|
2014-06-17 18:01:14 +00:00
|
|
|
#ifdef NO_MARBLE
|
|
|
|
ui.globePane->show();
|
|
|
|
#endif
|
2014-05-25 18:15:57 +00:00
|
|
|
}
|
|
|
|
|
2013-04-09 16:26:23 +00:00
|
|
|
void MainWindow::on_actionAddDive_triggered()
|
|
|
|
{
|
2014-09-17 22:39:49 +00:00
|
|
|
if (!plannerStateClean())
|
2013-11-09 00:09:46 +00:00
|
|
|
return;
|
2014-05-25 18:19:36 +00:00
|
|
|
|
2014-09-17 22:39:49 +00:00
|
|
|
if (dive_list()->selectedTrips().count() >= 1) {
|
2014-07-16 22:44:06 +00:00
|
|
|
dive_list()->rememberSelection();
|
|
|
|
dive_list()->clearSelection();
|
|
|
|
}
|
|
|
|
|
2013-11-09 00:09:46 +00:00
|
|
|
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
|
2013-11-12 07:33:27 +00:00
|
|
|
|
2014-07-04 14:14:16 +00:00
|
|
|
// setup things so we can later create our starting dive
|
|
|
|
setupForAddAndPlan("manually added dive"); // don't translate, stored in the XML file
|
2014-07-03 21:45:01 +00:00
|
|
|
|
|
|
|
// now show the mostly empty main tab
|
|
|
|
ui.InfoWidget->updateDiveInfo();
|
2013-12-03 23:25:20 +00:00
|
|
|
|
2014-07-03 21:45:01 +00:00
|
|
|
// show main tab
|
2013-11-14 03:18:33 +00:00
|
|
|
ui.InfoWidget->setCurrentIndex(0);
|
2014-07-03 21:45:01 +00:00
|
|
|
|
2013-11-12 07:33:27 +00:00
|
|
|
ui.InfoWidget->addDiveStarted();
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.infoPane->setCurrentIndex(MAINTAB);
|
2014-05-22 02:31:26 +00:00
|
|
|
|
|
|
|
ui.newProfile->setAddState();
|
2013-09-20 12:36:14 +00:00
|
|
|
DivePlannerPointsModel::instance()->createSimpleDive();
|
2014-07-03 21:45:01 +00:00
|
|
|
ui.newProfile->plotDive();
|
2013-04-09 16:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionRenumber_triggered()
|
|
|
|
{
|
2014-05-19 21:11:32 +00:00
|
|
|
RenumberDialog::instance()->renumberOnlySelected(false);
|
2013-06-17 16:41:00 +00:00
|
|
|
RenumberDialog::instance()->show();
|
2013-04-09 16:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionAutoGroup_triggered()
|
|
|
|
{
|
2013-10-17 23:30:32 +00:00
|
|
|
autogroup = ui.actionAutoGroup->isChecked();
|
|
|
|
if (autogroup)
|
|
|
|
autogroup_dives();
|
|
|
|
else
|
|
|
|
remove_autogen_trips();
|
|
|
|
refreshDisplay();
|
|
|
|
mark_divelist_changed(true);
|
2013-04-09 16:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionYearlyStatistics_triggered()
|
|
|
|
{
|
2014-08-25 18:46:08 +00:00
|
|
|
QDialog d;
|
|
|
|
QVBoxLayout *l = new QVBoxLayout(&d);
|
2014-08-25 18:48:26 +00:00
|
|
|
YearlyStatisticsModel *m = new YearlyStatisticsModel();
|
|
|
|
QTreeView *view = new QTreeView();
|
|
|
|
view->setModel(m);
|
|
|
|
l->addWidget(view);
|
2014-11-17 18:19:51 +00:00
|
|
|
d.resize(width() * .8, height() / 2);
|
2014-11-20 15:34:49 +00:00
|
|
|
d.move(width() * .1, height() / 4);
|
2014-11-17 18:19:51 +00:00
|
|
|
QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), &d);
|
|
|
|
connect(close, SIGNAL(activated()), &d, SLOT(close()));
|
|
|
|
QShortcut *quit = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), &d);
|
|
|
|
connect(quit, SIGNAL(activated()), this, SLOT(close()));
|
2014-11-20 15:34:49 +00:00
|
|
|
d.setWindowFlags(Qt::Window | Qt::CustomizeWindowHint
|
|
|
|
| Qt::WindowCloseButtonHint | Qt::WindowTitleHint);
|
2014-11-25 15:47:24 +00:00
|
|
|
d.setWindowTitle(tr("Yearly statistics"));
|
2014-08-25 18:46:08 +00:00
|
|
|
d.exec();
|
2013-04-09 16:26:23 +00:00
|
|
|
}
|
|
|
|
|
2013-06-12 18:54:55 +00:00
|
|
|
#define BEHAVIOR QList<int>()
|
2014-10-31 16:00:52 +00:00
|
|
|
|
|
|
|
#define TOGGLE_COLLAPSABLE( X ) \
|
|
|
|
ui.mainSplitter->setCollapsible(0, X); \
|
|
|
|
ui.mainSplitter->setCollapsible(1, X); \
|
|
|
|
ui.infoProfileSplitter->setCollapsible(0, X); \
|
|
|
|
ui.infoProfileSplitter->setCollapsible(1, X); \
|
|
|
|
ui.listGlobeSplitter->setCollapsible(0, X); \
|
|
|
|
ui.listGlobeSplitter->setCollapsible(1, X);
|
|
|
|
|
2013-04-09 16:26:23 +00:00
|
|
|
void MainWindow::on_actionViewList_triggered()
|
|
|
|
{
|
2014-10-31 16:00:52 +00:00
|
|
|
TOGGLE_COLLAPSABLE( true );
|
2013-11-07 16:37:27 +00:00
|
|
|
beginChangeState(LIST_MAXIMIZED);
|
2014-01-16 04:50:56 +00:00
|
|
|
ui.listGlobeSplitter->setSizes(BEHAVIOR << EXPANDED << COLLAPSED);
|
|
|
|
ui.mainSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED);
|
2013-04-09 16:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionViewProfile_triggered()
|
|
|
|
{
|
2014-10-31 16:00:52 +00:00
|
|
|
TOGGLE_COLLAPSABLE( true );
|
2013-11-07 16:37:27 +00:00
|
|
|
beginChangeState(PROFILE_MAXIMIZED);
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.infoProfileSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED);
|
2014-01-16 04:50:56 +00:00
|
|
|
ui.mainSplitter->setSizes(BEHAVIOR << EXPANDED << COLLAPSED);
|
2013-04-09 16:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionViewInfo_triggered()
|
|
|
|
{
|
2014-10-31 16:00:52 +00:00
|
|
|
TOGGLE_COLLAPSABLE( true );
|
2013-11-07 16:37:27 +00:00
|
|
|
beginChangeState(INFO_MAXIMIZED);
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.infoProfileSplitter->setSizes(BEHAVIOR << EXPANDED << COLLAPSED);
|
2014-01-16 04:50:56 +00:00
|
|
|
ui.mainSplitter->setSizes(BEHAVIOR << EXPANDED << COLLAPSED);
|
2013-06-12 18:53:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionViewGlobe_triggered()
|
|
|
|
{
|
2014-10-31 16:00:52 +00:00
|
|
|
TOGGLE_COLLAPSABLE( true );
|
2013-11-07 16:37:27 +00:00
|
|
|
beginChangeState(GLOBE_MAXIMIZED);
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.mainSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED);
|
|
|
|
ui.listGlobeSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED);
|
2013-04-09 16:26:23 +00:00
|
|
|
}
|
2013-06-12 18:54:55 +00:00
|
|
|
#undef BEHAVIOR
|
2013-04-09 16:26:23 +00:00
|
|
|
|
|
|
|
void MainWindow::on_actionViewAll_triggered()
|
|
|
|
{
|
2014-10-31 16:00:52 +00:00
|
|
|
TOGGLE_COLLAPSABLE( false );
|
2013-11-07 16:37:27 +00:00
|
|
|
beginChangeState(VIEWALL);
|
2013-11-22 01:52:21 +00:00
|
|
|
static QList<int> mainSizes;
|
|
|
|
const int appH = qApp->desktop()->size().height();
|
|
|
|
const int appW = qApp->desktop()->size().width();
|
2014-01-16 04:50:56 +00:00
|
|
|
if (mainSizes.empty()) {
|
|
|
|
mainSizes.append(appH * 0.7);
|
|
|
|
mainSizes.append(appH * 0.3);
|
2013-11-22 01:52:21 +00:00
|
|
|
}
|
|
|
|
static QList<int> infoProfileSizes;
|
2014-01-16 04:50:56 +00:00
|
|
|
if (infoProfileSizes.empty()) {
|
|
|
|
infoProfileSizes.append(appW * 0.3);
|
|
|
|
infoProfileSizes.append(appW * 0.7);
|
2013-11-22 01:52:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static QList<int> listGlobeSizes;
|
2014-01-16 04:50:56 +00:00
|
|
|
if (listGlobeSizes.empty()) {
|
|
|
|
listGlobeSizes.append(appW * 0.7);
|
|
|
|
listGlobeSizes.append(appW * 0.3);
|
2013-11-22 01:52:21 +00:00
|
|
|
}
|
|
|
|
|
2013-11-07 16:37:27 +00:00
|
|
|
QSettings settings;
|
|
|
|
settings.beginGroup("MainWindow");
|
2014-01-16 04:50:56 +00:00
|
|
|
if (settings.value("mainSplitter").isValid()) {
|
2013-11-07 16:37:27 +00:00
|
|
|
ui.mainSplitter->restoreState(settings.value("mainSplitter").toByteArray());
|
|
|
|
ui.infoProfileSplitter->restoreState(settings.value("infoProfileSplitter").toByteArray());
|
|
|
|
ui.listGlobeSplitter->restoreState(settings.value("listGlobeSplitter").toByteArray());
|
2014-01-16 04:50:56 +00:00
|
|
|
if (ui.mainSplitter->sizes().first() == 0 || ui.mainSplitter->sizes().last() == 0)
|
2013-11-22 01:52:21 +00:00
|
|
|
ui.mainSplitter->setSizes(mainSizes);
|
2014-01-16 04:50:56 +00:00
|
|
|
if (ui.infoProfileSplitter->sizes().first() == 0 || ui.infoProfileSplitter->sizes().last() == 0)
|
2013-11-22 01:52:21 +00:00
|
|
|
ui.infoProfileSplitter->setSizes(infoProfileSizes);
|
2014-01-16 04:50:56 +00:00
|
|
|
if (ui.listGlobeSplitter->sizes().first() == 0 || ui.listGlobeSplitter->sizes().last() == 0)
|
2013-11-22 01:52:21 +00:00
|
|
|
ui.listGlobeSplitter->setSizes(listGlobeSizes);
|
|
|
|
|
2013-11-07 16:37:27 +00:00
|
|
|
} else {
|
2014-01-16 04:50:56 +00:00
|
|
|
ui.mainSplitter->setSizes(mainSizes);
|
2013-11-07 16:37:27 +00:00
|
|
|
ui.infoProfileSplitter->setSizes(infoProfileSizes);
|
|
|
|
ui.listGlobeSplitter->setSizes(listGlobeSizes);
|
|
|
|
}
|
2014-10-31 16:00:52 +00:00
|
|
|
ui.mainSplitter->setCollapsible(0, false);
|
|
|
|
ui.mainSplitter->setCollapsible(1, false);
|
|
|
|
ui.infoProfileSplitter->setCollapsible(0, false);
|
|
|
|
ui.infoProfileSplitter->setCollapsible(1, false);
|
|
|
|
ui.listGlobeSplitter->setCollapsible(0,false);
|
|
|
|
ui.listGlobeSplitter->setCollapsible(1,false);
|
2013-04-09 16:26:23 +00:00
|
|
|
}
|
|
|
|
|
2014-10-31 16:00:52 +00:00
|
|
|
#undef TOGGLE_COLLAPSABLE
|
|
|
|
|
2014-02-14 06:11:05 +00:00
|
|
|
void MainWindow::beginChangeState(CurrentState s)
|
|
|
|
{
|
2014-01-16 04:50:56 +00:00
|
|
|
if (state == VIEWALL && state != s) {
|
2013-11-07 16:37:27 +00:00
|
|
|
saveSplitterSizes();
|
|
|
|
}
|
|
|
|
state = s;
|
|
|
|
}
|
|
|
|
|
2014-02-14 06:11:05 +00:00
|
|
|
void MainWindow::saveSplitterSizes()
|
|
|
|
{
|
2013-11-07 16:37:27 +00:00
|
|
|
QSettings settings;
|
|
|
|
settings.beginGroup("MainWindow");
|
|
|
|
settings.setValue("mainSplitter", ui.mainSplitter->saveState());
|
|
|
|
settings.setValue("infoProfileSplitter", ui.infoProfileSplitter->saveState());
|
|
|
|
settings.setValue("listGlobeSplitter", ui.listGlobeSplitter->saveState());
|
|
|
|
}
|
|
|
|
|
2013-04-09 16:26:23 +00:00
|
|
|
void MainWindow::on_actionPreviousDC_triggered()
|
|
|
|
{
|
2014-03-17 15:19:09 +00:00
|
|
|
unsigned nrdc = number_of_computers(current_dive);
|
|
|
|
dc_number = (dc_number + nrdc - 1) % nrdc;
|
2014-07-03 03:00:57 +00:00
|
|
|
ui.newProfile->plotDive();
|
2014-07-02 19:58:41 +00:00
|
|
|
ui.InfoWidget->updateDiveInfo();
|
2013-04-09 16:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionNextDC_triggered()
|
|
|
|
{
|
2014-03-17 15:19:09 +00:00
|
|
|
unsigned nrdc = number_of_computers(current_dive);
|
|
|
|
dc_number = (dc_number + 1) % nrdc;
|
2014-07-03 03:00:57 +00:00
|
|
|
ui.newProfile->plotDive();
|
2014-07-02 19:58:41 +00:00
|
|
|
ui.InfoWidget->updateDiveInfo();
|
2013-04-09 16:26:23 +00:00
|
|
|
}
|
|
|
|
|
2014-01-14 17:36:07 +00:00
|
|
|
void MainWindow::on_actionFullScreen_triggered(bool checked)
|
|
|
|
{
|
|
|
|
if (checked) {
|
|
|
|
setWindowState(windowState() | Qt::WindowFullScreen);
|
2014-01-16 04:50:56 +00:00
|
|
|
} else {
|
2014-01-14 17:36:07 +00:00
|
|
|
setWindowState(windowState() & ~Qt::WindowFullScreen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-09 16:26:23 +00:00
|
|
|
void MainWindow::on_actionAboutSubsurface_triggered()
|
|
|
|
{
|
2014-02-08 07:50:39 +00:00
|
|
|
SubsurfaceAbout dlg(this);
|
|
|
|
|
|
|
|
dlg.exec();
|
2013-04-09 16:26:23 +00:00
|
|
|
}
|
|
|
|
|
2014-04-02 19:41:39 +00:00
|
|
|
void MainWindow::on_action_Check_for_Updates_triggered()
|
|
|
|
{
|
2014-04-02 19:56:14 +00:00
|
|
|
if (!updateManager)
|
|
|
|
updateManager = new UpdateManager(this);
|
|
|
|
|
2014-04-02 19:41:39 +00:00
|
|
|
updateManager->checkForUpdates();
|
|
|
|
}
|
|
|
|
|
2013-04-09 16:26:23 +00:00
|
|
|
void MainWindow::on_actionUserManual_triggered()
|
|
|
|
{
|
2014-03-26 22:35:24 +00:00
|
|
|
#ifndef NO_USERMANUAL
|
2014-01-16 04:50:56 +00:00
|
|
|
if (!helpView) {
|
2014-06-30 20:45:52 +00:00
|
|
|
helpView = new UserManual();
|
2013-05-30 21:26:08 +00:00
|
|
|
}
|
2013-05-30 13:54:06 +00:00
|
|
|
helpView->show();
|
2014-03-26 22:35:24 +00:00
|
|
|
#endif
|
2013-04-09 16:26:23 +00:00
|
|
|
}
|
2013-04-13 13:17:59 +00:00
|
|
|
|
2014-12-17 03:59:41 +00:00
|
|
|
void MainWindow::on_actionUserSurvey_triggered()
|
|
|
|
{
|
|
|
|
#ifndef NO_USERSURVEY
|
|
|
|
if(!survey) {
|
|
|
|
survey = new UserSurvey();
|
|
|
|
}
|
|
|
|
survey->show();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-04-13 13:17:59 +00:00
|
|
|
QString MainWindow::filter()
|
|
|
|
{
|
|
|
|
QString f;
|
2014-11-07 17:56:23 +00:00
|
|
|
f += "Dive log files ( *.ssrf ";
|
|
|
|
f += "*.can *.CAN ";
|
|
|
|
f += "*.db *.DB " ;
|
|
|
|
f += "*.dld *.DLD ";
|
|
|
|
f += "*.jlb *.JLB ";
|
|
|
|
f += "*.lvd *.LVD ";
|
|
|
|
f += "*.sde *.SDE ";
|
|
|
|
f += "*.udcf *.UDCF ";
|
|
|
|
f += "*.uddf *.UDDF ";
|
|
|
|
f += "*.xml *.XML ";
|
2013-04-13 13:17:59 +00:00
|
|
|
f += ");;";
|
|
|
|
|
2013-10-02 06:34:12 +00:00
|
|
|
f += "Subsurface (*.ssrf);;";
|
2014-11-07 17:56:23 +00:00
|
|
|
f += "Cochran (*.can *.CAN);;";
|
|
|
|
f += "DiveLogs.de (*.dld *.DLD);;";
|
|
|
|
f += "JDiveLog (*.jlb *.JLB);;";
|
2014-11-09 18:03:05 +00:00
|
|
|
f += "Liquivision (*.lvd *.LVD);;";
|
2014-11-07 17:56:23 +00:00
|
|
|
f += "Suunto (*.sde *.SDE *.db *.DB);;";
|
2013-04-13 13:17:59 +00:00
|
|
|
f += "UDCF (*.udcf *.UDCF);;";
|
2014-11-07 17:56:23 +00:00
|
|
|
f += "UDDF (*.uddf *.UDDF);;";
|
|
|
|
f += "XML (*.xml *.XML)";
|
2013-04-13 13:17:59 +00:00
|
|
|
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MainWindow::askSaveChanges()
|
|
|
|
{
|
2013-05-19 21:46:53 +00:00
|
|
|
QString message;
|
2014-07-16 22:23:02 +00:00
|
|
|
QMessageBox response(this);
|
2013-04-13 13:17:59 +00:00
|
|
|
|
2013-05-19 21:46:53 +00:00
|
|
|
if (existing_filename)
|
2014-07-10 23:06:48 +00:00
|
|
|
message = tr("Do you want to save the changes that you made in the file %1?").arg(existing_filename);
|
2013-05-19 21:46:53 +00:00
|
|
|
else
|
2014-07-11 08:21:38 +00:00
|
|
|
message = tr("Do you want to save the changes that you made in the data file?");
|
2013-05-24 07:28:48 +00:00
|
|
|
|
|
|
|
response.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
|
|
|
|
response.setDefaultButton(QMessageBox::Save);
|
|
|
|
response.setText(message);
|
2014-07-10 23:06:48 +00:00
|
|
|
response.setWindowTitle(tr("Save changes?")); // Not displayed on MacOSX as described in Qt API
|
2013-05-24 07:28:48 +00:00
|
|
|
response.setInformativeText(tr("Changes will be lost if you don't save them."));
|
|
|
|
response.setIcon(QMessageBox::Warning);
|
2014-03-14 23:00:18 +00:00
|
|
|
response.setWindowModality(Qt::WindowModal);
|
2013-05-24 07:28:48 +00:00
|
|
|
int ret = response.exec();
|
|
|
|
|
|
|
|
switch (ret) {
|
|
|
|
case QMessageBox::Save:
|
2013-05-19 22:25:47 +00:00
|
|
|
file_save();
|
2013-04-13 13:17:59 +00:00
|
|
|
return true;
|
2013-05-24 07:28:48 +00:00
|
|
|
case QMessageBox::Discard:
|
2013-05-19 21:46:53 +00:00
|
|
|
return true;
|
2013-04-13 13:17:59 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2013-04-27 09:09:57 +00:00
|
|
|
|
2013-06-04 12:40:09 +00:00
|
|
|
void MainWindow::initialUiSetup()
|
2013-04-27 09:09:57 +00:00
|
|
|
{
|
2013-05-22 02:07:19 +00:00
|
|
|
QSettings settings;
|
2013-04-28 09:05:37 +00:00
|
|
|
settings.beginGroup("MainWindow");
|
2013-10-04 15:28:40 +00:00
|
|
|
QSize sz = settings.value("size", qApp->desktop()->size()).value<QSize>();
|
2013-12-02 10:32:27 +00:00
|
|
|
if (settings.value("maximized", isMaximized()).value<bool>())
|
|
|
|
showMaximized();
|
|
|
|
else
|
|
|
|
resize(sz);
|
2013-10-04 18:07:36 +00:00
|
|
|
|
2014-02-14 06:11:05 +00:00
|
|
|
state = (CurrentState)settings.value("lastState", 0).toInt();
|
2014-01-16 04:50:56 +00:00
|
|
|
switch (state) {
|
2014-02-14 06:11:05 +00:00
|
|
|
case VIEWALL:
|
|
|
|
on_actionViewAll_triggered();
|
|
|
|
break;
|
|
|
|
case GLOBE_MAXIMIZED:
|
|
|
|
on_actionViewGlobe_triggered();
|
|
|
|
break;
|
|
|
|
case INFO_MAXIMIZED:
|
|
|
|
on_actionViewInfo_triggered();
|
|
|
|
break;
|
|
|
|
case LIST_MAXIMIZED:
|
|
|
|
on_actionViewList_triggered();
|
|
|
|
break;
|
|
|
|
case PROFILE_MAXIMIZED:
|
|
|
|
on_actionViewProfile_triggered();
|
|
|
|
break;
|
2013-10-04 18:07:36 +00:00
|
|
|
}
|
2013-11-08 21:59:21 +00:00
|
|
|
settings.endGroup();
|
2013-06-04 12:40:09 +00:00
|
|
|
}
|
|
|
|
|
2014-06-12 18:52:59 +00:00
|
|
|
const char *getSetting(QSettings &s, QString name)
|
|
|
|
{
|
|
|
|
QVariant v;
|
|
|
|
v = s.value(name);
|
|
|
|
if (v.isValid()) {
|
|
|
|
return strdup(v.toString().toUtf8().data());
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-03-02 21:37:29 +00:00
|
|
|
#define TOOLBOX_PREF_BUTTON(pref, setting, button) \
|
2014-03-03 21:25:55 +00:00
|
|
|
prefs.pref = s.value(#setting).toBool(); \
|
2014-03-02 21:37:29 +00:00
|
|
|
ui.button->setChecked(prefs.pref);
|
|
|
|
|
2013-06-04 12:40:09 +00:00
|
|
|
void MainWindow::readSettings()
|
|
|
|
{
|
2014-06-30 21:42:48 +00:00
|
|
|
static bool firstRun = true;
|
2013-06-04 12:40:09 +00:00
|
|
|
QSettings s;
|
2014-08-27 13:39:57 +00:00
|
|
|
// the static object for preferences already reads in the settings
|
|
|
|
// and sets up the font, so just get what we need for the toolbox and other widgets here
|
2014-02-06 16:59:06 +00:00
|
|
|
|
|
|
|
s.beginGroup("TecDetails");
|
2014-04-16 20:03:44 +00:00
|
|
|
TOOLBOX_PREF_BUTTON(calcalltissues, calcalltissues, profCalcAllTissues);
|
|
|
|
TOOLBOX_PREF_BUTTON(calcceiling, calcceiling, profCalcCeiling);
|
|
|
|
TOOLBOX_PREF_BUTTON(dcceiling, dcceiling, profDcCeiling);
|
2014-03-02 21:37:29 +00:00
|
|
|
TOOLBOX_PREF_BUTTON(ead, ead, profEad);
|
2014-04-16 20:03:44 +00:00
|
|
|
TOOLBOX_PREF_BUTTON(calcceiling3m, calcceiling3m, profIncrement3m);
|
2014-03-02 21:37:29 +00:00
|
|
|
TOOLBOX_PREF_BUTTON(mod, mod, profMod);
|
2014-04-16 20:03:44 +00:00
|
|
|
TOOLBOX_PREF_BUTTON(calcndltts, calcndltts, profNdl_tts);
|
2014-03-02 21:37:29 +00:00
|
|
|
TOOLBOX_PREF_BUTTON(pp_graphs.phe, phegraph, profPhe);
|
|
|
|
TOOLBOX_PREF_BUTTON(pp_graphs.pn2, pn2graph, profPn2);
|
|
|
|
TOOLBOX_PREF_BUTTON(pp_graphs.po2, po2graph, profPO2);
|
2014-04-16 20:03:44 +00:00
|
|
|
TOOLBOX_PREF_BUTTON(hrgraph, hrgraph, profHR);
|
2014-05-05 22:53:46 +00:00
|
|
|
TOOLBOX_PREF_BUTTON(rulergraph, rulergraph, profRuler);
|
2014-03-02 21:37:29 +00:00
|
|
|
TOOLBOX_PREF_BUTTON(show_sac, show_sac, profSAC);
|
2014-07-11 00:33:06 +00:00
|
|
|
TOOLBOX_PREF_BUTTON(show_pictures_in_profile, show_pictures_in_profile, profTogglePicture);
|
2014-08-15 14:11:14 +00:00
|
|
|
TOOLBOX_PREF_BUTTON(tankbar, tankbar, profTankbar);
|
2014-09-20 20:56:56 +00:00
|
|
|
TOOLBOX_PREF_BUTTON(percentagegraph, percentagegraph, profTissues);
|
2014-06-12 18:52:59 +00:00
|
|
|
s.endGroup();
|
|
|
|
s.beginGroup("DiveComputer");
|
|
|
|
default_dive_computer_vendor = getSetting(s, "dive_computer_vendor");
|
|
|
|
default_dive_computer_product = getSetting(s, "dive_computer_product");
|
|
|
|
default_dive_computer_device = getSetting(s, "dive_computer_device");
|
|
|
|
s.endGroup();
|
2014-06-26 16:20:34 +00:00
|
|
|
QNetworkProxy proxy;
|
|
|
|
proxy.setType(QNetworkProxy::ProxyType(prefs.proxy_type));
|
|
|
|
proxy.setHostName(prefs.proxy_host);
|
|
|
|
proxy.setPort(prefs.proxy_port);
|
|
|
|
if (prefs.proxy_auth) {
|
|
|
|
proxy.setUser(prefs.proxy_user);
|
|
|
|
proxy.setPassword(prefs.proxy_pass);
|
|
|
|
}
|
|
|
|
QNetworkProxy::setApplicationProxy(proxy);
|
|
|
|
|
2014-06-12 18:52:59 +00:00
|
|
|
loadRecentFiles(&s);
|
2014-06-30 21:42:48 +00:00
|
|
|
if (firstRun) {
|
|
|
|
checkSurvey(&s);
|
|
|
|
firstRun = false;
|
|
|
|
}
|
2013-04-27 09:09:57 +00:00
|
|
|
}
|
|
|
|
|
2014-03-02 21:37:29 +00:00
|
|
|
#undef TOOLBOX_PREF_BUTTON
|
|
|
|
|
2014-06-13 17:56:46 +00:00
|
|
|
void MainWindow::checkSurvey(QSettings *s)
|
|
|
|
{
|
|
|
|
s->beginGroup("UserSurvey");
|
|
|
|
if (!s->contains("FirstUse42")) {
|
|
|
|
QVariant value = QDate().currentDate();
|
|
|
|
s->setValue("FirstUse42", value);
|
2014-06-14 21:45:42 +00:00
|
|
|
}
|
|
|
|
// wait a week for production versions, but not at all for non-tagged builds
|
|
|
|
QString ver(VERSION_STRING);
|
|
|
|
int waitTime = ver.contains('-') ? -1 : 7;
|
|
|
|
QDate firstUse42 = s->value("FirstUse42").toDate();
|
|
|
|
if (run_survey || (firstUse42.daysTo(QDate().currentDate()) > waitTime && !s->contains("SurveyDone"))) {
|
|
|
|
if (!survey)
|
|
|
|
survey = new UserSurvey(this);
|
|
|
|
survey->show();
|
2014-06-13 17:56:46 +00:00
|
|
|
}
|
|
|
|
s->endGroup();
|
|
|
|
}
|
|
|
|
|
2013-04-27 09:09:57 +00:00
|
|
|
void MainWindow::writeSettings()
|
|
|
|
{
|
2013-05-22 02:07:19 +00:00
|
|
|
QSettings settings;
|
2013-05-03 05:06:01 +00:00
|
|
|
|
2013-04-27 09:09:57 +00:00
|
|
|
settings.beginGroup("MainWindow");
|
2014-02-14 06:11:05 +00:00
|
|
|
settings.setValue("lastState", (int)state);
|
2013-12-02 10:32:27 +00:00
|
|
|
settings.setValue("maximized", isMaximized());
|
|
|
|
if (!isMaximized())
|
|
|
|
settings.setValue("size", size());
|
2014-01-16 04:50:56 +00:00
|
|
|
if (state == VIEWALL)
|
2013-11-07 16:37:27 +00:00
|
|
|
saveSplitterSizes();
|
2013-04-27 09:09:57 +00:00
|
|
|
settings.endGroup();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::closeEvent(QCloseEvent *event)
|
|
|
|
{
|
2014-01-16 04:50:56 +00:00
|
|
|
if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING ||
|
|
|
|
ui.InfoWidget->isEditing()) {
|
2014-06-04 01:22:22 +00:00
|
|
|
on_actionQuit_triggered();
|
2013-12-17 00:37:44 +00:00
|
|
|
event->ignore();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-24 21:43:43 +00:00
|
|
|
#ifndef NO_USERMANUAL
|
2014-01-16 04:50:56 +00:00
|
|
|
if (helpView && helpView->isVisible()) {
|
2013-05-30 13:54:06 +00:00
|
|
|
helpView->close();
|
|
|
|
helpView->deleteLater();
|
|
|
|
}
|
2014-08-24 21:43:43 +00:00
|
|
|
#endif
|
2013-05-30 21:26:08 +00:00
|
|
|
|
2014-12-17 03:59:41 +00:00
|
|
|
|
|
|
|
#ifndef NO_USERSURVEY
|
|
|
|
if (survey && survey->isVisible()) {
|
|
|
|
survey->close();
|
|
|
|
survey->deleteLater();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2014-01-15 08:30:42 +00:00
|
|
|
if (unsaved_changes() && (askSaveChanges() == false)) {
|
2013-04-27 09:09:57 +00:00
|
|
|
event->ignore();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
event->accept();
|
|
|
|
writeSettings();
|
2014-03-11 16:31:01 +00:00
|
|
|
QApplication::closeAllWindows();
|
2013-04-28 03:47:47 +00:00
|
|
|
}
|
2013-05-19 03:09:36 +00:00
|
|
|
|
2014-02-14 06:11:05 +00:00
|
|
|
DiveListView *MainWindow::dive_list()
|
2013-05-19 03:09:36 +00:00
|
|
|
{
|
2013-10-03 18:54:25 +00:00
|
|
|
return ui.ListWidget;
|
2013-05-19 03:09:36 +00:00
|
|
|
}
|
|
|
|
|
2014-02-14 06:11:05 +00:00
|
|
|
GlobeGPS *MainWindow::globe()
|
2013-05-19 03:09:36 +00:00
|
|
|
{
|
2013-10-03 18:54:25 +00:00
|
|
|
return ui.globe;
|
2013-05-19 03:09:36 +00:00
|
|
|
}
|
|
|
|
|
2014-02-14 06:11:05 +00:00
|
|
|
MainTab *MainWindow::information()
|
2013-05-19 03:09:36 +00:00
|
|
|
{
|
2013-10-03 18:54:25 +00:00
|
|
|
return ui.InfoWidget;
|
2013-05-19 03:09:36 +00:00
|
|
|
}
|
2013-05-19 22:25:47 +00:00
|
|
|
|
2014-02-13 21:48:07 +00:00
|
|
|
void MainWindow::loadRecentFiles(QSettings *s)
|
|
|
|
{
|
|
|
|
QStringList files;
|
|
|
|
bool modified = false;
|
|
|
|
|
|
|
|
s->beginGroup("Recent_Files");
|
2014-02-14 06:11:05 +00:00
|
|
|
for (int c = 1; c <= 4; c++) {
|
2014-02-13 21:48:07 +00:00
|
|
|
QString key = QString("File_%1").arg(c);
|
2014-02-14 06:11:05 +00:00
|
|
|
if (s->contains(key)) {
|
2014-02-13 21:48:07 +00:00
|
|
|
QString file = s->value(key).toString();
|
|
|
|
|
2014-02-14 06:11:05 +00:00
|
|
|
if (QFile::exists(file)) {
|
2014-02-13 21:48:07 +00:00
|
|
|
files.append(file);
|
2014-02-14 06:11:05 +00:00
|
|
|
} else {
|
2014-02-13 21:48:07 +00:00
|
|
|
modified = true;
|
|
|
|
}
|
2014-02-14 06:11:05 +00:00
|
|
|
} else {
|
2014-02-13 21:48:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-14 06:11:05 +00:00
|
|
|
if (modified) {
|
|
|
|
for (int c = 0; c < 4; c++) {
|
2014-02-13 21:48:07 +00:00
|
|
|
QString key = QString("File_%1").arg(c + 1);
|
|
|
|
|
2014-02-14 06:11:05 +00:00
|
|
|
if (files.count() > c) {
|
2014-02-13 21:48:07 +00:00
|
|
|
s->setValue(key, files.at(c));
|
2014-02-14 06:11:05 +00:00
|
|
|
} else {
|
|
|
|
if (s->contains(key)) {
|
2014-02-13 21:48:07 +00:00
|
|
|
s->remove(key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
s->sync();
|
|
|
|
}
|
|
|
|
s->endGroup();
|
|
|
|
|
2014-02-14 06:11:05 +00:00
|
|
|
for (int c = 0; c < 4; c++) {
|
2014-02-13 21:48:07 +00:00
|
|
|
QAction *action = this->findChild<QAction *>(QString("actionRecent%1").arg(c + 1));
|
|
|
|
|
2014-02-14 06:11:05 +00:00
|
|
|
if (files.count() > c) {
|
2014-02-13 21:48:07 +00:00
|
|
|
QFileInfo fi(files.at(c));
|
|
|
|
action->setText(fi.fileName());
|
|
|
|
action->setToolTip(fi.absoluteFilePath());
|
|
|
|
action->setVisible(true);
|
2014-02-14 06:11:05 +00:00
|
|
|
} else {
|
2014-02-13 21:48:07 +00:00
|
|
|
action->setVisible(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::addRecentFile(const QStringList &newFiles)
|
|
|
|
{
|
|
|
|
QStringList files;
|
|
|
|
QSettings s;
|
|
|
|
|
2014-02-28 09:04:00 +00:00
|
|
|
if (newFiles.isEmpty())
|
2014-02-13 21:48:07 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
s.beginGroup("Recent_Files");
|
|
|
|
|
2014-02-14 06:11:05 +00:00
|
|
|
for (int c = 1; c <= 4; c++) {
|
2014-02-13 21:48:07 +00:00
|
|
|
QString key = QString("File_%1").arg(c);
|
2014-02-14 06:11:05 +00:00
|
|
|
if (s.contains(key)) {
|
2014-02-13 21:48:07 +00:00
|
|
|
QString file = s.value(key).toString();
|
|
|
|
|
|
|
|
files.append(file);
|
2014-02-14 06:11:05 +00:00
|
|
|
} else {
|
2014-02-13 21:48:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-22 18:40:22 +00:00
|
|
|
foreach (const QString &file, newFiles) {
|
2014-08-02 20:52:46 +00:00
|
|
|
int index = files.indexOf(QDir::toNativeSeparators(file));
|
2014-02-13 21:48:07 +00:00
|
|
|
|
2014-02-14 06:11:05 +00:00
|
|
|
if (index >= 0) {
|
2014-02-13 21:48:07 +00:00
|
|
|
files.removeAt(index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-22 18:40:22 +00:00
|
|
|
foreach (const QString &file, newFiles) {
|
2014-02-14 06:11:05 +00:00
|
|
|
if (QFile::exists(file)) {
|
2014-08-02 20:52:46 +00:00
|
|
|
files.prepend(QDir::toNativeSeparators(file));
|
2014-02-13 21:48:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-14 06:11:05 +00:00
|
|
|
while (files.count() > 4) {
|
2014-02-13 21:48:07 +00:00
|
|
|
files.removeLast();
|
|
|
|
}
|
|
|
|
|
2014-02-28 09:04:00 +00:00
|
|
|
for (int c = 1; c <= 4; c++) {
|
|
|
|
QString key = QString("File_%1").arg(c);
|
2014-02-13 21:48:07 +00:00
|
|
|
|
2014-02-28 09:04:00 +00:00
|
|
|
if (files.count() >= c) {
|
|
|
|
s.setValue(key, files.at(c - 1));
|
2014-02-14 06:11:05 +00:00
|
|
|
} else {
|
|
|
|
if (s.contains(key)) {
|
2014-02-13 21:48:07 +00:00
|
|
|
s.remove(key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
s.endGroup();
|
|
|
|
s.sync();
|
|
|
|
|
|
|
|
loadRecentFiles(&s);
|
|
|
|
}
|
|
|
|
|
2014-02-28 09:04:00 +00:00
|
|
|
void MainWindow::removeRecentFile(QStringList failedFiles)
|
|
|
|
{
|
|
|
|
QStringList files;
|
|
|
|
QSettings s;
|
|
|
|
|
|
|
|
if (failedFiles.isEmpty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
s.beginGroup("Recent_Files");
|
|
|
|
|
|
|
|
for (int c = 1; c <= 4; c++) {
|
|
|
|
QString key = QString("File_%1").arg(c);
|
|
|
|
|
|
|
|
if (s.contains(key)) {
|
|
|
|
QString file = s.value(key).toString();
|
|
|
|
files.append(file);
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-29 16:06:30 +00:00
|
|
|
foreach (const QString &file, failedFiles)
|
2014-02-28 09:04:00 +00:00
|
|
|
files.removeAll(file);
|
|
|
|
|
|
|
|
for (int c = 1; c <= 4; c++) {
|
|
|
|
QString key = QString("File_%1").arg(c);
|
|
|
|
|
2014-07-29 16:06:30 +00:00
|
|
|
if (files.count() >= c)
|
2014-02-28 09:04:00 +00:00
|
|
|
s.setValue(key, files.at(c - 1));
|
2014-07-29 16:06:30 +00:00
|
|
|
else if (s.contains(key))
|
|
|
|
s.remove(key);
|
2014-02-28 09:04:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
s.endGroup();
|
|
|
|
s.sync();
|
|
|
|
|
|
|
|
loadRecentFiles(&s);
|
|
|
|
}
|
|
|
|
|
2014-02-13 21:48:07 +00:00
|
|
|
void MainWindow::recentFileTriggered(bool checked)
|
|
|
|
{
|
|
|
|
Q_UNUSED(checked);
|
|
|
|
|
2014-06-09 02:46:43 +00:00
|
|
|
if (!okToClose(tr("Please save or cancel the current dive edit before opening a new file.")))
|
|
|
|
return;
|
|
|
|
|
2014-02-13 21:48:07 +00:00
|
|
|
QAction *actionRecent = (QAction *)sender();
|
|
|
|
|
|
|
|
const QString &filename = actionRecent->toolTip();
|
|
|
|
|
|
|
|
updateLastUsedDir(QFileInfo(filename).dir().path());
|
2014-06-09 02:46:43 +00:00
|
|
|
closeCurrentFile();
|
2014-02-13 21:48:07 +00:00
|
|
|
loadFiles(QStringList() << filename);
|
|
|
|
}
|
|
|
|
|
2014-03-14 17:19:23 +00:00
|
|
|
int MainWindow::file_save_as(void)
|
2013-05-19 22:25:47 +00:00
|
|
|
{
|
|
|
|
QString filename;
|
2014-05-13 21:13:03 +00:00
|
|
|
const char *default_filename = existing_filename;
|
2014-07-10 23:06:48 +00:00
|
|
|
filename = QFileDialog::getSaveFileName(this, tr("Save file as"), default_filename,
|
2013-05-19 22:25:47 +00:00
|
|
|
tr("Subsurface XML files (*.ssrf *.xml *.XML)"));
|
2014-03-14 17:19:23 +00:00
|
|
|
if (filename.isNull() || filename.isEmpty())
|
|
|
|
return report_error("No filename to save into");
|
2013-11-23 02:40:48 +00:00
|
|
|
|
2014-03-14 17:19:23 +00:00
|
|
|
if (ui.InfoWidget->isEditing())
|
|
|
|
ui.InfoWidget->acceptChanges();
|
2013-11-23 02:40:48 +00:00
|
|
|
|
2014-03-14 17:35:09 +00:00
|
|
|
if (save_dives(filename.toUtf8().data())) {
|
|
|
|
showError(get_error_string());
|
2014-03-14 17:19:23 +00:00
|
|
|
return -1;
|
2014-03-14 17:35:09 +00:00
|
|
|
}
|
2014-03-14 17:19:23 +00:00
|
|
|
|
2014-03-19 20:28:47 +00:00
|
|
|
showError(get_error_string());
|
2014-03-14 17:19:23 +00:00
|
|
|
set_filename(filename.toUtf8().data(), true);
|
|
|
|
setTitle(MWTF_FILENAME);
|
|
|
|
mark_divelist_changed(false);
|
|
|
|
addRecentFile(QStringList() << filename);
|
|
|
|
return 0;
|
2013-05-19 22:25:47 +00:00
|
|
|
}
|
|
|
|
|
2014-03-14 17:19:23 +00:00
|
|
|
int MainWindow::file_save(void)
|
2013-05-19 22:25:47 +00:00
|
|
|
{
|
|
|
|
const char *current_default;
|
|
|
|
|
|
|
|
if (!existing_filename)
|
|
|
|
return file_save_as();
|
|
|
|
|
2014-01-16 04:50:56 +00:00
|
|
|
if (ui.InfoWidget->isEditing())
|
2013-11-23 02:40:48 +00:00
|
|
|
ui.InfoWidget->acceptChanges();
|
|
|
|
|
2013-05-19 22:25:47 +00:00
|
|
|
current_default = prefs.default_filename;
|
2014-02-14 06:11:05 +00:00
|
|
|
if (strcmp(existing_filename, current_default) == 0) {
|
2013-05-19 22:25:47 +00:00
|
|
|
/* if we are using the default filename the directory
|
|
|
|
* that we are creating the file in may not exist */
|
2013-05-20 00:18:44 +00:00
|
|
|
QDir current_def_dir = QFileInfo(current_default).absoluteDir();
|
|
|
|
if (!current_def_dir.exists())
|
|
|
|
current_def_dir.mkpath(current_def_dir.absolutePath());
|
2013-05-19 22:25:47 +00:00
|
|
|
}
|
2014-03-14 17:35:09 +00:00
|
|
|
if (save_dives(existing_filename)) {
|
|
|
|
showError(get_error_string());
|
2014-03-14 17:19:23 +00:00
|
|
|
return -1;
|
2014-03-14 17:35:09 +00:00
|
|
|
}
|
2014-03-19 20:28:47 +00:00
|
|
|
showError(get_error_string());
|
2014-01-15 08:30:42 +00:00
|
|
|
mark_divelist_changed(false);
|
2014-02-13 21:48:07 +00:00
|
|
|
addRecentFile(QStringList() << QString(existing_filename));
|
2014-03-14 17:19:23 +00:00
|
|
|
return 0;
|
2013-05-19 22:25:47 +00:00
|
|
|
}
|
2013-05-22 06:13:45 +00:00
|
|
|
|
|
|
|
void MainWindow::showError(QString message)
|
|
|
|
{
|
|
|
|
if (message.isEmpty())
|
|
|
|
return;
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.mainErrorMessage->setText(message);
|
|
|
|
ui.mainErrorMessage->setCloseButtonVisible(true);
|
|
|
|
ui.mainErrorMessage->setMessageType(KMessageWidget::Error);
|
|
|
|
ui.mainErrorMessage->animatedShow();
|
2013-05-22 06:13:45 +00:00
|
|
|
}
|
2013-06-26 12:13:06 +00:00
|
|
|
|
|
|
|
void MainWindow::setTitle(enum MainWindowTitleFormat format)
|
|
|
|
{
|
|
|
|
switch (format) {
|
|
|
|
case MWTF_DEFAULT:
|
|
|
|
setWindowTitle("Subsurface");
|
|
|
|
break;
|
|
|
|
case MWTF_FILENAME:
|
2013-12-05 12:38:12 +00:00
|
|
|
if (!existing_filename) {
|
|
|
|
setTitle(MWTF_DEFAULT);
|
|
|
|
return;
|
|
|
|
}
|
2013-06-26 12:13:06 +00:00
|
|
|
QFile f(existing_filename);
|
|
|
|
QFileInfo fileInfo(f);
|
|
|
|
QString fileName(fileInfo.fileName());
|
|
|
|
setWindowTitle("Subsurface: " + fileName);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-09-09 08:59:03 +00:00
|
|
|
|
|
|
|
void MainWindow::importFiles(const QStringList fileNames)
|
|
|
|
{
|
2013-10-04 15:12:46 +00:00
|
|
|
if (fileNames.isEmpty())
|
|
|
|
return;
|
|
|
|
|
2013-09-09 08:59:03 +00:00
|
|
|
QByteArray fileNamePtr;
|
2014-03-14 18:26:07 +00:00
|
|
|
|
2013-09-09 08:59:03 +00:00
|
|
|
for (int i = 0; i < fileNames.size(); ++i) {
|
2013-12-20 01:02:34 +00:00
|
|
|
fileNamePtr = QFile::encodeName(fileNames.at(i));
|
2014-03-14 18:26:07 +00:00
|
|
|
parse_file(fileNamePtr.data());
|
2013-09-09 08:59:03 +00:00
|
|
|
}
|
2014-01-15 08:30:42 +00:00
|
|
|
process_dives(true, false);
|
2013-11-01 13:43:41 +00:00
|
|
|
refreshDisplay();
|
2013-09-09 08:59:03 +00:00
|
|
|
}
|
|
|
|
|
2014-05-28 06:55:46 +00:00
|
|
|
void MainWindow::importTxtFiles(const QStringList fileNames)
|
|
|
|
{
|
|
|
|
if (fileNames.isEmpty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
QByteArray fileNamePtr, csv;
|
|
|
|
|
|
|
|
for (int i = 0; i < fileNames.size(); ++i) {
|
|
|
|
fileNamePtr = QFile::encodeName(fileNames.at(i));
|
|
|
|
csv = fileNamePtr.data();
|
|
|
|
csv.replace(strlen(csv.data()) - 3, 3, "csv");
|
|
|
|
parse_txt_file(fileNamePtr.data(), csv);
|
|
|
|
}
|
|
|
|
process_dives(true, false);
|
|
|
|
refreshDisplay();
|
|
|
|
}
|
|
|
|
|
2013-09-09 08:59:03 +00:00
|
|
|
void MainWindow::loadFiles(const QStringList fileNames)
|
|
|
|
{
|
2013-10-04 15:12:46 +00:00
|
|
|
if (fileNames.isEmpty())
|
|
|
|
return;
|
|
|
|
|
2013-09-09 08:59:03 +00:00
|
|
|
QByteArray fileNamePtr;
|
2014-02-28 09:04:00 +00:00
|
|
|
QStringList failedParses;
|
2013-09-09 08:59:03 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < fileNames.size(); ++i) {
|
2014-03-14 18:26:07 +00:00
|
|
|
int error;
|
2013-09-09 08:59:03 +00:00
|
|
|
|
2014-03-14 18:26:07 +00:00
|
|
|
fileNamePtr = QFile::encodeName(fileNames.at(i));
|
|
|
|
error = parse_file(fileNamePtr.data());
|
|
|
|
if (!error) {
|
|
|
|
set_filename(fileNamePtr.data(), true);
|
|
|
|
setTitle(MWTF_FILENAME);
|
|
|
|
} else {
|
2014-02-28 09:04:00 +00:00
|
|
|
failedParses.append(fileNames.at(i));
|
2013-09-09 08:59:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-15 08:30:42 +00:00
|
|
|
process_dives(false, false);
|
2014-02-13 21:48:07 +00:00
|
|
|
addRecentFile(fileNames);
|
2014-02-28 09:04:00 +00:00
|
|
|
removeRecentFile(failedParses);
|
2013-09-09 08:59:03 +00:00
|
|
|
|
2013-11-01 13:43:41 +00:00
|
|
|
refreshDisplay();
|
2013-10-17 23:30:32 +00:00
|
|
|
ui.actionAutoGroup->setChecked(autogroup);
|
2013-09-09 08:59:03 +00:00
|
|
|
}
|
2013-10-16 19:05:19 +00:00
|
|
|
|
2013-12-29 16:11:20 +00:00
|
|
|
void MainWindow::on_actionImportDiveLog_triggered()
|
2013-10-16 19:05:19 +00:00
|
|
|
{
|
2014-07-10 23:06:48 +00:00
|
|
|
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open dive log file"), lastUsedDir(),
|
2014-11-14 16:07:41 +00:00
|
|
|
tr("Dive log files (*.can *.csv *.db *.dld *.jlb *.lvd *.sde *.udcf *.uddf *.xml *.txt);;"
|
2014-11-07 17:56:23 +00:00
|
|
|
"Cochran files (*.can);;"
|
|
|
|
"CSV files (*.csv);;"
|
|
|
|
"DiveLog.de files (*.dld);;"
|
|
|
|
"JDiveLog files (*.jlb);;"
|
2014-11-09 18:03:05 +00:00
|
|
|
"Liquivision files (*.lvd);;"
|
2014-11-07 17:56:23 +00:00
|
|
|
"MkVI files (*.txt);;"
|
2014-11-15 16:01:12 +00:00
|
|
|
"Suunto files (*.sde *.db);;"
|
2014-11-07 17:56:23 +00:00
|
|
|
"UDDF/UDCF files (*.uddf *.udcf);;"
|
|
|
|
"XML files (*.xml);;"
|
2014-11-15 16:01:12 +00:00
|
|
|
"All files (*)"));
|
2014-01-07 20:01:28 +00:00
|
|
|
|
|
|
|
if (fileNames.isEmpty())
|
|
|
|
return;
|
|
|
|
updateLastUsedDir(QFileInfo(fileNames[0]).dir().path());
|
|
|
|
|
2014-10-28 20:34:33 +00:00
|
|
|
QStringList logFiles = fileNames.filter(QRegExp("^.*\\.(?!(csv|txt))", Qt::CaseInsensitive));
|
2014-01-07 20:01:28 +00:00
|
|
|
QStringList csvFiles = fileNames.filter(".csv", Qt::CaseInsensitive);
|
2014-05-28 06:55:46 +00:00
|
|
|
QStringList txtFiles = fileNames.filter(".txt", Qt::CaseInsensitive);
|
2014-10-28 20:34:33 +00:00
|
|
|
|
2014-01-07 20:01:28 +00:00
|
|
|
if (logFiles.size()) {
|
|
|
|
importFiles(logFiles);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (csvFiles.size()) {
|
2014-04-25 17:44:23 +00:00
|
|
|
DiveLogImportDialog *diveLogImport = new DiveLogImportDialog(&csvFiles, this);
|
2014-01-07 20:01:28 +00:00
|
|
|
diveLogImport->show();
|
2014-01-15 08:30:42 +00:00
|
|
|
process_dives(true, false);
|
2014-01-07 20:01:28 +00:00
|
|
|
refreshDisplay();
|
|
|
|
}
|
2014-05-28 06:55:46 +00:00
|
|
|
|
|
|
|
if (txtFiles.size()) {
|
|
|
|
importTxtFiles(txtFiles);
|
|
|
|
}
|
2013-10-16 19:05:19 +00:00
|
|
|
}
|
2013-11-01 15:48:34 +00:00
|
|
|
|
|
|
|
void MainWindow::editCurrentDive()
|
|
|
|
{
|
2014-01-16 04:50:56 +00:00
|
|
|
if (information()->isEditing() || DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING) {
|
2014-02-26 14:59:06 +00:00
|
|
|
QMessageBox::warning(this, tr("Warning"), tr("Please, first finish the current edition before trying to do another."));
|
2013-11-09 00:09:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-11-01 15:48:34 +00:00
|
|
|
struct dive *d = current_dive;
|
|
|
|
QString defaultDC(d->dc.model);
|
2013-11-09 00:09:46 +00:00
|
|
|
DivePlannerPointsModel::instance()->clear();
|
2014-01-16 04:50:56 +00:00
|
|
|
if (defaultDC == "manually added dive") {
|
2013-11-01 15:48:34 +00:00
|
|
|
disableDcShortcuts();
|
2013-11-09 00:09:46 +00:00
|
|
|
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
|
2014-06-26 19:16:53 +00:00
|
|
|
ui.newProfile->setAddState();
|
2013-11-01 15:48:34 +00:00
|
|
|
ui.infoPane->setCurrentIndex(MAINTAB);
|
|
|
|
DivePlannerPointsModel::instance()->loadFromDive(d);
|
|
|
|
ui.InfoWidget->enableEdition(MainTab::MANUALLY_ADDED_DIVE);
|
2014-01-16 04:50:56 +00:00
|
|
|
} else if (defaultDC == "planned dive") {
|
2013-12-07 15:25:43 +00:00
|
|
|
disableDcShortcuts();
|
|
|
|
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
|
2014-05-25 03:51:05 +00:00
|
|
|
//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.
|
2013-12-07 15:25:43 +00:00
|
|
|
ui.infoPane->setCurrentIndex(PLANNERWIDGET);
|
|
|
|
DivePlannerPointsModel::instance()->loadFromDive(d);
|
|
|
|
ui.InfoWidget->enableEdition(MainTab::MANUALLY_ADDED_DIVE);
|
2013-11-01 15:48:34 +00:00
|
|
|
}
|
|
|
|
}
|
2014-02-06 13:38:28 +00:00
|
|
|
|
2014-09-17 22:39:49 +00:00
|
|
|
#define PREF_PROFILE(QT_PREFS) \
|
|
|
|
QSettings s; \
|
|
|
|
s.beginGroup("TecDetails"); \
|
2014-07-10 22:48:00 +00:00
|
|
|
s.setValue(#QT_PREFS, triggered); \
|
2014-02-06 13:38:28 +00:00
|
|
|
PreferencesDialog::instance()->emitSettingsChanged();
|
|
|
|
|
2014-09-17 22:39:49 +00:00
|
|
|
#define TOOLBOX_PREF_PROFILE(METHOD, INTERNAL_PREFS, QT_PREFS) \
|
|
|
|
void MainWindow::on_##METHOD##_triggered(bool triggered) \
|
|
|
|
{ \
|
|
|
|
prefs.INTERNAL_PREFS = triggered; \
|
|
|
|
PREF_PROFILE(QT_PREFS); \
|
|
|
|
}
|
2014-07-10 22:48:00 +00:00
|
|
|
|
|
|
|
TOOLBOX_PREF_PROFILE(profCalcAllTissues, calcalltissues, calcalltissues);
|
|
|
|
TOOLBOX_PREF_PROFILE(profCalcCeiling, calcceiling, calcceiling);
|
|
|
|
TOOLBOX_PREF_PROFILE(profDcCeiling, dcceiling, dcceiling);
|
|
|
|
TOOLBOX_PREF_PROFILE(profEad, ead, ead);
|
|
|
|
TOOLBOX_PREF_PROFILE(profIncrement3m, calcceiling3m, calcceiling3m);
|
|
|
|
TOOLBOX_PREF_PROFILE(profMod, mod, mod);
|
|
|
|
TOOLBOX_PREF_PROFILE(profNdl_tts, calcndltts, calcndltts);
|
|
|
|
TOOLBOX_PREF_PROFILE(profPhe, pp_graphs.phe, phegraph);
|
|
|
|
TOOLBOX_PREF_PROFILE(profPn2, pp_graphs.pn2, pn2graph);
|
|
|
|
TOOLBOX_PREF_PROFILE(profPO2, pp_graphs.po2, po2graph);
|
|
|
|
TOOLBOX_PREF_PROFILE(profHR, hrgraph, hrgraph);
|
|
|
|
TOOLBOX_PREF_PROFILE(profRuler, rulergraph, rulergraph);
|
|
|
|
TOOLBOX_PREF_PROFILE(profSAC, show_sac, show_sac);
|
|
|
|
TOOLBOX_PREF_PROFILE(profScaled, zoomed_plot, zoomed_plot);
|
|
|
|
TOOLBOX_PREF_PROFILE(profTogglePicture, show_pictures_in_profile, show_pictures_in_profile);
|
2014-08-15 14:11:14 +00:00
|
|
|
TOOLBOX_PREF_PROFILE(profTankbar, tankbar, tankbar);
|
2014-09-15 12:09:00 +00:00
|
|
|
TOOLBOX_PREF_PROFILE(profTissues, percentagegraph, percentagegraph);
|
2014-07-11 00:15:20 +00:00
|
|
|
|
2014-06-04 20:41:50 +00:00
|
|
|
void MainWindow::turnOffNdlTts()
|
|
|
|
{
|
2014-06-09 21:05:59 +00:00
|
|
|
const bool triggered = false;
|
|
|
|
prefs.calcndltts = triggered;
|
2014-07-10 22:48:00 +00:00
|
|
|
PREF_PROFILE(calcndltts);
|
2014-07-10 16:50:49 +00:00
|
|
|
}
|
|
|
|
|
2014-02-08 07:50:39 +00:00
|
|
|
#undef TOOLBOX_PREF_PROFILE
|
2014-07-10 22:48:00 +00:00
|
|
|
#undef PERF_PROFILE
|
2014-05-20 16:33:32 +00:00
|
|
|
|
|
|
|
void MainWindow::on_actionExport_triggered()
|
|
|
|
{
|
2014-07-10 22:53:58 +00:00
|
|
|
DiveLogExportDialog diveLogExport;
|
|
|
|
diveLogExport.exec();
|
2014-05-20 16:33:32 +00:00
|
|
|
}
|
2014-08-04 15:58:21 +00:00
|
|
|
|
2014-05-29 15:54:19 +00:00
|
|
|
void MainWindow::on_actionConfigure_Dive_Computer_triggered()
|
|
|
|
{
|
|
|
|
ConfigureDiveComputerDialog *dcConfig = new ConfigureDiveComputerDialog(this);
|
|
|
|
dcConfig->show();
|
|
|
|
}
|
|
|
|
|
2014-08-04 15:58:21 +00:00
|
|
|
void MainWindow::setEnabledToolbar(bool arg1)
|
|
|
|
{
|
2014-09-17 22:39:49 +00:00
|
|
|
Q_FOREACH (QAction *b, profileToolbarActions)
|
2014-08-04 15:58:21 +00:00
|
|
|
b->setEnabled(arg1);
|
|
|
|
}
|
2014-08-16 15:32:23 +00:00
|
|
|
|
|
|
|
void MainWindow::on_copy_triggered()
|
|
|
|
{
|
|
|
|
// open dialog to select what gets copied
|
|
|
|
// copy the displayed dive
|
|
|
|
DiveComponentSelection dialog(this, ©PasteDive, &what);
|
|
|
|
dialog.exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_paste_triggered()
|
|
|
|
{
|
|
|
|
// take the data in our copyPasteDive and apply it to selected dives
|
2014-08-17 14:26:09 +00:00
|
|
|
selective_copy_dive(©PasteDive, &displayed_dive, what, false);
|
|
|
|
ui.InfoWidget->showAndTriggerEditSelective(what);
|
2014-08-16 15:32:23 +00:00
|
|
|
}
|
2014-09-17 17:50:41 +00:00
|
|
|
|
|
|
|
void MainWindow::on_actionFilterTags_triggered()
|
|
|
|
{
|
2014-11-13 22:24:09 +00:00
|
|
|
if (ui.multiFilter->isVisible())
|
|
|
|
ui.multiFilter->closeFilter();
|
|
|
|
else
|
|
|
|
ui.multiFilter->setVisible(true);
|
2014-09-17 17:50:41 +00:00
|
|
|
}
|