mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cylindermodel: Improve editing of tank use
Use the drop down for editing the tank use in the gas list in both the equipment tab and the dive planner. The tank use column is now available in the equipment tab for all dives and not just CCR dives, as 'not used' is a valid entry in both cases. However, if the current dive is an OC dive, only 'OC-gas' and 'not used' are shown. There still seems to be a problem that in some cases, when opening the planner after selecting an existing CCR dive the drop down in the planner does not list CCR gas uses - for some reason `displayed_dive` does not seem to be updated correctly on opening of the planner. But I have not been able to reproduce this consistently, and changing 'Dive mode' fixes this. Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
parent
1ed995aa7a
commit
1e3d378ad9
6 changed files with 21 additions and 19 deletions
|
@ -1,3 +1,4 @@
|
|||
desktop: use dynamic tank use drop down in equipment tab and planner
|
||||
desktop: fix brightness configuration for OSTC4
|
||||
equipment: Use 'diluent' as default gas use type if the dive mode is 'CCR'
|
||||
htmlexport: fix search in HTML export
|
||||
|
|
|
@ -51,6 +51,7 @@ DivePlannerWidget::DivePlannerWidget(QWidget *parent) : QWidget(parent, QFlag(0)
|
|||
view->setColumnHidden(CylindersModel::SIZE_INT, true);
|
||||
view->setColumnHidden(CylindersModel::SENSORS, true);
|
||||
view->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate(this));
|
||||
view->setItemDelegateForColumn(CylindersModel::USE, new TankUseDelegate(this));
|
||||
connect(ui.cylinderTableWidget, &TableView::addButtonClicked, plannerModel, &DivePlannerPointsModel::addCylinder_clicked);
|
||||
connect(ui.tableWidget, &TableView::addButtonClicked, plannerModel, &DivePlannerPointsModel::addDefaultStop);
|
||||
connect(cylinders, &CylindersModel::dataChanged, GasSelectionModel::instance(), &GasSelectionModel::repopulate);
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "qt-models/tankinfomodel.h"
|
||||
#include "qt-models/weightsysteminfomodel.h"
|
||||
#include "qt-models/weightmodel.h"
|
||||
#include "qt-models/diveplannermodel.h"
|
||||
#include "qt-models/divetripmodel.h"
|
||||
#include "qt-models/divelocationmodel.h"
|
||||
#include "core/qthelper.h"
|
||||
|
@ -254,9 +255,22 @@ TankUseDelegate::TankUseDelegate(QObject *parent) : QStyledItemDelegate(parent)
|
|||
|
||||
QWidget *TankUseDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &) const
|
||||
{
|
||||
struct divecomputer *currentDc;
|
||||
if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING) {
|
||||
currentDc = &displayed_dive.dc;
|
||||
} else {
|
||||
currentDc = get_dive_dc(current_dive, dc_number);
|
||||
}
|
||||
QComboBox *comboBox = new QComboBox(parent);
|
||||
for (int i = 0; i < NUM_GAS_USE; i++)
|
||||
if (!currentDc) {
|
||||
return comboBox;
|
||||
}
|
||||
bool isCcrDive = currentDc->divemode == CCR;
|
||||
for (int i = 0; i < NUM_GAS_USE; i++) {
|
||||
if (isCcrDive || (i != DILUENT && i != OXYGEN)) {
|
||||
comboBox->addItem(gettextFromC::tr(cylinderuse_text[i]));
|
||||
}
|
||||
}
|
||||
return comboBox;
|
||||
}
|
||||
|
||||
|
@ -270,7 +284,7 @@ void TankUseDelegate::setEditorData(QWidget *editor, const QModelIndex &index) c
|
|||
void TankUseDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
|
||||
{
|
||||
QComboBox *comboBox = qobject_cast<QComboBox *>(editor);
|
||||
model->setData(index, comboBox->currentIndex());
|
||||
model->setData(index, cylinderuse_from_text(qPrintable(comboBox->currentText())));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -142,11 +142,6 @@ void TabDiveEquipment::updateData()
|
|||
cylindersModel->updateDive(current_dive);
|
||||
weightModel->updateDive(current_dive);
|
||||
|
||||
bool is_ccr = current_dive && get_dive_dc(current_dive, dc_number)->divemode == CCR;
|
||||
if (is_ccr)
|
||||
ui.cylinders->view()->showColumn(CylindersModel::USE);
|
||||
else
|
||||
ui.cylinders->view()->hideColumn(CylindersModel::USE);
|
||||
if (current_dive && current_dive->suit)
|
||||
ui.suit->setText(QString(current_dive->suit));
|
||||
else
|
||||
|
|
|
@ -537,7 +537,7 @@ void CylindersModel::updateDive(dive *dIn)
|
|||
|
||||
Qt::ItemFlags CylindersModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
if (index.column() == REMOVE || index.column() == USE)
|
||||
if (index.column() == REMOVE)
|
||||
return Qt::ItemIsEnabled;
|
||||
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
|
||||
}
|
||||
|
@ -549,15 +549,6 @@ void CylindersModel::remove(QModelIndex index)
|
|||
{
|
||||
if (!d)
|
||||
return;
|
||||
if (index.column() == USE) {
|
||||
cylinder_t *cyl = cylinderAt(index);
|
||||
if (cyl->cylinder_use == OC_GAS)
|
||||
cyl->cylinder_use = NOT_USED;
|
||||
else if (cyl->cylinder_use == NOT_USED)
|
||||
cyl->cylinder_use = OC_GAS;
|
||||
dataChanged(index, index);
|
||||
return;
|
||||
}
|
||||
|
||||
if (index.column() != REMOVE)
|
||||
return;
|
||||
|
|
|
@ -1042,7 +1042,7 @@ void DivePlannerPointsModel::createTemporaryPlan()
|
|||
struct divedatapoint *dp = NULL;
|
||||
for (int i = 0; i < d->cylinders.nr; i++) {
|
||||
cylinder_t *cyl = get_cylinder(d, i);
|
||||
if (cyl->depth.mm && cyl->cylinder_use != NOT_USED) {
|
||||
if (cyl->depth.mm && cyl->cylinder_use == OC_GAS) {
|
||||
dp = create_dp(0, cyl->depth.mm, i, 0);
|
||||
if (diveplan.dp) {
|
||||
dp->next = diveplan.dp;
|
||||
|
|
Loading…
Add table
Reference in a new issue