summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/divecomponentselection.ui172
-rw-r--r--qt-ui/divelistview.cpp2
-rw-r--r--qt-ui/divelogexportdialog.cpp85
-rw-r--r--qt-ui/divelogexportdialog.h6
-rw-r--r--qt-ui/divelogexportdialog.ui10
-rw-r--r--qt-ui/diveplanner.cpp26
-rw-r--r--qt-ui/downloadfromdivecomputer.cpp4
-rw-r--r--qt-ui/downloadfromdivecomputer.ui19
-rw-r--r--qt-ui/maintab.cpp50
-rw-r--r--qt-ui/maintab.h2
-rw-r--r--qt-ui/mainwindow.cpp35
-rw-r--r--qt-ui/mainwindow.h5
-rw-r--r--qt-ui/mainwindow.ui54
-rw-r--r--qt-ui/models.cpp10
-rw-r--r--qt-ui/models.h4
-rw-r--r--qt-ui/plannerSettings.ui22
-rw-r--r--qt-ui/preferences.cpp1
-rw-r--r--qt-ui/preferences.ui12
-rw-r--r--qt-ui/profile/profilewidget2.cpp42
-rw-r--r--qt-ui/profile/profilewidget2.h2
-rw-r--r--qt-ui/profile/tankitem.cpp105
-rw-r--r--qt-ui/profile/tankitem.h38
-rw-r--r--qt-ui/simplewidgets.cpp44
-rw-r--r--qt-ui/simplewidgets.h14
-rw-r--r--qt-ui/usersurvey.cpp1
25 files changed, 705 insertions, 60 deletions
diff --git a/qt-ui/divecomponentselection.ui b/qt-ui/divecomponentselection.ui
new file mode 100644
index 000000000..dbd0839ba
--- /dev/null
+++ b/qt-ui/divecomponentselection.ui
@@ -0,0 +1,172 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DiveComponentSelectionDialog</class>
+ <widget class="QDialog" name="DiveComponentSelectionDialog">
+ <property name="windowModality">
+ <enum>Qt::WindowModal</enum>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>308</width>
+ <height>263</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="windowTitle">
+ <string>Component selection</string>
+ </property>
+ <property name="windowIcon">
+ <iconset>
+ <normalon>:/subsurface-icon</normalon>
+ </iconset>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Which components would you like to copy</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QCheckBox" name="location">
+ <property name="text">
+ <string>Location</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QCheckBox" name="suit">
+ <property name="text">
+ <string>Suit</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QCheckBox" name="gps">
+ <property name="text">
+ <string>GPS coordinates</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QCheckBox" name="divemaster">
+ <property name="text">
+ <string>Divemaster</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QCheckBox" name="buddy">
+ <property name="text">
+ <string>Buddy</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QCheckBox" name="rating">
+ <property name="text">
+ <string>Rating</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0">
+ <widget class="QCheckBox" name="visibility">
+ <property name="text">
+ <string>Visibility</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0">
+ <widget class="QCheckBox" name="notes">
+ <property name="text">
+ <string>Notes</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QCheckBox" name="tags">
+ <property name="text">
+ <string>Tags</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QCheckBox" name="weights">
+ <property name="text">
+ <string>Weights</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QCheckBox" name="cylinders">
+ <property name="text">
+ <string>Cylinders</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources>
+ <include location="../subsurface.qrc"/>
+ </resources>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>DiveComponentSelectionDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>DiveComponentSelectionDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp
index d58f31284..8d771b5df 100644
--- a/qt-ui/divelistview.cpp
+++ b/qt-ui/divelistview.cpp
@@ -383,7 +383,7 @@ void DiveListView::reloadHeaderActions()
QString settingName = QString("showColumn%1").arg(i);
QAction *a = new QAction(title, header());
bool showHeaderFirstRun = !(
- i == DiveTripModel::MAXCNS || i == DiveTripModel::NITROX || i == DiveTripModel::OTU || i == DiveTripModel::TEMPERATURE || i == DiveTripModel::TOTALWEIGHT || i == DiveTripModel::SUIT || i == DiveTripModel::CYLINDER || i == DiveTripModel::SAC);
+ i == DiveTripModel::MAXCNS || i == DiveTripModel::GAS || i == DiveTripModel::OTU || i == DiveTripModel::TEMPERATURE || i == DiveTripModel::TOTALWEIGHT || i == DiveTripModel::SUIT || i == DiveTripModel::CYLINDER || i == DiveTripModel::SAC);
bool shown = s.value(settingName, showHeaderFirstRun).toBool();
a->setCheckable(true);
a->setChecked(shown);
diff --git a/qt-ui/divelogexportdialog.cpp b/qt-ui/divelogexportdialog.cpp
index 03bdaf9cb..99669d6d4 100644
--- a/qt-ui/divelogexportdialog.cpp
+++ b/qt-ui/divelogexportdialog.cpp
@@ -45,6 +45,15 @@ DiveLogExportDialog::DiveLogExportDialog(QWidget *parent) : QDialog(parent),
if (settings.contains("themeSelection")) {
ui->themeSelection->setCurrentIndex(settings.value("themeSelection").toInt());
}
+ if (settings.contains("subsurfaceNumbers")) {
+ ui->exportSubsurfaceNumber->setChecked(settings.value("subsurfaceNumbers").toBool());
+ }
+ if (settings.contains("yearlyStatistics")) {
+ ui->exportStatistics->setChecked(settings.value("yearlyStatistics").toBool());
+ }
+ if (settings.contains("listOnly")) {
+ ui->exportListOnly->setChecked(settings.value("listOnly").toBool());
+ }
settings.endGroup();
}
@@ -86,6 +95,7 @@ void DiveLogExportDialog::exportHtmlInit(const QString &filename)
QString json_dive_data = exportFiles + QDir::separator() + "file.json";
QString json_settings = exportFiles + QDir::separator() + "settings.json";
+ QString translation = exportFiles + QDir::separator() + "translation.json";
QString stat_file = exportFiles + QDir::separator() + "stat.json";
QString photos_directory = exportFiles + QDir::separator() + "photos" + QDir::separator();
mainDir.mkdir(photos_directory);
@@ -93,6 +103,8 @@ void DiveLogExportDialog::exportHtmlInit(const QString &filename)
exportHTMLsettings(json_settings);
exportHTMLstatistics(stat_file);
+ export_translation(translation.toUtf8().data());
+
export_HTML(json_dive_data.toUtf8().data(), photos_directory.toUtf8().data(), ui->exportSelectedDives->isChecked(), ui->exportListOnly->isChecked());
QString searchPath = getSubsurfaceDataPath("theme");
@@ -121,6 +133,9 @@ void DiveLogExportDialog::exportHTMLsettings(const QString &filename)
settings.setValue("fontSelection", ui->fontSelection->currentIndex());
settings.setValue("fontSizeSelection", ui->fontSizeSelection->currentIndex());
settings.setValue("themeSelection", ui->themeSelection->currentIndex());
+ settings.setValue("subsurfaceNumbers", ui->exportSubsurfaceNumber->isChecked());
+ settings.setValue("yearlyStatistics", ui->exportStatistics->isChecked());
+ settings.setValue("listOnly", ui->exportListOnly->isChecked());
settings.endGroup();
QString fontSize = ui->fontSizeSelection->currentText();
@@ -138,32 +153,64 @@ void DiveLogExportDialog::exportHTMLstatistics(const QString &filename)
QFile file(filename);
file.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream out(&file);
+
+ stats_t total_stats;
+
+ total_stats.selection_size = 0;
+ total_stats.total_time.seconds = 0;
+
int i = 0;
out << "divestat=[";
- while (stats_yearly != NULL && stats_yearly[i].period) {
- out << "{";
- out << "\"YEAR\":\"" << stats_yearly[i].period << "\",";
- out << "\"DIVES\":\"" << stats_yearly[i].selection_size << "\",";
- out << "\"TOTAL_TIME\":\"" << get_time_string(stats_yearly[i].total_time.seconds, 0) << "\",";
- out << "\"AVERAGE_TIME\":\"" << get_minutes(stats_yearly[i].total_time.seconds / stats_yearly[i].selection_size) << "\",";
- out << "\"SHORTEST_TIME\":\"" << get_minutes(stats_yearly[i].shortest_time.seconds) << "\",";
- out << "\"LONGEST_TIME\":\"" << get_minutes(stats_yearly[i].longest_time.seconds) << "\",";
- out << "\"AVG_DEPTH\":\"" << get_depth_string(stats_yearly[i].avg_depth) << "\",";
- out << "\"MIN_DEPTH\":\"" << get_depth_string(stats_yearly[i].min_depth) << "\",";
- out << "\"MAX_DEPTH\":\"" << get_depth_string(stats_yearly[i].max_depth) << "\",";
- out << "\"AVG_SAC\":\"" << get_volume_string(stats_yearly[i].avg_sac) << "\",";
- out << "\"MIN_SAC\":\"" << get_volume_string(stats_yearly[i].min_sac) << "\",";
- out << "\"MAX_SAC\":\"" << get_volume_string(stats_yearly[i].max_sac) << "\",";
- out << "\"AVG_TEMP\":\"" << QString::number(stats_yearly[i].combined_temp / stats_yearly[i].combined_count, 'f', 1) << "\",";
- out << "\"MIN_TEMP\":\"" << get_temp_units(stats_yearly[i].min_temp, NULL) << "\",";
- out << "\"MAX_TEMP\":\"" << get_temp_units(stats_yearly[i].max_temp, NULL) << "\",";
- out << "},";
- i++;
+ if (ui->exportStatistics->isChecked()) {
+ while (stats_yearly != NULL && stats_yearly[i].period) {
+ out << "{";
+ out << "\"YEAR\":\"" << stats_yearly[i].period << "\",";
+ out << "\"DIVES\":\"" << stats_yearly[i].selection_size << "\",";
+ out << "\"TOTAL_TIME\":\"" << get_time_string(stats_yearly[i].total_time.seconds, 0) << "\",";
+ out << "\"AVERAGE_TIME\":\"" << get_minutes(stats_yearly[i].total_time.seconds / stats_yearly[i].selection_size) << "\",";
+ out << "\"SHORTEST_TIME\":\"" << get_minutes(stats_yearly[i].shortest_time.seconds) << "\",";
+ out << "\"LONGEST_TIME\":\"" << get_minutes(stats_yearly[i].longest_time.seconds) << "\",";
+ out << "\"AVG_DEPTH\":\"" << get_depth_string(stats_yearly[i].avg_depth) << "\",";
+ out << "\"MIN_DEPTH\":\"" << get_depth_string(stats_yearly[i].min_depth) << "\",";
+ out << "\"MAX_DEPTH\":\"" << get_depth_string(stats_yearly[i].max_depth) << "\",";
+ out << "\"AVG_SAC\":\"" << get_volume_string(stats_yearly[i].avg_sac) << "\",";
+ out << "\"MIN_SAC\":\"" << get_volume_string(stats_yearly[i].min_sac) << "\",";
+ out << "\"MAX_SAC\":\"" << get_volume_string(stats_yearly[i].max_sac) << "\",";
+ out << "\"AVG_TEMP\":\"" << QString::number(stats_yearly[i].combined_temp / stats_yearly[i].combined_count, 'f', 1) << "\",";
+ out << "\"MIN_TEMP\":\"" << get_temp_units(stats_yearly[i].min_temp, NULL) << "\",";
+ out << "\"MAX_TEMP\":\"" << get_temp_units(stats_yearly[i].max_temp, NULL) << "\",";
+ out << "},";
+ total_stats.selection_size += stats_yearly[i].selection_size;
+ total_stats.total_time.seconds += stats_yearly[i].total_time.seconds;
+ i++;
+ }
+ exportHTMLstatisticsTotal(out, &total_stats);
}
out << "]";
file.close();
}
+void exportHTMLstatisticsTotal(QTextStream &out, stats_t *total_stats)
+{
+ out << "{";
+ out << "\"YEAR\":\"Total\",";
+ out << "\"DIVES\":\"" << total_stats->selection_size << "\",";
+ out << "\"TOTAL_TIME\":\"" << get_time_string(total_stats->total_time.seconds, 0) << "\",";
+ out << "\"AVERAGE_TIME\":\"--\",";
+ out << "\"SHORTEST_TIME\":\"--\",";
+ out << "\"LONGEST_TIME\":\"--\",";
+ out << "\"AVG_DEPTH\":\"--\",";
+ out << "\"MIN_DEPTH\":\"--\",";
+ out << "\"MAX_DEPTH\":\"--\",";
+ out << "\"AVG_SAC\":\"--\",";
+ out << "\"MIN_SAC\":\"--\",";
+ out << "\"MAX_SAC\":\"--\",";
+ out << "\"AVG_TEMP\":\"--\",";
+ out << "\"MIN_TEMP\":\"--\",";
+ out << "\"MAX_TEMP\":\"--\",";
+ out << "},";
+}
+
void DiveLogExportDialog::on_exportGroup_buttonClicked(QAbstractButton *button)
{
showExplanation();
diff --git a/qt-ui/divelogexportdialog.h b/qt-ui/divelogexportdialog.h
index e398a5a05..8472f8075 100644
--- a/qt-ui/divelogexportdialog.h
+++ b/qt-ui/divelogexportdialog.h
@@ -2,12 +2,18 @@
#define DIVELOGEXPORTDIALOG_H
#include <QDialog>
+#include <QTextStream>
+#include "helpers.h"
+#include "statistics.h"
+
class QAbstractButton;
namespace Ui {
class DiveLogExportDialog;
}
+void exportHTMLstatisticsTotal(QTextStream &out, stats_t *total_stats);
+
class DiveLogExportDialog : public QDialog {
Q_OBJECT
diff --git a/qt-ui/divelogexportdialog.ui b/qt-ui/divelogexportdialog.ui
index aeed08895..ce1513efb 100644
--- a/qt-ui/divelogexportdialog.ui
+++ b/qt-ui/divelogexportdialog.ui
@@ -194,6 +194,9 @@
<property name="text">
<string>Subsurface numbers</string>
</property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
</widget>
</item>
<item row="0" column="1">
@@ -216,9 +219,12 @@
</widget>
</item>
<item row="1" column="0">
- <widget class="QCheckBox" name="checkBox_2">
+ <widget class="QCheckBox" name="exportStatistics">
<property name="text">
- <string>Minimum Javascript</string>
+ <string>Export Yearly Statistics</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
</property>
</widget>
</item>
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 09320cafe..e51400ac0 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -416,8 +416,8 @@ PlannerSettingsWidget::PlannerSettingsWidget(QWidget *parent, Qt::WindowFlags f)
connect(ui.gflow, SIGNAL(editingFinished()), plannerModel, SLOT(triggerGFLow()));
connect(ui.backgasBreaks, SIGNAL(toggled(bool)), this, SLOT(setBackgasBreaks(bool)));
- ui.bottomSAC->setValue(prefs.bottomsac / 1000.0);
- ui.decoStopSAC->setValue(prefs.decosac / 1000.0);
+ ui.bottomSAC->setValue(rint(get_volume_units(prefs.bottomsac, NULL, NULL)));
+ ui.decoStopSAC->setValue(rint(get_volume_units(prefs.decosac, NULL, NULL)));
ui.gflow->setValue(prefs.gflow);
ui.gfhigh->setValue(prefs.gfhigh);
@@ -466,6 +466,21 @@ void PlannerSettingsWidget::settingsChanged()
ui.asc50to6->setText(tr("50% avg. depth to 6m"));
ui.asc6toSurf->setText(tr("6m to surface"));
}
+ if(get_units()->volume == units::CUFT) {
+ ui.bottomSAC->setSuffix(tr("cuft/min"));
+ ui.decoStopSAC->setSuffix(tr("cuft/min"));
+ ui.bottomSAC->setPrefix(".");
+ ui.decoStopSAC->setPrefix(".");
+ ui.bottomSAC->setValue(rint(ml_to_cuft(prefs.bottomsac) * 100.0));
+ ui.decoStopSAC->setValue(rint(ml_to_cuft(prefs.decosac) * 100.0));
+ } else {
+ ui.bottomSAC->setSuffix(tr("ℓ/min"));
+ ui.decoStopSAC->setSuffix(tr("ℓ/min"));
+ ui.bottomSAC->setPrefix("");
+ ui.decoStopSAC->setPrefix("");
+ ui.bottomSAC->setValue(rint((double) prefs.bottomsac / 1000.0));
+ ui.decoStopSAC->setValue(rint((double) prefs.decosac / 1000.0));
+ }
updateUnitsUI();
ui.ascRate75->setSuffix(vs);
ui.ascRate50->setSuffix(vs);
@@ -690,14 +705,17 @@ void DivePlannerPointsModel::emitDataChanged()
void DivePlannerPointsModel::setBottomSac(int sac)
{
- diveplan.bottomsac = sac * 1000;
+ volume_t newSAC;
+ newSAC.mliter = units_to_sac(sac);
+ diveplan.bottomsac = newSAC.mliter;
prefs.bottomsac = diveplan.bottomsac;
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
}
void DivePlannerPointsModel::setDecoSac(int sac)
{
- diveplan.decosac = sac * 1000;
+ volume_t newSAC;
+ diveplan.decosac = units_to_sac(sac);
prefs.decosac = diveplan.decosac;
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
}
diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp
index d2a5fae1c..fe5d4ee9a 100644
--- a/qt-ui/downloadfromdivecomputer.cpp
+++ b/qt-ui/downloadfromdivecomputer.cpp
@@ -284,6 +284,8 @@ void DownloadFromDCWidget::on_ok_clicked()
data.descriptor = descriptorLookup[ui.vendor->currentText() + ui.product->currentText()];
data.force_download = ui.forceDownload->isChecked();
+ data.create_new_trip = ui.createNewTrip->isChecked();
+ data.trip = NULL;
data.deviceid = data.diveid = 0;
set_default_dive_computer(data.vendor, data.product);
set_default_dive_computer_device(data.devname);
@@ -413,6 +415,7 @@ void DownloadFromDCWidget::markChildrenAsDisabled()
ui.vendor->setDisabled(true);
ui.product->setDisabled(true);
ui.forceDownload->setDisabled(true);
+ ui.createNewTrip->setDisabled(true);
ui.preferDownloaded->setDisabled(true);
ui.ok->setDisabled(true);
ui.search->setDisabled(true);
@@ -428,6 +431,7 @@ void DownloadFromDCWidget::markChildrenAsEnabled()
ui.vendor->setDisabled(false);
ui.product->setDisabled(false);
ui.forceDownload->setDisabled(false);
+ ui.createNewTrip->setDisabled(false);
ui.preferDownloaded->setDisabled(false);
ui.ok->setDisabled(false);
ui.cancel->setDisabled(false);
diff --git a/qt-ui/downloadfromdivecomputer.ui b/qt-ui/downloadfromdivecomputer.ui
index e99782ee8..9ea85afc8 100644
--- a/qt-ui/downloadfromdivecomputer.ui
+++ b/qt-ui/downloadfromdivecomputer.ui
@@ -74,7 +74,7 @@
</property>
</widget>
</item>
- <item row="8" column="0" colspan="3">
+ <item row="9" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
@@ -105,41 +105,48 @@
</item>
</layout>
</item>
- <item row="9" column="0" colspan="3">
+ <item row="10" column="0" colspan="3">
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
- <item row="6" column="0" colspan="2">
+ <item row="7" column="0" colspan="2">
<widget class="QCheckBox" name="logToFile">
<property name="text">
<string>Save libdivecomputer logfile</string>
</property>
</widget>
</item>
- <item row="7" column="0" colspan="2">
+ <item row="8" column="0" colspan="2">
<widget class="QCheckBox" name="dumpToFile">
<property name="text">
<string>Save libdivecomputer dumpfile</string>
</property>
</widget>
</item>
- <item row="6" column="2">
+ <item row="7" column="2">
<widget class="QToolButton" name="chooseLogFile">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
- <item row="7" column="2">
+ <item row="8" column="2">
<widget class="QToolButton" name="chooseDumpFile">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
+ <item row="6" column="0">
+ <widget class="QCheckBox" name="createNewTrip">
+ <property name="text">
+ <string>Download into new trip</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<resources/>
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index e8087c7cc..6bb6f14f8 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -771,10 +771,7 @@ void MainTab::acceptChanges()
}
if (editMode == ADD || editMode == MANUALLY_ADDED_DIVE) {
fixup_dive(current_dive);
- if (dive_table.nr == 1)
- current_dive->number = 1;
- else if (selected_dive == dive_table.nr - 1 && get_dive(dive_table.nr - 2)->number)
- current_dive->number = get_dive(dive_table.nr - 2)->number + 1;
+ set_dive_nr_for_current_dive();
MainWindow::instance()->showProfile();
mark_divelist_changed(true);
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::NOTHING);
@@ -1026,9 +1023,12 @@ void MainTab::on_location_textChanged(const QString &text)
// If we have GPS data for the location entered, add it.
void MainTab::on_location_editingFinished()
{
+ // 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
if (!currentTrip &&
!same_string(displayed_dive.location, "") &&
- ui.coordinates->text().trimmed().isEmpty()) {
+ ui.coordinates->text().trimmed().isEmpty() &&
+ !(editMode == DIVE && dive_has_gps_location(current_dive))) {
struct dive *dive;
int i = 0;
for_each_dive (i, dive) {
@@ -1170,3 +1170,43 @@ void MainTab::removeSelectedPhotos()
QString fileUrl = photoIndex.data(Qt::DisplayPropertyRole).toString();
DivePictureModel::instance()->removePicture(fileUrl);
}
+
+#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();
+ 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;
+ }
+}
diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h
index f3aec5458..93bb1c949 100644
--- a/qt-ui/maintab.h
+++ b/qt-ui/maintab.h
@@ -49,6 +49,8 @@ public:
bool isEditing();
void updateCoordinatesText(qreal lat, qreal lon);
void nextInputField(QKeyEvent *event);
+ void showAndTriggerEditSelective(struct dive_components what);
+
signals:
void addDiveFinished();
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 85b31608c..74015c73f 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -115,6 +115,8 @@ MainWindow::MainWindow() : QMainWindow(),
#ifdef NO_PRINTING
ui.menuFile->removeAction(ui.actionPrint);
#endif
+ memset(&copyPasteDive, 0, sizeof(copyPasteDive));
+ memset(&what, 0, sizeof(what));
}
MainWindow::~MainWindow()
@@ -243,6 +245,7 @@ void MainWindow::setToolButtonsEnabled(bool enabled)
ui.profScaled->setEnabled(enabled);
ui.profHR->setEnabled(enabled);
ui.profTogglePicture->setEnabled(enabled);
+ ui.profTankbar->setEnabled(enabled);
}
bool MainWindow::okToClose(QString message)
@@ -400,6 +403,12 @@ void MainWindow::planCanceled()
void MainWindow::planCreated()
{
+ // get the new dive selected and assign a number if reasonable
+ dive_list()->unselectDives();
+ select_dive(dive_table.nr - 1);
+ dive_list()->selectDive(selected_dive);
+ set_dive_nr_for_current_dive();
+
showProfile();
refreshDisplay();
}
@@ -797,6 +806,7 @@ void MainWindow::readSettings()
TOOLBOX_PREF_BUTTON(rulergraph, rulergraph, profRuler);
TOOLBOX_PREF_BUTTON(show_sac, show_sac, profSAC);
TOOLBOX_PREF_BUTTON(show_pictures_in_profile, show_pictures_in_profile, profTogglePicture);
+ TOOLBOX_PREF_BUTTON(tankbar, tankbar, profTankbar);
s.endGroup();
s.beginGroup("DiveComputer");
default_dive_computer_vendor = getSetting(s, "dive_computer_vendor");
@@ -1271,6 +1281,7 @@ TOOLBOX_PREF_PROFILE(profRuler, rulergraph, rulergraph);
TOOLBOX_PREF_PROFILE(profSAC, show_sac, show_sac);
TOOLBOX_PREF_PROFILE(profScaled, zoomed_plot, zoomed_plot);
TOOLBOX_PREF_PROFILE(profTogglePicture, show_pictures_in_profile, show_pictures_in_profile);
+TOOLBOX_PREF_PROFILE(profTankbar, tankbar, tankbar);
void MainWindow::turnOffNdlTts()
{
@@ -1296,10 +1307,26 @@ void MainWindow::on_actionConfigure_Dive_Computer_triggered()
void MainWindow::setEnabledToolbar(bool arg1)
{
- QList<QToolButton*> toolBar; toolBar << ui.profCalcAllTissues << ui.profCalcCeiling
- << ui.profDcCeiling << ui.profEad << ui.profHR << ui.profIncrement3m
- << ui.profMod << ui.profNdl_tts << ui.profNdl_tts << ui.profPhe << ui.profPn2
- << ui.profPO2 << ui.profRuler << ui.profSAC << ui.profScaled << ui.profTogglePicture;
+ QList<QToolButton*> toolBar;
+ toolBar << ui.profCalcAllTissues << ui.profCalcCeiling << ui.profDcCeiling << ui.profEad <<
+ ui.profHR << ui.profIncrement3m << ui.profMod << ui.profNdl_tts << ui.profNdl_tts <<
+ ui.profPhe << ui.profPn2 << ui.profPO2 << ui.profRuler << ui.profSAC << ui.profScaled <<
+ ui.profTogglePicture << ui.profTankbar;
Q_FOREACH(QToolButton *b, toolBar)
b->setEnabled(arg1);
}
+
+void MainWindow::on_copy_triggered()
+{
+ // open dialog to select what gets copied
+ // copy the displayed dive
+ DiveComponentSelection dialog(this, &copyPasteDive, &what);
+ dialog.exec();
+}
+
+void MainWindow::on_paste_triggered()
+{
+ // take the data in our copyPasteDive and apply it to selected dives
+ selective_copy_dive(&copyPasteDive, &displayed_dive, what, false);
+ ui.InfoWidget->showAndTriggerEditSelective(what);
+}
diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h
index b9c8e4682..5ef5eed4a 100644
--- a/qt-ui/mainwindow.h
+++ b/qt-ui/mainwindow.h
@@ -141,7 +141,10 @@ slots:
void on_profSAC_clicked(bool triggered);
void on_profScaled_clicked(bool triggered);
void on_profTogglePicture_clicked(bool triggered);
+ void on_profTankbar_clicked(bool triggered);
void on_actionExport_triggered();
+ void on_copy_triggered();
+ void on_paste_triggered();
void on_actionConfigure_Dive_Computer_triggered();
@@ -186,6 +189,8 @@ private:
bool plannerStateClean();
void setupForAddAndPlan(const char *model);
QDialog *survey;
+ struct dive copyPasteDive;
+ struct dive_components what;
};
#endif // MAINWINDOW_H
diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui
index bd5581f64..dca59e706 100644
--- a/qt-ui/mainwindow.ui
+++ b/qt-ui/mainwindow.ui
@@ -109,7 +109,7 @@
<property name="spacing">
<number>0</number>
</property>
- <item row="15" column="0">
+ <item row="17" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -440,6 +440,9 @@
</property>
</widget>
</item>
+ <item row="0" column="1" rowspan="19">
+ <widget class="ProfileWidget2" name="newProfile"/>
+ </item>
<item row="0" column="0">
<widget class="QToolButton" name="profPO2">
<property name="toolTip">
@@ -466,9 +469,6 @@
</property>
</widget>
</item>
- <item row="0" column="1" rowspan="16">
- <widget class="ProfileWidget2" name="newProfile"/>
- </item>
<item row="1" column="0">
<widget class="QToolButton" name="profPn2">
<property name="toolTip">
@@ -495,6 +495,32 @@
</property>
</widget>
</item>
+ <item row="15" column="0">
+ <widget class="QToolButton" name="profTankbar">
+ <property name="toolTip">
+ <string>Toggle Cylinder Bar</string>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ <property name="icon">
+ <iconset resource="../subsurface.qrc">
+ <normaloff>:/gaschange</normaloff>:/gaschange</iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>24</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
<item row="14" column="0">
<widget class="QToolButton" name="profTogglePicture">
<property name="toolTip">
@@ -664,7 +690,7 @@ p, li { white-space: pre-wrap; }
<x>0</x>
<y>0</y>
<width>1682</width>
- <height>27</height>
+ <height>19</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
@@ -696,6 +722,8 @@ p, li { white-space: pre-wrap; }
</property>
<addaction name="actionAddDive"/>
<addaction name="actionDivePlanner"/>
+ <addaction name="copy"/>
+ <addaction name="paste"/>
<addaction name="separator"/>
<addaction name="actionRenumber"/>
<addaction name="actionAutoGroup"/>
@@ -855,6 +883,22 @@ p, li { white-space: pre-wrap; }
<string>Ctrl++</string>
</property>
</action>
+ <action name="copy">
+ <property name="text">
+ <string>&amp;Copy dive components</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+C</string>
+ </property>
+ </action>
+ <action name="paste">
+ <property name="text">
+ <string>&amp;Paste dive components</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+V</string>
+ </property>
+ </action>
<action name="actionRenumber">
<property name="text">
<string>&amp;Renumber</string>
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index 11e84c9c2..82fdbdc43 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -1102,7 +1102,7 @@ QVariant DiveItem::data(int column, int role) const
case CYLINDER:
retVal = QString(dive->cylinder[0].type.description);
break;
- case NITROX:
+ case GAS:
retVal = nitrox_sort_value(dive);
break;
case SAC:
@@ -1146,8 +1146,8 @@ QVariant DiveItem::data(int column, int role) const
case CYLINDER:
retVal = QString(dive->cylinder[0].type.description);
break;
- case NITROX:
- retVal = QString(get_nitrox_string(dive));
+ case GAS:
+ retVal = QString(get_dive_gas_string(dive));
break;
case SAC:
retVal = displaySac();
@@ -1338,8 +1338,8 @@ QVariant DiveTripModel::headerData(int section, Qt::Orientation orientation, int
case CYLINDER:
ret = tr("Cyl");
break;
- case NITROX:
- ret = QString("O%1%").arg(UTF8_SUBSCRIPT_2);
+ case GAS:
+ ret = tr("Gas");
break;
case SAC:
ret = tr("SAC");
diff --git a/qt-ui/models.h b/qt-ui/models.h
index aa314f119..c4a3a077d 100644
--- a/qt-ui/models.h
+++ b/qt-ui/models.h
@@ -191,7 +191,7 @@ struct DiveItem : public TreeItem {
TOTALWEIGHT,
SUIT,
CYLINDER,
- NITROX,
+ GAS,
SAC,
OTU,
MAXCNS,
@@ -245,7 +245,7 @@ public:
TOTALWEIGHT,
SUIT,
CYLINDER,
- NITROX,
+ GAS,
SAC,
OTU,
MAXCNS,
diff --git a/qt-ui/plannerSettings.ui b/qt-ui/plannerSettings.ui
index 0ad0f5b70..a28453c01 100644
--- a/qt-ui/plannerSettings.ui
+++ b/qt-ui/plannerSettings.ui
@@ -30,8 +30,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>1089</width>
- <height>404</height>
+ <width>1078</width>
+ <height>418</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
@@ -271,6 +271,9 @@
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="gflow">
+ <property name="suffix">
+ <string>%</string>
+ </property>
<property name="minimum">
<number>1</number>
</property>
@@ -288,6 +291,9 @@
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="gfhigh">
+ <property name="suffix">
+ <string>%</string>
+ </property>
<property name="minimum">
<number>1</number>
</property>
@@ -362,7 +368,11 @@
</widget>
</item>
<item row="0" column="1">
- <widget class="QSpinBox" name="bottomSAC"/>
+ <widget class="QSpinBox" name="bottomSAC">
+ <property name="suffix">
+ <string>ℓ/min</string>
+ </property>
+ </widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_14">
@@ -372,7 +382,11 @@
</widget>
</item>
<item row="1" column="1">
- <widget class="QSpinBox" name="decoStopSAC"/>
+ <widget class="QSpinBox" name="decoStopSAC">
+ <property name="suffix">
+ <string>ℓ/min</string>
+ </property>
+ </widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp
index 6000f453a..edd95d838 100644
--- a/qt-ui/preferences.cpp
+++ b/qt-ui/preferences.cpp
@@ -315,6 +315,7 @@ void PreferencesDialog::loadSettings()
GET_BOOL("calcndltts", calcndltts);
GET_BOOL("calcalltissues", calcalltissues);
GET_BOOL("hrgraph", hrgraph);
+ GET_BOOL("tankbar", tankbar);
GET_INT("gflow", gflow);
GET_INT("gfhigh", gfhigh);
GET_BOOL("gf_low_at_maxdepth", gf_low_at_maxdepth);
diff --git a/qt-ui/preferences.ui b/qt-ui/preferences.ui
index 48592ae1d..c021ae872 100644
--- a/qt-ui/preferences.ui
+++ b/qt-ui/preferences.ui
@@ -612,6 +612,9 @@
<property name="enabled">
<bool>true</bool>
</property>
+ <property name="singleStep">
+ <double>0.100000000000000</double>
+ </property>
</widget>
</item>
</layout>
@@ -633,6 +636,9 @@
<property name="enabled">
<bool>true</bool>
</property>
+ <property name="singleStep">
+ <double>0.100000000000000</double>
+ </property>
</widget>
</item>
</layout>
@@ -654,6 +660,9 @@
<property name="enabled">
<bool>true</bool>
</property>
+ <property name="singleStep">
+ <double>0.100000000000000</double>
+ </property>
</widget>
</item>
</layout>
@@ -675,6 +684,9 @@
<property name="enabled">
<bool>true</bool>
</property>
+ <property name="singleStep">
+ <double>0.100000000000000</double>
+ </property>
</widget>
</item>
</layout>
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 413414ec8..409328918 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -13,6 +13,7 @@
#include "planner.h"
#include "device.h"
#include "ruleritem.h"
+#include "tankitem.h"
#include "dive.h"
#include "pref.h"
#include <libdivecomputer/parser.h>
@@ -52,8 +53,10 @@ static struct _ItemPos {
};
_Pos background;
_Pos dcLabel;
+ _Pos tankBar;
_Axis depth;
_Axis partialPressure;
+ _Axis partialPressureWithTankBar;
_Axis time;
_Axis cylinder;
_Axis temperature;
@@ -89,6 +92,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent),
mouseFollowerVertical(new DiveLineItem()),
mouseFollowerHorizontal(new DiveLineItem()),
rulerItem(new RulerItem2()),
+ tankItem(new TankItem()),
isGrayscale(false),
printMode(false),
shouldCalculateMaxTime(true),
@@ -160,6 +164,7 @@ void ProfileWidget2::addItemsToScene()
scene()->addItem(rulerItem);
scene()->addItem(rulerItem->sourceNode());
scene()->addItem(rulerItem->destNode());
+ scene()->addItem(tankItem);
scene()->addItem(mouseFollowerHorizontal);
scene()->addItem(mouseFollowerVertical);
QPen pen(QColor(Qt::red).lighter());
@@ -177,6 +182,7 @@ void ProfileWidget2::setupItemOnScene()
toolTipItem->setZValue(9998);
toolTipItem->setTimeAxis(timeAxis);
rulerItem->setZValue(9997);
+ tankItem->setZValue(100);
profileYAxis->setOrientation(DiveCartesianAxis::TopToBottom);
profileYAxis->setMinimum(0);
@@ -219,6 +225,7 @@ void ProfileWidget2::setupItemOnScene()
diveComputerText->setBrush(getColor(TIME_TEXT, isGrayscale));
rulerItem->setAxis(timeAxis, profileYAxis);
+ tankItem->setHorizontalAxis(timeAxis);
setupItem(reportedCeiling, timeAxis, profileYAxis, dataModel, DivePlotDataModel::CEILING, DivePlotDataModel::TIME, 1);
setupItem(diveCeiling, timeAxis, profileYAxis, dataModel, DivePlotDataModel::CEILING, DivePlotDataModel::TIME, 1);
@@ -301,6 +308,8 @@ void ProfileWidget2::setupItemSizes()
itemPos.partialPressure.pos.off.setY(63);
itemPos.partialPressure.expanded.setP1(QPointF(0, 0));
itemPos.partialPressure.expanded.setP2(QPointF(0, 30));
+ itemPos.partialPressureWithTankBar = itemPos.partialPressure;
+ itemPos.partialPressureWithTankBar.expanded.setP2(QPointF(0, 27));
// cylinder axis config
itemPos.cylinder.pos.on.setX(3);
@@ -331,6 +340,9 @@ void ProfileWidget2::setupItemSizes()
itemPos.dcLabel.on.setY(100);
itemPos.dcLabel.off.setX(-10);
itemPos.dcLabel.off.setY(100);
+
+ itemPos.tankBar.on.setX(0);
+ itemPos.tankBar.on.setY(92);
}
void ProfileWidget2::setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *hAxis,
@@ -409,6 +421,14 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
// reset some item visibility on printMode changes
toolTipItem->setVisible(!printMode);
rulerItem->setVisible(prefs.rulergraph && !printMode);
+ tankItem->setVisible(prefs.tankbar);
+ if (prefs.tankbar) {
+ gasYAxis->setPos(itemPos.partialPressureWithTankBar.pos.on);
+ gasYAxis->setLine(itemPos.partialPressureWithTankBar.expanded);
+ } else {
+ gasYAxis->setPos(itemPos.partialPressure.pos.on);
+ gasYAxis->setLine(itemPos.partialPressure.expanded);
+ }
if (currentState == EMPTY)
setProfileState();
@@ -487,6 +507,7 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
cylinderPressureAxis->setMaximum(pInfo.maxpressure);
rulerItem->setPlotInfo(pInfo);
+ tankItem->setData(dataModel, &pInfo, &displayed_dive);
meanDepth->setVisible(prefs.show_average_depth);
meanDepth->setMeanDepth(pInfo.meandepth);
meanDepth->setLine(0, 0, timeAxis->posAtValue(currentdc->duration.seconds), 0);
@@ -552,6 +573,13 @@ void ProfileWidget2::settingsChanged()
temperatureAxis->animateChangeLine(itemPos.temperature.expanded);
cylinderPressureAxis->animateChangeLine(itemPos.cylinder.expanded);
}
+ if (prefs.tankbar) {
+ gasYAxis->setPos(itemPos.partialPressureWithTankBar.pos.on);
+ gasYAxis->animateChangeLine(itemPos.partialPressureWithTankBar.expanded);
+ } else {
+ gasYAxis->setPos(itemPos.partialPressure.pos.on);
+ gasYAxis->animateChangeLine(itemPos.partialPressure.expanded);
+ }
if (prefs.zoomed_plot != isPlotZoomed) {
isPlotZoomed = prefs.zoomed_plot;
needReplot = true;
@@ -727,6 +755,7 @@ void ProfileWidget2::setEmptyState()
diveCeiling->setVisible(false);
reportedCeiling->setVisible(false);
rulerItem->setVisible(false);
+ tankItem->setVisible(false);
pn2GasItem->setVisible(false);
po2GasItem->setVisible(false);
pheGasItem->setVisible(false);
@@ -784,9 +813,13 @@ void ProfileWidget2::setProfileState()
po2GasItem->setVisible(prefs.pp_graphs.po2);
pheGasItem->setVisible(prefs.pp_graphs.phe);
- gasYAxis->setPos(itemPos.partialPressure.pos.on);
- gasYAxis->setLine(itemPos.partialPressure.expanded);
-
+ if (prefs.tankbar) {
+ gasYAxis->setPos(itemPos.partialPressureWithTankBar.pos.on);
+ gasYAxis->setLine(itemPos.partialPressureWithTankBar.expanded);
+ } else {
+ gasYAxis->setPos(itemPos.partialPressure.pos.on);
+ gasYAxis->setLine(itemPos.partialPressure.expanded);
+ }
timeAxis->setPos(itemPos.time.pos.on);
timeAxis->setLine(itemPos.time.expanded);
@@ -809,6 +842,9 @@ void ProfileWidget2::setProfileState()
}
}
rulerItem->setVisible(prefs.rulergraph);
+ tankItem->setVisible(prefs.tankbar);
+ tankItem->setPos(itemPos.tankBar.on);
+
#define HIDE_ALL(TYPE, CONTAINER) \
Q_FOREACH (TYPE *item, CONTAINER) item->setVisible(false);
HIDE_ALL(DiveHandler, handles);
diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h
index c3db9845c..fa5e53e26 100644
--- a/qt-ui/profile/profilewidget2.h
+++ b/qt-ui/profile/profilewidget2.h
@@ -40,6 +40,7 @@ class DiveCalculatedTissue;
class PartialPressureGasItem;
class PartialGasPressureAxis;
class AbstractProfilePolygonItem;
+class TankItem;
class DiveHandler;
class QGraphicsSimpleTextItem;
class QModelIndex;
@@ -164,6 +165,7 @@ private:
DiveLineItem *mouseFollowerVertical;
DiveLineItem *mouseFollowerHorizontal;
RulerItem2 *rulerItem;
+ TankItem *tankItem;
bool isGrayscale;
bool printMode;
diff --git a/qt-ui/profile/tankitem.cpp b/qt-ui/profile/tankitem.cpp
new file mode 100644
index 000000000..a5ec5050c
--- /dev/null
+++ b/qt-ui/profile/tankitem.cpp
@@ -0,0 +1,105 @@
+#include "tankitem.h"
+#include "diveplotdatamodel.h"
+#include "divetextitem.h"
+#include "profile.h"
+#include <QGradient>
+#include <QDebug>
+#include <QPen>
+
+TankItem::TankItem(QObject *parent) :
+ QGraphicsRectItem(),
+ dataModel(0),
+ dive(0),
+ pInfo(0)
+{
+ height = 3;
+ QColor red(PERSIANRED1);
+ QColor blue(AIR_BLUE);
+ QColor yellow(NITROX_YELLOW);
+ QColor green(NITROX_GREEN);
+ QLinearGradient nitroxGradient(QPointF(0, 0), QPointF(0, height));
+ nitroxGradient.setColorAt(0.0, green);
+ nitroxGradient.setColorAt(0.49, green);
+ nitroxGradient.setColorAt(0.5, yellow);
+ nitroxGradient.setColorAt(1.0, yellow);
+ nitrox = nitroxGradient;
+ QLinearGradient trimixGradient(QPointF(0, 0), QPointF(0, height));
+ trimixGradient.setColorAt(0.0, green);
+ trimixGradient.setColorAt(0.49, green);
+ trimixGradient.setColorAt(0.5, red);
+ trimixGradient.setColorAt(1.0, red);
+ trimix = trimixGradient;
+ air = blue;
+}
+
+void TankItem::setData(DivePlotDataModel *model, struct plot_info *plotInfo, struct dive *d)
+{
+ pInfo = plotInfo;
+ dive = d;
+ dataModel = model;
+ connect(dataModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(modelDataChanged(QModelIndex, QModelIndex)));
+ modelDataChanged();
+}
+
+void TankItem::createBar(qreal x, qreal w, struct gasmix *gas)
+{
+ // pick the right gradient, size, position and text
+ QGraphicsRectItem *rect = new QGraphicsRectItem(x, 0, w, height, this);
+ if (gasmix_is_air(gas))
+ rect->setBrush(air);
+ else if (gas->he.permille)
+ rect->setBrush(trimix);
+ else
+ rect->setBrush(nitrox);
+ rect->setPen(QPen(QBrush(), 0.0)); // get rid of the thick line around the rectangle
+ rects.push_back(rect);
+ DiveTextItem *label = new DiveTextItem(rect);
+ label->setText(gasname(gas));
+ label->setBrush(Qt::black);
+ label->setPos(x + 1, 0);
+ label->setAlignment(Qt::AlignBottom | Qt::AlignRight);
+ label->setZValue(101);
+}
+
+void TankItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
+{
+ // We don't have enougth data to calculate things, quit.
+
+ if (!dive || !dataModel || !pInfo || !pInfo->nr)
+ return;
+
+ // remove the old rectangles
+ foreach (QGraphicsRectItem *r, rects) {
+ delete(r);
+ }
+ rects.clear();
+
+ // walk the list and figure out which tanks go where
+ struct plot_data *entry = pInfo->entry;
+ int cylIdx = entry->cylinderindex;
+ int i = -1;
+ int startTime = 0;
+ struct gasmix *gas = &dive->cylinder[cylIdx].gasmix;
+ qreal width, left;
+ while (++i < pInfo->nr) {
+ entry = &pInfo->entry[i];
+ if (entry->cylinderindex == cylIdx)
+ continue;
+ width = hAxis->posAtValue(entry->sec) - hAxis->posAtValue(startTime);
+ left = hAxis->posAtValue(startTime);
+ createBar(left, width, gas);
+ cylIdx = entry->cylinderindex;
+ gas = &dive->cylinder[cylIdx].gasmix;
+ startTime = entry->sec;
+ }
+ width = hAxis->posAtValue(entry->sec) - hAxis->posAtValue(startTime);
+ left = hAxis->posAtValue(startTime);
+ createBar(left, width, gas);
+}
+
+void TankItem::setHorizontalAxis(DiveCartesianAxis *horizontal)
+{
+ hAxis = horizontal;
+ connect(hAxis, SIGNAL(sizeChanged()), this, SLOT(modelDataChanged()));
+ modelDataChanged();
+}
diff --git a/qt-ui/profile/tankitem.h b/qt-ui/profile/tankitem.h
new file mode 100644
index 000000000..615a7017d
--- /dev/null
+++ b/qt-ui/profile/tankitem.h
@@ -0,0 +1,38 @@
+#ifndef TANKITEM_H
+#define TANKITEM_H
+
+#include <QGraphicsItem>
+#include <QModelIndex>
+#include <QBrush>
+#include "divelineitem.h"
+#include "divecartesianaxis.h"
+#include "dive.h"
+
+class TankItem : public QObject, public QGraphicsRectItem
+{
+ Q_OBJECT
+ Q_INTERFACES(QGraphicsItem)
+
+public:
+ explicit TankItem(QObject *parent = 0);
+ void setHorizontalAxis(DiveCartesianAxis *horizontal);
+ void setData(DivePlotDataModel *model, struct plot_info *plotInfo, struct dive *d);
+
+signals:
+
+public slots:
+ virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex());
+
+private:
+ void createBar(qreal x, qreal w, struct gasmix *gas);
+ DivePlotDataModel *dataModel;
+ DiveCartesianAxis *hAxis;
+ int hDataColumn;
+ struct dive *dive;
+ struct plot_info *pInfo;
+ qreal yPos, height;
+ QBrush air, nitrox, trimix;
+ QList<QGraphicsRectItem *> rects;
+};
+
+#endif // TANKITEM_H
diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp
index 217291277..772c8d1b9 100644
--- a/qt-ui/simplewidgets.cpp
+++ b/qt-ui/simplewidgets.cpp
@@ -411,3 +411,47 @@ void DateWidget::keyPressEvent(QKeyEvent *event)
QWidget::keyPressEvent(event);
}
}
+
+#define COMPONENT_FROM_UI(_component) what->_component = ui._component->isChecked()
+#define UI_FROM_COMPONENT(_component) ui._component->setChecked(what->_component)
+
+DiveComponentSelection::DiveComponentSelection(QWidget *parent, struct dive *target, struct dive_components *_what):
+ targetDive(target)
+{
+ ui.setupUi(this);
+ what = _what;
+ UI_FROM_COMPONENT(location);
+ UI_FROM_COMPONENT(gps);
+ UI_FROM_COMPONENT(divemaster);
+ UI_FROM_COMPONENT(buddy);
+ UI_FROM_COMPONENT(rating);
+ UI_FROM_COMPONENT(visibility);
+ UI_FROM_COMPONENT(notes);
+ UI_FROM_COMPONENT(suit);
+ UI_FROM_COMPONENT(tags);
+ UI_FROM_COMPONENT(cylinders);
+ UI_FROM_COMPONENT(weights);
+ connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *)));
+ QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this);
+ connect(close, SIGNAL(activated()), this, SLOT(close()));
+ QShortcut *quit = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this);
+ connect(quit, SIGNAL(activated()), parent, SLOT(close()));
+}
+
+void DiveComponentSelection::buttonClicked(QAbstractButton *button)
+{
+ if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) {
+ COMPONENT_FROM_UI(location);
+ COMPONENT_FROM_UI(gps);
+ COMPONENT_FROM_UI(divemaster);
+ COMPONENT_FROM_UI(buddy);
+ COMPONENT_FROM_UI(rating);
+ COMPONENT_FROM_UI(visibility);
+ COMPONENT_FROM_UI(notes);
+ COMPONENT_FROM_UI(suit);
+ COMPONENT_FROM_UI(tags);
+ COMPONENT_FROM_UI(cylinders);
+ COMPONENT_FROM_UI(weights);
+ selective_copy_dive(&displayed_dive, targetDive, *what, true);
+ }
+}
diff --git a/qt-ui/simplewidgets.h b/qt-ui/simplewidgets.h
index 58c9199a5..b41189fe5 100644
--- a/qt-ui/simplewidgets.h
+++ b/qt-ui/simplewidgets.h
@@ -11,6 +11,7 @@ class QAbstractButton;
#include "ui_renumber.h"
#include "ui_shifttimes.h"
#include "ui_shiftimagetimes.h"
+#include "ui_divecomponentselection.h"
#include "exif.h"
class MinMaxAvgWidget : public QWidget {
@@ -112,6 +113,19 @@ private:
QCalendarWidget *calendarWidget;
};
+class DiveComponentSelection : public QDialog {
+ Q_OBJECT
+public:
+ explicit DiveComponentSelection(QWidget *parent, struct dive *target, struct dive_components *_what);
+private
+slots:
+ void buttonClicked(QAbstractButton *button);
+private:
+ Ui::DiveComponentSelectionDialog ui;
+ struct dive *targetDive;
+ struct dive_components *what;
+};
+
bool isGnome3Session();
QImage grayImage(const QImage& coloredImg);
diff --git a/qt-ui/usersurvey.cpp b/qt-ui/usersurvey.cpp
index f436fce47..a8916c990 100644
--- a/qt-ui/usersurvey.cpp
+++ b/qt-ui/usersurvey.cpp
@@ -15,6 +15,7 @@ UserSurvey::UserSurvey(QWidget *parent) : QDialog(parent),
ui(new Ui::UserSurvey)
{
ui->setupUi(this);
+ ui->buttonBox->buttons().first()->setText(tr("Send"));
this->adjustSize();
QShortcut *closeKey = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this);
connect(closeKey, SIGNAL(activated()), this, SLOT(close()));