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"
|
|
|
|
|
2013-04-13 13:17:59 +00:00
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QMessageBox>
|
2013-10-04 15:28:40 +00:00
|
|
|
#include <QDesktopWidget>
|
2014-02-13 21:48:07 +00:00
|
|
|
#include <QSettings>
|
2014-04-25 04:37:47 +00:00
|
|
|
#include <QShortcut>
|
2014-08-23 01:26:07 +00:00
|
|
|
#include <QToolBar>
|
2015-02-15 18:25:18 +00:00
|
|
|
#include "version.h"
|
2015-02-09 20:27:59 +00:00
|
|
|
#include "divelistview.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-24 11:36:38 +00:00
|
|
|
#include "about.h"
|
2014-04-02 19:41:39 +00:00
|
|
|
#include "updatemanager.h"
|
2014-06-04 21:34:09 +00:00
|
|
|
#include "planner.h"
|
2014-11-13 18:31:03 +00:00
|
|
|
#include "filtermodels.h"
|
2015-09-03 18:56:37 +00:00
|
|
|
#include "profile-widget/profilewidget2.h"
|
2015-02-09 20:43:41 +00:00
|
|
|
#include "globe.h"
|
2015-05-29 17:19:56 +00:00
|
|
|
#include "divecomputer.h"
|
2015-02-09 20:58:40 +00:00
|
|
|
#include "maintab.h"
|
2015-02-09 22:37:17 +00:00
|
|
|
#include "diveplanner.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
|
2015-05-28 19:39:15 +00:00
|
|
|
#include "tankinfomodel.h"
|
2015-05-28 19:52:13 +00:00
|
|
|
#include "weigthsysteminfomodel.h"
|
2015-05-28 21:12:11 +00:00
|
|
|
#include "yearlystatisticsmodel.h"
|
2015-05-28 19:23:49 +00:00
|
|
|
#include "diveplannermodel.h"
|
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"
|
2015-05-10 15:44:35 +00:00
|
|
|
#include "divesitehelpers.h"
|
2015-06-16 13:04:34 +00:00
|
|
|
#include "windowtitleupdate.h"
|
2015-07-25 15:30:20 +00:00
|
|
|
#include "locationinformation.h"
|
2015-09-17 20:16:40 +00:00
|
|
|
#include "preferences/preferencesdialog.h"
|
2015-07-25 15:30:20 +00:00
|
|
|
|
2014-03-26 22:35:24 +00:00
|
|
|
#ifndef NO_USERMANUAL
|
|
|
|
#include "usermanual.h"
|
|
|
|
#endif
|
2015-05-29 17:42:57 +00:00
|
|
|
#include "divepicturemodel.h"
|
2015-06-13 15:01:06 +00:00
|
|
|
#include "git-access.h"
|
2014-06-26 16:20:34 +00:00
|
|
|
#include <QNetworkProxy>
|
2015-02-11 06:26:17 +00:00
|
|
|
#include <QUndoStack>
|
2015-02-26 13:39:42 +00:00
|
|
|
#include <qthelper.h>
|
|
|
|
#include <QtConcurrentRun>
|
2015-09-03 17:20:19 +00:00
|
|
|
#include "subsurface-core/color.h"
|
2013-04-13 13:17:59 +00:00
|
|
|
|
2015-09-16 19:43:01 +00:00
|
|
|
#if defined(FBSUPPORT)
|
|
|
|
#include "socialnetworks.h"
|
|
|
|
#endif
|
|
|
|
|
2015-09-09 20:02:39 +00:00
|
|
|
QProgressDialog *progressDialog = NULL;
|
|
|
|
bool progressDialogCanceled = false;
|
|
|
|
|
|
|
|
extern "C" int updateProgress(int percent)
|
|
|
|
{
|
|
|
|
if (progressDialog)
|
|
|
|
progressDialog->setValue(percent);
|
|
|
|
return progressDialogCanceled;
|
|
|
|
}
|
|
|
|
|
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),
|
2015-09-09 20:02:39 +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);
|
2015-02-26 13:39:42 +00:00
|
|
|
read_hashes();
|
2015-02-09 18:23:30 +00:00
|
|
|
// Define the States of the Application Here, Currently the states are situations where the different
|
|
|
|
// widgets will change on the mainwindow.
|
|
|
|
|
|
|
|
// for the "default" mode
|
|
|
|
MainTab *mainTab = new MainTab();
|
|
|
|
DiveListView *diveListView = new DiveListView();
|
|
|
|
ProfileWidget2 *profileWidget = new ProfileWidget2();
|
2015-02-10 19:36:16 +00:00
|
|
|
|
|
|
|
#ifndef NO_MARBLE
|
2015-07-31 00:51:38 +00:00
|
|
|
GlobeGPS *globeGps = GlobeGPS::instance();
|
2015-02-10 19:36:16 +00:00
|
|
|
#else
|
|
|
|
QWidget *globeGps = NULL;
|
|
|
|
#endif
|
2015-02-09 18:23:30 +00:00
|
|
|
|
2015-02-09 18:28:33 +00:00
|
|
|
PlannerSettingsWidget *plannerSettings = new PlannerSettingsWidget();
|
|
|
|
DivePlannerWidget *plannerWidget = new DivePlannerWidget();
|
2015-02-09 20:05:27 +00:00
|
|
|
PlannerDetails *plannerDetails = new PlannerDetails();
|
2015-02-09 18:28:33 +00:00
|
|
|
|
2015-01-04 15:30:09 +00:00
|
|
|
// what is a sane order for those icons? we should have the ones the user is
|
|
|
|
// most likely to want towards the top so they are always visible
|
|
|
|
// and the ones that someone likely sets and then never touches again towards the bottom
|
|
|
|
profileToolbarActions << ui.profCalcCeiling << ui.profCalcAllTissues << // start with various ceilings
|
|
|
|
ui.profIncrement3m << ui.profDcCeiling <<
|
|
|
|
ui.profPhe << ui.profPn2 << ui.profPO2 << // partial pressure graphs
|
|
|
|
ui.profRuler << ui.profScaled << // measuring and scaling
|
|
|
|
ui.profTogglePicture << ui.profTankbar <<
|
|
|
|
ui.profMod << ui.profNdl_tts << // various values that a user is either interested in or not
|
|
|
|
ui.profEad << ui.profSAC <<
|
|
|
|
ui.profHR << // very few dive computers support this
|
|
|
|
ui.profTissues; // maybe less frequently used
|
2015-02-17 02:33:25 +00:00
|
|
|
|
|
|
|
QToolBar *toolBar = new QToolBar();
|
|
|
|
Q_FOREACH (QAction *a, profileToolbarActions)
|
|
|
|
toolBar->addAction(a);
|
|
|
|
toolBar->setOrientation(Qt::Vertical);
|
|
|
|
toolBar->setIconSize(QSize(24,24));
|
|
|
|
QWidget *profileContainer = new QWidget();
|
|
|
|
QHBoxLayout *profLayout = new QHBoxLayout();
|
2015-05-25 19:14:59 +00:00
|
|
|
profLayout->setSpacing(0);
|
|
|
|
profLayout->setMargin(0);
|
|
|
|
profLayout->setContentsMargins(0,0,0,0);
|
2015-02-17 02:33:25 +00:00
|
|
|
profLayout->addWidget(toolBar);
|
|
|
|
profLayout->addWidget(profileWidget);
|
|
|
|
profileContainer->setLayout(profLayout);
|
2015-07-25 15:30:20 +00:00
|
|
|
|
|
|
|
LocationInformationWidget * diveSiteEdit = new LocationInformationWidget();
|
2015-07-31 00:18:57 +00:00
|
|
|
connect(diveSiteEdit, &LocationInformationWidget::endEditDiveSite,
|
2015-07-25 15:35:14 +00:00
|
|
|
this, &MainWindow::setDefaultState);
|
|
|
|
|
2015-07-31 00:32:50 +00:00
|
|
|
connect(diveSiteEdit, &LocationInformationWidget::endEditDiveSite,
|
|
|
|
mainTab, &MainTab::refreshDiveInfo);
|
|
|
|
|
2015-08-29 23:00:22 +00:00
|
|
|
connect(diveSiteEdit, &LocationInformationWidget::endEditDiveSite,
|
|
|
|
mainTab, &MainTab::refreshDisplayedDiveSite);
|
|
|
|
|
2015-07-25 15:30:20 +00:00
|
|
|
QWidget *diveSitePictures = new QWidget(); // Placeholder
|
|
|
|
|
2015-08-21 01:24:49 +00:00
|
|
|
std::pair<QByteArray, QVariant> enabled = std::make_pair("enabled", QVariant(true));
|
|
|
|
std::pair<QByteArray, QVariant> disabled = std::make_pair("enabled", QVariant(false));
|
|
|
|
PropertyList enabledList;
|
|
|
|
PropertyList disabledList;
|
|
|
|
enabledList.push_back(enabled);
|
|
|
|
disabledList.push_back(disabled);
|
|
|
|
|
2015-02-17 02:33:25 +00:00
|
|
|
registerApplicationState("Default", mainTab, profileContainer, diveListView, globeGps );
|
|
|
|
registerApplicationState("AddDive", mainTab, profileContainer, diveListView, globeGps );
|
|
|
|
registerApplicationState("EditDive", mainTab, profileContainer, diveListView, globeGps );
|
|
|
|
registerApplicationState("PlanDive", plannerWidget, profileContainer, plannerSettings, plannerDetails );
|
|
|
|
registerApplicationState("EditPlannedDive", plannerWidget, profileContainer, diveListView, globeGps );
|
2015-08-25 21:12:02 +00:00
|
|
|
registerApplicationState("EditDiveSite", diveSiteEdit, profileContainer, diveListView, globeGps);
|
2015-02-17 02:33:25 +00:00
|
|
|
|
2015-08-21 01:24:49 +00:00
|
|
|
setStateProperties("Default", enabledList, enabledList, enabledList,enabledList);
|
|
|
|
setStateProperties("AddDive", enabledList, enabledList, enabledList,enabledList);
|
|
|
|
setStateProperties("EditDive", enabledList, enabledList, enabledList,enabledList);
|
|
|
|
setStateProperties("PlanDive", enabledList, enabledList, enabledList,enabledList);
|
|
|
|
setStateProperties("EditPlannedDive", enabledList, enabledList, enabledList,enabledList);
|
2015-08-25 21:12:02 +00:00
|
|
|
setStateProperties("EditDiveSite", enabledList, disabledList, disabledList, enabledList);
|
2015-08-21 01:24:49 +00:00
|
|
|
|
2015-02-17 02:33:25 +00:00
|
|
|
setApplicationState("Default");
|
|
|
|
|
|
|
|
ui.multiFilter->hide();
|
|
|
|
|
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");
|
|
|
|
}
|
2015-02-09 20:27:59 +00:00
|
|
|
connect(dive_list(), 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()));
|
2015-02-09 20:27:59 +00:00
|
|
|
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), diveListView, SLOT(update()));
|
|
|
|
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), diveListView, SLOT(reloadHeaderActions()));
|
2015-02-09 20:58:40 +00:00
|
|
|
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), information(), SLOT(updateDiveInfo()));
|
2015-02-09 21:19:10 +00:00
|
|
|
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), divePlannerWidget(), SLOT(settingsChanged()));
|
2015-02-09 22:37:17 +00:00
|
|
|
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), divePlannerSettingsWidget(), 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)));
|
2015-02-09 21:51:31 +00:00
|
|
|
connect(information(), SIGNAL(addDiveFinished()), graphics(), 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()));
|
2015-02-09 22:14:08 +00:00
|
|
|
connect(plannerDetails->printPlan(), SIGNAL(pressed()), divePlannerWidget(), SLOT(printDecoPlan()));
|
2015-08-25 21:27:19 +00:00
|
|
|
connect(this, SIGNAL(startDiveSiteEdit()), this, SLOT(on_actionDiveSiteEdit_triggered()));
|
|
|
|
|
2015-06-29 16:41:33 +00:00
|
|
|
#ifndef NO_MARBLE
|
2015-07-16 19:41:04 +00:00
|
|
|
connect(information(), SIGNAL(diveSiteChanged(struct dive_site *)), globeGps, SLOT(centerOnDiveSite(struct dive_site *)));
|
2015-06-29 16:41:33 +00:00
|
|
|
#endif
|
2015-06-16 13:04:34 +00:00
|
|
|
wtu = new WindowTitleUpdate();
|
|
|
|
connect(WindowTitleUpdate::instance(), SIGNAL(updateTitle()), this, SLOT(setAutomaticTitle()));
|
2014-06-26 15:04:39 +00:00
|
|
|
#ifdef NO_PRINTING
|
2015-03-09 08:14:01 +00:00
|
|
|
plannerDetails->printPlan()->hide();
|
2015-02-09 17:44:53 +00:00
|
|
|
ui.menuFile->removeAction(ui.actionPrint);
|
2014-06-26 15:04:39 +00:00
|
|
|
#endif
|
2015-06-01 16:58:09 +00:00
|
|
|
#ifndef USE_LIBGIT23_API
|
|
|
|
ui.menuFile->removeAction(ui.actionCloudstorageopen);
|
|
|
|
ui.menuFile->removeAction(ui.actionCloudstoragesave);
|
|
|
|
qDebug() << "disabled / made invisible the cloud storage stuff";
|
2015-06-14 22:42:28 +00:00
|
|
|
#else
|
|
|
|
enableDisableCloudActions();
|
2015-06-01 16:58:09 +00:00
|
|
|
#endif
|
2014-06-26 15:04:39 +00:00
|
|
|
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.mainErrorMessage->hide();
|
2015-02-09 21:51:31 +00:00
|
|
|
graphics()->setEmptyState();
|
2013-06-04 12:40:09 +00:00
|
|
|
initialUiSetup();
|
2013-05-22 01:29:23 +00:00
|
|
|
readSettings();
|
2015-02-09 20:27:59 +00:00
|
|
|
diveListView->reload(DiveTripModel::TREE);
|
|
|
|
diveListView->reloadHeaderActions();
|
|
|
|
diveListView->setFocus();
|
2015-07-31 00:51:38 +00:00
|
|
|
GlobeGPS::instance()->reload();
|
2015-02-09 20:27:59 +00:00
|
|
|
diveListView->expand(dive_list()->model()->index(0, 0));
|
|
|
|
diveListView->scrollTo(dive_list()->model()->index(0, 0), QAbstractItemView::PositionAtCenter);
|
2015-02-09 21:19:10 +00:00
|
|
|
divePlannerWidget()->settingsChanged();
|
2015-02-09 22:37:17 +00:00
|
|
|
divePlannerSettingsWidget()->settingsChanged();
|
2014-03-26 22:08:56 +00:00
|
|
|
#ifdef NO_MARBLE
|
|
|
|
ui.menuView->removeAction(ui.actionViewGlobe);
|
|
|
|
#endif
|
2014-03-26 22:35:24 +00:00
|
|
|
#ifdef NO_USERMANUAL
|
|
|
|
ui.menuHelp->removeAction(ui.actionUserManual);
|
2014-03-26 22:36:06 +00:00
|
|
|
#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
|
|
|
|
2015-01-02 04:49:24 +00:00
|
|
|
updateManager = new UpdateManager(this);
|
2015-02-11 06:26:17 +00:00
|
|
|
undoStack = new QUndoStack(this);
|
|
|
|
QAction *undoAction = undoStack->createUndoAction(this, tr("&Undo"));
|
|
|
|
QAction *redoAction = undoStack->createRedoAction(this, tr("&Redo"));
|
|
|
|
undoAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Z));
|
|
|
|
redoAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Z));
|
|
|
|
QList<QAction*>undoRedoActions;
|
|
|
|
undoRedoActions.append(undoAction);
|
|
|
|
undoRedoActions.append(redoAction);
|
|
|
|
ui.menu_Edit->addActions(undoRedoActions);
|
2015-05-10 15:44:35 +00:00
|
|
|
|
2015-05-15 21:27:08 +00:00
|
|
|
ReverseGeoLookupThread *geoLookup = ReverseGeoLookupThread::instance();
|
|
|
|
connect(geoLookup, SIGNAL(started()),information(), SLOT(disableGeoLookupEdition()));
|
|
|
|
connect(geoLookup, SIGNAL(finished()), information(), SLOT(enableGeoLookupEdition()));
|
2015-07-24 07:26:25 +00:00
|
|
|
#ifndef NO_PRINTING
|
2015-10-18 21:25:14 +00:00
|
|
|
// copy the bundled print templates to the user path; no overwriting occurs!
|
|
|
|
copyPath(getPrintingTemplatePathBundle(), getPrintingTemplatePathUser());
|
2015-07-24 07:26:25 +00:00
|
|
|
find_all_templates();
|
|
|
|
#endif
|
2015-08-25 08:56:07 +00:00
|
|
|
|
2015-09-16 19:43:01 +00:00
|
|
|
#if defined(FBSUPPORT)
|
|
|
|
FacebookManager *fb = FacebookManager::instance();
|
|
|
|
connect(fb, SIGNAL(justLoggedIn(bool)), ui.actionFacebook, SLOT(setEnabled(bool)));
|
|
|
|
connect(fb, SIGNAL(justLoggedOut(bool)), ui.actionFacebook, SLOT(setEnabled(bool)));
|
|
|
|
connect(ui.actionFacebook, SIGNAL(triggered(bool)), fb, SLOT(sendDive()));
|
|
|
|
ui.actionFacebook->setEnabled(fb->loggedIn());
|
|
|
|
#else
|
|
|
|
ui.actionFacebook->setEnabled(false);
|
|
|
|
#endif
|
|
|
|
|
2015-10-11 20:24:35 +00:00
|
|
|
|
2015-08-25 08:56:07 +00:00
|
|
|
ui.menubar->show();
|
2015-09-09 20:02:39 +00:00
|
|
|
set_git_update_cb(&updateProgress);
|
2015-09-17 20:16:40 +00:00
|
|
|
PreferencesDialogV2 *d = new PreferencesDialogV2();
|
|
|
|
d->show();
|
2013-05-14 11:18:26 +00:00
|
|
|
}
|
|
|
|
|
2014-02-12 14:22:54 +00:00
|
|
|
MainWindow::~MainWindow()
|
|
|
|
{
|
2015-02-26 13:39:42 +00:00
|
|
|
write_hashes();
|
2014-02-12 14:22:54 +00:00
|
|
|
m_Instance = NULL;
|
|
|
|
}
|
|
|
|
|
2015-08-21 01:24:49 +00:00
|
|
|
void MainWindow::setStateProperties(const QByteArray& state, const PropertyList& tl, const PropertyList& tr, const PropertyList& bl, const PropertyList& br)
|
|
|
|
{
|
|
|
|
stateProperties[state] = PropertiesForQuadrant(tl, tr, bl, br);
|
|
|
|
}
|
|
|
|
|
2015-07-25 15:30:20 +00:00
|
|
|
void MainWindow::on_actionDiveSiteEdit_triggered() {
|
|
|
|
setApplicationState("EditDiveSite");
|
|
|
|
}
|
|
|
|
|
2015-06-14 22:42:28 +00:00
|
|
|
void MainWindow::enableDisableCloudActions()
|
|
|
|
{
|
|
|
|
#ifdef USE_LIBGIT23_API
|
|
|
|
ui.actionCloudstorageopen->setEnabled(prefs.cloud_verification_status == CS_VERIFIED);
|
|
|
|
ui.actionCloudstoragesave->setEnabled(prefs.cloud_verification_status == CS_VERIFIED);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-02-09 22:14:08 +00:00
|
|
|
PlannerDetails *MainWindow::plannerDetails() const {
|
|
|
|
return qobject_cast<PlannerDetails*>(applicationState["PlanDive"].bottomRight);
|
|
|
|
}
|
|
|
|
|
2015-02-09 22:37:17 +00:00
|
|
|
PlannerSettingsWidget *MainWindow::divePlannerSettingsWidget() {
|
|
|
|
return qobject_cast<PlannerSettingsWidget*>(applicationState["PlanDive"].bottomLeft);
|
|
|
|
}
|
|
|
|
|
2015-02-11 15:58:23 +00:00
|
|
|
void MainWindow::setDefaultState() {
|
|
|
|
setApplicationState("Default");
|
2015-08-26 00:08:05 +00:00
|
|
|
if (information()->getEditMode() != MainTab::NONE) {
|
|
|
|
ui.bottomLeft->currentWidget()->setEnabled(false);
|
|
|
|
}
|
2015-02-11 15:58:23 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2015-02-27 00:57:56 +00:00
|
|
|
getNotificationWidget()->showNotification(get_error_string(), KMessageWidget::Error);
|
2015-02-09 20:58:40 +00:00
|
|
|
information()->reload();
|
2013-12-28 22:56:01 +00:00
|
|
|
TankInfoModel::instance()->update();
|
2015-07-31 00:51:38 +00:00
|
|
|
GlobeGPS::instance()->reload();
|
2014-05-18 10:08:58 +00:00
|
|
|
if (doRecreateDiveList)
|
|
|
|
recreateDiveList();
|
2015-02-09 22:14:08 +00:00
|
|
|
|
|
|
|
setApplicationState("Default");
|
2015-02-09 20:27:59 +00:00
|
|
|
dive_list()->setEnabled(true);
|
|
|
|
dive_list()->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()
|
|
|
|
{
|
2015-02-09 20:27:59 +00:00
|
|
|
dive_list()->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
|
|
|
}
|
|
|
|
|
2015-10-11 20:24:35 +00:00
|
|
|
void MainWindow::configureToolbar() {
|
|
|
|
if (selected_dive>0) {
|
|
|
|
if (current_dive->dc.divemode == FREEDIVE) {
|
|
|
|
ui.profCalcCeiling->setDisabled(true);
|
|
|
|
ui.profCalcAllTissues ->setDisabled(true);
|
|
|
|
ui.profIncrement3m->setDisabled(true);
|
|
|
|
ui.profDcCeiling->setDisabled(true);
|
|
|
|
ui.profPhe->setDisabled(true);
|
|
|
|
ui.profPn2->setDisabled(true); //TODO is the same as scuba?
|
|
|
|
ui.profPO2->setDisabled(true); //TODO is the same as scuba?
|
|
|
|
ui.profRuler->setDisabled(false);
|
|
|
|
ui.profScaled->setDisabled(false); // measuring and scaling
|
|
|
|
ui.profTogglePicture->setDisabled(false);
|
|
|
|
ui.profTankbar->setDisabled(true);
|
|
|
|
ui.profMod->setDisabled(true);
|
|
|
|
ui.profNdl_tts->setDisabled(true);
|
|
|
|
ui.profEad->setDisabled(true);
|
|
|
|
ui.profSAC->setDisabled(true);
|
|
|
|
ui.profHR->setDisabled(false);
|
|
|
|
ui.profTissues->setDisabled(true);
|
|
|
|
} else {
|
|
|
|
ui.profCalcCeiling->setDisabled(false);
|
|
|
|
ui.profCalcAllTissues ->setDisabled(false);
|
|
|
|
ui.profIncrement3m->setDisabled(false);
|
|
|
|
ui.profDcCeiling->setDisabled(false);
|
|
|
|
ui.profPhe->setDisabled(false);
|
|
|
|
ui.profPn2->setDisabled(false);
|
|
|
|
ui.profPO2->setDisabled(false); // partial pressure graphs
|
|
|
|
ui.profRuler->setDisabled(false);
|
|
|
|
ui.profScaled->setDisabled(false); // measuring and scaling
|
|
|
|
ui.profTogglePicture->setDisabled(false);
|
|
|
|
ui.profTankbar->setDisabled(false);
|
|
|
|
ui.profMod->setDisabled(false);
|
|
|
|
ui.profNdl_tts->setDisabled(false); // various values that a user is either interested in or not
|
|
|
|
ui.profEad->setDisabled(false);
|
|
|
|
ui.profSAC->setDisabled(false);
|
|
|
|
ui.profHR->setDisabled(false); // very few dive computers support this
|
|
|
|
ui.profTissues->setDisabled(false);; // maybe less frequently used
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
2015-02-09 21:51:31 +00:00
|
|
|
graphics()->plotDive();
|
2015-02-09 20:58:40 +00:00
|
|
|
information()->updateDiveInfo();
|
2015-10-11 20:24:35 +00:00
|
|
|
configureToolbar();
|
2015-07-31 00:51:38 +00:00
|
|
|
GlobeGPS::instance()->reload();
|
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"));
|
2015-08-07 16:12:28 +00:00
|
|
|
dialog.setAcceptMode(QFileDialog::AcceptOpen);
|
2014-11-23 00:06:01 +00:00
|
|
|
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();
|
2015-06-21 23:28:38 +00:00
|
|
|
// some file dialogs decide to add the default extension to a filename without extension
|
|
|
|
// so we would get dir[branch].ssrf when trying to select dir[branch].
|
|
|
|
// let's detect that and remove the incorrect extension
|
|
|
|
QStringList cleanFilenames;
|
|
|
|
QRegularExpression reg(".*\\[[^]]+]\\.ssrf", QRegularExpression::CaseInsensitiveOption);
|
|
|
|
|
|
|
|
Q_FOREACH (QString filename, filenames) {
|
|
|
|
if (reg.match(filename).hasMatch())
|
|
|
|
filename.remove(QRegularExpression("\\.ssrf$", QRegularExpression::CaseInsensitiveOption));
|
|
|
|
cleanFilenames << filename;
|
|
|
|
}
|
|
|
|
loadFiles(cleanFilenames);
|
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
|
|
|
|
2015-06-01 05:11:27 +00:00
|
|
|
void MainWindow::on_actionCloudstorageopen_triggered()
|
|
|
|
{
|
|
|
|
if (!okToClose(tr("Please save or cancel the current dive edit before opening a new file.")))
|
|
|
|
return;
|
|
|
|
|
|
|
|
QString filename;
|
|
|
|
if (getCloudURL(filename)) {
|
|
|
|
getNotificationWidget()->showNotification(get_error_string(), KMessageWidget::Error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
qDebug() << filename;
|
|
|
|
|
|
|
|
closeCurrentFile();
|
|
|
|
|
|
|
|
int error;
|
|
|
|
|
2015-09-09 20:02:39 +00:00
|
|
|
showProgressBar();
|
2015-06-01 05:11:27 +00:00
|
|
|
QByteArray fileNamePtr = QFile::encodeName(filename);
|
|
|
|
error = parse_file(fileNamePtr.data());
|
|
|
|
if (!error) {
|
|
|
|
set_filename(fileNamePtr.data(), true);
|
|
|
|
setTitle(MWTF_FILENAME);
|
|
|
|
}
|
|
|
|
getNotificationWidget()->hideNotification();
|
|
|
|
process_dives(false, false);
|
2015-09-09 20:02:39 +00:00
|
|
|
hideProgressBar();
|
2015-06-01 05:11:27 +00:00
|
|
|
refreshDisplay();
|
|
|
|
ui.actionAutoGroup->setChecked(autogroup);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionCloudstoragesave_triggered()
|
|
|
|
{
|
|
|
|
QString filename;
|
|
|
|
if (getCloudURL(filename)) {
|
|
|
|
getNotificationWidget()->showNotification(get_error_string(), KMessageWidget::Error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
qDebug() << filename;
|
|
|
|
if (information()->isEditing())
|
|
|
|
information()->acceptChanges();
|
|
|
|
|
2015-09-09 20:02:39 +00:00
|
|
|
showProgressBar();
|
2015-08-25 19:49:48 +00:00
|
|
|
|
2015-06-01 05:11:27 +00:00
|
|
|
if (save_dives(filename.toUtf8().data())) {
|
|
|
|
getNotificationWidget()->showNotification(get_error_string(), KMessageWidget::Error);
|
|
|
|
return;
|
|
|
|
}
|
2015-08-25 19:49:48 +00:00
|
|
|
|
2015-09-09 20:02:39 +00:00
|
|
|
hideProgressBar();
|
2015-08-25 19:49:48 +00:00
|
|
|
|
2015-06-01 05:11:27 +00:00
|
|
|
getNotificationWidget()->showNotification(get_error_string(), KMessageWidget::Error);
|
|
|
|
set_filename(filename.toUtf8().data(), true);
|
|
|
|
setTitle(MWTF_FILENAME);
|
|
|
|
mark_divelist_changed(false);
|
|
|
|
}
|
|
|
|
|
2015-03-26 21:53:44 +00:00
|
|
|
void learnImageDirs(QStringList dirnames)
|
|
|
|
{
|
|
|
|
QList<QFuture<void> > futures;
|
|
|
|
foreach (QString dir, dirnames) {
|
|
|
|
futures << QtConcurrent::run(learnImages, QDir(dir), 10, false);
|
|
|
|
}
|
|
|
|
DivePictureModel::instance()->updateDivePicturesWhenDone(futures);
|
|
|
|
}
|
|
|
|
|
2015-02-26 13:44:27 +00:00
|
|
|
void MainWindow::on_actionHash_images_triggered()
|
|
|
|
{
|
2015-04-29 20:17:59 +00:00
|
|
|
QFuture<void> future;
|
2015-02-26 13:44:27 +00:00
|
|
|
QFileDialog dialog(this, tr("Traverse image directories"), lastUsedDir(), filter());
|
|
|
|
dialog.setFileMode(QFileDialog::Directory);
|
|
|
|
dialog.setViewMode(QFileDialog::Detail);
|
|
|
|
dialog.setLabelText(QFileDialog::Accept, tr("Scan"));
|
|
|
|
dialog.setLabelText(QFileDialog::Reject, tr("Cancel"));
|
|
|
|
QStringList dirnames;
|
|
|
|
if (dialog.exec())
|
|
|
|
dirnames = dialog.selectedFiles();
|
|
|
|
if (dirnames.isEmpty())
|
|
|
|
return;
|
2015-04-29 20:17:59 +00:00
|
|
|
future = QtConcurrent::run(learnImageDirs,dirnames);
|
|
|
|
MainWindow::instance()->getNotificationWidget()->showNotification(tr("Scanning images...(this can take a while)"), KMessageWidget::Information);
|
|
|
|
MainWindow::instance()->getNotificationWidget()->setFuture(future);
|
|
|
|
|
2015-02-26 13:44:27 +00:00
|
|
|
}
|
|
|
|
|
2014-05-22 18:40:22 +00:00
|
|
|
ProfileWidget2 *MainWindow::graphics() const
|
2014-03-07 15:42:13 +00:00
|
|
|
{
|
2015-02-17 02:33:25 +00:00
|
|
|
return qobject_cast<ProfileWidget2*>(applicationState["Default"].topRight->layout()->itemAt(1)->widget());
|
2014-03-07 15:42:13 +00:00
|
|
|
}
|
|
|
|
|
2013-09-23 05:24:28 +00:00
|
|
|
void MainWindow::cleanUpEmpty()
|
|
|
|
{
|
2015-02-09 20:58:40 +00:00
|
|
|
information()->clearStats();
|
|
|
|
information()->clearInfo();
|
|
|
|
information()->clearEquipment();
|
|
|
|
information()->updateDiveInfo(true);
|
2015-02-09 21:51:31 +00:00
|
|
|
graphics()->setEmptyState();
|
2015-02-09 20:27:59 +00:00
|
|
|
dive_list()->reload(DiveTripModel::TREE);
|
2015-07-31 00:51:38 +00:00
|
|
|
GlobeGPS::instance()->reload();
|
2013-12-05 12:38:12 +00:00
|
|
|
if (!existing_filename)
|
|
|
|
setTitle(MWTF_DEFAULT);
|
2015-02-03 15:30:08 +00:00
|
|
|
disableShortcuts();
|
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 ||
|
2015-06-26 15:58:47 +00:00
|
|
|
information()->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()
|
|
|
|
{
|
2015-02-09 21:51:31 +00:00
|
|
|
graphics()->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();
|
2015-07-24 20:18:30 +00:00
|
|
|
clear_dive_file_data();
|
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();
|
2014-12-30 20:32:10 +00:00
|
|
|
|
2015-01-29 22:00:19 +00:00
|
|
|
dcList.dcMap.clear();
|
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
|
|
|
}
|
|
|
|
|
2015-02-03 15:30:08 +00:00
|
|
|
void MainWindow::disableShortcuts(bool disablePaste)
|
2013-07-04 15:30:05 +00:00
|
|
|
{
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.actionPreviousDC->setShortcut(QKeySequence());
|
|
|
|
ui.actionNextDC->setShortcut(QKeySequence());
|
2015-02-03 15:30:08 +00:00
|
|
|
ui.copy->setShortcut(QKeySequence());
|
|
|
|
if (disablePaste)
|
|
|
|
ui.paste->setShortcut(QKeySequence());
|
2013-07-04 15:30:05 +00:00
|
|
|
}
|
|
|
|
|
2015-02-03 15:30:08 +00:00
|
|
|
void MainWindow::enableShortcuts()
|
2013-07-04 15:30:05 +00:00
|
|
|
{
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.actionPreviousDC->setShortcut(Qt::Key_Left);
|
|
|
|
ui.actionNextDC->setShortcut(Qt::Key_Right);
|
2015-02-03 15:30:08 +00:00
|
|
|
ui.copy->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_C));
|
|
|
|
ui.paste->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_V));
|
2013-07-04 15:30:05 +00:00
|
|
|
}
|
|
|
|
|
2013-06-27 17:48:03 +00:00
|
|
|
void MainWindow::showProfile()
|
|
|
|
{
|
2015-02-03 15:30:08 +00:00
|
|
|
enableShortcuts();
|
2015-02-09 21:51:31 +00:00
|
|
|
graphics()->setProfileState();
|
2015-02-09 21:19:10 +00:00
|
|
|
setApplicationState("Default");
|
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();
|
2015-10-06 22:02:38 +00:00
|
|
|
PreferencesDialog::instance()->raise();
|
2013-04-09 16:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionQuit_triggered()
|
|
|
|
{
|
2015-02-09 20:58:40 +00:00
|
|
|
if (information()->isEditing()) {
|
|
|
|
information()->rejectChanges();
|
|
|
|
if (information()->isEditing())
|
2014-06-04 01:17:32 +00:00
|
|
|
// 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 ||
|
2015-06-04 03:44:00 +00:00
|
|
|
information()->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;
|
|
|
|
}
|
|
|
|
|
2015-09-23 02:55:48 +00:00
|
|
|
void MainWindow::refreshProfile()
|
|
|
|
{
|
|
|
|
showProfile();
|
2015-10-11 20:24:35 +00:00
|
|
|
configureToolbar();
|
2015-09-23 02:55:48 +00:00
|
|
|
graphics()->replot(get_dive(selected_dive));
|
|
|
|
DivePictureModel::instance()->updateDivePictures();
|
|
|
|
}
|
|
|
|
|
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
|
2015-09-23 02:55:48 +00:00
|
|
|
refreshProfile();
|
2014-07-06 19:36:25 +00:00
|
|
|
refreshDisplay(false);
|
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
|
2015-02-09 21:51:31 +00:00
|
|
|
graphics()->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
|
2015-02-09 20:58:40 +00:00
|
|
|
information()->updateDiveInfo();
|
2014-05-28 18:54:04 +00:00
|
|
|
showProfile();
|
|
|
|
refreshDisplay();
|
|
|
|
}
|
|
|
|
|
2015-06-16 12:37:02 +00:00
|
|
|
void MainWindow::setPlanNotes()
|
2014-06-01 04:14:44 +00:00
|
|
|
{
|
2015-06-16 12:37:02 +00:00
|
|
|
plannerDetails()->divePlanOutput()->setHtml(displayed_dive.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
|
2015-02-09 22:14:08 +00:00
|
|
|
QString diveplan = plannerDetails()->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;
|
|
|
|
|
2015-02-09 22:14:08 +00:00
|
|
|
plannerDetails()->divePlanOutput()->setHtml(withDisclaimer);
|
|
|
|
plannerDetails()->divePlanOutput()->print(&printer);
|
|
|
|
plannerDetails()->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);
|
2015-07-06 19:09:20 +00:00
|
|
|
clear_dive_site(&displayed_dive_site);
|
2014-07-04 14:14:16 +00:00
|
|
|
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()
|
|
|
|
{
|
2015-03-20 04:05:41 +00:00
|
|
|
if (!plannerStateClean() || !current_dive || !current_dive->dc.model)
|
2014-08-19 20:03:53 +00:00
|
|
|
return;
|
2015-03-20 04:05:41 +00:00
|
|
|
else if (strcmp(current_dive->dc.model, "planned dive")) {
|
2015-09-09 09:53:30 +00:00
|
|
|
if (QMessageBox::warning(this, tr("Warning"), tr("Trying to replan a dive that's not a planned dive."),
|
2015-06-04 03:44:00 +00:00
|
|
|
QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Cancel)
|
2015-05-07 20:59:12 +00:00
|
|
|
return;
|
2014-08-19 20:03:53 +00:00
|
|
|
}
|
|
|
|
// 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);
|
|
|
|
|
2015-02-09 21:51:31 +00:00
|
|
|
graphics()->setPlanState();
|
|
|
|
graphics()->clearHandlers();
|
2015-02-09 21:19:10 +00:00
|
|
|
setApplicationState("PlanDive");
|
|
|
|
divePlannerWidget()->setReplanButton(true);
|
2014-08-19 20:03:53 +00:00
|
|
|
DivePlannerPointsModel::instance()->loadFromDive(current_dive);
|
|
|
|
reset_cylinders(&displayed_dive, true);
|
|
|
|
}
|
|
|
|
|
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);
|
2015-02-09 21:19:10 +00:00
|
|
|
setApplicationState("PlanDive");
|
2014-07-04 13:53:33 +00:00
|
|
|
|
2015-02-09 21:51:31 +00:00
|
|
|
graphics()->setPlanState();
|
2014-05-27 18:32:18 +00:00
|
|
|
|
2015-03-19 12:32:43 +00:00
|
|
|
// create a simple starting dive, using the first gas from the just copied cylinders
|
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();
|
2015-02-09 21:19:10 +00:00
|
|
|
divePlannerWidget()->setReplanButton(false);
|
2014-05-25 18:15:57 +00:00
|
|
|
}
|
|
|
|
|
2015-02-09 21:19:10 +00:00
|
|
|
DivePlannerWidget* MainWindow::divePlannerWidget() {
|
|
|
|
return qobject_cast<DivePlannerWidget*>(applicationState["PlanDive"].topLeft);
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2015-02-09 21:19:10 +00:00
|
|
|
setApplicationState("AddDive");
|
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
|
2015-02-09 20:58:40 +00:00
|
|
|
information()->updateDiveInfo();
|
2013-12-03 23:25:20 +00:00
|
|
|
|
2014-07-03 21:45:01 +00:00
|
|
|
// show main tab
|
2015-02-09 20:58:40 +00:00
|
|
|
information()->setCurrentIndex(0);
|
2014-07-03 21:45:01 +00:00
|
|
|
|
2015-02-09 20:58:40 +00:00
|
|
|
information()->addDiveStarted();
|
2014-05-22 02:31:26 +00:00
|
|
|
|
2015-02-09 21:51:31 +00:00
|
|
|
graphics()->setAddState();
|
2013-09-20 12:36:14 +00:00
|
|
|
DivePlannerPointsModel::instance()->createSimpleDive();
|
2015-10-11 20:24:35 +00:00
|
|
|
configureToolbar();
|
2015-02-09 21:51:31 +00:00
|
|
|
graphics()->plotDive();
|
2013-04-09 16:26:23 +00:00
|
|
|
}
|
|
|
|
|
2015-03-25 14:07:42 +00:00
|
|
|
void MainWindow::on_actionEditDive_triggered()
|
|
|
|
{
|
|
|
|
if (information()->isEditing() || DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING) {
|
|
|
|
QMessageBox::warning(this, tr("Warning"), tr("Please, first finish the current edition before trying to do another."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const bool isTripEdit = dive_list()->selectedTrips().count() >= 1;
|
2015-10-08 15:59:37 +00:00
|
|
|
if (!current_dive || isTripEdit || (current_dive->dc.model && strcmp(current_dive->dc.model, "manually added dive"))) {
|
2015-04-08 18:20:12 +00:00
|
|
|
QMessageBox::warning(this, tr("Warning"), tr("Trying to edit a dive that's not a manually added dive."));
|
2015-03-25 14:07:42 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DivePlannerPointsModel::instance()->clear();
|
|
|
|
disableShortcuts();
|
|
|
|
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
|
|
|
|
graphics()->setAddState();
|
2015-07-31 00:51:38 +00:00
|
|
|
GlobeGPS::instance()->endGetDiveCoordinates();
|
2015-03-25 14:07:42 +00:00
|
|
|
setApplicationState("EditDive");
|
|
|
|
DivePlannerPointsModel::instance()->loadFromDive(current_dive);
|
|
|
|
information()->enableEdition(MainTab::MANUALLY_ADDED_DIVE);
|
|
|
|
}
|
|
|
|
|
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"));
|
2015-10-14 11:08:01 +00:00
|
|
|
d.setWindowIcon(QIcon(":/subsurface-icon"));
|
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); \
|
2015-02-09 19:09:06 +00:00
|
|
|
ui.topSplitter->setCollapsible(0, X); \
|
|
|
|
ui.topSplitter->setCollapsible(1, X); \
|
|
|
|
ui.bottomSplitter->setCollapsible(0, X); \
|
|
|
|
ui.bottomSplitter->setCollapsible(1, X);
|
2014-10-31 16:00:52 +00:00
|
|
|
|
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);
|
2015-02-09 19:09:06 +00:00
|
|
|
ui.topSplitter->setSizes(BEHAVIOR << EXPANDED << COLLAPSED);
|
2014-01-16 04:50:56 +00:00
|
|
|
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);
|
2015-02-09 19:09:06 +00:00
|
|
|
ui.topSplitter->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);
|
2015-02-09 19:09:06 +00:00
|
|
|
ui.topSplitter->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);
|
2015-02-09 19:09:06 +00:00
|
|
|
ui.bottomSplitter->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());
|
2015-02-09 19:09:06 +00:00
|
|
|
ui.topSplitter->restoreState(settings.value("topSplitter").toByteArray());
|
|
|
|
ui.bottomSplitter->restoreState(settings.value("bottomSplitter").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);
|
2015-02-09 19:09:06 +00:00
|
|
|
if (ui.topSplitter->sizes().first() == 0 || ui.topSplitter->sizes().last() == 0)
|
|
|
|
ui.topSplitter->setSizes(infoProfileSizes);
|
|
|
|
if (ui.bottomSplitter->sizes().first() == 0 || ui.bottomSplitter->sizes().last() == 0)
|
|
|
|
ui.bottomSplitter->setSizes(listGlobeSizes);
|
2013-11-22 01:52:21 +00:00
|
|
|
|
2013-11-07 16:37:27 +00:00
|
|
|
} else {
|
2014-01-16 04:50:56 +00:00
|
|
|
ui.mainSplitter->setSizes(mainSizes);
|
2015-02-09 19:09:06 +00:00
|
|
|
ui.topSplitter->setSizes(infoProfileSizes);
|
|
|
|
ui.bottomSplitter->setSizes(listGlobeSizes);
|
2013-11-07 16:37:27 +00:00
|
|
|
}
|
2014-10-31 16:00:52 +00:00
|
|
|
ui.mainSplitter->setCollapsible(0, false);
|
|
|
|
ui.mainSplitter->setCollapsible(1, false);
|
2015-02-09 19:09:06 +00:00
|
|
|
ui.topSplitter->setCollapsible(0, false);
|
|
|
|
ui.topSplitter->setCollapsible(1, false);
|
|
|
|
ui.bottomSplitter->setCollapsible(0,false);
|
|
|
|
ui.bottomSplitter->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());
|
2015-02-09 19:09:06 +00:00
|
|
|
settings.setValue("topSplitter", ui.topSplitter->saveState());
|
|
|
|
settings.setValue("bottomSplitter", ui.bottomSplitter->saveState());
|
2013-11-07 16:37:27 +00:00
|
|
|
}
|
|
|
|
|
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;
|
2015-10-11 20:24:35 +00:00
|
|
|
configureToolbar();
|
2015-02-09 21:51:31 +00:00
|
|
|
graphics()->plotDive();
|
2015-02-09 20:58:40 +00:00
|
|
|
information()->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;
|
2015-10-11 20:24:35 +00:00
|
|
|
configureToolbar();
|
2015-02-09 21:51:31 +00:00
|
|
|
graphics()->plotDive();
|
2015-02-09 20:58:40 +00:00
|
|
|
information()->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()
|
|
|
|
{
|
|
|
|
if(!survey) {
|
2014-12-30 15:37:04 +00:00
|
|
|
survey = new UserSurvey(this);
|
2014-12-17 03:59:41 +00:00
|
|
|
}
|
|
|
|
survey->show();
|
|
|
|
}
|
|
|
|
|
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 " ;
|
2015-07-12 17:46:46 +00:00
|
|
|
f += "*.sql *.SQL " ;
|
2014-11-07 17:56:23 +00:00
|
|
|
f += "*.dld *.DLD ";
|
|
|
|
f += "*.jlb *.JLB ";
|
|
|
|
f += "*.lvd *.LVD ";
|
|
|
|
f += "*.sde *.SDE ";
|
|
|
|
f += "*.udcf *.UDCF ";
|
|
|
|
f += "*.uddf *.UDDF ";
|
|
|
|
f += "*.xml *.XML ";
|
2014-12-28 07:58:50 +00:00
|
|
|
f += "*.dlf *.DLF ";
|
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)";
|
2014-12-28 07:58:50 +00:00
|
|
|
f += "Divesoft (*.dlf *.DLF)";
|
Import Datatrak/WLog files
Sequentially parses a file, expected to be a Datatrak/WLog divelog, and
converts the dive info into Subsurface's dive structure.
As my first DC, back in 90s, was an Aladin Air X, the obvious choice of log
software was DTrak (Win version). After using it for some time we moved to WLog
(shareware software more user friendly than Dtrak, printing capable, and still
better, it runs under wine, which, as linux user, was definitive for me). Then,
some years later, my last Aladin died and I moved to an OSTC, forcing me to
look for a software that support this DC.
I found JDivelog which was capable of import Dtrak logs and used it for some
time until discovered Subsurface existence and devoted to it.
The fact was that importing Dtrak dives in JDivelog and then re-importing them
in Subsurface caused a significant data loss (mainly in the profile events and
alarms) and weird location of some other info in the dive notes (mostly tag
items in the original Dtrak software). This situation can't actually be solved
with tools like divelogs.de which causes similar if no greater data loss.
Although this won't be a core feature for Subsurface, I expect it can be useful
for some other divers as has been for me.
Comments and issues:
Datatrak/Wlog files include a lot of diving data which are not directly
supported in Subsurface, in these cases we choose mostly to use "tags".
The lack of some important info in Datatrak archives (e.g. tank's initial
pressure) forces us to do some arbitrary assumptions (e.g. initial pressure =
200 bar).
There might be archives coming directly from old DOS days, as first versions
of Datatrak run on that OS; they were coded CP437 or CP850, while dive logs
coming from Win versions seems to be coded CP1252. Finally, Wlog seems to use a
mixed confusing style. Program directly converts some of the old encoded chars
to iso8859 but is expected there be some issues with non alphabetic chars, e.g.
"ª".
There are two text fields: "Other activities" and "Dive notes", both limited to
256 char size. We have merged them in Subsurface's "Dive Notes" although the
first one could be "tagged", but we're unsure that the user had filled it in
a tag friendly way.
WLog adds some information to the dive and lets the user to write more than
256 chars notes. This is achieved, while keeping compatibility with DTrak
divelogs, by adding a complementary file named equally as the .log file and
with .add extension where all this info is stored. We have, still, not worked
with this complementary files.
This work is based on the paper referenced in butracker #194 which has some
errors (e.g. beginning of log and beginning of dive are changed) and a lot of
bytes of unknown meaning. Example.log shows, at least, one more byte than those
referred in the paper for the O2 Aladin computer, this could be a byte referred
to the use of SCR but the lack of an OC dive with O2 computer makes impossible
for us to compare.
The only way we have figured out to distinguish a priori between SCR and non
SCR dives with O2 computers is that the dives are tagged with a "rebreather"
tag. Obviously this is not a very trusty way of doing things. In SCR dives,
the O2% in mix means, probably, the maximum O2% in the circuit, not the O2%
of the EAN mix in the tanks, which would be unknown in this case.
The list of DCs related in bug #194 paper seems incomplete, we have added
one or two from WLog and discarded those which are known to exist but whose
model is unknown, grouping them under the imaginative name of "unknown". The
list can easily be increased in the future if we ever know the models
identifiers.
BTW, in Example.log, 0x00 identifier is used for some DC dives and from my own
divelogs is inferred that 0x00 is used for manually entered dives, this could
easily be an error in Example.log coming from a preproduction DC model.
Example.log which is shipped in datatrak package is included in dives
directory for testing pourposes.
[Dirk Hohndel: some small cleanups, merged with latest master, support
divesites, remove the pointless memset() before free() calls
add to cmake build]
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-05 18:38:27 +00:00
|
|
|
f += "Datatrak/WLog Files (*.log *.LOG)";
|
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)
|
2015-06-12 13:56:08 +00:00
|
|
|
message = tr("Do you want to save the changes that you made in the file %1?")
|
|
|
|
.arg(displayedFilename(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");
|
2015-10-09 16:03:12 +00:00
|
|
|
if (settings.value("maximized", isMaximized()).value<bool>()) {
|
2013-12-02 10:32:27 +00:00
|
|
|
showMaximized();
|
2015-10-09 16:03:12 +00:00
|
|
|
} else {
|
|
|
|
restoreGeometry(settings.value("geometry").toByteArray());
|
|
|
|
restoreState(settings.value("windowState", 0).toByteArray());
|
|
|
|
}
|
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();
|
2015-10-09 16:03:12 +00:00
|
|
|
show();
|
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);
|
2015-10-06 05:21:44 +00:00
|
|
|
TOOLBOX_PREF_BUTTON(zoomed_plot, zoomed_plot, profScaled);
|
|
|
|
s.endGroup(); // note: why doesn't the list of 17 buttons match the order in the gui?
|
2014-06-12 18:52:59 +00:00
|
|
|
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");
|
2015-09-06 20:59:28 +00:00
|
|
|
default_dive_computer_download_mode = s.value("dive_computer_download_mode").toInt();
|
2014-06-12 18:52:59 +00:00
|
|
|
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);
|
|
|
|
|
2015-07-26 03:49:16 +00:00
|
|
|
#if !defined(SUBSURFACE_MOBILE)
|
2014-06-12 18:52:59 +00:00
|
|
|
loadRecentFiles(&s);
|
2014-06-30 21:42:48 +00:00
|
|
|
if (firstRun) {
|
|
|
|
checkSurvey(&s);
|
|
|
|
firstRun = false;
|
|
|
|
}
|
2015-07-26 03:49:16 +00:00
|
|
|
#endif
|
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
|
2015-02-15 18:25:18 +00:00
|
|
|
QString ver(subsurface_version());
|
2015-01-02 06:50:03 +00:00
|
|
|
int waitTime = 7;
|
2014-06-14 21:45:42 +00:00
|
|
|
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");
|
2015-10-09 16:03:12 +00:00
|
|
|
settings.setValue("geometry", saveGeometry());
|
|
|
|
settings.setValue("windowState", saveState());
|
2013-12-02 10:32:27 +00:00
|
|
|
settings.setValue("maximized", isMaximized());
|
2015-10-09 16:03:12 +00:00
|
|
|
settings.setValue("lastState", (int)state);
|
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 ||
|
2015-06-04 03:44:00 +00:00
|
|
|
information()->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
|
|
|
if (survey && survey->isVisible()) {
|
|
|
|
survey->close();
|
|
|
|
survey->deleteLater();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2015-02-09 20:27:59 +00:00
|
|
|
return qobject_cast<DiveListView*>(applicationState["Default"].bottomLeft);
|
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
|
|
|
{
|
2015-02-09 20:58:40 +00:00
|
|
|
return qobject_cast<MainTab*>(applicationState["Default"].topLeft);
|
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;
|
2015-05-11 22:26:56 +00:00
|
|
|
|
2015-09-20 15:39:15 +00:00
|
|
|
// if the default is to save to cloud storage, pick something that will work as local file:
|
|
|
|
// simply extract the branch name which should be the users email address
|
|
|
|
if (default_filename && strstr(default_filename, prefs.cloud_git_url)) {
|
|
|
|
QString filename(default_filename);
|
|
|
|
filename.remove(prefs.cloud_git_url);
|
|
|
|
filename.remove(0, filename.indexOf("[") + 1);
|
|
|
|
filename.replace("]", ".ssrf");
|
|
|
|
default_filename = strdup(qPrintable(filename));
|
|
|
|
}
|
2015-05-11 22:26:56 +00:00
|
|
|
// create a file dialog that allows us to save to a new file
|
2015-03-21 15:10:55 +00:00
|
|
|
QFileDialog selection_dialog(this, tr("Save file as"), default_filename,
|
2015-06-04 03:44:00 +00:00
|
|
|
tr("Subsurface XML files (*.ssrf *.xml *.XML)"));
|
2015-05-11 22:26:56 +00:00
|
|
|
selection_dialog.setAcceptMode(QFileDialog::AcceptSave);
|
|
|
|
selection_dialog.setFileMode(QFileDialog::AnyFile);
|
2015-05-27 18:14:26 +00:00
|
|
|
selection_dialog.setDefaultSuffix("");
|
2015-10-05 02:34:27 +00:00
|
|
|
if (same_string(default_filename, "")) {
|
|
|
|
QFileInfo defaultFile(system_default_filename());
|
|
|
|
selection_dialog.setDirectory(qPrintable(defaultFile.absolutePath()));
|
|
|
|
}
|
2015-03-21 15:10:55 +00:00
|
|
|
/* if the exit/cancel button is pressed return */
|
|
|
|
if (!selection_dialog.exec())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* get the first selected file */
|
|
|
|
filename = selection_dialog.selectedFiles().at(0);
|
2015-05-27 18:14:26 +00:00
|
|
|
|
|
|
|
/* now for reasons I don't understand we appear to add a .ssrf to
|
|
|
|
* git style filenames <path>/directory[branch]
|
|
|
|
* so let's remove that */
|
2015-06-21 23:28:38 +00:00
|
|
|
QRegularExpression reg(".*\\[[^]]+]\\.ssrf", QRegularExpression::CaseInsensitiveOption);
|
|
|
|
if (reg.match(filename).hasMatch())
|
|
|
|
filename.remove(QRegularExpression("\\.ssrf$", QRegularExpression::CaseInsensitiveOption));
|
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
|
|
|
|
2015-02-09 20:58:40 +00:00
|
|
|
if (information()->isEditing())
|
|
|
|
information()->acceptChanges();
|
2013-11-23 02:40:48 +00:00
|
|
|
|
2014-03-14 17:35:09 +00:00
|
|
|
if (save_dives(filename.toUtf8().data())) {
|
2015-02-27 00:57:56 +00:00
|
|
|
getNotificationWidget()->showNotification(get_error_string(), KMessageWidget::Error);
|
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
|
|
|
|
2015-02-27 00:57:56 +00:00
|
|
|
getNotificationWidget()->showNotification(get_error_string(), KMessageWidget::Error);
|
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;
|
2015-09-28 17:05:20 +00:00
|
|
|
bool is_cloud = false;
|
2013-05-19 22:25:47 +00:00
|
|
|
|
|
|
|
if (!existing_filename)
|
|
|
|
return file_save_as();
|
|
|
|
|
2015-09-28 17:05:20 +00:00
|
|
|
is_cloud = (strncmp(existing_filename, "http", 4) == 0);
|
|
|
|
|
2015-02-09 20:58:40 +00:00
|
|
|
if (information()->isEditing())
|
|
|
|
information()->acceptChanges();
|
2013-11-23 02:40:48 +00:00
|
|
|
|
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
|
|
|
}
|
2015-09-28 17:05:20 +00:00
|
|
|
if (is_cloud)
|
|
|
|
showProgressBar();
|
2014-03-14 17:35:09 +00:00
|
|
|
if (save_dives(existing_filename)) {
|
2015-02-27 00:57:56 +00:00
|
|
|
getNotificationWidget()->showNotification(get_error_string(), KMessageWidget::Error);
|
2015-09-28 17:05:20 +00:00
|
|
|
if (is_cloud)
|
|
|
|
hideProgressBar();
|
2014-03-14 17:19:23 +00:00
|
|
|
return -1;
|
2014-03-14 17:35:09 +00:00
|
|
|
}
|
2015-09-28 17:05:20 +00:00
|
|
|
if (is_cloud)
|
|
|
|
hideProgressBar();
|
2015-02-27 00:57:56 +00:00
|
|
|
getNotificationWidget()->showNotification(get_error_string(), KMessageWidget::Error);
|
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
|
|
|
|
2015-02-26 14:07:39 +00:00
|
|
|
NotificationWidget *MainWindow::getNotificationWidget()
|
|
|
|
{
|
|
|
|
return ui.mainErrorMessage;
|
2013-05-22 06:13:45 +00:00
|
|
|
}
|
2013-06-26 12:13:06 +00:00
|
|
|
|
2015-10-05 22:52:39 +00:00
|
|
|
void MainWindow::showError()
|
|
|
|
{
|
|
|
|
getNotificationWidget()->showNotification(get_error_string(), KMessageWidget::Error);
|
|
|
|
}
|
|
|
|
|
2015-06-12 13:53:00 +00:00
|
|
|
QString MainWindow::displayedFilename(QString fullFilename)
|
|
|
|
{
|
|
|
|
QFile f(fullFilename);
|
|
|
|
QFileInfo fileInfo(f);
|
|
|
|
QString fileName(fileInfo.fileName());
|
|
|
|
|
2015-06-15 13:05:00 +00:00
|
|
|
if (fullFilename.contains(prefs.cloud_git_url))
|
2015-06-12 13:53:00 +00:00
|
|
|
return tr("[cloud storage for] %1").arg(fileName.left(fileName.indexOf('[')));
|
|
|
|
else
|
|
|
|
return fileName;
|
|
|
|
}
|
|
|
|
|
2015-06-16 13:04:34 +00:00
|
|
|
void MainWindow::setAutomaticTitle()
|
|
|
|
{
|
|
|
|
setTitle();
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
2015-06-12 13:48:51 +00:00
|
|
|
QString unsaved = (unsaved_changes() ? " *" : "");
|
2015-06-12 13:53:00 +00:00
|
|
|
setWindowTitle("Subsurface: " + displayedFilename(existing_filename) + unsaved);
|
2013-06-26 12:13:06 +00:00
|
|
|
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)
|
|
|
|
{
|
2015-06-16 19:42:17 +00:00
|
|
|
bool showWarning = false;
|
2015-10-08 06:40:29 +00:00
|
|
|
if (fileNames.isEmpty()) {
|
|
|
|
refreshDisplay();
|
2013-10-04 15:12:46 +00:00
|
|
|
return;
|
2015-10-08 06:40:29 +00:00
|
|
|
}
|
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
|
|
|
|
2015-09-23 19:16:45 +00:00
|
|
|
showProgressBar();
|
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);
|
2015-06-16 19:42:17 +00:00
|
|
|
// if there were any messages, show them
|
|
|
|
QString warning = get_error_string();
|
|
|
|
if (!warning.isEmpty()) {
|
|
|
|
showWarning = true;
|
|
|
|
getNotificationWidget()->showNotification(warning , KMessageWidget::Information);
|
|
|
|
}
|
2014-03-14 18:26:07 +00:00
|
|
|
} else {
|
2014-02-28 09:04:00 +00:00
|
|
|
failedParses.append(fileNames.at(i));
|
2013-09-09 08:59:03 +00:00
|
|
|
}
|
|
|
|
}
|
2015-09-23 19:16:45 +00:00
|
|
|
hideProgressBar();
|
2015-06-16 19:42:17 +00:00
|
|
|
if (!showWarning)
|
|
|
|
getNotificationWidget()->hideNotification();
|
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);
|
2015-06-22 19:14:42 +00:00
|
|
|
|
2015-06-25 17:55:40 +00:00
|
|
|
int min_datafile_version = get_min_datafile_version();
|
|
|
|
if (min_datafile_version >0 && min_datafile_version < DATAFORMAT_VERSION) {
|
2015-06-22 19:14:42 +00:00
|
|
|
QMessageBox::warning(this, tr("Opening datafile from older version"),
|
2015-06-25 17:55:40 +00:00
|
|
|
tr("You opened a data file from an older version of Subsurface. We recommend "
|
2015-09-04 22:25:35 +00:00
|
|
|
"you read the manual to learn about the changes in the new version, especially "
|
|
|
|
"about dive site management which has changed significantly.\n"
|
|
|
|
"Subsurface has already tried to pre-populate the data but it might be worth "
|
|
|
|
"while taking a look at the new dive site management system and to make "
|
2015-06-22 19:14:42 +00:00
|
|
|
"sure that everything looks correct."));
|
|
|
|
}
|
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(),
|
2015-07-12 17:46:46 +00:00
|
|
|
tr("Dive log files (*.ssrf *.can *.csv *.db *.sql *.dld *.jlb *.lvd *.sde *.udcf *.uddf *.xml *.txt *.dlf *.apd"
|
|
|
|
"*.SSRF *.CAN *.CSV *.DB *.SQL *.DLD *.JLB *.LVD *.SDE *.UDCF *.UDDF *.xml *.TXT *.DLF *.APD);;"
|
2015-03-08 19:40:32 +00:00
|
|
|
"Cochran files (*.can *.CAN);;"
|
|
|
|
"CSV files (*.csv *.CSV);;"
|
|
|
|
"DiveLog.de files (*.dld *.DLD);;"
|
|
|
|
"JDiveLog files (*.jlb *.JLB);;"
|
|
|
|
"Liquivision files (*.lvd *.LVD);;"
|
|
|
|
"MkVI files (*.txt *.TXT);;"
|
|
|
|
"Suunto files (*.sde *.db *.SDE *.DB);;"
|
|
|
|
"Divesoft files (*.dlf *.DLF);;"
|
|
|
|
"UDDF/UDCF files (*.uddf *.udcf *.UDDF *.UDCF);;"
|
|
|
|
"XML files (*.xml *.XML);;"
|
|
|
|
"APD log viewer (*.apd *.APD);;"
|
Import Datatrak/WLog files
Sequentially parses a file, expected to be a Datatrak/WLog divelog, and
converts the dive info into Subsurface's dive structure.
As my first DC, back in 90s, was an Aladin Air X, the obvious choice of log
software was DTrak (Win version). After using it for some time we moved to WLog
(shareware software more user friendly than Dtrak, printing capable, and still
better, it runs under wine, which, as linux user, was definitive for me). Then,
some years later, my last Aladin died and I moved to an OSTC, forcing me to
look for a software that support this DC.
I found JDivelog which was capable of import Dtrak logs and used it for some
time until discovered Subsurface existence and devoted to it.
The fact was that importing Dtrak dives in JDivelog and then re-importing them
in Subsurface caused a significant data loss (mainly in the profile events and
alarms) and weird location of some other info in the dive notes (mostly tag
items in the original Dtrak software). This situation can't actually be solved
with tools like divelogs.de which causes similar if no greater data loss.
Although this won't be a core feature for Subsurface, I expect it can be useful
for some other divers as has been for me.
Comments and issues:
Datatrak/Wlog files include a lot of diving data which are not directly
supported in Subsurface, in these cases we choose mostly to use "tags".
The lack of some important info in Datatrak archives (e.g. tank's initial
pressure) forces us to do some arbitrary assumptions (e.g. initial pressure =
200 bar).
There might be archives coming directly from old DOS days, as first versions
of Datatrak run on that OS; they were coded CP437 or CP850, while dive logs
coming from Win versions seems to be coded CP1252. Finally, Wlog seems to use a
mixed confusing style. Program directly converts some of the old encoded chars
to iso8859 but is expected there be some issues with non alphabetic chars, e.g.
"ª".
There are two text fields: "Other activities" and "Dive notes", both limited to
256 char size. We have merged them in Subsurface's "Dive Notes" although the
first one could be "tagged", but we're unsure that the user had filled it in
a tag friendly way.
WLog adds some information to the dive and lets the user to write more than
256 chars notes. This is achieved, while keeping compatibility with DTrak
divelogs, by adding a complementary file named equally as the .log file and
with .add extension where all this info is stored. We have, still, not worked
with this complementary files.
This work is based on the paper referenced in butracker #194 which has some
errors (e.g. beginning of log and beginning of dive are changed) and a lot of
bytes of unknown meaning. Example.log shows, at least, one more byte than those
referred in the paper for the O2 Aladin computer, this could be a byte referred
to the use of SCR but the lack of an OC dive with O2 computer makes impossible
for us to compare.
The only way we have figured out to distinguish a priori between SCR and non
SCR dives with O2 computers is that the dives are tagged with a "rebreather"
tag. Obviously this is not a very trusty way of doing things. In SCR dives,
the O2% in mix means, probably, the maximum O2% in the circuit, not the O2%
of the EAN mix in the tanks, which would be unknown in this case.
The list of DCs related in bug #194 paper seems incomplete, we have added
one or two from WLog and discarded those which are known to exist but whose
model is unknown, grouping them under the imaginative name of "unknown". The
list can easily be increased in the future if we ever know the models
identifiers.
BTW, in Example.log, 0x00 identifier is used for some DC dives and from my own
divelogs is inferred that 0x00 is used for manually entered dives, this could
easily be an error in Example.log coming from a preproduction DC model.
Example.log which is shipped in datatrak package is included in dives
directory for testing pourposes.
[Dirk Hohndel: some small cleanups, merged with latest master, support
divesites, remove the pointless memset() before free() calls
add to cmake build]
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-05 18:38:27 +00:00
|
|
|
"Datatrak/WLog Files (*.log *.LOG);;"
|
2015-04-03 23:07:59 +00:00
|
|
|
"OSTCtools Files (*.dive *.DIVE);;"
|
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());
|
|
|
|
|
2015-02-07 14:42:27 +00:00
|
|
|
QStringList logFiles = fileNames.filter(QRegExp("^.*\\.(?!(csv|txt|apd))", Qt::CaseInsensitive));
|
2014-01-07 20:01:28 +00:00
|
|
|
QStringList csvFiles = fileNames.filter(".csv", Qt::CaseInsensitive);
|
2015-02-07 14:42:27 +00:00
|
|
|
csvFiles += fileNames.filter(".apd", 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()) {
|
2015-01-06 18:11:27 +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") {
|
2015-02-03 15:30:08 +00:00
|
|
|
disableShortcuts();
|
2013-11-09 00:09:46 +00:00
|
|
|
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
|
2015-02-09 21:51:31 +00:00
|
|
|
graphics()->setAddState();
|
2015-02-09 21:19:10 +00:00
|
|
|
setApplicationState("EditDive");
|
2013-11-01 15:48:34 +00:00
|
|
|
DivePlannerPointsModel::instance()->loadFromDive(d);
|
2015-02-09 20:58:40 +00:00
|
|
|
information()->enableEdition(MainTab::MANUALLY_ADDED_DIVE);
|
2014-01-16 04:50:56 +00:00
|
|
|
} else if (defaultDC == "planned dive") {
|
2015-02-03 15:30:08 +00:00
|
|
|
disableShortcuts();
|
2013-12-07 15:25:43 +00:00
|
|
|
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
|
2015-02-09 21:19:10 +00:00
|
|
|
setApplicationState("EditPlannedDive");
|
2013-12-07 15:25:43 +00:00
|
|
|
DivePlannerPointsModel::instance()->loadFromDive(d);
|
2015-02-09 20:58:40 +00:00
|
|
|
information()->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
|
|
|
|
2015-10-06 05:21:44 +00:00
|
|
|
// note: why doesn't the list of 17 buttons match the order in the gui? or the order above? (line 1136)
|
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);
|
2015-10-06 05:21:44 +00:00
|
|
|
// couldn't the args to TOOLBOX_PREF_PROFILE be made to go in the same sequence as TOOLBOX_PREF_BUTTON?
|
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);
|
2015-02-09 20:58:40 +00:00
|
|
|
information()->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
|
|
|
}
|
2015-02-09 08:24:32 +00:00
|
|
|
|
2015-02-10 18:41:15 +00:00
|
|
|
void MainWindow::registerApplicationState(const QByteArray& state, QWidget *topLeft, QWidget *topRight, QWidget *bottomLeft, QWidget *bottomRight)
|
2015-02-09 17:42:32 +00:00
|
|
|
{
|
2015-02-10 18:41:15 +00:00
|
|
|
applicationState[state] = WidgetForQuadrant(topLeft, topRight, bottomLeft, bottomRight);
|
2015-02-10 19:36:16 +00:00
|
|
|
if (ui.topLeft->indexOf(topLeft) == -1 && topLeft) {
|
2015-02-10 17:51:30 +00:00
|
|
|
ui.topLeft->addWidget(topLeft);
|
|
|
|
}
|
2015-02-10 19:36:16 +00:00
|
|
|
if (ui.topRight->indexOf(topRight) == -1 && topRight) {
|
2015-02-10 17:51:30 +00:00
|
|
|
ui.topRight->addWidget(topRight);
|
|
|
|
}
|
2015-02-10 19:36:16 +00:00
|
|
|
if (ui.bottomLeft->indexOf(bottomLeft) == -1 && bottomLeft) {
|
2015-02-10 17:51:30 +00:00
|
|
|
ui.bottomLeft->addWidget(bottomLeft);
|
|
|
|
}
|
2015-02-10 19:36:16 +00:00
|
|
|
if(ui.bottomRight->indexOf(bottomRight) == -1 && bottomRight) {
|
2015-02-10 17:51:30 +00:00
|
|
|
ui.bottomRight->addWidget(bottomRight);
|
|
|
|
}
|
2015-02-09 17:42:32 +00:00
|
|
|
}
|
2015-02-09 19:10:08 +00:00
|
|
|
|
|
|
|
void MainWindow::setApplicationState(const QByteArray& state) {
|
|
|
|
if (!applicationState.keys().contains(state))
|
|
|
|
return;
|
|
|
|
|
2015-08-22 14:05:13 +00:00
|
|
|
if (getCurrentAppState() == state)
|
2015-02-10 17:22:14 +00:00
|
|
|
return;
|
|
|
|
|
2015-08-22 14:05:13 +00:00
|
|
|
setCurrentAppState(state);
|
2015-08-12 10:06:52 +00:00
|
|
|
|
2015-02-10 19:36:16 +00:00
|
|
|
#define SET_CURRENT_INDEX( X ) \
|
|
|
|
if (applicationState[state].X) { \
|
|
|
|
ui.X->setCurrentWidget( applicationState[state].X); \
|
|
|
|
ui.X->show(); \
|
|
|
|
} else { \
|
|
|
|
ui.X->hide(); \
|
|
|
|
}
|
|
|
|
|
|
|
|
SET_CURRENT_INDEX( topLeft )
|
2015-08-21 01:24:49 +00:00
|
|
|
Q_FOREACH(const WidgetProperty& p, stateProperties[state].topLeft) {
|
|
|
|
ui.topLeft->currentWidget()->setProperty( p.first.data(), p.second);
|
|
|
|
}
|
2015-02-10 19:36:16 +00:00
|
|
|
SET_CURRENT_INDEX( topRight )
|
2015-08-21 01:24:49 +00:00
|
|
|
Q_FOREACH(const WidgetProperty& p, stateProperties[state].topRight) {
|
|
|
|
ui.topRight->currentWidget()->setProperty( p.first.data(), p.second);
|
|
|
|
}
|
2015-02-10 19:36:16 +00:00
|
|
|
SET_CURRENT_INDEX( bottomLeft )
|
2015-08-21 01:24:49 +00:00
|
|
|
Q_FOREACH(const WidgetProperty& p, stateProperties[state].bottomLeft) {
|
|
|
|
ui.bottomLeft->currentWidget()->setProperty( p.first.data(), p.second);
|
|
|
|
}
|
2015-02-10 19:36:16 +00:00
|
|
|
SET_CURRENT_INDEX( bottomRight )
|
2015-08-21 01:24:49 +00:00
|
|
|
Q_FOREACH(const WidgetProperty& p, stateProperties[state].bottomRight) {
|
|
|
|
ui.bottomRight->currentWidget()->setProperty( p.first.data(), p.second);
|
|
|
|
}
|
2015-02-10 19:36:16 +00:00
|
|
|
#undef SET_CURRENT_INDEX
|
2015-02-09 19:10:08 +00:00
|
|
|
}
|
2015-08-25 19:49:48 +00:00
|
|
|
|
2015-09-09 20:02:39 +00:00
|
|
|
void MainWindow::showProgressBar()
|
2015-08-25 19:49:48 +00:00
|
|
|
{
|
2015-10-09 21:19:10 +00:00
|
|
|
delete progressDialog;
|
2015-09-09 20:02:39 +00:00
|
|
|
|
|
|
|
progressDialog = new QProgressDialog(tr("Contacting cloud service..."), tr("Cancel"), 0, 100, this);
|
|
|
|
progressDialog->setWindowModality(Qt::WindowModal);
|
2015-09-28 10:54:55 +00:00
|
|
|
progressDialog->setMinimumDuration(200);
|
2015-09-09 20:02:39 +00:00
|
|
|
progressDialogCanceled = false;
|
|
|
|
connect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelCloudStorageOperation()));
|
2015-08-25 19:49:48 +00:00
|
|
|
}
|
|
|
|
|
2015-09-09 20:02:39 +00:00
|
|
|
void MainWindow::cancelCloudStorageOperation()
|
2015-08-25 19:49:48 +00:00
|
|
|
{
|
2015-09-09 20:02:39 +00:00
|
|
|
progressDialogCanceled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::hideProgressBar()
|
|
|
|
{
|
|
|
|
if (progressDialog) {
|
|
|
|
progressDialog->setValue(100);
|
|
|
|
progressDialog->deleteLater();
|
|
|
|
progressDialog = NULL;
|
|
|
|
}
|
2015-08-25 19:49:48 +00:00
|
|
|
}
|