| 
									
										
										
										
											2019-03-12 22:35:43 +01:00
										 |  |  | // SPDX-License-Identifier: GPL-2.0
 | 
					
						
							|  |  |  | // Note: this header file is used by the undo-machinery and should not be included elsewhere.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef COMMAND_DIVESITE_H
 | 
					
						
							|  |  |  | #define COMMAND_DIVESITE_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "command_base.h"
 | 
					
						
							| 
									
										
										
										
											2019-11-16 21:35:26 +01:00
										 |  |  | #include "core/gpslocation.h"
 | 
					
						
							| 
									
										
										
										
											2019-03-12 22:35:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <QVector>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // We put everything in a namespace, so that we can shorten names without polluting the global namespace
 | 
					
						
							|  |  |  | namespace Command { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-13 20:58:25 +01:00
										 |  |  | class AddDiveSite : public Base { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	AddDiveSite(const QString &name); | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	bool workToBeDone() override; | 
					
						
							|  |  |  | 	void undo() override; | 
					
						
							|  |  |  | 	void redo() override; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Note: we only add one dive site. Nevertheless, we use vectors so that we
 | 
					
						
							|  |  |  | 	// can reuse the dive site deletion code.
 | 
					
						
							| 
									
										
										
										
											2019-05-04 20:40:27 -07:00
										 |  |  | 	// For undo
 | 
					
						
							| 
									
										
										
										
											2019-03-13 20:58:25 +01:00
										 |  |  | 	std::vector<dive_site *> sitesToRemove; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-04 20:40:27 -07:00
										 |  |  | 	// For redo
 | 
					
						
							|  |  |  | 	std::vector<OwningDiveSitePtr> sitesToAdd; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class ImportDiveSites : public Base { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	// Note: the dive site table is consumed after the call it will be empty.
 | 
					
						
							|  |  |  | 	ImportDiveSites(struct dive_site_table *sites, const QString &source); | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	bool workToBeDone() override; | 
					
						
							|  |  |  | 	void undo() override; | 
					
						
							|  |  |  | 	void redo() override; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-13 20:58:25 +01:00
										 |  |  | 	// For undo
 | 
					
						
							| 
									
										
										
										
											2019-05-04 20:40:27 -07:00
										 |  |  | 	std::vector<dive_site *> sitesToRemove; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// For redo
 | 
					
						
							| 
									
										
										
										
											2019-03-13 20:58:25 +01:00
										 |  |  | 	std::vector<OwningDiveSitePtr> sitesToAdd; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-12 22:35:43 +01:00
										 |  |  | class DeleteDiveSites : public Base { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	DeleteDiveSites(const QVector<dive_site *> &sites); | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	bool workToBeDone() override; | 
					
						
							| 
									
										
										
										
											2019-03-12 23:51:39 +01:00
										 |  |  | 	void undo() override; | 
					
						
							|  |  |  | 	void redo() override; | 
					
						
							| 
									
										
										
										
											2019-03-12 22:35:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// For redo
 | 
					
						
							|  |  |  | 	std::vector<dive_site *> sitesToRemove; | 
					
						
							| 
									
										
										
										
											2019-03-19 19:52:54 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// For undo
 | 
					
						
							|  |  |  | 	std::vector<OwningDiveSitePtr> sitesToAdd; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class PurgeUnusedDiveSites : public Base { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	PurgeUnusedDiveSites(); | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	bool workToBeDone() override; | 
					
						
							|  |  |  | 	void undo() override; | 
					
						
							|  |  |  | 	void redo() override; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// For redo
 | 
					
						
							|  |  |  | 	std::vector<dive_site *> sitesToRemove; | 
					
						
							| 
									
										
										
										
											2019-03-12 22:35:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// For undo
 | 
					
						
							|  |  |  | 	std::vector<OwningDiveSitePtr> sitesToAdd; | 
					
						
							| 
									
										
										
										
											2019-03-12 23:51:39 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class EditDiveSiteName : public Base { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	EditDiveSiteName(dive_site *ds, const QString &name); | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	bool workToBeDone() override; | 
					
						
							| 
									
										
										
										
											2019-03-12 22:35:43 +01:00
										 |  |  | 	void undo() override; | 
					
						
							|  |  |  | 	void redo() override; | 
					
						
							| 
									
										
										
										
											2019-03-12 23:51:39 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	dive_site *ds; | 
					
						
							|  |  |  | 	QString value; // Value to be set
 | 
					
						
							| 
									
										
										
										
											2019-03-12 22:35:43 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-13 20:10:22 +01:00
										 |  |  | class EditDiveSiteDescription : public Base { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	EditDiveSiteDescription(dive_site *ds, const QString &description); | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	bool workToBeDone() override; | 
					
						
							|  |  |  | 	void undo() override; | 
					
						
							|  |  |  | 	void redo() override; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	dive_site *ds; | 
					
						
							|  |  |  | 	QString value; // Value to be set
 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-14 00:00:54 +01:00
										 |  |  | class EditDiveSiteNotes : public Base { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	EditDiveSiteNotes(dive_site *ds, const QString ¬es); | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	bool workToBeDone() override; | 
					
						
							|  |  |  | 	void undo() override; | 
					
						
							|  |  |  | 	void redo() override; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	dive_site *ds; | 
					
						
							|  |  |  | 	QString value; // Value to be set
 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-14 08:26:50 +01:00
										 |  |  | class EditDiveSiteCountry : public Base { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	EditDiveSiteCountry(dive_site *ds, const QString &country); | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	bool workToBeDone() override; | 
					
						
							|  |  |  | 	void undo() override; | 
					
						
							|  |  |  | 	void redo() override; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	dive_site *ds; | 
					
						
							|  |  |  | 	QString value; // Value to be set
 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-14 22:07:48 +01:00
										 |  |  | class EditDiveSiteLocation : public Base { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2019-03-14 23:28:45 +01:00
										 |  |  | 	EditDiveSiteLocation(dive_site *ds, location_t location); | 
					
						
							| 
									
										
										
										
											2019-03-14 22:07:48 +01:00
										 |  |  | private: | 
					
						
							|  |  |  | 	bool workToBeDone() override; | 
					
						
							|  |  |  | 	void undo() override; | 
					
						
							|  |  |  | 	void redo() override; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	dive_site *ds; | 
					
						
							|  |  |  | 	location_t value; // Value to be set
 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-15 14:32:55 +01:00
										 |  |  | class EditDiveSiteTaxonomy : public Base { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	EditDiveSiteTaxonomy(dive_site *ds, taxonomy_data &taxonomy); | 
					
						
							|  |  |  | 	~EditDiveSiteTaxonomy(); // free taxonomy
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	bool workToBeDone() override; | 
					
						
							|  |  |  | 	void undo() override; | 
					
						
							|  |  |  | 	void redo() override; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	dive_site *ds; | 
					
						
							|  |  |  | 	taxonomy_data value; // Value to be set
 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-15 17:41:31 +01:00
										 |  |  | class MergeDiveSites : public Base { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	MergeDiveSites(dive_site *ds, const QVector<dive_site *> &sites); | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	bool workToBeDone() override; | 
					
						
							|  |  |  | 	void undo() override; | 
					
						
							|  |  |  | 	void redo() override; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	dive_site *ds; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// For redo
 | 
					
						
							|  |  |  | 	std::vector<dive_site *> sitesToRemove; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// For undo
 | 
					
						
							|  |  |  | 	std::vector<OwningDiveSitePtr> sitesToAdd; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-16 21:35:26 +01:00
										 |  |  | class ApplyGPSFixes : public Base { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	// Note: the dive site table is consumed after the call it will be empty.
 | 
					
						
							|  |  |  | 	ApplyGPSFixes(const std::vector<DiveAndLocation> &fixes); | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	bool workToBeDone() override; | 
					
						
							|  |  |  | 	void undo() override; | 
					
						
							|  |  |  | 	void redo() override; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// For undo
 | 
					
						
							|  |  |  | 	std::vector<dive_site *> sitesToRemove; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// For redo
 | 
					
						
							|  |  |  | 	std::vector<OwningDiveSitePtr> sitesToAdd; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// For redo and undo
 | 
					
						
							|  |  |  | 	struct SiteAndLocation { | 
					
						
							|  |  |  | 		dive_site *ds; | 
					
						
							|  |  |  | 		location_t location; | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 	std::vector<SiteAndLocation> siteLocations; | 
					
						
							|  |  |  | 	void editDiveSites(); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-12 22:35:43 +01:00
										 |  |  | } // namespace Command
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif // COMMAND_DIVESITE_H
 |