core: remove filterconstraint C boilerplate code

Since all code can now directly access C++ structures these
accessor functions were not necessary.

Split out the table from the filterconstraint source file
and include it directly into the divelog.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-06-08 18:54:23 +02:00 committed by bstoeger
parent 2bdcdab391
commit 91968ac579
20 changed files with 212 additions and 250 deletions

View file

@ -492,11 +492,11 @@ ImportDives::ImportDives(struct divelog *log, int flags, const QString &source)
// When encountering filter presets with equal names, check whether they are
// the same. If they are, ignore them.
for (const filter_preset &preset: *log->filter_presets) {
for (const filter_preset &preset: log->filter_presets) {
std::string name = preset.name;
auto it = std::find_if(divelog.filter_presets->begin(), divelog.filter_presets->end(),
auto it = std::find_if(divelog.filter_presets.begin(), divelog.filter_presets.end(),
[&name](const filter_preset &preset) { return preset.name == name; });
if (it != divelog.filter_presets->end() && it->data == preset.data)
if (it != divelog.filter_presets.end() && it->data == preset.data)
continue;
filterPresetsToAdd.emplace_back(preset.name, preset.data);
}
@ -530,7 +530,7 @@ void ImportDives::redoit()
// Add new filter presets
for (auto &it: filterPresetsToAdd) {
filterPresetsToRemove.push_back(filter_preset_add(it.first, it.second));
filterPresetsToRemove.push_back(divelog.filter_presets.add(it.first, it.second));
emit diveListNotifier.filterPresetAdded(filterPresetsToRemove.back());
}
filterPresetsToAdd.clear();
@ -559,9 +559,10 @@ void ImportDives::undoit()
// Remove filter presets. Do this in reverse order.
for (auto it = filterPresetsToRemove.rbegin(); it != filterPresetsToRemove.rend(); ++it) {
int index = *it;
std::string oldName = filter_preset_name(index);
FilterData oldData = filter_preset_get(index);
filter_preset_delete(index);
const filter_preset &preset = divelog.filter_presets[index];
std::string oldName = preset.name;
FilterData oldData = preset.data;
divelog.filter_presets.remove(index);
emit diveListNotifier.filterPresetRemoved(index);
filterPresetsToAdd.emplace_back(oldName, oldData);
}