core: turn struct dive string data into std::string

Much easier memory management!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-05-29 20:40:18 +02:00 committed by bstoeger
parent 2b3d2f1020
commit 3cb04d230b
34 changed files with 208 additions and 313 deletions

View file

@ -328,17 +328,17 @@ void DiveComponentSelection::buttonClicked(QAbstractButton *button)
if (what->divesite && current_dive->dive_site)
text << tr("Dive site: ") << QString::fromStdString(current_dive->dive_site->name) << "\n";
if (what->diveguide)
text << tr("Dive guide: ") << current_dive->diveguide << "\n";
text << tr("Dive guide: ") << QString::fromStdString(current_dive->diveguide) << "\n";
if (what->buddy)
text << tr("Buddy: ") << current_dive->buddy << "\n";
text << tr("Buddy: ") << QString::fromStdString(current_dive->buddy) << "\n";
if (what->rating)
text << tr("Rating: ") + QString("*").repeated(current_dive->rating) << "\n";
if (what->visibility)
text << tr("Visibility: ") + QString("*").repeated(current_dive->visibility) << "\n";
if (what->notes)
text << tr("Notes:\n") << current_dive->notes << "\n";
text << tr("Notes:\n") << QString::fromStdString(current_dive->notes) << "\n";
if (what->suit)
text << tr("Suit: ") << current_dive->suit << "\n";
text << tr("Suit: ") << QString::fromStdString(current_dive->suit) << "\n";
if (what-> tags) {
text << tr("Tags: ");
for (const divetag *tag: current_dive->tags)

View file

@ -118,7 +118,7 @@ void TabDiveEquipment::divesChanged(const QVector<dive *> &dives, DiveField fiel
return;
if (field.suit)
ui.suit->setText(QString(parent.currentDive->suit));
ui.suit->setText(QString::fromStdString(parent.currentDive->suit));
}
void TabDiveEquipment::toggleTriggeredColumn()
@ -145,8 +145,8 @@ void TabDiveEquipment::updateData(const std::vector<dive *> &, dive *currentDive
sensorDelegate.setCurrentDC(dc);
tankUseDelegate.setCurrentDC(dc);
if (currentDive && currentDive->suit)
ui.suit->setText(QString(currentDive->suit));
if (currentDive && !currentDive->suit.empty())
ui.suit->setText(QString::fromStdString(currentDive->suit));
else
ui.suit->clear();
}

View file

@ -120,9 +120,9 @@ void TabDiveNotes::divesChanged(const QVector<dive *> &dives, DiveField field)
if (field.tags)
ui.tagWidget->setText(QString::fromStdString(taglist_get_tagstring(currentDive->tags)));
if (field.buddy)
ui.buddy->setText(currentDive->buddy);
ui.buddy->setText(QString::fromStdString(currentDive->buddy));
if (field.diveguide)
ui.diveguide->setText(currentDive->diveguide);
ui.diveguide->setText(QString::fromStdString(currentDive->diveguide));
}
void TabDiveNotes::diveSiteEdited(dive_site *ds, int)
@ -152,7 +152,7 @@ static bool isHtml(const QString &s)
void TabDiveNotes::updateNotes(const struct dive *d)
{
QString tmp(d->notes);
QString tmp = QString::fromStdString(d->notes);
if (isHtml(tmp)) {
ui.notes->setHtml(tmp);
} else {
@ -263,8 +263,8 @@ void TabDiveNotes::updateData(const std::vector<dive *> &, dive *currentDive, in
updateNotes(currentDive);
updateDiveSite(currentDive);
updateDateTime(currentDive);
ui.diveguide->setText(currentDive->diveguide);
ui.buddy->setText(currentDive->buddy);
ui.diveguide->setText(QString::fromStdString(currentDive->diveguide));
ui.buddy->setText(QString::fromStdString(currentDive->buddy));
}
ui.duration->setText(render_seconds_to_string(currentDive->duration.seconds));
ui.depth->setText(get_depth_string(currentDive->maxdepth, true));

View file

@ -540,11 +540,11 @@ QVariant TemplateLayout::getValue(QString list, QString property, const State &s
} else if (property == "meandepth") {
return get_depth_string(d->dcs[0].meandepth.mm, true, true);
} else if (property == "divemaster") {
return d->diveguide;
return QString::fromStdString(d->diveguide);
} else if (property == "diveguide") {
return d->diveguide;
return QString::fromStdString(d->diveguide);
} else if (property == "buddy") {
return d->buddy;
return QString::fromStdString(d->buddy);
} else if (property == "airTemp") {
return get_temperature_string(d->airtemp, true);
} else if (property == "waterTemp") {
@ -564,7 +564,7 @@ QVariant TemplateLayout::getValue(QString list, QString property, const State &s
} else if (property == "singleWeight") {
return d->weightsystems.size() <= 1;
} else if (property == "suit") {
return d->suit;
return QString::fromStdString(d->suit);
} else if (property == "cylinderList") {
return formatFullCylinderList();
} else if (property == "cylinders") {