subsurface/desktop-widgets/tab-widgets/TabDiveExtraInfo.cpp
Berthold Stoeger 9f455b1457 selection: move current dive and divecomputer to selection.cpp
This tries to encapsulate the management of the current dive and
divecomputer in the selection code. The current dive is alreay
set by setSelection(). Add a new parameter to also set the
current divecomputer. If -1 is passed, then the current
computer number is remained. This will allow us to audit the code.
Because for now, the whole "current dive computer" thing seems
to be ill-defined.

This fixes a bug: the dive-computer number wasn't validated
when making a new dive the current dive. The new code has some
drawbacks though: when selecting a whole trip, the validation
will be called for all dives in the trip and thus the dive computer
number will depend on the dive with the lowest amount of dive
computers in the trip. This will need to be fixed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2023-04-16 20:23:59 +02:00

32 lines
715 B
C++

// SPDX-License-Identifier: GPL-2.0
#include "TabDiveExtraInfo.h"
#include "ui_TabDiveExtraInfo.h"
#include "core/dive.h"
#include "core/selection.h"
#include "qt-models/divecomputerextradatamodel.h"
TabDiveExtraInfo::TabDiveExtraInfo(QWidget *parent) :
TabBase(parent),
ui(new Ui::TabDiveExtraInfo()),
extraDataModel(new ExtraDataModel(this))
{
ui->setupUi(this);
ui->extraData->setModel(extraDataModel);
}
TabDiveExtraInfo::~TabDiveExtraInfo()
{
delete ui;
}
void TabDiveExtraInfo::updateData()
{
const struct divecomputer *currentdc = get_dive_dc(current_dive, dc_number);
if (currentdc)
extraDataModel->updateDiveComputer(currentdc);
}
void TabDiveExtraInfo::clear()
{
extraDataModel->clear();
}