diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-11-14 17:42:59 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-11-14 10:01:50 -0800 |
commit | 38a784f5af3e19936df29e93b70a66e3741f8ea8 (patch) | |
tree | 2a6832759936eb91497d99457d8bae8c01db00a5 /qt-models/completionmodels.h | |
parent | 52d5125926f430a86dc14a60911b04b8072c712a (diff) | |
download | subsurface-38a784f5af3e19936df29e93b70a66e3741f8ea8.tar.gz |
desktop: automatically reload completion-models
Instead of programatically reload the completion models, listen
to the relevant signals in the models. To that goal, derive all
the models from a base class.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/completionmodels.h')
-rw-r--r-- | qt-models/completionmodels.h | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/qt-models/completionmodels.h b/qt-models/completionmodels.h index 24ba67e5f..6d271c348 100644 --- a/qt-models/completionmodels.h +++ b/qt-models/completionmodels.h @@ -2,30 +2,49 @@ #ifndef COMPLETIONMODELS_H #define COMPLETIONMODELS_H +#include "core/subsurface-qt/divelistnotifier.h" #include <QStringListModel> -class BuddyCompletionModel : public QStringListModel { +struct dive; + +class CompletionModelBase : public QStringListModel { Q_OBJECT public: + CompletionModelBase(); +private slots: void updateModel(); + void divesChanged(const QVector<dive *> &dives, DiveField field); +protected: + virtual QStringList getStrings() = 0; + virtual bool relevantDiveField(const DiveField &f) = 0; }; -class DiveMasterCompletionModel : public QStringListModel { +class BuddyCompletionModel final : public CompletionModelBase { Q_OBJECT -public: - void updateModel(); +private: + QStringList getStrings() override; + bool relevantDiveField(const DiveField &f) override; }; -class SuitCompletionModel : public QStringListModel { +class DiveMasterCompletionModel final : public CompletionModelBase { Q_OBJECT -public: - void updateModel(); +private: + QStringList getStrings() override; + bool relevantDiveField(const DiveField &f) override; }; -class TagCompletionModel : public QStringListModel { +class SuitCompletionModel final : public CompletionModelBase { Q_OBJECT -public: - void updateModel(); +private: + QStringList getStrings() override; + bool relevantDiveField(const DiveField &f) override; +}; + +class TagCompletionModel final : public CompletionModelBase { + Q_OBJECT +private: + QStringList getStrings() override; + bool relevantDiveField(const DiveField &f) override; }; #endif // COMPLETIONMODELS_H |