core: turn C dive-table into an owning table

This is a humongous commit, because it touches all parts of the
code. It removes the last user of our horrible TABLE macros, which
simulate std::vector<> in a very clumsy way.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-06-07 10:25:09 +02:00 committed by bstoeger
parent f00c30ad4a
commit b95ac3f79c
73 changed files with 1030 additions and 1230 deletions

View file

@ -1,6 +1,8 @@
// SPDX-License-Identifier: GPL-2.0
#include "qt-models/completionmodels.h"
#include "core/dive.h"
#include "core/divelist.h"
#include "core/divelog.h"
#include "core/tag.h"
#include <QSet>
@ -31,10 +33,8 @@ void CompletionModelBase::divesChanged(const QVector<dive *> &, DiveField field)
static QStringList getCSVList(const std::string dive::*item)
{
QSet<QString> set;
struct dive *dive;
int i = 0;
for_each_dive (i, dive) {
QString str = QString::fromStdString(dive->*item);
for (auto &dive: divelog.dives) {
QString str = QString::fromStdString(dive.get()->*item);
for (const QString &value: str.split(",", SKIP_EMPTY))
set.insert(value.trimmed());
}
@ -66,9 +66,7 @@ bool DiveGuideCompletionModel::relevantDiveField(const DiveField &f)
QStringList SuitCompletionModel::getStrings()
{
QStringList list;
struct dive *dive;
int i = 0;
for_each_dive (i, dive) {
for (auto &dive: divelog.dives) {
QString suit = QString::fromStdString(dive->suit);
if (!list.contains(suit))
list.append(suit);