filter: implement importing of filter presets

When importing a divelog, import filter presets. If there are
equal names, import only if the presets differ. In that case,
disambiguate the name. This made things a bit more complicated,
as comparison of filter presets had to be implemented.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2020-06-28 15:24:19 +02:00 committed by Dirk Hohndel
parent 631be569fe
commit f9721fce4b
14 changed files with 81 additions and 13 deletions

View file

@ -5,6 +5,7 @@
#define COMMAND_DIVELIST_H
#include "command_base.h"
#include "core/filterpreset.h"
#include <QVector>
@ -97,7 +98,8 @@ private:
class ImportDives : public DiveListBase {
public:
// Note: dives and trips are consumed - after the call they will be empty.
ImportDives(struct dive_table *dives, struct trip_table *trips, struct dive_site_table *sites, int flags, const QString &source);
ImportDives(struct dive_table *dives, struct trip_table *trips, struct dive_site_table *sites,
filter_preset_table_t *filter_presets, int flags, const QString &source);
private:
void undoit() override;
void redoit() override;
@ -109,11 +111,14 @@ private:
// For redo
std::vector<OwningDiveSitePtr> sitesToAdd;
std::vector<std::pair<QString,FilterData>>
filterPresetsToAdd;
// For undo
std::vector<dive_site *> sitesToRemove;
std::vector<dive *> selection;
dive * currentDive;
std::vector<dive *> selection;
dive *currentDive;
std::vector<int> filterPresetsToRemove;
};
class DeleteDive : public DiveListBase {