diff options
-rw-r--r-- | desktop-widgets/tab-widgets/TabDiveInformation.cpp | 93 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/TabDiveInformation.h | 5 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/TabDiveInformation.ui | 409 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/maintab.cpp | 43 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/maintab.h | 3 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/maintab.ui | 138 |
6 files changed, 445 insertions, 246 deletions
diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.cpp b/desktop-widgets/tab-widgets/TabDiveInformation.cpp index 928627311..641e762f2 100644 --- a/desktop-widgets/tab-widgets/TabDiveInformation.cpp +++ b/desktop-widgets/tab-widgets/TabDiveInformation.cpp @@ -1,6 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 #include "TabDiveInformation.h" #include "ui_TabDiveInformation.h" +#include "desktop-widgets/mainwindow.h" // TODO: Only used temporarilly for edit mode changes +#include "profile-widget/profilewidget2.h" #include "../tagwidget.h" #include "core/units.h" #include "core/dive.h" @@ -12,6 +14,7 @@ #define COMBO_CHANGED 0 #define TEXT_EDITED 1 +#define CSS_SET_HEADING_BLUE "QLabel { color: mediumblue;} " TabDiveInformation::TabDiveInformation(QWidget *parent) : TabBase(parent), ui(new Ui::TabDiveInformation()) { @@ -20,6 +23,28 @@ TabDiveInformation::TabDiveInformation(QWidget *parent) : TabBase(parent), ui(ne QStringList atmPressTypes { "mbar", get_depth_unit() ,"use dc"}; ui->atmPressType->insertItems(0, atmPressTypes); pressTypeIndex = 0; + // This needs to be the same order as enum dive_comp_type in dive.h! + QStringList types; + for (int i = 0; i < NUM_DIVEMODE; i++) + types.append(gettextFromC::tr(divemode_text_ui[i])); + ui->diveType->insertItems(0, types); + connect(ui->diveType, SIGNAL(currentIndexChanged(int)), this, SLOT(diveModeChanged(int))); + QString CSSSetSmallLabel = "QLabel { color: mediumblue; font-size: " + /* // Using label height ... */ + QString::number((int)(0.5 + ui->diveHeadingLabel->geometry().height() * 0.66)) + "px;}"; // .. set CSS font size of star widget subscripts + ui->scrollAreaWidgetContents_3->setStyleSheet("QGroupBox::title { color: mediumblue;} "); + ui->diveModeBox->setStyleSheet("QGroupBox{ padding: 0;} "); + ui->diveHeadingLabel->setStyleSheet(CSS_SET_HEADING_BLUE); + ui->gasHeadingLabel->setStyleSheet(CSS_SET_HEADING_BLUE); + ui->environmentHeadingLabel->setStyleSheet(CSS_SET_HEADING_BLUE); + ui->groupBox_visibility->setStyleSheet(CSSSetSmallLabel); + QAction *action = new QAction(tr("OK"), this); + connect(action, &QAction::triggered, this, &TabDiveInformation::closeWarning); + ui->multiDiveWarningMessage->addAction(action); + action = new QAction(tr("Undo"), this); + connect(action, &QAction::triggered, Command::undoAction(this), &QAction::trigger); + connect(action, &QAction::triggered, this, &TabDiveInformation::closeWarning); + ui->multiDiveWarningMessage->addAction(action); + ui->multiDiveWarningMessage->hide(); } TabDiveInformation::~TabDiveInformation() @@ -34,7 +59,6 @@ void TabDiveInformation::clear() ui->maxcnsText->clear(); ui->oxygenHeliumText->clear(); ui->gasUsedText->clear(); - ui->dateText->clear(); ui->diveTimeText->clear(); ui->surfaceIntervalText->clear(); ui->maximumDepthText->clear(); @@ -43,6 +67,22 @@ void TabDiveInformation::clear() ui->airTemperatureText->clear(); ui->atmPressVal->clear(); ui->salinityText->clear(); + ui->waterTypeText->clear(); +} + +void TabDiveInformation::divesEdited(int i) +{ + // No warning if only one dive was edited + if (i <= 1) + return; + ui->multiDiveWarningMessage->setCloseButtonVisible(false); + ui->multiDiveWarningMessage->setText(tr("Warning: edited %1 dives").arg(i)); + ui->multiDiveWarningMessage->show(); +} + +void TabDiveInformation::closeWarning() +{ + ui->multiDiveWarningMessage->hide(); } // Update fields that depend on the dive profile @@ -87,7 +127,6 @@ void TabDiveInformation::updateProfile() if (current_dive->surface_pressure.mbar == 0) { ui->atmPressVal->clear(); // If no atm pressure for dive then clear text box } else { - ui->atmPressVal->setEnabled(true); QString pressStr; pressStr.sprintf("%d",current_dive->surface_pressure.mbar); @@ -98,7 +137,6 @@ void TabDiveInformation::updateProfile() // Update fields that depend on start of dive void TabDiveInformation::updateWhen() { - ui->dateText->setText(get_short_dive_date_string(current_dive->when)); timestamp_t surface_interval = get_surface_interval(current_dive->when); if (surface_interval >= 0) ui->surfaceIntervalText->setText(get_dive_surfint_string(surface_interval, tr("d"), tr("h"), tr("min"))); @@ -108,10 +146,19 @@ void TabDiveInformation::updateWhen() void TabDiveInformation::updateSalinity() { - if (current_dive->salinity) + if (current_dive->salinity) { // Set up the salinity string: ui->salinityText->setText(QString("%1g/ℓ").arg(current_dive->salinity / 10.0)); - else + if (current_dive->salinity < 10050) // Set water type indicator: + ui->waterTypeText->setText(tr("Fresh")); + else if (current_dive->salinity < 10190) + ui->waterTypeText->setText(tr("Salty")); + else if (current_dive->salinity < 10210) // (EN13319 = 1.019 - 1.021 g/l) + ui->waterTypeText->setText(tr("EN13319")); + else ui->waterTypeText->setText(tr("Salt")); + } else { ui->salinityText->clear(); + ui->waterTypeText->clear(); + } } void TabDiveInformation::updateData() @@ -125,12 +172,11 @@ void TabDiveInformation::updateData() updateWhen(); ui->waterTemperatureText->setText(get_temperature_string(current_dive->watertemp, true)); ui->airTemperatureText->setText(get_temperature_string(current_dive->airtemp, true)); - updateSalinity(); - - ui->atmPressType->setEditable(true); ui->atmPressType->setItemText(1, get_depth_unit()); // Check for changes in depth unit (imperial/metric) - ui->atmPressType->setEditable(false); - ui->atmPressType->setCurrentIndex(0); // Set the atmospheric pressure combo box to mbar + ui->atmPressType->setCurrentIndex(0); // Set the atmospheric pressure combo box to mbar + updateMode(current_dive); + updateSalinity(); + ui->visibility->setCurrentStars(current_dive->visibility); } // This function gets called if a field gets updated by an undo command. @@ -141,6 +187,10 @@ void TabDiveInformation::divesChanged(const QVector<dive *> &dives, DiveField fi if (!current_dive || !dives.contains(current_dive)) return; + if (field.visibility) + ui->visibility->setCurrentStars(current_dive->visibility); + if (field.mode) + updateMode(current_dive); if (field.duration || field.depth || field.mode) updateProfile(); if (field.air_temp) @@ -149,12 +199,29 @@ void TabDiveInformation::divesChanged(const QVector<dive *> &dives, DiveField fi ui->waterTemperatureText->setText(get_temperature_string(current_dive->watertemp, true)); if (field.atm_press) ui->atmPressVal->setText(ui->atmPressVal->text().sprintf("%d",current_dive->surface_pressure.mbar)); - if (field.datetime) - updateWhen(); if (field.salinity) updateSalinity(); } + +void TabDiveInformation::on_visibility_valueChanged(int value) +{ + if (current_dive) + divesEdited(Command::editVisibility(value, false)); +} + +void TabDiveInformation::updateMode(struct dive *d) +{ + ui->diveType->setCurrentIndex(get_dive_dc(d, dc_number)->divemode); + MainWindow::instance()->graphics->replot(); +} + +void TabDiveInformation::diveModeChanged(int index) +{ + if (current_dive) + divesEdited(Command::editMode(dc_number, (enum divemode_t)index, false)); +} + void TabDiveInformation::on_atmPressType_currentIndexChanged(int index) { updateTextBox(COMBO_CHANGED); } void TabDiveInformation::on_atmPressVal_editingFinished() { updateTextBox(TEXT_EDITED); } @@ -193,7 +260,7 @@ void TabDiveInformation::updateTextBox(int event) // Either the text box has bee break; } if (atmpress.mbar) - Command::editAtmPress(atmpress.mbar, false); // and save the pressure for undo + divesEdited(Command::editAtmPress(atmpress.mbar, false)); // and save the pressure for undo } } diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.h b/desktop-widgets/tab-widgets/TabDiveInformation.h index 5305f4146..8b38797c3 100644 --- a/desktop-widgets/tab-widgets/TabDiveInformation.h +++ b/desktop-widgets/tab-widgets/TabDiveInformation.h @@ -18,8 +18,10 @@ public: void clear() override; private slots: void divesChanged(const QVector<dive *> &dives, DiveField field); + void diveModeChanged(int index); void on_atmPressVal_editingFinished(); void on_atmPressType_currentIndexChanged(int index); + void on_visibility_valueChanged(int value); private: Ui::TabDiveInformation *ui; void updateProfile(); @@ -27,6 +29,9 @@ private: void updateWhen(); int pressTypeIndex; void updateTextBox(int event); + void updateMode(struct dive *d); + void divesEdited(int); + void closeWarning(); }; #endif diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.ui b/desktop-widgets/tab-widgets/TabDiveInformation.ui index b35ddf01d..41be1bd8a 100644 --- a/desktop-widgets/tab-widgets/TabDiveInformation.ui +++ b/desktop-widgets/tab-widgets/TabDiveInformation.ui @@ -15,6 +15,9 @@ </property> <layout class="QVBoxLayout" name="verticalLayout"> <item> + <widget class="KMessageWidget" name="multiDiveWarningMessage"/> + </item> + <item> <widget class="QScrollArea" name="scrollArea_3"> <property name="frameShape"> <enum>QFrame::NoFrame</enum> @@ -48,35 +51,65 @@ <number>0</number> </property> <property name="horizontalSpacing"> - <number>6</number> + <number>4</number> </property> <property name="verticalSpacing"> <number>0</number> </property> + + <item row="0" column="0"> + <widget class="QLabel" name="diveHeadingLabel"> + <property name="text"> + <string>DIVE</string> + </property> + </widget> + </item> + <item row="0" column="0"> - <widget class="QGroupBox" name="groupBox_5"> + <widget class="QLabel" name="diveHeadingLabel"> + <property name="text"> + <string>DIVE</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QGroupBox" name="diveModeBox"> <property name="title"> - <string>Date</string> + <string>Dive mode</string> + </property> + <property name="alignment"> + <set>Qt::AlignHCenter</set> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Ignored" vsizetype="Preferred"> + </sizepolicy> + </property> + <layout class="QHBoxLayout" name="diveModeLayout"> + <property name="alignment"> + <set>Qt::AlignBottom</set> </property> - <layout class="QHBoxLayout" name="diveInfoDateLayout"> <item> - <widget class="QLabel" name="dateText"> - <property name="text"> - <string/> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> + <widget class="QComboBox" name="diveType"> </widget> </item> </layout> </widget> </item> - <item row="0" column="2"> + + <item row="1" column="1"> <widget class="QGroupBox" name="groupBox_12"> <property name="title"> <string>Interval</string> </property> + <property name="alignment"> + <set>Qt::AlignHCenter</set> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Ignored" vsizetype="Preferred"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <layout class="QHBoxLayout" name="diveInfoSurfintervallLayout"> <item> <widget class="QLabel" name="surfaceIntervalText"> @@ -84,78 +117,124 @@ <string/> </property> <property name="alignment"> - <set>Qt::AlignCenter</set> + <set>Qt::AlignHCenter</set> </property> </widget> </item> </layout> </widget> </item> - <item row="1" column="0"> - <widget class="QGroupBox" name="groupBox_3"> + <item row="1" column="2"> + <widget class="QGroupBox" name="groupBox_11"> <property name="title"> - <string>Gases used</string> + <string>Duration</string> </property> - <layout class="QHBoxLayout" name="diveInfoGasesUsedLayout"> + <property name="alignment"> + <set>Qt::AlignHCenter</set> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Ignored" vsizetype="Preferred"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <layout class="QHBoxLayout" name="diveInfoDiveTimeLayout"> <item> - <widget class="QLabel" name="oxygenHeliumText"> + <widget class="QLabel" name="diveTimeText"> <property name="text"> <string/> </property> <property name="alignment"> - <set>Qt::AlignCenter</set> + <set>Qt::AlignHCenter</set> </property> </widget> </item> </layout> </widget> </item> - <item row="1" column="1"> - <widget class="QGroupBox" name="groupBox_4"> + <item row="1" column="3"> + <widget class="QGroupBox" name="groupBox_6"> <property name="title"> - <string>Gas consumed</string> + <string>Max. depth</string> </property> - <layout class="QHBoxLayout" name="diveInfoGasConsumedLayout"> + <property name="alignment"> + <set>Qt::AlignHCenter</set> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Ignored" vsizetype="Preferred"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <layout class="QHBoxLayout" name="diveInfoMaxDepthLayout"> <item> - <widget class="QLabel" name="gasUsedText"> + <widget class="QLabel" name="maximumDepthText"> <property name="text"> <string/> </property> <property name="alignment"> - <set>Qt::AlignCenter</set> + <set>Qt::AlignHCenter</set> </property> </widget> </item> </layout> </widget> </item> - <item row="1" column="2"> - <widget class="QGroupBox" name="groupBox"> + + <item row="1" column="4"> + <widget class="QGroupBox" name="groupBox_7"> <property name="title"> - <string>SAC</string> + <string>Avg. depth</string> </property> - <layout class="QHBoxLayout" name="diveInfoSacLayout"> + <property name="alignment"> + <set>Qt::AlignHCenter</set> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Ignored" vsizetype="Preferred"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <layout class="QHBoxLayout" name="diveInfoAvgDepthLayout"> <item> - <widget class="QLabel" name="sacText"> + <widget class="QLabel" name="averageDepthText"> <property name="text"> <string/> </property> <property name="alignment"> - <set>Qt::AlignCenter</set> + <set>Qt::AlignHCenter</set> </property> </widget> </item> </layout> </widget> </item> + <item row="2" column="0"> - <widget class="QGroupBox" name="groupBox_15"> + <widget class="QLabel" name="gasHeadingLabel"> + <property name="text"> + <string>GAS</string> + </property> + </widget> + </item> + + <item row="3" column="0"> + <widget class="QGroupBox" name="groupBox_3"> <property name="title"> - <string>CNS</string> + <string> Gas name</string> </property> - <layout class="QHBoxLayout" name="diveInfoCnsLayout"> + <property name="alignment"> + <set>Qt::AlignHCenter</set> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Ignored" vsizetype="Preferred"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <layout class="QHBoxLayout" name="diveInfoGasesUsedLayout"> <item> - <widget class="QLabel" name="maxcnsText"> + <widget class="QLabel" name="oxygenHeliumText"> <property name="text"> <string/> </property> @@ -167,14 +246,23 @@ </layout> </widget> </item> - <item row="2" column="1"> - <widget class="QGroupBox" name="groupBox_2"> + <item row="3" column="1"> + <widget class="QGroupBox" name="groupBox_4"> <property name="title"> - <string>OTU</string> + <string>Gas consumed</string> </property> - <layout class="QHBoxLayout" name="diveInfoOtuLayout"> + <property name="alignment"> + <set>Qt::AlignHCenter</set> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Ignored" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <layout class="QHBoxLayout" name="diveInfoGasConsumedLayout"> <item> - <widget class="QLabel" name="otuText"> + <widget class="QLabel" name="gasUsedText"> <property name="text"> <string/> </property> @@ -186,14 +274,23 @@ </layout> </widget> </item> - <item row="3" column="1"> - <widget class="QGroupBox" name="groupBox_6"> + <item row="3" column="2"> + <widget class="QGroupBox" name="groupBox"> <property name="title"> - <string>Max. depth</string> + <string>SAC</string> </property> - <layout class="QHBoxLayout" name="diveInfoMaxDepthLayout"> + <property name="alignment"> + <set>Qt::AlignHCenter</set> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Ignored" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <layout class="QHBoxLayout" name="diveInfoSacLayout"> <item> - <widget class="QLabel" name="maximumDepthText"> + <widget class="QLabel" name="sacText"> <property name="text"> <string/> </property> @@ -205,14 +302,23 @@ </layout> </widget> </item> - <item row="3" column="0"> - <widget class="QGroupBox" name="groupBox_7"> + <item row="3" column="3"> + <widget class="QGroupBox" name="groupBox_15"> <property name="title"> - <string>Avg. depth</string> + <string>CNS</string> </property> - <layout class="QHBoxLayout" name="diveInfoAvgDepthLayout"> + <property name="alignment"> + <set>Qt::AlignHCenter</set> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Ignored" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>1</verstretch> + </sizepolicy> + </property> + <layout class="QHBoxLayout" name="diveInfoCnsLayout"> <item> - <widget class="QLabel" name="averageDepthText"> + <widget class="QLabel" name="maxcnsText"> <property name="text"> <string/> </property> @@ -224,42 +330,63 @@ </layout> </widget> </item> - - <item row="2" column="2" colspan="1"> - <widget class="QGroupBox" name="groupBox_10"> + <item row="3" column="4"> + <widget class="QGroupBox" name="groupBox_2"> <property name="title"> - <string>Atm. pressure</string> + <string>OTU</string> </property> <property name="alignment"> <set>Qt::AlignHCenter</set> </property> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <layout class="QHBoxLayout" name="diveInfoAirPressureLayout"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Ignored" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <layout class="QHBoxLayout" name="diveInfoOtuLayout"> <item> - <widget class="QLineEdit" name="atmPressVal"> - <property name="readOnly"> - <bool>false</bool> + <widget class="QLabel" name="otuText"> + <property name="text"> + <string/> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="atmPressType"> </widget> </item> </layout> </widget> </item> - <item row="3" column="2"> + <item row="4" column="0"> + <widget class="QLabel" name="environmentHeadingLabel"> + <property name="text"> + <string>ENVIRONMENT</string> + </property> + </widget> + </item> + + <item row="5" column="0"> <widget class="QGroupBox" name="groupBox_9"> <property name="title"> <string>Air temp.</string> </property> + <property name="alignment"> + <set>Qt::AlignHCenter</set> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Ignored" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <layout class="QHBoxLayout" name="diveInfoAirTempLayout"> <item> <widget class="QLabel" name="airTemperatureText"> @@ -267,18 +394,28 @@ <string/> </property> <property name="alignment"> - <set>Qt::AlignCenter</set> + <set>Qt::AlignHCenter</set> </property> </widget> </item> </layout> </widget> </item> - <item row="4" column="0"> + + <item row="5" column="1"> <widget class="QGroupBox" name="groupBox_8"> <property name="title"> <string>Water temp.</string> </property> + <property name="alignment"> + <set>Qt::AlignHCenter</set> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Ignored" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <layout class="QHBoxLayout" name="diveInfoWaterTempLayout"> <item> <widget class="QLabel" name="waterTemperatureText"> @@ -286,49 +423,139 @@ <string/> </property> <property name="alignment"> - <set>Qt::AlignCenter</set> + <set>Qt::AlignHCenter</set> </property> </widget> </item> </layout> </widget> </item> - <item row="0" column="1"> - <widget class="QGroupBox" name="groupBox_11"> + + <item row="5" column="2" colspan="3"> + <layout class="QGridLayout" name="envGroupLayout"> + <property name="horizontalSpacing"> + <number>4</number> + </property> + + <item row="0" column="0"> + <widget class="QGroupBox" name="groupBox_1"> <property name="title"> - <string>Dive time</string> + <string>Water type/Density</string> </property> - <layout class="QHBoxLayout" name="diveInfoDiveTimeLayout"> + <property name="alignment"> + <set>Qt::AlignHCenter</set> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Ignored" vsizetype="Preferred"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <layout class="QHBoxLayout" name="diveInfoWaterDensityLayout"> + <item> - <widget class="QLabel" name="diveTimeText"> - <property name="text"> - <string/> - </property> + <widget class="QLabel" name="waterTypeText"> + <property name="text"> + <string>EN13319</string> + </property> + </widget> + </item> + + <item> + <widget class="QLabel" name="salinityText"> <property name="alignment"> <set>Qt::AlignCenter</set> </property> </widget> </item> + </layout> </widget> </item> - <item row="4" column="1"> - <widget class="QGroupBox" name="groupBox_1"> + + <item row="0" column="1"> + <widget class="QGroupBox" name="groupBox_10"> <property name="title"> - <string>Water type</string> + <string>Atm. pressure/Altitude</string> + </property> + <property name="alignment"> + <set>Qt::AlignHCenter</set> </property> - <layout class="QHBoxLayout" name="diveInfoSalinityLayout"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Ignored" vsizetype="Preferred"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <layout class="QHBoxLayout" name="diveInfoAirPressureLayout"> <item> - <widget class="QLabel" name="salinityText"> - <property name="alignment"> - <set>Qt::AlignCenter</set> + <widget class="QLineEdit" name="atmPressVal"> + <property name="readOnly"> + <bool>false</bool> </property> </widget> </item> + <item> + <widget class="QComboBox" name="atmPressType"> + </widget> + </item> </layout> </widget> </item> - <item row="5" column="0"> + + </layout> + </item> + + <item row="6" column="1" alignment="Qt::AlignVCenter"> + <widget class="QGroupBox" name="groupBox_visibility"> + <property name="title"> + <string>Visibility</string> + </property> + <property name="alignment"> + <set>Qt::AlignHCenter</set> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <layout class="QGridLayout" name="visibilityLayout"> + <property name="verticalSpacing"> + <number>0</number> + </property> + <item row="0" column="0" colspan="2" alignment="Qt::AlignHCenter"> + <widget class="StarWidget" name="visibility" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="focusPolicy"> + <enum>Qt::StrongFocus</enum> + </property> + </widget> + </item> + <item row="1" column="0" alignment="Qt::AlignLeft"> + <widget class="QLabel" name="visLabel1"> + <property name="text"> + <string>Bad</string> + </property> + </widget> + </item> + <item row="1" column="1" alignment="Qt::AlignRight"> + <widget class="QLabel" name="visLabel2"> + <property name="text"> + <string>Good</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + + <item row="7" column="0"> <spacer> <property name="orientation"> <enum>Qt::Vertical</enum> @@ -336,6 +563,12 @@ <property name="sizeType"> <enum>QSizePolicy::Expanding</enum> </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <property name="sizeHint" stdset="0"> <size> <width>20</width> diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp index e10575942..7e82ca5f1 100644 --- a/desktop-widgets/tab-widgets/maintab.cpp +++ b/desktop-widgets/tab-widgets/maintab.cpp @@ -116,13 +116,6 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), // filled from a dive, they are made writeable setEnabled(false); - // This needs to be the same order as enum dive_comp_type in dive.h! - QStringList types = QStringList(); - for (int i = 0; i < NUM_DIVEMODE; i++) - types.append(gettextFromC::tr(divemode_text_ui[i])); - ui.DiveType->insertItems(0, types); - connect(ui.DiveType, SIGNAL(currentIndexChanged(int)), this, SLOT(divetype_Changed(int))); - Completers completers; completers.buddy = new QCompleter(&buddyModel, ui.buddy); completers.divemaster = new QCompleter(&diveMasterModel, ui.divemaster); @@ -282,12 +275,8 @@ void MainTab::divesChanged(const QVector<dive *> &dives, DiveField field) ui.watertemp->setText(get_temperature_string(current_dive->watertemp, true)); if (field.rating) ui.rating->setCurrentStars(current_dive->rating); - if (field.visibility) - ui.visibility->setCurrentStars(current_dive->visibility); if (field.notes) updateNotes(current_dive); - if (field.mode) - updateMode(current_dive); if (field.datetime) { updateDateTime(current_dive); MainWindow::instance()->graphics->dateTimeChanged(); @@ -352,12 +341,6 @@ void MainTab::updateNotes(const struct dive *d) } } -void MainTab::updateMode(struct dive *d) -{ - ui.DiveType->setCurrentIndex(get_dive_dc(d, dc_number)->divemode); - MainWindow::instance()->graphics->replot(); -} - static QDateTime timestampToDateTime(timestamp_t when) { // Subsurface always uses "local time" as in "whatever was the local time at the location" @@ -442,14 +425,10 @@ void MainTab::updateDiveInfo() ui.BuddyLabel->setVisible(false); ui.rating->setVisible(false); ui.RatingLabel->setVisible(false); - ui.visibility->setVisible(false); - ui.visibilityLabel->setVisible(false); ui.tagWidget->setVisible(false); ui.TagLabel->setVisible(false); ui.airTempLabel->setVisible(false); ui.airtemp->setVisible(false); - ui.DiveType->setVisible(false); - ui.TypeLabel->setVisible(false); ui.waterTempLabel->setVisible(false); ui.watertemp->setVisible(false); ui.dateEdit->setReadOnly(true); @@ -496,16 +475,12 @@ void MainTab::updateDiveInfo() ui.buddy->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); ui.TagLabel->setVisible(true); ui.tagWidget->setVisible(true); ui.airTempLabel->setVisible(true); ui.airtemp->setVisible(true); - ui.TypeLabel->setVisible(true); - ui.DiveType->setVisible(true); ui.waterTempLabel->setVisible(true); ui.watertemp->setVisible(true); ui.dateEdit->setReadOnly(false); @@ -513,7 +488,6 @@ void MainTab::updateDiveInfo() ui.timeEdit->setVisible(true); /* and fill them from the dive */ ui.rating->setCurrentStars(current_dive->rating); - ui.visibility->setCurrentStars(current_dive->visibility); // reset labels in case we last displayed trip notes ui.LocationLabel->setText(tr("Location")); ui.NotesLabel->setText(tr("Notes")); @@ -525,7 +499,6 @@ void MainTab::updateDiveInfo() ui.durationLabel->setVisible(isManual); updateNotes(current_dive); - updateMode(current_dive); updateDiveSite(current_dive); updateDateTime(current_dive); ui.divemaster->setText(current_dive->divemaster); @@ -548,7 +521,6 @@ void MainTab::updateDiveInfo() /* clear the fields */ clearTabs(); ui.rating->setCurrentStars(0); - ui.visibility->setCurrentStars(0); ui.location->clear(); ui.divemaster->clear(); ui.buddy->clear(); @@ -771,13 +743,6 @@ void MainTab::on_airtemp_editingFinished() divesEdited(Command::editAirTemp(parseTemperatureToMkelvin(ui.airtemp->text()), false)); } -void MainTab::divetype_Changed(int index) -{ - if (editMode == IGNORE_MODE || !current_dive) - return; - divesEdited(Command::editMode(dc_number, (enum divemode_t)index, false)); -} - void MainTab::on_watertemp_editingFinished() { // If the field wasn't modified by the user, don't post a new undo command. @@ -881,14 +846,6 @@ void MainTab::on_rating_valueChanged(int value) divesEdited(Command::editRating(value, false)); } -void MainTab::on_visibility_valueChanged(int value) -{ - if (editMode == IGNORE_MODE || !current_dive) - return; - - divesEdited(Command::editVisibility(value, false)); -} - // Remove focus from any active field to update the corresponding value in the dive. // Do this by setting the focus to ourself void MainTab::stealFocus() diff --git a/desktop-widgets/tab-widgets/maintab.h b/desktop-widgets/tab-widgets/maintab.h index 55227c993..e4994a231 100644 --- a/desktop-widgets/tab-widgets/maintab.h +++ b/desktop-widgets/tab-widgets/maintab.h @@ -51,7 +51,6 @@ slots: void tripChanged(dive_trip *trip, TripField field); void updateDiveInfo(); void updateNotes(const struct dive *d); - void updateMode(struct dive *d); void updateDateTime(const struct dive *d); void updateTripDate(const struct dive_trip *t); void updateDiveSite(struct dive *d); @@ -66,12 +65,10 @@ slots: void on_airtemp_editingFinished(); void on_duration_editingFinished(); void on_depth_editingFinished(); - void divetype_Changed(int); void on_watertemp_editingFinished(); void on_dateEdit_dateChanged(const QDate &date); void on_timeEdit_timeChanged(const QTime & time); void on_rating_valueChanged(int value); - void on_visibility_valueChanged(int value); void on_tagWidget_editingFinished(); void hideMessage(); void closeMessage(); diff --git a/desktop-widgets/tab-widgets/maintab.ui b/desktop-widgets/tab-widgets/maintab.ui index 606f1dd54..8e172f91a 100644 --- a/desktop-widgets/tab-widgets/maintab.ui +++ b/desktop-widgets/tab-widgets/maintab.ui @@ -298,100 +298,15 @@ </layout> </item> <item> - <layout class="QGridLayout" name="gridLayout_8" columnstretch="0,0,1"> - <property name="leftMargin"> - <number>5</number> - </property> - <property name="rightMargin"> - <number>5</number> - </property> - <property name="horizontalSpacing"> + <layout class="QHBoxLayout" name="gridLayout_9"> + <property name="Spacing"> <number>5</number> </property> - <property name="verticalSpacing"> - <number>0</number> - </property> - <item row="0" column="0"> - <widget class="QLabel" name="RatingLabel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Rating</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLabel" name="visibilityLabel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Visibility</string> - </property> - </widget> - </item> - <item row="1" column="0" alignment="Qt::AlignVCenter"> - <widget class="StarWidget" name="rating" native="true"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="focusPolicy"> - <enum>Qt::StrongFocus</enum> - </property> - </widget> - </item> - <item row="1" column="1" alignment="Qt::AlignVCenter"> - <widget class="StarWidget" name="visibility" native="true"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="focusPolicy"> - <enum>Qt::StrongFocus</enum> - </property> - </widget> - </item> - <item row="1" column="2"> - <spacer> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> <item> - <layout class="QGridLayout" name="gridLayout_9"> - <property name="horizontalSpacing"> + <layout class="QVBoxLayout" name="gridLayout_tags"> + <property name="Spacing"> <number>5</number> </property> - <property name="verticalSpacing"> - <number>0</number> - </property> - <item row="1" column="1"> - <widget class="QComboBox" name="DiveType"/> - </item> <item row="0" column="0"> <widget class="QLabel" name="TagLabel"> <property name="text"> @@ -402,16 +317,6 @@ </property> </widget> </item> - <item row="0" column="1"> - <widget class="QLabel" name="TypeLabel"> - <property name="text"> - <string>Dive mode</string> - </property> - <property name="alignment"> - <set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set> - </property> - </widget> - </item> <item row="1" column="0"> <widget class="TagWidget" name="tagWidget"> <property name="sizePolicy"> @@ -440,6 +345,41 @@ </layout> </item> <item> + <layout class="QVBoxLayout" name="gridLayout_rating"> + <property name="Spacing"> + <number>5</number> + </property> + <item row="0" column="1"> + <widget class="QLabel" name="RatingLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Rating</string> + </property> + </widget> + </item> + <item row="1" column="1" alignment="Qt::AlignVCenter"> + <widget class="StarWidget" name="rating" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="focusPolicy"> + <enum>Qt::StrongFocus</enum> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + <item> <layout class="QVBoxLayout" name="verticalLayout_7"> <property name="spacing"> <number>0</number> |