subsurface/desktop-widgets/tab-widgets/TabDiveExtraInfo.cpp
Berthold Stoeger 8cd191c271 desktop: store pointer to parent in tab-widgets
Make it possible for the individual tab-widgets to access the
parent widget. In principle this could have been done by
downcasting the pointer returned by parent(), but this makes
it explicit.

The goal here is to store information on the selection,
current dive, etc. without repeating it in every subwidget.

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

32 lines
775 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(MainTab *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 std::vector<dive *> &, dive *currentDive, int currentDC)
{
const struct divecomputer *currentdc = get_dive_dc(currentDive, currentDC);
if (currentdc)
extraDataModel->updateDiveComputer(currentdc);
}
void TabDiveExtraInfo::clear()
{
extraDataModel->clear();
}