mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
52d5125926
commit
38a784f5af
5 changed files with 83 additions and 36 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue