mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Undo: implement invalidate-dive command
Connect command to context menu. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
		
							parent
							
								
									329641fdcd
								
							
						
					
					
						commit
						4e47cdfa2c
					
				
					 8 changed files with 43 additions and 21 deletions
				
			
		|  | @ -1,3 +1,4 @@ | |||
| Desktop: implement dive invalidation | ||||
| Mobile-android: remove libusb/FTDI support (largely non-functional) | ||||
| Mobile-android: Continue download after obtaining USB permission | ||||
| Mobile-android: Add usb-serial-for-android driver support | ||||
|  |  | |||
|  | @ -168,6 +168,11 @@ int editMode(int index, int newValue, bool currentDiveOnly) | |||
| 	return execute_edit(new EditMode(index, newValue, currentDiveOnly)); | ||||
| } | ||||
| 
 | ||||
| int editInvalid(int newValue, bool currentDiveOnly) | ||||
| { | ||||
| 	return execute_edit(new EditInvalid(newValue, currentDiveOnly)); | ||||
| } | ||||
| 
 | ||||
| int editSuit(const QString &newValue, bool currentDiveOnly) | ||||
| { | ||||
| 	return execute_edit(new EditSuit(newValue, currentDiveOnly)); | ||||
|  |  | |||
|  | @ -66,6 +66,7 @@ void purgeUnusedDiveSites(); | |||
| int editNotes(const QString &newValue, bool currentDiveOnly); | ||||
| int editSuit(const QString &newValue, bool currentDiveOnly); | ||||
| int editMode(int index, int newValue, bool currentDiveOnly); | ||||
| int editInvalid(int newValue, bool currentDiveOnly); | ||||
| int editRating(int newValue, bool currentDiveOnly); | ||||
| int editVisibility(int newValue, bool currentDiveOnly); | ||||
| int editWaveSize(int newValue, bool currentDiveOnly); | ||||
|  |  | |||
|  | @ -574,6 +574,27 @@ DiveField EditMode::fieldId() const | |||
| 	return DiveField::MODE; | ||||
| } | ||||
| 
 | ||||
| // ***** Invalid *****
 | ||||
| void EditInvalid::set(struct dive *d, int invalid) const | ||||
| { | ||||
| 	d->invalid = invalid; | ||||
| } | ||||
| 
 | ||||
| int EditInvalid::data(struct dive *d) const | ||||
| { | ||||
| 	return d->invalid; | ||||
| } | ||||
| 
 | ||||
| QString EditInvalid::fieldName() const | ||||
| { | ||||
| 	return tr("invalid"); | ||||
| } | ||||
| 
 | ||||
| DiveField EditInvalid::fieldId() const | ||||
| { | ||||
| 	return DiveField::INVALID; | ||||
| } | ||||
| 
 | ||||
| // ***** Tag based commands *****
 | ||||
| EditTagsBase::EditTagsBase(const QStringList &newListIn, bool currentDiveOnly) : | ||||
| 	EditDivesBase(currentDiveOnly), | ||||
|  |  | |||
|  | @ -222,6 +222,15 @@ public: | |||
| 	DiveField fieldId() const override; | ||||
| }; | ||||
| 
 | ||||
| class EditInvalid : public EditBase<int> { | ||||
| public: | ||||
| 	using EditBase<int>::EditBase;	// Use constructor of base class.
 | ||||
| 	void set(struct dive *d, int number) const override; | ||||
| 	int data(struct dive *d) const override; | ||||
| 	QString fieldName() const override; | ||||
| 	DiveField fieldId() const override; | ||||
| }; | ||||
| 
 | ||||
| // Fields that work with tag-lists (tags, buddies, divemasters) work differently and therefore
 | ||||
| // have their own base class. In this case, it's not a template, as all these lists are base
 | ||||
| // on strings.
 | ||||
|  |  | |||
|  | @ -499,7 +499,7 @@ void save_one_dive_to_mb(struct membuffer *b, struct dive *dive, bool anonymize) | |||
| 	if (dive->chill) | ||||
| 		put_format(b, " chill='%d'", dive->chill); | ||||
| 	if (dive->invalid) | ||||
| 		put_format(b, " invalid"); | ||||
| 		put_format(b, " invalid='1'"); | ||||
| 	save_tags(b, dive->tag_list); | ||||
| 	if (dive->dive_site) | ||||
| 		put_format(b, " divesiteid='%8x'", dive->dive_site->uuid); | ||||
|  |  | |||
|  | @ -35,6 +35,7 @@ struct DiveField { | |||
| 	unsigned int mode : 1; | ||||
| 	unsigned int notes : 1; | ||||
| 	unsigned int salinity : 1; | ||||
| 	unsigned int invalid : 1; | ||||
| 	enum Flags { | ||||
| 		NONE = 0, | ||||
| 		NR = 1 << 0, | ||||
|  | @ -57,7 +58,8 @@ struct DiveField { | |||
| 		TAGS = 1 << 17, | ||||
| 		MODE = 1 << 18, | ||||
| 		NOTES = 1 << 19, | ||||
| 		SALINITY = 1 << 20 | ||||
| 		SALINITY = 1 << 20, | ||||
| 		INVALID = 1 << 21 | ||||
| 	}; | ||||
| 	DiveField(int flags); | ||||
| }; | ||||
|  |  | |||
|  | @ -838,22 +838,7 @@ void DiveListView::addToTrip(int delta) | |||
| 
 | ||||
| void DiveListView::markDiveInvalid() | ||||
| { | ||||
| 	int i; | ||||
| 	struct dive *d = contextMenuIndex.data(DiveTripModelBase::DIVE_ROLE).value<struct dive *>(); | ||||
| 	if (!d) | ||||
| 		return; | ||||
| 	for_each_dive (i, d) { | ||||
| 		if (!d->selected) | ||||
| 			continue; | ||||
| 		//TODO: this should be done in the future
 | ||||
| 		// now mark the dive invalid... how do we do THAT?
 | ||||
| 		// d->invalid = true;
 | ||||
| 	} | ||||
| 	mark_divelist_changed(true); | ||||
| 	MainWindow::instance()->refreshDisplay(); | ||||
| 	if (prefs.display_invalid_dives == false) { | ||||
| 		clearSelection(); | ||||
| 	} | ||||
| 	Command::editInvalid(true, false); | ||||
| } | ||||
| 
 | ||||
| void DiveListView::deleteDive() | ||||
|  | @ -935,9 +920,7 @@ void DiveListView::contextMenuEvent(QContextMenuEvent *event) | |||
| 	} | ||||
| 	if (d) { | ||||
| 		popup.addAction(tr("Delete dive(s)"), this, &DiveListView::deleteDive); | ||||
| #if 0 | ||||
| 		popup.addAction(tr("Mark dive(s) invalid", this, &DiveListView::markDiveInvalid); | ||||
| #endif | ||||
| 		popup.addAction(tr("Mark dive(s) invalid"), this, &DiveListView::markDiveInvalid); | ||||
| 	} | ||||
| 	if (amount_selected > 1 && consecutive_selected()) | ||||
| 		popup.addAction(tr("Merge selected dives"), this, &DiveListView::mergeDives); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue