subsurface/desktop-widgets/tab-widgets/TabDiveExtraInfo.cpp
Berthold Stoeger f1f082d86a core: move get_dive_dc() to struct dive
Feels natural in a C++ code base.

This removes a nullptr-check so some care has to be taken.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-08-13 19:28:30 +02:00

35 lines
909 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)
{
if (currentDive)
extraDataModel->updateDiveComputer(currentDive->get_dc(currentDC));
ui->extraData->setVisible(false); // This will cause the resize to include rows outside the current viewport
ui->extraData->resizeColumnsToContents();
ui->extraData->setVisible(true);
}
void TabDiveExtraInfo::clear()
{
extraDataModel->clear();
}