2013-04-13 20:44:02 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/*
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * maintab.cpp
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * classes for the "notebook" area of the main window of Subsurface
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 *
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							
								
									
										
										
										
											2013-04-07 15:20:43 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include "maintab.h"
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-19 00:09:36 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "mainwindow.h"
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-06 20:36:37 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "../helpers.h"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include "../statistics.h"
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-19 00:09:36 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "divelistview.h"
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-22 14:11:49 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "modeldelegates.h"
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-05 11:39:40 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "globe.h"
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-18 23:33:39 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "diveplanner.h"
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-19 14:16:33 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "divelist.h"
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-05 09:48:26 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "qthelper.h"
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-07 12:42:13 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "display.h"
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-02 19:50:42 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "divepicturewidget.h"
							 | 
						
					
						
							
								
									
										
										
										
											2014-12-28 20:24:02 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include "socialnetworks.h"
							 | 
						
					
						
							
								
									
										
										
										
											2013-04-13 10:17:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#include <QLabel>
							 | 
						
					
						
							
								
									
										
										
										
											2013-08-13 10:49:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include <QCompleter>
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-18 20:42:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include <QDebug>
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-14 09:17:46 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include <QSet>
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-28 09:17:30 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include <QSettings>
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-02 16:21:08 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include <QTableView>
							 | 
						
					
						
							
								
									
										
										
										
											2013-08-16 15:38:18 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include <QPalette>
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-11 23:08:56 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include <QScrollBar>
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-03 15:29:28 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include <QShortcut>
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-03 18:01:00 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include <QMessageBox>
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-27 16:17:33 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#include <QDesktopServices>
							 | 
						
					
						
							
								
									
										
										
										
											2013-04-07 15:20:43 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									weightModel(new WeightModel(this)),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									cylindersModel(CylindersModel::instance()),
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-06 11:24:38 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									extraDataModel(new ExtraDataModel(this)),
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-02 19:50:42 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									editMode(NONE),
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-30 08:52:11 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									divePictureModel(DivePictureModel::instance()),
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-08 14:11:06 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									copyPaste(false),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									currentTrip(0)
							 | 
						
					
						
							
								
									
										
										
										
											2013-04-07 15:20:43 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.setupUi(this);
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-16 20:35:22 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.dateEdit->setDisplayFormat(getDateFormat());
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-09 19:49:15 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 11:50:28 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									memset(&displayed_dive, 0, sizeof(displayed_dive));
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-30 08:52:11 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									memset(&displayedTrip, 0, sizeof(displayedTrip));
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-09 19:49:15 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.cylinders->setModel(cylindersModel);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.weights->setModel(weightModel);
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-02 19:50:42 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.photosView->setModel(divePictureModel);
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-27 16:17:33 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									connect(ui.photosView, SIGNAL(photoDoubleClicked(QString)), this, SLOT(photoDoubleClicked(QString)));
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-06 11:24:38 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.extraData->setModel(extraDataModel);
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-03 21:44:48 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									closeMessage();
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-26 17:02:27 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-23 07:41:25 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									QAction *action = new QAction(tr("Apply changes"), this);
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-02 15:33:00 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									connect(action, SIGNAL(triggered(bool)), this, SLOT(acceptChanges()));
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-03 21:44:48 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addMessageAction(action);
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-02 15:33:00 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-23 07:41:25 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									action = new QAction(tr("Discard changes"), this);
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-02 15:33:00 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									connect(action, SIGNAL(triggered(bool)), this, SLOT(rejectChanges()));
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-03 15:29:28 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									QShortcut *closeKey = new QShortcut(QKeySequence(Qt::Key_Escape), this);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									connect(closeKey, SIGNAL(activated()), this, SLOT(escDetected()));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-03 21:44:48 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									addMessageAction(action);
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-02 15:33:00 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-26 17:02:27 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (qApp->style()->objectName() == "oxygen")
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-26 16:51:11 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										setDocumentMode(true);
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-26 17:02:27 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									else
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										setDocumentMode(false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-19 17:38:20 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									// we start out with the fields read-only; once things are
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									// filled from a dive, they are made writeable
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-18 21:56:53 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									setEnabled(false);
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-19 11:45:01 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.location->installEventFilter(this);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.coordinates->installEventFilter(this);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.divemaster->installEventFilter(this);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.buddy->installEventFilter(this);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.suit->installEventFilter(this);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.notes->viewport()->installEventFilter(this);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.rating->installEventFilter(this);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.visibility->installEventFilter(this);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.airtemp->installEventFilter(this);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.watertemp->installEventFilter(this);
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-19 13:52:34 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.dateEdit->installEventFilter(this);
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-26 14:54:16 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.timeEdit->installEventFilter(this);
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-02 02:20:02 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.tagWidget->installEventFilter(this);
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 14:43:20 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									Q_FOREACH (QObject *obj, ui.statisticsTab->children()) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										QLabel *label = qobject_cast<QLabel *>(obj);
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-10 23:56:05 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if (label)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											label->setAlignment(Qt::AlignHCenter);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.cylinders->setTitle(tr("Cylinders"));
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-25 15:47:24 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.cylinders->setBtnToolTip(tr("Add cylinder"));
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									connect(ui.cylinders, SIGNAL(addButtonClicked()), this, SLOT(addCylinder_clicked()));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.weights->setTitle(tr("Weights"));
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-25 15:47:24 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.weights->setBtnToolTip(tr("Add weight system"));
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									connect(ui.weights, SIGNAL(addButtonClicked()), this, SLOT(addWeight_clicked()));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									connect(ui.cylinders->view(), SIGNAL(clicked(QModelIndex)), this, SLOT(editCylinderWidget(QModelIndex)));
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-04 02:04:51 +03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									connect(ui.weights->view(), SIGNAL(clicked(QModelIndex)), this, SLOT(editWeightWidget(QModelIndex)));
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-15 18:52:42 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.cylinders->view()->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate(this));
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-17 14:03:37 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.cylinders->view()->setItemDelegateForColumn(CylindersModel::USE, new TankUseDelegate(this));
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-15 18:52:42 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.weights->view()->setItemDelegateForColumn(WeightModel::TYPE, new WSInfoDelegate(this));
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-22 15:13:58 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.cylinders->view()->setColumnHidden(CylindersModel::DEPTH, true);
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-11 18:46:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									completers.buddy = new QCompleter(&buddyModel, ui.buddy);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									completers.divemaster = new QCompleter(&diveMasterModel, ui.divemaster);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									completers.location = new QCompleter(&locationModel, ui.location);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									completers.suit = new QCompleter(&suitModel, ui.suit);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									completers.tags = new QCompleter(&tagModel, ui.tagWidget);
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-06 20:00:10 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									completers.buddy->setCaseSensitivity(Qt::CaseInsensitive);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									completers.divemaster->setCaseSensitivity(Qt::CaseInsensitive);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									completers.location->setCaseSensitivity(Qt::CaseInsensitive);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									completers.suit->setCaseSensitivity(Qt::CaseInsensitive);
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-15 01:39:02 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									completers.tags->setCaseSensitivity(Qt::CaseInsensitive);
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.buddy->setCompleter(completers.buddy);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.divemaster->setCompleter(completers.divemaster);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.location->setCompleter(completers.location);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.suit->setCompleter(completers.suit);
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-02 02:20:02 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.tagWidget->setCompleter(completers.tags);
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-26 18:14:09 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									setMinimumHeight(0);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									setMinimumWidth(0);
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-27 12:52:01 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									// Current display of things on Gnome3 looks like shit, so
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									// let`s fix that.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									if (isGnome3Session()) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										QPalette p;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										p.setColor(QPalette::Window, QColor(Qt::white));
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.scrollArea->viewport()->setPalette(p);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.scrollArea_2->viewport()->setPalette(p);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.scrollArea_3->viewport()->setPalette(p);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.scrollArea_4->viewport()->setPalette(p);
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-04 18:24:37 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										// GroupBoxes in Gnome3 looks like I'v drawn them...
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										static const QString gnomeCss(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											"QGroupBox {"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											"    background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											"    stop: 0 #E0E0E0, stop: 1 #FFFFFF);"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											"    border: 2px solid gray;"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											"    border-radius: 5px;"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											"    margin-top: 1ex;"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											"}"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											"QGroupBox::title {"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											"    subcontrol-origin: margin;"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											"    subcontrol-position: top center;"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											"    padding: 0 3px;"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											"    background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-07 08:13:55 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											"    stop: 0 #E0E0E0, stop: 1 #FFFFFF);"
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-04 18:24:37 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											"}");
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-22 11:40:22 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										Q_FOREACH (QGroupBox *box, findChildren<QGroupBox *>()) {
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-04 18:24:37 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											box->setStyleSheet(gnomeCss);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										}
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-27 12:52:01 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2014-12-23 10:16:11 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									// QLineEdit and QLabels should have minimal margin on the left and right but not waste vertical space
							 | 
						
					
						
							
								
									
										
										
										
											2015-01-02 12:42:02 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									QMargins margins(3, 2, 1, 0);
							 | 
						
					
						
							
								
									
										
										
										
											2014-12-23 10:16:11 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									Q_FOREACH (QLabel *label, findChildren<QLabel *>()) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										label->setContentsMargins(margins);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-28 09:17:30 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.cylinders->view()->horizontalHeader()->setContextMenuPolicy(Qt::ActionsContextMenu);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									QSettings s;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									s.beginGroup("cylinders_dialog");
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									for (int i = 0; i < CylindersModel::COLUMNS; i++) {
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-28 09:17:30 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if ((i == CylindersModel::REMOVE) || (i == CylindersModel::TYPE))
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											continue;
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-28 09:17:30 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										bool checked = s.value(QString("column%1_hidden").arg(i)).toBool();
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-12 06:07:32 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										action = new QAction(cylindersModel->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString(), ui.cylinders->view());
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-28 09:17:30 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										action->setCheckable(true);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										action->setData(i);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										action->setChecked(!checked);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										connect(action, SIGNAL(triggered(bool)), this, SLOT(toggleTriggeredColumn()));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.cylinders->view()->setColumnHidden(i, checked);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.cylinders->view()->horizontalHeader()->addAction(action);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-06 18:05:54 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									QAction *deletePhoto = new QAction(this);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									deletePhoto->setShortcut(Qt::Key_Delete);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									deletePhoto->setShortcutContext(Qt::WidgetShortcut);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.photosView->addAction(deletePhoto);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.photosView->setSelectionMode(QAbstractItemView::SingleSelection);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									connect(deletePhoto, SIGNAL(triggered(bool)), this, SLOT(removeSelectedPhotos()));
							 | 
						
					
						
							
								
									
										
										
										
											2014-12-28 20:24:02 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									FacebookManager *fb = FacebookManager::instance();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									connect(fb, &FacebookManager::justLoggedIn, ui.facebookPublish, &QPushButton::show);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									connect(fb, &FacebookManager::justLoggedOut, ui.facebookPublish, &QPushButton::hide);
							 | 
						
					
						
							
								
									
										
										
										
											2014-12-28 21:06:07 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									connect(ui.facebookPublish, &QPushButton::clicked, fb, &FacebookManager::sendDive);
							 | 
						
					
						
							
								
									
										
										
										
											2014-12-28 20:24:02 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.facebookPublish->setVisible(fb->loggedIn());
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-28 09:17:30 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								MainTab::~MainTab()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									QSettings s;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									s.beginGroup("cylinders_dialog");
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									for (int i = 0; i < CylindersModel::COLUMNS; i++) {
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-28 09:17:30 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if ((i == CylindersModel::REMOVE) || (i == CylindersModel::TYPE))
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											continue;
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-28 09:17:30 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										s.setValue(QString("column%1_hidden").arg(i), ui.cylinders->view()->isColumnHidden(i));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void MainTab::toggleTriggeredColumn()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									QAction *action = qobject_cast<QAction *>(sender());
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-28 09:17:30 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									int col = action->data().toInt();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									QTableView *view = ui.cylinders->view();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-16 11:50:56 +07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (action->isChecked()) {
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-28 09:17:30 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										view->showColumn(col);
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-16 11:50:56 +07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if (view->columnWidth(col) <= 15)
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-28 09:17:30 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											view->setColumnWidth(col, 80);
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									} else
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-28 09:17:30 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										view->hideColumn(col);
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-27 15:33:43 +03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-22 09:17:18 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-18 23:33:39 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::addDiveStarted()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-27 08:18:53 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									enableEdition(ADD);
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-18 23:33:39 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::addMessageAction(QAction *action)
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-03 21:44:48 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.diveEquipmentMessage->addAction(action);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.diveNotesMessage->addAction(action);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.diveInfoMessage->addAction(action);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.diveStatisticsMessage->addAction(action);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void MainTab::hideMessage()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.diveNotesMessage->animatedHide();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.diveEquipmentMessage->animatedHide();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.diveInfoMessage->animatedHide();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.diveStatisticsMessage->animatedHide();
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-05 11:03:45 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									updateTextLabels(false);
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-03 21:44:48 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void MainTab::closeMessage()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									hideMessage();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.diveNotesMessage->setCloseButtonVisible(false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.diveEquipmentMessage->setCloseButtonVisible(false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.diveInfoMessage->setCloseButtonVisible(false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.diveStatisticsMessage->setCloseButtonVisible(false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void MainTab::displayMessage(QString str)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-04 22:45:17 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.diveNotesMessage->setCloseButtonVisible(false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.diveEquipmentMessage->setCloseButtonVisible(false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.diveInfoMessage->setCloseButtonVisible(false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.diveStatisticsMessage->setCloseButtonVisible(false);
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-03 21:44:48 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.diveNotesMessage->setText(str);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.diveNotesMessage->animatedShow();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.diveEquipmentMessage->setText(str);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.diveEquipmentMessage->animatedShow();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.diveInfoMessage->setText(str);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.diveInfoMessage->animatedShow();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.diveStatisticsMessage->setText(str);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.diveStatisticsMessage->animatedShow();
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-05 11:03:45 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									updateTextLabels();
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-16 23:28:48 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.tagWidget->fixPopupPosition(ui.diveNotesMessage->bestContentHeight());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.buddy->fixPopupPosition(ui.diveNotesMessage->bestContentHeight());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.divemaster->fixPopupPosition(ui.diveNotesMessage->bestContentHeight());
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-10 22:49:08 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void MainTab::updateTextLabels(bool showUnits)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-05 11:03:45 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (showUnits) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-11 00:06:51 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.airTempLabel->setText(tr("Air temp. [%1]").arg(get_temp_unit()));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.waterTempLabel->setText(tr("Water temp. [%1]").arg(get_temp_unit()));
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-10 22:49:08 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									} else {
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-11 00:06:51 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.airTempLabel->setText(tr("Air temp."));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.waterTempLabel->setText(tr("Water temp."));
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-10 22:49:08 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-03 21:44:48 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-01 11:48:34 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::enableEdition(EditMode newEditMode)
							 | 
						
					
						
							
								
									
										
										
										
											2013-08-13 08:34:04 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-03 14:45:01 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (((newEditMode == DIVE || newEditMode == NONE) && current_dive == NULL) || editMode != NONE)
							 | 
						
					
						
							
								
									
										
										
										
											2013-08-13 08:34:04 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										return;
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 21:33:03 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									modified = false;
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-05 06:34:29 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									copyPaste = false;
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-27 08:18:53 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if ((newEditMode == DIVE || newEditMode == NONE) &&
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-03 14:49:17 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									    current_dive->dc.model &&
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-27 08:18:53 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									    strcmp(current_dive->dc.model, "manually added dive") == 0) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										// editCurrentDive will call enableEdition with newEditMode == MANUALLY_ADDED_DIVE
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										// so exit this function here after editCurrentDive() returns
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-03 14:45:01 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										// FIXME : can we get rid of this recursive crap?
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-12 15:22:54 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										MainWindow::instance()->editCurrentDive();
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-27 08:18:53 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										return;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-12 15:22:54 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									MainWindow::instance()->dive_list()->setEnabled(false);
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-04 12:58:21 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									MainWindow::instance()->setEnabledToolbar(false);
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-03 14:45:01 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									// only setup the globe for editing if we are editing exactly one existing dive
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									if (amount_selected == 1 && newEditMode != ADD)
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-07 14:01:05 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										MainWindow::instance()->globe()->prepareForGetDiveCoordinates();
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-03 14:45:01 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-12 15:22:54 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (MainWindow::instance() && MainWindow::instance()->dive_list()->selectedTrips().count() == 1) {
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-18 21:56:53 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										// we are editing trip location and notes
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-03 21:44:48 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										displayMessage(tr("This trip is being edited."));
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-30 08:52:11 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										currentTrip = current_dive->divetrip;
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-19 13:52:34 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.dateEdit->setEnabled(false);
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-18 21:56:53 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										editMode = TRIP;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									} else {
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-23 11:49:28 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.dateEdit->setEnabled(true);
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-05 15:57:24 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if (amount_selected > 1) {
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-03 21:44:48 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											displayMessage(tr("Multiple dives are being edited."));
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-05 15:57:24 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										} else {
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-03 21:44:48 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											displayMessage(tr("This dive is being edited."));
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-05 15:57:24 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										}
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-01 11:48:34 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										editMode = newEditMode != NONE ? newEditMode : DIVE;
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-18 21:56:53 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2013-08-13 08:34:04 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-04-13 10:17:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::clearEquipment()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-10 10:16:32 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									cylindersModel->clear();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									weightModel->clear();
							 | 
						
					
						
							
								
									
										
										
										
											2013-04-13 10:17:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-16 15:12:46 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::nextInputField(QKeyEvent *event)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									keyPressEvent(event);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-04-13 10:17:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::clearInfo()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.sacText->clear();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.otuText->clear();
							 | 
						
					
						
							
								
									
										
										
										
											2014-09-12 11:58:33 -10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.maxcnsText->clear();
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.oxygenHeliumText->clear();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.gasUsedText->clear();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.dateText->clear();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.diveTimeText->clear();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.surfaceIntervalText->clear();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.maximumDepthText->clear();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.averageDepthText->clear();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.waterTemperatureText->clear();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.airTemperatureText->clear();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.airPressureText->clear();
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-10 10:16:32 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.salinityText->clear();
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-02 02:20:02 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.tagWidget->clear();
							 | 
						
					
						
							
								
									
										
										
										
											2013-04-13 10:17:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void MainTab::clearStats()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.depthLimits->clear();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.sacLimits->clear();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.divesAllText->clear();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.tempLimits->clear();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.totalTimeAllText->clear();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.timeLimits->clear();
							 | 
						
					
						
							
								
									
										
										
										
											2013-04-13 10:17:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#define UPDATE_TEXT(d, field)          \
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 22:15:08 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (clear || !d.field)         \
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-21 20:34:15 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.field->setText(QString()); \
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									else                           \
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 14:15:17 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.field->setText(d.field)
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-06 10:16:16 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#define UPDATE_TEMP(d, field)            \
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 14:15:17 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (clear || d.field.mkelvin == 0) \
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.field->setText("");   \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									else                             \
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 14:15:17 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.field->setText(get_temperature_string(d.field, true))
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-20 16:41:42 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-11 06:23:18 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								bool MainTab::isEditing()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									return editMode != NONE;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 14:15:17 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::updateDiveInfo(bool clear)
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-06 13:23:14 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-26 15:17:34 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									// don't execute this while adding / planning a dive
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									if (editMode == ADD || editMode == MANUALLY_ADDED_DIVE || MainWindow::instance()->graphics()->isPlanner())
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-12 16:33:27 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										return;
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 14:15:17 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (!isEnabled() && !clear)
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-18 21:56:53 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										setEnabled(true);
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 14:15:17 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (isEnabled() && clear)
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-22 08:19:05 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										setEnabled(false);
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 22:15:08 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									editMode = IGNORE; // don't trigger on changes to the widgets
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-14 09:17:46 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									// This method updates ALL tabs whenever a new dive or trip is
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									// selected.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									// If exactly one trip has been selected, we show the location / notes
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									// for the trip in the Info tab, otherwise we show the info of the
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									// selected_dive
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-19 22:42:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									temperature_t temp;
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-19 08:08:29 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									struct dive *prevd;
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-27 17:26:22 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									char buf[1024];
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-19 08:08:29 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-19 22:42:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									process_selected_dives();
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 14:15:17 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									process_all_dives(&displayed_dive, &prevd);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									divePictureModel->updateDivePictures();
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-21 20:34:15 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.notes->setText(QString());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									if (!clear) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										QString tmp(displayed_dive.notes);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										if (tmp.indexOf("<table") != -1)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.notes->setHtml(tmp);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										else
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.notes->setPlainText(tmp);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 14:15:17 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									UPDATE_TEXT(displayed_dive, notes);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									UPDATE_TEXT(displayed_dive, location);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									UPDATE_TEXT(displayed_dive, suit);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									UPDATE_TEXT(displayed_dive, divemaster);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									UPDATE_TEXT(displayed_dive, buddy);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									UPDATE_TEMP(displayed_dive, airtemp);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									UPDATE_TEMP(displayed_dive, watertemp);
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 22:15:08 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 14:15:17 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (!clear) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										updateGpsCoordinates(&displayed_dive);
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-29 10:58:35 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										// Subsurface always uses "local time" as in "whatever was the local time at the location"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										// so all time stamps have no time zone information and are in UTC
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-16 20:23:15 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										QDateTime localTime = QDateTime::fromTime_t(displayed_dive.when - gettimezoneoffset(displayed_dive.when));
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-29 10:58:35 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										localTime.setTimeSpec(Qt::UTC);
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-26 16:05:48 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.dateEdit->setDate(localTime.date());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.timeEdit->setTime(localTime.time());
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-12 15:22:54 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if (MainWindow::instance() && MainWindow::instance()->dive_list()->selectedTrips().count() == 1) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-11 00:06:42 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											setTabText(0, tr("Trip notes"));
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-30 08:52:11 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											currentTrip = *MainWindow::instance()->dive_list()->selectedTrips().begin();
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-14 09:17:46 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											// only use trip relevant fields
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.coordinates->setVisible(false);
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-04 20:28:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.CoordinatedLabel->setVisible(false);
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.divemaster->setVisible(false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.DivemasterLabel->setVisible(false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.buddy->setVisible(false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.BuddyLabel->setVisible(false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.suit->setVisible(false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.SuitLabel->setVisible(false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.rating->setVisible(false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.RatingLabel->setVisible(false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.visibility->setVisible(false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.visibilityLabel->setVisible(false);
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-04 20:28:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.tagWidget->setVisible(false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.TagLabel->setVisible(false);
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-30 11:13:40 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.airTempLabel->setVisible(false);
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-07 12:38:35 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.airtemp->setVisible(false);
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-30 11:13:40 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.waterTempLabel->setVisible(false);
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-07 12:38:35 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.watertemp->setVisible(false);
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-14 09:17:46 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											// rename the remaining fields and fill data from selected trip
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-11 00:06:42 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.LocationLabel->setText(tr("Trip location"));
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.location->setText(currentTrip->location);
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-11 00:06:42 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.NotesLabel->setText(tr("Trip notes"));
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.notes->setText(currentTrip->notes);
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-27 17:26:22 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											clearEquipment();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.equipmentTab->setEnabled(false);
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-14 09:17:46 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										} else {
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-11 00:06:42 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											setTabText(0, tr("Dive notes"));
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-30 08:52:11 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											currentTrip = NULL;
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-14 09:17:46 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											// make all the fields visible writeable
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.coordinates->setVisible(true);
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-04 20:28:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.CoordinatedLabel->setVisible(true);
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.divemaster->setVisible(true);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.buddy->setVisible(true);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.suit->setVisible(true);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.SuitLabel->setVisible(true);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.rating->setVisible(true);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.RatingLabel->setVisible(true);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.visibility->setVisible(true);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.visibilityLabel->setVisible(true);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.BuddyLabel->setVisible(true);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.DivemasterLabel->setVisible(true);
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-04 20:28:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.TagLabel->setVisible(true);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.tagWidget->setVisible(true);
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-30 11:13:40 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.airTempLabel->setVisible(true);
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-07 12:38:35 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.airtemp->setVisible(true);
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-30 11:13:40 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.waterTempLabel->setVisible(true);
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-07 12:38:35 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.watertemp->setVisible(true);
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-14 09:17:46 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											/* and fill them from the dive */
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 14:15:17 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.rating->setCurrentStars(displayed_dive.rating);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.visibility->setCurrentStars(displayed_dive.visibility);
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-14 09:17:46 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											// reset labels in case we last displayed trip notes
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.LocationLabel->setText(tr("Location"));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.NotesLabel->setText(tr("Notes"));
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-27 17:26:22 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.equipmentTab->setEnabled(true);
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 22:38:08 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											cylindersModel->updateDive();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											weightModel->updateDive();
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-06 11:24:38 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											extraDataModel->updateDive();
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 14:15:17 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											taglist_get_tagstring(displayed_dive.tag_list, buf, 1024);
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-27 17:26:22 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.tagWidget->setText(QString(buf));
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-14 09:17:46 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										}
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 14:15:17 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.maximumDepthText->setText(get_depth_string(displayed_dive.maxdepth, true));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.averageDepthText->setText(get_depth_string(displayed_dive.meandepth, true));
							 | 
						
					
						
							
								
									
										
										
										
											2014-09-12 11:58:33 -10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.maxcnsText->setText(QString("%1\%").arg(displayed_dive.maxcns));
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 14:15:17 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.otuText->setText(QString("%1").arg(displayed_dive.otu));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.waterTemperatureText->setText(get_temperature_string(displayed_dive.watertemp, true));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.airTemperatureText->setText(get_temperature_string(displayed_dive.airtemp, true));
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-09 22:37:49 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										volume_t gases[MAX_CYLINDERS] = {};
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 14:15:17 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										get_gas_used(&displayed_dive, gases);
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												Make gas use statistics be coherent and more complete
The gas use logic in the dive statistics page is confused.
The SAC case had a special case for "unknown", but only for
the first gas. Other gases had the normal empty case.
Also, the logic was really odd - if you had gases that weren't used (or
pressures not known) intermixed with gases you *did* have pressure for,
the statistics got really confused.
The list of gases showed all gases that we know about during the dive,
but then the gas use and SAC-rate lists wouldn't necessarily match,
because the loops that computed those stopped after the first gas that
didn't have any pressure change.
To make things worse, the first cylinder was special-cased again, so it
all lined up for the single-cylinder case.
This makes all the cylinders act the same way, leaving unknown gas use
(and thus SAC) just empty for that gas.
It also fixes the SAC calculation case where we don't have real samples,
and the profile is a fake profile - possibly with gas changes in between
the fake points. We now make the SAC calculations match what we show -
which is admittedly not at all necessarily what the dive was, but at
least we're consistent.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
											
										 
										
											2014-07-30 10:08:33 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										QString volumes;
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-19 22:50:02 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										int mean[MAX_CYLINDERS], duration[MAX_CYLINDERS];
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 14:15:17 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										per_cylinder_mean_depth(&displayed_dive, select_dc(&displayed_dive), mean, duration);
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-19 22:50:02 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										volume_t sac;
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												Make gas use statistics be coherent and more complete
The gas use logic in the dive statistics page is confused.
The SAC case had a special case for "unknown", but only for
the first gas. Other gases had the normal empty case.
Also, the logic was really odd - if you had gases that weren't used (or
pressures not known) intermixed with gases you *did* have pressure for,
the statistics got really confused.
The list of gases showed all gases that we know about during the dive,
but then the gas use and SAC-rate lists wouldn't necessarily match,
because the loops that computed those stopped after the first gas that
didn't have any pressure change.
To make things worse, the first cylinder was special-cased again, so it
all lined up for the single-cylinder case.
This makes all the cylinders act the same way, leaving unknown gas use
(and thus SAC) just empty for that gas.
It also fixes the SAC calculation case where we don't have real samples,
and the profile is a fake profile - possibly with gas changes in between
the fake points. We now make the SAC calculations match what we show -
which is admittedly not at all necessarily what the dive was, but at
least we're consistent.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
											
										 
										
											2014-07-30 10:08:33 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										QString gaslist, SACs, separator;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										gaslist = ""; SACs = ""; volumes = ""; separator = "";
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										for (int i = 0; i < MAX_CYLINDERS; i++) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											if (!is_cylinder_used(&displayed_dive, i))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												continue;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											gaslist.append(separator); volumes.append(separator); SACs.append(separator);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											separator = "\n";
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											gaslist.append(gasname(&displayed_dive.cylinder[i].gasmix));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											if (!gases[i].mliter)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												continue;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											volumes.append(get_volume_string(gases[i], true));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											if (duration[i]) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 14:15:17 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
												sac.mliter = gases[i].mliter / (depth_to_atm(mean[i], &displayed_dive) * duration[i] / 60);
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												Make gas use statistics be coherent and more complete
The gas use logic in the dive statistics page is confused.
The SAC case had a special case for "unknown", but only for
the first gas. Other gases had the normal empty case.
Also, the logic was really odd - if you had gases that weren't used (or
pressures not known) intermixed with gases you *did* have pressure for,
the statistics got really confused.
The list of gases showed all gases that we know about during the dive,
but then the gas use and SAC-rate lists wouldn't necessarily match,
because the loops that computed those stopped after the first gas that
didn't have any pressure change.
To make things worse, the first cylinder was special-cased again, so it
all lined up for the single-cylinder case.
This makes all the cylinders act the same way, leaving unknown gas use
(and thus SAC) just empty for that gas.
It also fixes the SAC calculation case where we don't have real samples,
and the profile is a fake profile - possibly with gas changes in between
the fake points. We now make the SAC calculations match what we show -
which is admittedly not at all necessarily what the dive was, but at
least we're consistent.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
											
										 
										
											2014-07-30 10:08:33 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
												SACs.append(get_volume_string(sac, true).append(tr("/min")));
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-19 22:50:02 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										}
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-20 00:29:32 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.gasUsedText->setText(volumes);
							 | 
						
					
						
							
								
									
										
											 
										 
										
											
												Make gas use statistics be coherent and more complete
The gas use logic in the dive statistics page is confused.
The SAC case had a special case for "unknown", but only for
the first gas. Other gases had the normal empty case.
Also, the logic was really odd - if you had gases that weren't used (or
pressures not known) intermixed with gases you *did* have pressure for,
the statistics got really confused.
The list of gases showed all gases that we know about during the dive,
but then the gas use and SAC-rate lists wouldn't necessarily match,
because the loops that computed those stopped after the first gas that
didn't have any pressure change.
To make things worse, the first cylinder was special-cased again, so it
all lined up for the single-cylinder case.
This makes all the cylinders act the same way, leaving unknown gas use
(and thus SAC) just empty for that gas.
It also fixes the SAC calculation case where we don't have real samples,
and the profile is a fake profile - possibly with gas changes in between
the fake points. We now make the SAC calculations match what we show -
which is admittedly not at all necessarily what the dive was, but at
least we're consistent.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
											
										 
										
											2014-07-30 10:08:33 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.oxygenHeliumText->setText(gaslist);
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 14:15:17 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.dateText->setText(get_short_dive_date_string(displayed_dive.when));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.diveTimeText->setText(QString::number((int)((displayed_dive.duration.seconds + 30) / 60)));
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-19 08:08:29 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if (prevd)
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 14:15:17 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.surfaceIntervalText->setText(get_time_string(displayed_dive.when - (prevd->when + prevd->duration.seconds), 4));
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-14 19:36:41 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										else
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.surfaceIntervalText->clear();
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-19 22:50:02 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if (mean[0])
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.sacText->setText(SACs);
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-08 12:08:00 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										else
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.sacText->clear();
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 14:15:17 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if (displayed_dive.surface_pressure.mbar)
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-08 12:08:00 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											/* this is ALWAYS displayed in mbar */
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 14:15:17 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.airPressureText->setText(QString("%1mbar").arg(displayed_dive.surface_pressure.mbar));
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-08 12:08:00 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										else
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.airPressureText->clear();
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 14:15:17 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if (displayed_dive.salinity)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.salinityText->setText(QString("%1g/l").arg(displayed_dive.salinity / 10.0));
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-10 10:16:32 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										else
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.salinityText->clear();
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-15 09:30:42 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.depthLimits->setMaximum(get_depth_string(stats_selection.max_depth, true));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.depthLimits->setMinimum(get_depth_string(stats_selection.min_depth, true));
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-09 20:32:44 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										// the overall average depth is really confusing when listed between the
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										// deepest and shallowest dive - let's just not set it
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										// ui.depthLimits->setAverage(get_depth_string(stats_selection.avg_depth, true));
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-11 00:06:42 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.depthLimits->overrideMaxToolTipText(tr("Deepest dive"));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.depthLimits->overrideMinToolTipText(tr("Shallowest dive"));
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-17 18:40:08 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if (amount_selected > 1 && stats_selection.max_sac.mliter)
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-06 07:38:18 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.sacLimits->setMaximum(get_volume_string(stats_selection.max_sac, true).append(tr("/min")));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										else
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.sacLimits->setMaximum("");
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-17 18:40:08 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if (amount_selected > 1 && stats_selection.min_sac.mliter)
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-06 07:38:18 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.sacLimits->setMinimum(get_volume_string(stats_selection.min_sac, true).append(tr("/min")));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										else
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.sacLimits->setMinimum("");
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										if (stats_selection.avg_sac.mliter)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.sacLimits->setAverage(get_volume_string(stats_selection.avg_sac, true).append(tr("/min")));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										else
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.sacLimits->setAverage("");
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-17 18:40:08 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.sacLimits->overrideMaxToolTipText(tr("Highest total SAC of a dive"));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.sacLimits->overrideMinToolTipText(tr("Lowest total SAC of a dive"));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.sacLimits->overrideAvgToolTipText(tr("Average total SAC of all selected dives"));
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.divesAllText->setText(QString::number(stats_selection.selection_size));
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-19 22:42:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										temp.mkelvin = stats_selection.max_temp;
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-15 09:30:42 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.tempLimits->setMaximum(get_temperature_string(temp, true));
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-19 22:42:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										temp.mkelvin = stats_selection.min_temp;
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-15 09:30:42 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.tempLimits->setMinimum(get_temperature_string(temp, true));
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-19 22:42:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if (stats_selection.combined_temp && stats_selection.combined_count) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											const char *unit;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											get_temp_units(0, &unit);
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											ui.tempLimits->setAverage(QString("%1%2").arg(stats_selection.combined_temp / stats_selection.combined_count, 0, 'f', 1).arg(unit));
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-19 22:42:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										}
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-17 18:40:08 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.tempLimits->overrideMaxToolTipText(tr("Highest temperature"));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.tempLimits->overrideMinToolTipText(tr("Lowest temperature"));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.tempLimits->overrideAvgToolTipText(tr("Average temperature of all selected dives"));
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.totalTimeAllText->setText(get_time_string(stats_selection.total_time.seconds, 0));
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-19 22:42:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										int seconds = stats_selection.total_time.seconds;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										if (stats_selection.selection_size)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											seconds /= stats_selection.selection_size;
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.timeLimits->setAverage(get_time_string(seconds, 0));
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-17 18:40:08 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if (amount_selected > 1) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.timeLimits->setMaximum(get_time_string(stats_selection.longest_time.seconds, 0));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.timeLimits->setMinimum(get_time_string(stats_selection.shortest_time.seconds, 0));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.timeLimits->overrideMaxToolTipText(tr("Longest dive"));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.timeLimits->overrideMinToolTipText(tr("Shortest dive"));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.timeLimits->overrideAvgToolTipText(tr("Average length of all selected dives"));
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-09 22:45:44 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										// now let's get some gas use statistics
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										QVector<QPair<QString, int> > gasUsed;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										QString gasUsedString;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										volume_t vol;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										selectedDivesGasUsed(gasUsed);
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-10 11:45:20 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										for (int j = 0; j < 20; j++) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-09 22:45:44 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											if (gasUsed.isEmpty())
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												break;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											QPair<QString, int> gasPair = gasUsed.last();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											gasUsed.pop_back();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											vol.mliter = gasPair.second;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											gasUsedString.append(gasPair.first).append(": ").append(get_volume_string(vol, true)).append("\n");
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										if (!gasUsed.isEmpty())
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											gasUsedString.append("...");
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-29 20:01:56 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										volume_t o2_tot = {}, he_tot = {};
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										selected_dives_gas_parts(&o2_tot, &he_tot);
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-06 05:34:43 +03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										/* No need to show the gas mixing information if diving
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										 * with pure air, and only display the he / O2 part when
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										 * it is used.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										 */
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										if (he_tot.mliter || o2_tot.mliter) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-16 21:37:06 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											gasUsedString.append(tr("These gases could be\nmixed from Air and using:\n"));
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-06 05:34:43 +03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											if (he_tot.mliter)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												gasUsedString.append(QString("He: %1").arg(get_volume_string(he_tot, true)));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											if (he_tot.mliter && o2_tot.mliter)
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-16 21:37:06 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
												gasUsedString.append(tr(" and "));
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-06 05:34:43 +03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											if (o2_tot.mliter)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												gasUsedString.append(QString("O2: %2\n").arg(get_volume_string(o2_tot, true)));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										}
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-09 22:45:44 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.gasConsumption->setText(gasUsedString);
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-08 12:08:00 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									} else {
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-19 17:38:20 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										/* clear the fields */
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-10 10:16:32 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										clearInfo();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										clearStats();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										clearEquipment();
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.rating->setCurrentStars(0);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.coordinates->clear();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.visibility->setCurrentStars(0);
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-08 12:08:00 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 22:15:08 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									editMode = NONE;
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-05 17:40:50 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.cylinders->view()->hideColumn(CylindersModel::DEPTH);
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-17 14:03:37 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (get_dive_dc(&displayed_dive, dc_number)->dctype == CCR)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.cylinders->view()->showColumn(CylindersModel::USE);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									else
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.cylinders->view()->hideColumn(CylindersModel::USE);
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-06 13:23:14 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-22 09:40:26 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::addCylinder_clicked()
							 | 
						
					
						
							
								
									
										
										
										
											2013-04-13 10:17:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-16 11:50:56 +07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (editMode == NONE)
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-25 15:05:48 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										enableEdition();
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-22 14:52:38 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									cylindersModel->add();
							 | 
						
					
						
							
								
									
										
										
										
											2013-04-13 10:17:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-22 09:40:26 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::addWeight_clicked()
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-01 14:30:34 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-16 11:50:56 +07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (editMode == NONE)
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-25 15:05:48 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										enableEdition();
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-22 14:52:38 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									weightModel->add();
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-01 14:30:34 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-04-13 10:17:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::reload()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-11 18:46:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									suitModel.updateModel();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									buddyModel.updateModel();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									locationModel.updateModel();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									diveMasterModel.updateModel();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									tagModel.updateModel();
							 | 
						
					
						
							
								
									
										
										
										
											2013-04-07 15:20:43 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-18 20:42:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-07 13:00:33 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								// tricky little macro to edit all the selected dives
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// loop over all dives, for each selected dive do WHAT, but do it
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// last for the current dive; this is required in case the invocation
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								// wants to compare things to the original value in current_dive like it should
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 11:50:28 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#define MODIFY_SELECTED_DIVES(WHAT)                            \
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-07 13:00:33 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									do {                                                 \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										struct dive *mydive = NULL;                  \
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-20 06:37:19 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										int _i;                                      \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										for_each_dive (_i, mydive) {                 \
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-02 18:13:50 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											if (!mydive->selected || mydive == cd) \
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-07 13:00:33 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
												continue;                    \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
															     \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											WHAT;                                \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										}                                            \
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-02 18:13:50 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										mydive = cd;                                 \
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-07 13:00:33 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										WHAT;                                        \
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-02 18:13:50 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										mark_divelist_changed(true);                 \
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-07 13:00:33 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									} while (0)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-05 06:34:29 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#define EDIT_TEXT(what)                                          \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									if (same_string(mydive->what, cd->what) || copyPaste) {  \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										free(mydive->what);                              \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										mydive->what = copy_string(displayed_dive.what); \
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-07 13:00:33 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-05 06:34:29 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#define EDIT_VALUE(what)                             \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									if (mydive->what == cd->what || copyPaste) { \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										mydive->what = displayed_dive.what;  \
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-07 13:00:33 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-18 21:56:53 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::acceptChanges()
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-18 20:42:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-03 14:45:01 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									int i, addedId = -1;
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-02 18:13:50 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									struct dive *d;
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-03 09:47:24 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									bool do_replot = false;
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-18 22:38:38 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									tabBar()->setTabIcon(0, QIcon()); // Notes
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									tabBar()->setTabIcon(1, QIcon()); // Equipment
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-23 11:49:28 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.dateEdit->setEnabled(true);
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-03 21:44:48 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									hideMessage();
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-27 17:26:22 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.equipmentTab->setEnabled(true);
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-09 06:35:27 -10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									on_location_editingFinished(); // complete coordinates *before* saving
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-03 14:45:01 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (editMode == ADD) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-03 13:12:47 -10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										// We need to add the dive we just created to the dive list and select it.
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-03 14:45:01 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										// Easy, right?
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										struct dive *added_dive = clone_dive(&displayed_dive);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										record_dive(added_dive);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										addedId = added_dive->id;
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-21 17:58:15 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										// unselect everything as far as the UI is concerned and select the new
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										// dive - we'll have to undo/redo this later after we resort the dive_table
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										// but we need the dive selected for the middle part of this function - this
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										// way we can reuse the code used for editing dives
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-03 14:45:01 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										MainWindow::instance()->dive_list()->unselectDives();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										selected_dive = get_divenr(added_dive);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										amount_selected = 1;
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-24 08:20:34 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									} else if (MainWindow::instance() && MainWindow::instance()->dive_list()->selectedTrips().count() == 1) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-03 14:45:01 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										/* now figure out if things have changed */
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-30 08:52:11 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if (!same_string(displayedTrip.notes, currentTrip->notes)) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-11 21:41:47 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											currentTrip->notes = copy_string(displayedTrip.notes);
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-02 18:13:50 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											mark_divelist_changed(true);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										}
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-30 08:52:11 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if (!same_string(displayedTrip.location, currentTrip->location)) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-11 21:41:47 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											currentTrip->location = copy_string(displayedTrip.location);
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-15 09:30:42 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											mark_divelist_changed(true);
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-02 18:13:50 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										}
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-30 08:52:11 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										currentTrip = NULL;
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-19 13:52:34 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.dateEdit->setEnabled(true);
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-19 09:00:57 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									} else {
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-31 14:41:30 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if (editMode == MANUALLY_ADDED_DIVE) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											// preserve any changes to the profile
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											free(current_dive->dc.sample);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											copy_samples(&displayed_dive.dc, ¤t_dive->dc);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										}
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-02 18:13:50 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										struct dive *cd = current_dive;
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-19 18:37:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										//Reset coordinates field, in case it contains garbage.
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 11:50:28 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										updateGpsCoordinates(&displayed_dive);
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-02 18:13:50 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										// now check if something has changed and if yes, edit the selected dives that
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										// were identical with the master dive shown (and mark the divelist as changed)
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 11:50:28 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if (!same_string(displayed_dive.buddy, cd->buddy))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											MODIFY_SELECTED_DIVES(EDIT_TEXT(buddy));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										if (!same_string(displayed_dive.suit, cd->suit))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											MODIFY_SELECTED_DIVES(EDIT_TEXT(suit));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										if (!same_string(displayed_dive.notes, cd->notes))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											MODIFY_SELECTED_DIVES(EDIT_TEXT(notes));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										if (!same_string(displayed_dive.divemaster, cd->divemaster))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											MODIFY_SELECTED_DIVES(EDIT_TEXT(divemaster));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										if (displayed_dive.rating != cd->rating)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											MODIFY_SELECTED_DIVES(EDIT_VALUE(rating));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										if (displayed_dive.visibility != cd->visibility)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											MODIFY_SELECTED_DIVES(EDIT_VALUE(visibility));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										if (displayed_dive.airtemp.mkelvin != cd->airtemp.mkelvin)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											MODIFY_SELECTED_DIVES(EDIT_VALUE(airtemp.mkelvin));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										if (displayed_dive.watertemp.mkelvin != cd->watertemp.mkelvin)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											MODIFY_SELECTED_DIVES(EDIT_VALUE(watertemp.mkelvin));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										if (displayed_dive.when != cd->when) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-09 06:35:27 -10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											time_t offset = cd->when - displayed_dive.when;
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 11:50:28 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											MODIFY_SELECTED_DIVES(mydive->when -= offset;);
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-20 16:41:42 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										}
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-09 06:35:27 -10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if (displayed_dive.latitude.udeg != cd->latitude.udeg ||
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										    displayed_dive.longitude.udeg != cd->longitude.udeg)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											MODIFY_SELECTED_DIVES(
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-05 06:34:29 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
												if (copyPaste ||
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												    (same_string(mydive->location, cd->location) &&
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												     mydive->latitude.udeg == cd->latitude.udeg &&
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												     mydive->longitude.udeg == cd->longitude.udeg))
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-09 06:35:27 -10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
													gpsHasChanged(mydive, cd, ui.coordinates->text(), 0);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										if (!same_string(displayed_dive.location, cd->location))
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 11:50:28 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											MODIFY_SELECTED_DIVES(EDIT_TEXT(location));
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-09 06:35:27 -10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-08 18:18:33 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										saveTags();
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-03 14:45:01 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										if (editMode != ADD && cylindersModel->changed) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-15 09:30:42 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											mark_divelist_changed(true);
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 11:50:28 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											MODIFY_SELECTED_DIVES(
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-25 14:59:11 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
												for (int i = 0; i < MAX_CYLINDERS; i++) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-02 18:13:50 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
													if (mydive != cd) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-05 06:34:29 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
														if (same_string(mydive->cylinder[i].type.description, cd->cylinder[i].type.description) || copyPaste) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
															// if we started out with the same cylinder description (for multi-edit) or if we do copt & paste
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
															// make sure that we have the same cylinder type and copy the gasmix, but DON'T copy the start
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
															// and end pressures (those are per dive after all)
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-04 14:18:27 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
															if (!same_string(mydive->cylinder[i].type.description, displayed_dive.cylinder[i].type.description)) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
																free((void*)mydive->cylinder[i].type.description);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
																mydive->cylinder[i].type.description = copy_string(displayed_dive.cylinder[i].type.description);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
															}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
															mydive->cylinder[i].type.size = displayed_dive.cylinder[i].type.size;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
															mydive->cylinder[i].type.workingpressure = displayed_dive.cylinder[i].type.workingpressure;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
															mydive->cylinder[i].gasmix = displayed_dive.cylinder[i].gasmix;
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-17 10:45:14 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
															mydive->cylinder[i].cylinder_use = displayed_dive.cylinder[i].cylinder_use;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
															mydive->cylinder[i].depth = displayed_dive.cylinder[i].depth;
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-04 14:18:27 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
														}
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-02 18:13:50 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
													}
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-25 14:57:41 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
												}
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-02 18:13:50 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											);
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-04 14:18:27 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											for (int i = 0; i < MAX_CYLINDERS; i++) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												// copy the cylinder but make sure we have our own copy of the strings
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												free((void*)cd->cylinder[i].type.description);
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 20:29:14 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
												cd->cylinder[i] = displayed_dive.cylinder[i];
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-04 14:18:27 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
												cd->cylinder[i].type.description = copy_string(displayed_dive.cylinder[i].type.description);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											}
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-03 09:47:24 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											do_replot = true;
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-25 14:57:41 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										if (weightModel->changed) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-15 09:30:42 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											mark_divelist_changed(true);
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 11:50:28 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											MODIFY_SELECTED_DIVES(
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-01 15:52:23 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
												for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-17 10:41:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
													if (mydive != cd && (copyPaste || same_string(mydive->weightsystem[i].description, cd->weightsystem[i].description))) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 11:50:28 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
														mydive->weightsystem[i] = displayed_dive.weightsystem[i];
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-17 10:41:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
														mydive->weightsystem[i].description = copy_string(displayed_dive.weightsystem[i].description);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
													}
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-25 14:57:41 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
												}
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-02 18:13:50 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											);
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-17 10:41:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 20:29:14 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
												cd->weightsystem[i] = displayed_dive.weightsystem[i];
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-17 10:41:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
												cd->weightsystem[i].description = copy_string(displayed_dive.weightsystem[i].description);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											}
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-02 18:13:50 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										// each dive that was selected might have had the temperatures in its active divecomputer changed
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										// so re-populate the temperatures - easiest way to do this is by calling fixup_dive
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										for_each_dive (i, d) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											if (d->selected)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												fixup_dive(d);
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-25 14:57:41 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										}
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-19 11:45:01 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-19 14:16:33 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (current_dive->divetrip) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										current_dive->divetrip->when = current_dive->when;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										find_new_trip_start_time(current_dive->divetrip);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-01 11:48:34 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (editMode == ADD || editMode == MANUALLY_ADDED_DIVE) {
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-18 23:33:39 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										fixup_dive(current_dive);
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-18 14:12:05 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										set_dive_nr_for_current_dive();
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-12 15:22:54 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										MainWindow::instance()->showProfile();
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-15 09:30:42 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										mark_divelist_changed(true);
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-08 22:09:46 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::NOTHING);
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-18 23:33:39 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-12 15:22:54 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									int scrolledBy = MainWindow::instance()->dive_list()->verticalScrollBar()->sliderPosition();
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-25 14:36:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									resetPallete();
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-16 11:50:56 +07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (editMode == ADD || editMode == MANUALLY_ADDED_DIVE) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-21 17:58:15 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										// since a newly added dive could be in the middle of the dive_table we need
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										// to resort the dive list and make sure the newly added dive gets selected again
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-24 08:20:34 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										sort_table(&dive_table);
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-03 21:05:08 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										MainWindow::instance()->dive_list()->reload(DiveTripModel::CURRENT, true);
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-03 14:45:01 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										int newDiveNr = get_divenr(get_dive_by_uniq_id(addedId));
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-21 17:58:15 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										MainWindow::instance()->dive_list()->unselectDives();
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-03 14:45:01 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										MainWindow::instance()->dive_list()->selectDive(newDiveNr, true);
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-03 21:25:20 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										editMode = NONE;
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-12 15:22:54 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										MainWindow::instance()->refreshDisplay();
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-09 10:59:31 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										MainWindow::instance()->graphics()->replot();
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-21 20:34:06 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										emit addDiveFinished();
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-10 06:17:15 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									} else {
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-03 21:25:20 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										editMode = NONE;
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-03 09:47:24 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if (do_replot)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											MainWindow::instance()->graphics()->replot();
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-12 15:22:54 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										MainWindow::instance()->dive_list()->rememberSelection();
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-03 20:34:05 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										sort_table(&dive_table);
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-07 10:23:08 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										MainWindow::instance()->refreshDisplay();
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-12 15:22:54 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										MainWindow::instance()->dive_list()->restoreSelection();
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-03 20:34:05 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-19 19:43:34 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::NOTHING);
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-12 15:22:54 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									MainWindow::instance()->dive_list()->verticalScrollBar()->setSliderPosition(scrolledBy);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									MainWindow::instance()->dive_list()->setFocus();
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 20:33:48 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									cylindersModel->changed = false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									weightModel->changed = false;
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-04 12:58:21 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									MainWindow::instance()->setEnabledToolbar(true);
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-25 14:36:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void MainTab::resetPallete()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2013-08-16 15:38:18 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									QPalette p;
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.buddy->setPalette(p);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.notes->setPalette(p);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.location->setPalette(p);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.coordinates->setPalette(p);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.divemaster->setPalette(p);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.suit->setPalette(p);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.airtemp->setPalette(p);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.watertemp->setPalette(p);
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-19 13:52:34 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.dateEdit->setPalette(p);
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-26 14:54:16 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.timeEdit->setPalette(p);
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-02 02:20:02 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.tagWidget->setPalette(p);
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-18 20:42:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#define EDIT_TEXT2(what, text)         \
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-16 23:50:42 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									textByteArray = text.toUtf8(); \
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									free(what);                    \
							 | 
						
					
						
							
								
									
										
										
										
											2013-08-16 13:31:52 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									what = strdup(textByteArray.data());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 11:50:28 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#define FREE_IF_DIFFERENT(what)              \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									if (displayed_dive.what != cd->what) \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										free(displayed_dive.what)
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-03 18:12:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-18 21:56:53 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::rejectChanges()
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-18 20:42:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-12 14:41:29 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									EditMode lastMode = editMode;
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 21:33:03 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									if (lastMode != NONE && current_dive &&
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									    (modified ||
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									     memcmp(¤t_dive->cylinder[0], &displayed_dive.cylinder[0], sizeof(cylinder_t) * MAX_CYLINDERS) ||
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									     memcmp(¤t_dive->cylinder[0], &displayed_dive.weightsystem[0], sizeof(weightsystem_t) * MAX_WEIGHTSYSTEMS))) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-11 09:21:38 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if (QMessageBox::warning(MainWindow::instance(), TITLE_OR_TEXT(tr("Discard the changes?"),
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-03 18:01:00 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
																	       tr("You are about to discard your changes.")),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
													 QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard) != QMessageBox::Discard) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											return;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-23 11:49:28 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									ui.dateEdit->setEnabled(true);
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-27 20:31:18 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									editMode = NONE;
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-18 22:38:38 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									tabBar()->setTabIcon(0, QIcon()); // Notes
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									tabBar()->setTabIcon(1, QIcon()); // Equipment
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-03 21:44:48 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									hideMessage();
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-25 14:36:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									resetPallete();
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-06 12:36:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									// no harm done to call cancelPlan even if we were not in ADD or PLAN mode...
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									DivePlannerPointsModel::instance()->cancelPlan();
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-16 19:44:06 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if(lastMode == ADD)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										MainWindow::instance()->dive_list()->restoreSelection();
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-06 12:36:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									// now make sure that the correct dive is displayed
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									if (selected_dive >= 0)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										copy_dive(current_dive, &displayed_dive);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									else
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										clear_dive(&displayed_dive);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									updateDiveInfo(selected_dive < 0);
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-02 22:05:52 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									DivePictureModel::instance()->updateDivePictures();
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-01 21:26:18 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									// the user could have edited the location and then canceled the edit
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									// let's get the correct location back in view
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-07 13:58:07 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									MainWindow::instance()->globe()->centerOnCurrentDive();
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-06 12:36:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									MainWindow::instance()->globe()->reload();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									// show the profile and dive info
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									MainWindow::instance()->graphics()->replot();
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-04 12:58:21 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									MainWindow::instance()->setEnabledToolbar(true);
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-15 20:33:48 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									cylindersModel->changed = false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									weightModel->changed = false;
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-06 12:36:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									cylindersModel->updateDive();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									weightModel->updateDive();
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-06 11:24:38 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									extraDataModel->updateDive();
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-18 20:42:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							
								
									
										
										
										
											2013-08-16 13:31:52 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#undef EDIT_TEXT2
							 | 
						
					
						
							
								
									
										
										
										
											2013-08-16 15:52:40 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 21:33:03 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::markChangedWidget(QWidget *w)
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2013-08-16 15:38:18 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									QPalette p;
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-24 09:49:38 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									qreal h, s, l, a;
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 22:15:08 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									enableEdition();
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-24 09:49:38 -02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									qApp->palette().color(QPalette::Text).getHslF(&h, &s, &l, &a);
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									p.setBrush(QPalette::Base, (l <= 0.3) ? QColor(Qt::yellow).lighter() : (l <= 0.6) ? QColor(Qt::yellow).light() : /* else */ QColor(Qt::yellow).darker(300));
							 | 
						
					
						
							
								
									
										
										
										
											2013-08-16 15:52:40 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									w->setPalette(p);
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 22:15:08 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (!modified) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										modified = true;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										enableEdition();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2013-08-16 15:52:40 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-18 20:42:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-15 22:35:14 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::on_buddy_textChanged()
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-18 20:42:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 22:15:08 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (editMode == IGNORE)
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-02 18:13:50 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										return;
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-26 15:09:01 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									QStringList text_list = ui.buddy->toPlainText().split(",", QString::SkipEmptyParts);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									for (int i = 0; i < text_list.size(); i++)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										text_list[i] = text_list[i].trimmed();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									QString text = text_list.join(", ");
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 21:31:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									free(displayed_dive.buddy);
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 11:50:28 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									displayed_dive.buddy = strdup(text.toUtf8().data());
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									markChangedWidget(ui.buddy);
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-18 20:42:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-19 19:30:47 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::on_divemaster_textChanged()
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-18 20:42:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 22:15:08 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (editMode == IGNORE)
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-02 18:13:50 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										return;
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-26 15:09:01 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									QStringList text_list = ui.divemaster->toPlainText().split(",", QString::SkipEmptyParts);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									for (int i = 0; i < text_list.size(); i++)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										text_list[i] = text_list[i].trimmed();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									QString text = text_list.join(", ");
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 21:31:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									free(displayed_dive.divemaster);
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 11:50:28 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									displayed_dive.divemaster = strdup(text.toUtf8().data());
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									markChangedWidget(ui.divemaster);
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-18 20:42:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::on_airtemp_textChanged(const QString &text)
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-20 16:41:42 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 22:15:08 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (editMode == IGNORE)
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-02 18:13:50 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										return;
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 11:50:28 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									displayed_dive.airtemp.mkelvin = parseTemperatureToMkelvin(text);
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									markChangedWidget(ui.airtemp);
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-13 18:19:15 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									validate_temp_field(ui.airtemp, text);
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-20 16:41:42 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::on_watertemp_textChanged(const QString &text)
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-20 16:41:42 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 22:15:08 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (editMode == IGNORE)
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-02 18:13:50 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										return;
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 11:50:28 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									displayed_dive.watertemp.mkelvin = parseTemperatureToMkelvin(text);
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									markChangedWidget(ui.watertemp);
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-13 18:19:15 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									validate_temp_field(ui.watertemp, text);
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-20 16:41:42 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-22 11:40:22 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::validate_temp_field(QLineEdit *tempField, const QString &text)
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-13 18:19:15 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									static bool missing_unit = false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									static bool missing_precision = false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									if (!text.contains(QRegExp("^[-+]{0,1}[0-9]+([,.][0-9]+){0,1}(°[CF]){0,1}$")) &&
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									    !text.isEmpty() &&
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									    !text.contains(QRegExp("^[-+]$"))) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										if (text.contains(QRegExp("^[-+]{0,1}[0-9]+([,.][0-9]+){0,1}(°)$")) && !missing_unit) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											if (!missing_unit) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												missing_unit = true;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												return;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										if (text.contains(QRegExp("^[-+]{0,1}[0-9]+([,.]){0,1}(°[CF]){0,1}$")) && !missing_precision) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											if (!missing_precision) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												missing_precision = true;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												return;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										QPalette p;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										p.setBrush(QPalette::Base, QColor(Qt::red).lighter());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										tempField->setPalette(p);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									} else {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										missing_unit = false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										missing_precision = false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-06 13:56:46 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-26 14:57:25 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::on_dateEdit_dateChanged(const QDate &date)
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-20 16:41:42 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 22:15:08 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (editMode == IGNORE)
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-02 18:13:50 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										return;
							 | 
						
					
						
							
								
									
										
										
										
											2014-10-20 17:25:13 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									markChangedWidget(ui.dateEdit);
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-29 10:58:35 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									QDateTime dateTime = QDateTime::fromTime_t(displayed_dive.when - gettimezoneoffset(displayed_dive.when));
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-26 14:57:25 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									dateTime.setTimeSpec(Qt::UTC);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									dateTime.setDate(date);
							 | 
						
					
						
							
								
									
										
										
										
											2014-10-20 17:25:13 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									DivePlannerPointsModel::instance()->getDiveplan().when = displayed_dive.when = dateTime.toTime_t();
							 | 
						
					
						
							
								
									
										
										
										
											2014-10-20 17:36:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									emit dateTimeChanged();
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-20 16:41:42 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-26 14:54:16 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::on_timeEdit_timeChanged(const QTime &time)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 22:15:08 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (editMode == IGNORE)
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-26 14:54:16 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										return;
							 | 
						
					
						
							
								
									
										
										
										
											2014-10-20 17:25:13 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									markChangedWidget(ui.timeEdit);
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-29 10:58:35 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									QDateTime dateTime = QDateTime::fromTime_t(displayed_dive.when - gettimezoneoffset(displayed_dive.when));
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-26 14:57:25 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									dateTime.setTimeSpec(Qt::UTC);
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-26 14:54:16 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									dateTime.setTime(time);
							 | 
						
					
						
							
								
									
										
										
										
											2014-10-20 17:25:13 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									DivePlannerPointsModel::instance()->getDiveplan().when = displayed_dive.when = dateTime.toTime_t();
							 | 
						
					
						
							
								
									
										
										
										
											2014-10-20 17:36:24 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									emit dateTimeChanged();
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-26 14:54:16 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-06 13:56:46 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								// changing the tags on multiple dives is semantically strange - what's the right thing to do?
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-02 02:20:02 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::saveTags()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-02 18:13:50 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									struct dive *cd = current_dive;
							 | 
						
					
						
							
								
									
										
										
										
											2014-10-30 13:01:09 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									taglist_free(displayed_dive.tag_list);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									displayed_dive.tag_list = NULL;
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-10 09:39:51 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									Q_FOREACH (const QString& tag, ui.tagWidget->getBlockStringList())
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-09 08:43:49 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										taglist_add_tag(&displayed_dive.tag_list, tag.toUtf8().data());
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-10 09:39:51 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									taglist_cleanup(&displayed_dive.tag_list);
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 11:50:28 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									MODIFY_SELECTED_DIVES(
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-22 11:40:22 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										QString tag;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										taglist_free(mydive->tag_list);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										mydive->tag_list = NULL;
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-02 18:13:50 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										Q_FOREACH (tag, ui.tagWidget->getBlockStringList())
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-08 18:45:20 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											taglist_add_tag(&mydive->tag_list, tag.toUtf8().data());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									);
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-02 02:20:02 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void MainTab::on_tagWidget_textChanged()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 22:15:08 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (editMode == IGNORE)
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-02 18:13:50 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										return;
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-08 18:45:20 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									markChangedWidget(ui.tagWidget);
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-02 02:20:02 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::on_location_textChanged(const QString &text)
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-18 20:42:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 22:15:08 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (editMode == IGNORE)
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-07 23:51:39 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										return;
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-30 08:52:11 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (currentTrip) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										free(displayedTrip.location);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										displayedTrip.location = strdup(ui.location->text().toUtf8().data());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									} else {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										free(displayed_dive.location);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										displayed_dive.location = strdup(ui.location->text().toUtf8().data());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									markChangedWidget(ui.location);
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-18 20:42:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-09 06:35:27 -10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								// If we have GPS data for the location entered, add it.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void MainTab::on_location_editingFinished()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-16 07:09:11 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									// if we have a location and no GPS data, look up the GPS data;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									// but if the GPS data was intentionally cleared then don't
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-30 08:52:11 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (!currentTrip &&
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									    !same_string(displayed_dive.location, "") &&
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-16 07:09:11 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									    ui.coordinates->text().trimmed().isEmpty() &&
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									    !(editMode == DIVE && dive_has_gps_location(current_dive))) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-09 06:35:27 -10:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										struct dive *dive;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										int i = 0;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										for_each_dive (i, dive) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											if (same_string(displayed_dive.location, dive->location) &&
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											    (dive->latitude.udeg || dive->longitude.udeg)) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												displayed_dive.latitude = dive->latitude;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												displayed_dive.longitude = dive->longitude;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												MainWindow::instance()->globe()->reload();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												updateGpsCoordinates(&displayed_dive);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												break;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::on_suit_textChanged(const QString &text)
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-18 20:42:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 22:15:08 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (editMode == IGNORE)
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-02 18:13:50 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										return;
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 21:31:55 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									free(displayed_dive.suit);
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 11:50:28 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									displayed_dive.suit = strdup(text.toUtf8().data());
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									markChangedWidget(ui.suit);
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-18 20:42:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void MainTab::on_notes_textChanged()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 22:15:08 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (editMode == IGNORE)
							 | 
						
					
						
							
								
									
										
										
										
											2013-08-16 13:31:52 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										return;
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-30 08:52:11 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (currentTrip) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										free(displayedTrip.notes);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										displayedTrip.notes = strdup(ui.notes->toPlainText().toUtf8().data());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									} else {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										free(displayed_dive.notes);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										if (ui.notes->toHtml().indexOf("<table") != -1)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											displayed_dive.notes = strdup(ui.notes->toHtml().toUtf8().data());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										else
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											displayed_dive.notes = strdup(ui.notes->toPlainText().toUtf8().data());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									markChangedWidget(ui.notes);
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-18 20:42:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::on_coordinates_textChanged(const QString &text)
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-17 21:50:15 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 22:15:08 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (editMode == IGNORE)
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-02 18:13:50 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										return;
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-23 14:56:40 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									bool gpsChanged = false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									bool parsed = false;
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-07 15:14:01 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									QPalette p;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.coordinates->setPalette(p); // reset palette
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 11:50:28 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									gpsChanged = gpsHasChanged(&displayed_dive, current_dive, text, &parsed);
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-07 15:14:01 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (gpsChanged)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										markChangedWidget(ui.coordinates); // marks things yellow
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									if (!parsed) {
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-19 18:37:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										p.setBrush(QPalette::Base, QColor(Qt::red).lighter());
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-07 15:14:01 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.coordinates->setPalette(p); // marks things red
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-19 18:37:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-17 21:50:15 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-18 20:42:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::on_rating_valueChanged(int value)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 21:33:03 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (displayed_dive.rating != value) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										displayed_dive.rating = value;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										modified = true;
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 22:15:08 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										enableEdition();
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 21:33:03 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-18 20:42:59 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-20 06:25:16 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void MainTab::on_visibility_valueChanged(int value)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 21:33:03 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (displayed_dive.visibility != value) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										displayed_dive.visibility = value;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										modified = true;
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 22:15:08 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										enableEdition();
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 21:33:03 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-20 06:25:16 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-16 14:36:23 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-02 21:33:03 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#undef MODIFY_SELECTED_DIVES
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-06 13:56:46 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								#undef EDIT_TEXT
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#undef EDIT_VALUE
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::editCylinderWidget(const QModelIndex &index)
							 | 
						
					
						
							
								
									
										
										
										
											2013-07-17 12:13:04 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-01 10:18:21 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									// we need a local copy or bad things happen when enableEdition() is called
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									QModelIndex editIndex = index;
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-15 15:14:59 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (cylindersModel->changed && editMode == NONE) {
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-25 14:11:38 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										enableEdition();
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-15 15:14:59 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										return;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-01 10:18:21 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (editIndex.isValid() && editIndex.column() != CylindersModel::REMOVE) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-15 15:14:59 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if (editMode == NONE)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											enableEdition();
							 | 
						
					
						
							
								
									
										
										
										
											2014-07-01 10:18:21 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.cylinders->edit(editIndex);
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-15 15:14:59 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2013-07-17 12:13:04 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::editWeightWidget(const QModelIndex &index)
							 | 
						
					
						
							
								
									
										
										
										
											2013-07-17 12:13:04 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-25 14:11:38 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (editMode == NONE)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										enableEdition();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-02 16:21:08 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (index.isValid() && index.column() != WeightModel::REMOVE)
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-03 11:54:25 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										ui.weights->edit(index);
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-16 14:36:23 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-07 11:48:14 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-19 04:12:31 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::updateCoordinatesText(qreal lat, qreal lon)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									int ulat = rint(lat * 1000000);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									int ulon = rint(lon * 1000000);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									ui.coordinates->setText(printGPSCoords(ulat, ulon));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-12 00:21:45 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::updateGpsCoordinates(const struct dive *dive)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-13 22:23:59 +09:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									if (dive) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.coordinates->setText(printGPSCoords(dive->latitude.udeg, dive->longitude.udeg));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.coordinates->setModified(dive->latitude.udeg || dive->longitude.udeg);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									} else {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.coordinates->clear();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-12 00:21:45 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-07 15:12:45 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-03 15:29:28 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								void MainTab::escDetected()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									if (editMode != NONE)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										rejectChanges();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-27 16:17:33 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void MainTab::photoDoubleClicked(const QString filePath)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									QDesktopServices::openUrl(QUrl::fromLocalFile(filePath));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-06 18:05:54 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void MainTab::removeSelectedPhotos()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									if (!ui.photosView->selectionModel()->hasSelection())
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										return;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									QModelIndex photoIndex = ui.photosView->selectionModel()->selectedIndexes().first();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									QString fileUrl = photoIndex.data(Qt::DisplayPropertyRole).toString();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									DivePictureModel::instance()->removePicture(fileUrl);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-17 08:26:09 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#define SHOW_SELECTIVE(_component) \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									if (what._component)       \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui._component->setText(displayed_dive._component);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void MainTab::showAndTriggerEditSelective(struct dive_components what)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									// take the data in our copyPasteDive and apply it to selected dives
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									enableEdition();
							 | 
						
					
						
							
								
									
										
										
										
											2014-11-05 06:34:29 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									copyPaste = true;
							 | 
						
					
						
							
								
									
										
										
										
											2014-08-17 08:26:09 -06:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									SHOW_SELECTIVE(location);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									SHOW_SELECTIVE(buddy);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									SHOW_SELECTIVE(divemaster);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									SHOW_SELECTIVE(suit);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									if (what.notes) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										QString tmp(displayed_dive.notes);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										if (tmp.contains("<table"))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.notes->setHtml(tmp);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										else
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											ui.notes->setPlainText(tmp);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									if (what.rating)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.rating->setCurrentStars(displayed_dive.rating);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									if (what.visibility)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.visibility->setCurrentStars(displayed_dive.visibility);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									if (what.gps)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										updateGpsCoordinates(&displayed_dive);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									if (what.tags) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										char buf[1024];
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										taglist_get_tagstring(displayed_dive.tag_list, buf, 1024);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										ui.tagWidget->setText(QString(buf));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									if (what.cylinders) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										cylindersModel->updateDive();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										cylindersModel->changed = true;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									if (what.weights) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										weightModel->updateDive();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										weightModel->changed = true;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 |