Warn if Dive Mode / Cylinders are Changed to an Incorrect Configuration.

Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
Michael Keller 2025-01-22 14:00:28 +13:00 committed by Subsurface CI
parent 55a8b9089f
commit b5f823c85a
4 changed files with 35 additions and 7 deletions

View file

@ -43,6 +43,9 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent),
connect(m, &MultiFilterSortModel::divesSelected, this, &DiveListView::divesSelectedSlot);
connect(m, &MultiFilterSortModel::tripSelected, this, &DiveListView::tripSelected);
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);
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()
{
QAction *action = qobject_cast<QAction *>(sender());