mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
731052c776
commit
f1f082d86a
15 changed files with 59 additions and 55 deletions
|
@ -52,7 +52,7 @@ DivePlannerWidget::DivePlannerWidget(dive &planned_dive, int dcNr, PlannerWidget
|
|||
view->setColumnHidden(CylindersModel::SENSORS, true);
|
||||
view->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate(this));
|
||||
auto tankUseDelegate = new TankUseDelegate(this);
|
||||
tankUseDelegate->setCurrentDC(get_dive_dc(&planned_dive, dcNr));
|
||||
tankUseDelegate->setCurrentDC(planned_dive.get_dc(dcNr));
|
||||
view->setItemDelegateForColumn(CylindersModel::USE, tankUseDelegate);
|
||||
connect(ui.cylinderTableWidget, &TableView::addButtonClicked, plannerModel, &DivePlannerPointsModel::addCylinder_clicked);
|
||||
connect(ui.tableWidget, &TableView::addButtonClicked, plannerModel, &DivePlannerPointsModel::addDefaultStop);
|
||||
|
@ -563,7 +563,7 @@ int PlannerWidgets::getDcNr()
|
|||
|
||||
divemode_t PlannerWidgets::getRebreatherMode() const
|
||||
{
|
||||
return get_dive_dc(planned_dive.get(), dcNr)->divemode;
|
||||
return planned_dive->get_dc(dcNr)->divemode;
|
||||
}
|
||||
|
||||
void PlannerWidgets::preparePlanDive(const dive *currentDive, int currentDcNr)
|
||||
|
@ -575,8 +575,8 @@ void PlannerWidgets::preparePlanDive(const dive *currentDive, int currentDcNr)
|
|||
|
||||
// plan the dive in the same mode as the currently selected one
|
||||
if (currentDive) {
|
||||
plannerSettingsWidget.setDiveMode(get_dive_dc(currentDive, currentDcNr)->divemode);
|
||||
plannerSettingsWidget.setBailoutVisibility(get_dive_dc(currentDive, currentDcNr)->divemode);
|
||||
plannerSettingsWidget.setDiveMode(currentDive->get_dc(currentDcNr)->divemode);
|
||||
plannerSettingsWidget.setBailoutVisibility(currentDive->get_dc(currentDcNr)->divemode);
|
||||
if (currentDive->salinity)
|
||||
plannerWidget.setSalinity(currentDive->salinity);
|
||||
else // No salinity means salt water
|
||||
|
|
|
@ -663,7 +663,7 @@ void MainWindow::on_actionReplanDive_triggered()
|
|||
if (!plannerStateClean() || !current_dive || !userMayChangeAppState())
|
||||
return;
|
||||
|
||||
const struct divecomputer *dc = get_dive_dc(current_dive, profile->dc);
|
||||
const struct divecomputer *dc = current_dive->get_dc(profile->dc);
|
||||
if (!(is_dc_planner(dc) || is_dc_manually_added_dive(dc))) {
|
||||
if (QMessageBox::warning(this, tr("Warning"), tr("Trying to replan a dive profile that has not been manually added."),
|
||||
QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Cancel)
|
||||
|
|
|
@ -167,7 +167,7 @@ void ProfileWidget::setDive(const struct dive *d, int dcNr)
|
|||
{
|
||||
stack->setCurrentIndex(1); // show profile
|
||||
|
||||
bool freeDiveMode = get_dive_dc(d, dcNr)->divemode == FREEDIVE;
|
||||
bool freeDiveMode = d->get_dc(dcNr)->divemode == FREEDIVE;
|
||||
ui.profCalcCeiling->setDisabled(freeDiveMode);
|
||||
ui.profCalcCeiling->setDisabled(freeDiveMode);
|
||||
ui.profCalcAllTissues ->setDisabled(freeDiveMode);
|
||||
|
@ -219,7 +219,7 @@ void ProfileWidget::plotDive(dive *dIn, int dcIn)
|
|||
// or already editing the dive, switch to edit mode.
|
||||
if (d && !editedDive &&
|
||||
DivePlannerPointsModel::instance()->currentMode() == DivePlannerPointsModel::NOTHING) {
|
||||
struct divecomputer *comp = get_dive_dc(d, dc);
|
||||
struct divecomputer *comp = d->get_dc(dc);
|
||||
if (comp && is_dc_manually_added_dive(comp) && !comp->samples.empty() && comp->samples.size() <= 50)
|
||||
editDive();
|
||||
}
|
||||
|
@ -346,7 +346,7 @@ void ProfileWidget::exitEditMode()
|
|||
// Update depths of edited dive
|
||||
static void calcDepth(dive &d, int dcNr)
|
||||
{
|
||||
d.maxdepth.mm = get_dive_dc(&d, dcNr)->maxdepth.mm = 0;
|
||||
d.maxdepth.mm = d.get_dc(dcNr)->maxdepth.mm = 0;
|
||||
divelog.dives.fixup_dive(d);
|
||||
}
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ void TabDiveEquipment::toggleTriggeredColumn()
|
|||
|
||||
void TabDiveEquipment::updateData(const std::vector<dive *> &, dive *currentDive, int currentDC)
|
||||
{
|
||||
divecomputer *dc = get_dive_dc(currentDive, currentDC);
|
||||
divecomputer *dc = currentDive->get_dc(currentDC);
|
||||
|
||||
cylindersModel->updateDive(currentDive, currentDC);
|
||||
weightModel->updateDive(currentDive);
|
||||
|
|
|
@ -21,9 +21,8 @@ TabDiveExtraInfo::~TabDiveExtraInfo()
|
|||
|
||||
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);
|
||||
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();
|
||||
|
|
|
@ -188,5 +188,5 @@ bool MainTab::includesCurrentDive(const QVector<dive *> &dives) const
|
|||
|
||||
divecomputer *MainTab::getCurrentDC() const
|
||||
{
|
||||
return get_dive_dc(currentDive, currentDC);
|
||||
return currentDive ? currentDive->get_dc(currentDC) : nullptr;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue