Update filters on refreshDisplay and remember old selecttions

Update the filters if the list of dives is updated by calling
MultiFilterSortModel::instance()->myInvalidate();
This had the side effect of clearing all selections. Thus, in
the repopulate() methods of the FilterModels, check those
entries that were checked previously. Since all the filter
models use the same code, introduce a base class FilterModelBase.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2017-11-25 16:15:57 +01:00 committed by Dirk Hohndel
parent 4da6a0a732
commit dd2466f518
3 changed files with 53 additions and 25 deletions

View file

@ -16,7 +16,13 @@ public:
bool anyChecked;
};
class TagFilterModel : public QStringListModel, public MultiFilterInterface {
class FilterModelBase : public QStringListModel, public MultiFilterInterface {
protected:
explicit FilterModelBase(QObject *parent = 0);
void updateList(const QStringList &new_list);
};
class TagFilterModel : public FilterModelBase {
Q_OBJECT
public:
static TagFilterModel *instance();
@ -33,7 +39,7 @@ private:
explicit TagFilterModel(QObject *parent = 0);
};
class BuddyFilterModel : public QStringListModel, public MultiFilterInterface {
class BuddyFilterModel : public FilterModelBase {
Q_OBJECT
public:
static BuddyFilterModel *instance();
@ -50,7 +56,7 @@ private:
explicit BuddyFilterModel(QObject *parent = 0);
};
class LocationFilterModel : public QStringListModel, public MultiFilterInterface {
class LocationFilterModel : public FilterModelBase {
Q_OBJECT
public:
static LocationFilterModel *instance();
@ -67,7 +73,7 @@ private:
explicit LocationFilterModel(QObject *parent = 0);
};
class SuitsFilterModel : public QStringListModel, public MultiFilterInterface {
class SuitsFilterModel : public FilterModelBase {
Q_OBJECT
public:
static SuitsFilterModel *instance();