mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	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>
		
			
				
	
	
		
			50 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			50 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| // SPDX-License-Identifier: GPL-2.0
 | |
| #ifndef COMPLETIONMODELS_H
 | |
| #define COMPLETIONMODELS_H
 | |
| 
 | |
| #include "core/subsurface-qt/divelistnotifier.h"
 | |
| #include <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 BuddyCompletionModel final : public CompletionModelBase {
 | |
| 	Q_OBJECT
 | |
| private:
 | |
| 	QStringList getStrings() override;
 | |
| 	bool relevantDiveField(const DiveField &f) override;
 | |
| };
 | |
| 
 | |
| class DiveMasterCompletionModel final : public CompletionModelBase {
 | |
| 	Q_OBJECT
 | |
| private:
 | |
| 	QStringList getStrings() override;
 | |
| 	bool relevantDiveField(const DiveField &f) override;
 | |
| };
 | |
| 
 | |
| class SuitCompletionModel final : public CompletionModelBase {
 | |
| 	Q_OBJECT
 | |
| 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
 |