core: port tag-list to C++

Also adds a new test, which tests merging of two tag-lists.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-05-29 17:57:48 +02:00 committed by bstoeger
parent 640ecb345b
commit f18acf6fb9
25 changed files with 195 additions and 227 deletions

View file

@ -1324,7 +1324,7 @@ void QMLManager::commitChanges(QString diveId, QString number, QString date, QSt
}
// normalize the tag list we have and the one we get from the UI
// try hard to deal with accidental white space issues
QStringList existingTagList = QString::fromStdString(taglist_get_tagstring(d->tag_list)).split(",", SKIP_EMPTY);
QStringList existingTagList = QString::fromStdString(taglist_get_tagstring(d->tags)).split(",", SKIP_EMPTY);
QStringList newTagList = tags.split(",", SKIP_EMPTY);
QStringList newCleanTagList;
for (QString s: newTagList) {
@ -1335,10 +1335,9 @@ void QMLManager::commitChanges(QString diveId, QString number, QString date, QSt
existingTagList.sort();
if (newCleanTagList.join(",") != existingTagList.join(",")) {
diveChanged = true;
taglist_free(d->tag_list);
d->tag_list = nullptr;
d->tags.clear();
for (QString tag: newCleanTagList)
taglist_add_tag(&d->tag_list, qPrintable(tag));
taglist_add_tag(d->tags, qPrintable(tag));
}
if (d->rating != rating) {
diveChanged = true;