mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Merge b5f823c85a into 71ebee8ab6
This commit is contained in:
commit
51308627e9
5 changed files with 54 additions and 1 deletions
|
|
@ -1042,6 +1042,27 @@ static void fixup_dc_sample_sensors(struct dive &dive, struct divecomputer &dc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int check_dc_cylinder_use(struct dive &dive, struct divecomputer &dc)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (dc.divemode != OC && dc.divemode != CCR && dc.divemode != PSCR)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
// Check that we have at least one cylinder that is suitable for the dive
|
||||||
|
|
||||||
|
// For OC we default to air if we don't have any cylinders
|
||||||
|
|
||||||
|
if (dc.divemode == OC && dive.cylinders.empty())
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
for (auto &cylinder: dive.cylinders)
|
||||||
|
if ((dc.divemode == CCR && cylinder.cylinder_use == DILUENT) || ((dc.divemode == PSCR || dc.divemode == OC) && cylinder.cylinder_use == OC_GAS))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return report_error("Dive: %u, dive computer: %s: %s dive, but no %s cylinder found. Please add or select the correct cylinder use.", dive.number, dc.model.c_str(), dc.divemode == OC ? "open circuit" : dc.divemode == CCR ? "CCR" : "PSCR", dc.divemode == OC ? "open circuit" : dc.divemode == CCR ? "diluent" : "drive gas");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void fixup_dive_dc(struct dive &dive, struct divecomputer &dc)
|
static void fixup_dive_dc(struct dive &dive, struct divecomputer &dc)
|
||||||
{
|
{
|
||||||
/* Fixup duration and mean depth */
|
/* Fixup duration and mean depth */
|
||||||
|
|
@ -1070,6 +1091,9 @@ static void fixup_dive_dc(struct dive &dive, struct divecomputer &dc)
|
||||||
/* Fixup CCR / PSCR dives with o2sensor values, but without no_o2sensors */
|
/* Fixup CCR / PSCR dives with o2sensor values, but without no_o2sensors */
|
||||||
fixup_no_o2sensors(dc);
|
fixup_no_o2sensors(dc);
|
||||||
|
|
||||||
|
/* Check cylinder use */
|
||||||
|
check_dc_cylinder_use(dive, dc);
|
||||||
|
|
||||||
/* If there are no samples, generate a fake profile based on depth and time */
|
/* If there are no samples, generate a fake profile based on depth and time */
|
||||||
if (dc.samples.empty())
|
if (dc.samples.empty())
|
||||||
fake_dc(&dc);
|
fake_dc(&dc);
|
||||||
|
|
|
||||||
|
|
@ -206,6 +206,8 @@ extern bool cylinder_with_sensor_sample(const struct dive *dive, int cylinder_id
|
||||||
|
|
||||||
extern void update_setpoint_events(const struct dive *dive, struct divecomputer *dc);
|
extern void update_setpoint_events(const struct dive *dive, struct divecomputer *dc);
|
||||||
|
|
||||||
|
extern int check_dc_cylinder_use(struct dive &dive, struct divecomputer &dc);
|
||||||
|
|
||||||
/* Make pointers to dive and dive_trip "Qt metatypes" so that they can be passed through
|
/* Make pointers to dive and dive_trip "Qt metatypes" so that they can be passed through
|
||||||
* QVariants and through QML.
|
* QVariants and through QML.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -62,8 +62,9 @@ void sanitize_gasmix(struct gasmix &mix)
|
||||||
/* Sane mix? */
|
/* Sane mix? */
|
||||||
if (o2 <= 1000 && he <= 1000 && o2 + he <= 1000)
|
if (o2 <= 1000 && he <= 1000 && o2 + he <= 1000)
|
||||||
return;
|
return;
|
||||||
report_info("Odd gasmix: %u O2 %u He", o2, he);
|
|
||||||
mix = gasmix_air;
|
mix = gasmix_air;
|
||||||
|
report_error("Odd gasmix: %u O2 %u He, switched to air.", o2, he);
|
||||||
}
|
}
|
||||||
|
|
||||||
int gasmix_distance(struct gasmix a, struct gasmix b)
|
int gasmix_distance(struct gasmix a, struct gasmix b)
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,9 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent),
|
||||||
connect(m, &MultiFilterSortModel::divesSelected, this, &DiveListView::divesSelectedSlot);
|
connect(m, &MultiFilterSortModel::divesSelected, this, &DiveListView::divesSelectedSlot);
|
||||||
connect(m, &MultiFilterSortModel::tripSelected, this, &DiveListView::tripSelected);
|
connect(m, &MultiFilterSortModel::tripSelected, this, &DiveListView::tripSelected);
|
||||||
connect(&diveListNotifier, &DiveListNotifier::settingsChanged, this, &DiveListView::settingsChanged);
|
connect(&diveListNotifier, &DiveListNotifier::settingsChanged, this, &DiveListView::settingsChanged);
|
||||||
|
connect(&diveListNotifier, &DiveListNotifier::divesChanged, this, &DiveListView::divesChanged);
|
||||||
|
connect(&diveListNotifier, &DiveListNotifier::cylinderEdited, this, &DiveListView::cylinderEdited);
|
||||||
|
connect(&diveListNotifier, &DiveListNotifier::cylinderRemoved, this, &DiveListView::cylinderEdited);
|
||||||
|
|
||||||
setSortingEnabled(true);
|
setSortingEnabled(true);
|
||||||
setContextMenuPolicy(Qt::DefaultContextMenu);
|
setContextMenuPolicy(Qt::DefaultContextMenu);
|
||||||
|
|
@ -389,6 +392,27 @@ void DiveListView::settingsChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void check_cylinder_use(struct dive &dive)
|
||||||
|
{
|
||||||
|
for (auto &divecomputer: dive.dcs)
|
||||||
|
check_dc_cylinder_use(dive, divecomputer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DiveListView::divesChanged(const QVector<dive *> &dives, DiveField field)
|
||||||
|
{
|
||||||
|
if (!field.mode)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (auto &dive: dives)
|
||||||
|
check_cylinder_use(*dive);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DiveListView::cylinderEdited(struct dive *dive, int)
|
||||||
|
{
|
||||||
|
check_cylinder_use(*dive);
|
||||||
|
}
|
||||||
|
|
||||||
void DiveListView::toggleColumnVisibilityByIndex()
|
void DiveListView::toggleColumnVisibilityByIndex()
|
||||||
{
|
{
|
||||||
QAction *action = qobject_cast<QAction *>(sender());
|
QAction *action = qobject_cast<QAction *>(sender());
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,8 @@ slots:
|
||||||
void shiftTimes();
|
void shiftTimes();
|
||||||
void divesSelectedSlot(const QVector<QModelIndex> &indices, QModelIndex currentDive, int currentDC);
|
void divesSelectedSlot(const QVector<QModelIndex> &indices, QModelIndex currentDive, int currentDC);
|
||||||
void tripSelected(QModelIndex trip, QModelIndex currentDive);
|
void tripSelected(QModelIndex trip, QModelIndex currentDive);
|
||||||
|
void divesChanged(const QVector<dive *> &dives, DiveField field);
|
||||||
|
void cylinderEdited(dive *dive, int);
|
||||||
private:
|
private:
|
||||||
void rowsInserted(const QModelIndex &parent, int start, int end) override;
|
void rowsInserted(const QModelIndex &parent, int start, int end) override;
|
||||||
void reset() override;
|
void reset() override;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue