mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Undo: move dive-list logic into edit commands
The edit-commands were called with a list of selected dives and the original value. Move the creation of the list and extraction of the original value into the edit-commmands. This removes the "current is last" rule and allows for more flexibility. Since the depth- and duration editing applies only to the current dive and not all selected dives, add a parameter to the edit-commands controlling whether only the current or all selected dives are edited. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
		
							parent
							
								
									cddd5942f8
								
							
						
					
					
						commit
						5436f9b859
					
				
					 5 changed files with 114 additions and 100 deletions
				
			
		|  | @ -130,74 +130,74 @@ void purgeUnusedDiveSites() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Dive editing related commands
 | // Dive editing related commands
 | ||||||
| void editNotes(const QVector<dive *> dives, const QString &newValue, const QString &oldValue) | void editNotes(const QString &newValue, bool currentDiveOnly) | ||||||
| { | { | ||||||
| 	execute(new EditNotes(dives, newValue, oldValue)); | 	execute(new EditNotes(newValue, currentDiveOnly)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void editMode(const QVector<dive *> dives, int index, int newValue, int oldValue) | void editMode(int index, int newValue, bool currentDiveOnly) | ||||||
| { | { | ||||||
| 	execute(new EditMode(dives, index, newValue, oldValue)); | 	execute(new EditMode(index, newValue, currentDiveOnly)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void editSuit(const QVector<dive *> dives, const QString &newValue, const QString &oldValue) | void editSuit(const QString &newValue, bool currentDiveOnly) | ||||||
| { | { | ||||||
| 	execute(new EditSuit(dives, newValue, oldValue)); | 	execute(new EditSuit(newValue, currentDiveOnly)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void editRating(const QVector<dive *> dives, int newValue, int oldValue) | void editRating(int newValue, bool currentDiveOnly) | ||||||
| { | { | ||||||
| 	execute(new EditRating(dives, newValue, oldValue)); | 	execute(new EditRating(newValue, currentDiveOnly)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void editVisibility(const QVector<dive *> dives, int newValue, int oldValue) | void editVisibility(int newValue, bool currentDiveOnly) | ||||||
| { | { | ||||||
| 	execute(new EditVisibility(dives, newValue, oldValue)); | 	execute(new EditVisibility(newValue, currentDiveOnly)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void editAirTemp(const QVector<dive *> dives, int newValue, int oldValue) | void editAirTemp(int newValue, bool currentDiveOnly) | ||||||
| { | { | ||||||
| 	execute(new EditAirTemp(dives, newValue, oldValue)); | 	execute(new EditAirTemp(newValue, currentDiveOnly)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void editWaterTemp(const QVector<dive *> dives, int newValue, int oldValue) | void editWaterTemp(int newValue, bool currentDiveOnly) | ||||||
| { | { | ||||||
| 	execute(new EditWaterTemp(dives, newValue, oldValue)); | 	execute(new EditWaterTemp(newValue, currentDiveOnly)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void editDepth(const QVector<dive *> dives, int newValue, int oldValue) | void editDepth(int newValue, bool currentDiveOnly) | ||||||
| { | { | ||||||
| 	execute(new EditDepth(dives, newValue, oldValue)); | 	execute(new EditDepth(newValue, currentDiveOnly)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void editDuration(const QVector<dive *> dives, int newValue, int oldValue) | void editDuration(int newValue, bool currentDiveOnly) | ||||||
| { | { | ||||||
| 	execute(new EditDuration(dives, newValue, oldValue)); | 	execute(new EditDuration(newValue, currentDiveOnly)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void editDiveSite(const QVector<dive *> dives, struct dive_site *newValue, struct dive_site *oldValue) | void editDiveSite(struct dive_site *newValue, bool currentDiveOnly) | ||||||
| { | { | ||||||
| 	execute(new EditDiveSite(dives, newValue, oldValue)); | 	execute(new EditDiveSite(newValue, currentDiveOnly)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void editDiveSiteNew(const QVector<dive *> dives, const QString &newName, struct dive_site *oldValue) | void editDiveSiteNew(const QString &newName, bool currentDiveOnly) | ||||||
| { | { | ||||||
| 	execute(new EditDiveSiteNew(dives, newName, oldValue)); | 	execute(new EditDiveSiteNew(newName, currentDiveOnly)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void editTags(const QVector<dive *> &dives, const QStringList &newList, struct dive *d) | void editTags(const QStringList &newList, bool currentDiveOnly) | ||||||
| { | { | ||||||
| 	execute(new EditTags(dives, newList, d)); | 	execute(new EditTags(newList, currentDiveOnly)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void editBuddies(const QVector<dive *> &dives, const QStringList &newList, struct dive *d) | void editBuddies(const QStringList &newList, bool currentDiveOnly) | ||||||
| { | { | ||||||
| 	execute(new EditBuddies(dives, newList, d)); | 	execute(new EditBuddies(newList, currentDiveOnly)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void editDiveMaster(const QVector<dive *> &dives, const QStringList &newList, struct dive *d) | void editDiveMaster(const QStringList &newList, bool currentDiveOnly) | ||||||
| { | { | ||||||
| 	execute(new EditDiveMaster(dives, newList, d)); | 	execute(new EditDiveMaster(newList, currentDiveOnly)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } // namespace Command
 | } // namespace Command
 | ||||||
|  |  | ||||||
|  | @ -52,20 +52,20 @@ void purgeUnusedDiveSites(); | ||||||
| 
 | 
 | ||||||
| // 4) Dive editing related commands
 | // 4) Dive editing related commands
 | ||||||
| 
 | 
 | ||||||
| void editNotes(const QVector<dive *> dives, const QString &newValue, const QString &oldValue); | void editNotes(const QString &newValue, bool currentDiveOnly); | ||||||
| void editSuit(const QVector<dive *> dives, const QString &newValue, const QString &oldValue); | void editSuit(const QString &newValue, bool currentDiveOnly); | ||||||
| void editMode(const QVector<dive *> dives, int index, int newValue, int oldValue); | void editMode(int index, int newValue, bool currentDiveOnly); | ||||||
| void editRating(const QVector<dive *> dives, int newValue, int oldValue); | void editRating(int newValue, bool currentDiveOnly); | ||||||
| void editVisibility(const QVector<dive *> dives, int newValue, int oldValue); | void editVisibility(int newValue, bool currentDiveOnly); | ||||||
| void editAirTemp(const QVector<dive *> dives, int newValue, int oldValue); | void editAirTemp(int newValue, bool currentDiveOnly); | ||||||
| void editWaterTemp(const QVector<dive *> dives, int newValue, int oldValue); | void editWaterTemp(int newValue, bool currentDiveOnly); | ||||||
| void editDepth(const QVector<dive *> dives, int newValue, int oldValue); | void editDepth(int newValue, bool currentDiveOnly); | ||||||
| void editDuration(const QVector<dive *> dives, int newValue, int oldValue); | void editDuration(int newValue, bool currentDiveOnly); | ||||||
| void editDiveSite(const QVector<dive *> dives, struct dive_site *newValue, struct dive_site *oldValue); | void editDiveSite(struct dive_site *newValue, bool currentDiveOnly); | ||||||
| void editDiveSiteNew(const QVector<dive *> dives, const QString &newName, struct dive_site *oldValue); | void editDiveSiteNew(const QString &newName, bool currentDiveOnly); | ||||||
| void editTags(const QVector<dive *> &dives, const QStringList &newList, struct dive *d); | void editTags(const QStringList &newList, bool currentDiveOnly); | ||||||
| void editBuddies(const QVector<dive *> &dives, const QStringList &newList, struct dive *d); | void editBuddies(const QStringList &newList, bool currentDiveOnly); | ||||||
| void editDiveMaster(const QVector<dive *> &dives, const QStringList &newList, struct dive *d); | void editDiveMaster(const QStringList &newList, bool currentDiveOnly); | ||||||
| 
 | 
 | ||||||
| } // namespace Command
 | } // namespace Command
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -8,16 +8,28 @@ | ||||||
| 
 | 
 | ||||||
| namespace Command { | namespace Command { | ||||||
| 
 | 
 | ||||||
| template<typename T> | static std::vector<dive *> getSelectedDives(bool currentDiveOnly) | ||||||
| EditBase<T>::EditBase(const QVector<dive *> &divesIn, T newValue, T oldValue) : | { | ||||||
| 	value(std::move(newValue)), | 	if (currentDiveOnly) | ||||||
| 	old(std::move(oldValue)), | 		return current_dive ? std::vector<dive *> { current_dive } | ||||||
| 	dives(divesIn.toStdVector()) | 				    : std::vector<dive *> { }; | ||||||
|  | 
 | ||||||
|  | 	std::vector<dive *> res; | ||||||
|  | 	struct dive *d; | ||||||
|  | 	int i; | ||||||
|  | 	for_each_dive (i, d) { | ||||||
|  | 		if (d->selected) | ||||||
|  | 			res.push_back(d); | ||||||
|  | 	} | ||||||
|  | 	return res; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | template<typename T> | ||||||
|  | EditBase<T>::EditBase(T newValue, bool currentDiveOnly) : | ||||||
|  | 	value(std::move(newValue)), | ||||||
|  | 	dives(getSelectedDives(currentDiveOnly)), | ||||||
|  | 	current(current_dive) | ||||||
| { | { | ||||||
| 	// If there is nothing to do, clear the dives vector.
 |  | ||||||
| 	// This signals that no action has to be taken.
 |  | ||||||
| 	if (old == value) |  | ||||||
| 		dives.clear(); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // This is quite hackish: we can't use virtual functions in the constructor and
 | // This is quite hackish: we can't use virtual functions in the constructor and
 | ||||||
|  | @ -28,6 +40,16 @@ EditBase<T>::EditBase(const QVector<dive *> &divesIn, T newValue, T oldValue) : | ||||||
| template<typename T> | template<typename T> | ||||||
| bool EditBase<T>::workToBeDone() | bool EditBase<T>::workToBeDone() | ||||||
| { | { | ||||||
|  | 	// First, let's fetch the old value, i.e. the value of the current dive.
 | ||||||
|  | 	// If no current dive exists, bail.
 | ||||||
|  | 	if (!current) | ||||||
|  | 		return false; | ||||||
|  | 	old = data(current); | ||||||
|  | 
 | ||||||
|  | 	// If there is no change - do nothing.
 | ||||||
|  | 	if (old == value) | ||||||
|  | 		return false; | ||||||
|  | 
 | ||||||
| 	std::vector<dive *> divesNew; | 	std::vector<dive *> divesNew; | ||||||
| 	divesNew.reserve(dives.size()); | 	divesNew.reserve(dives.size()); | ||||||
| 	for (dive *d: dives) { | 	for (dive *d: dives) { | ||||||
|  | @ -42,7 +64,7 @@ bool EditBase<T>::workToBeDone() | ||||||
| 		//: remove the part in parantheses for %n = 1
 | 		//: remove the part in parantheses for %n = 1
 | ||||||
| 		setText(tr("Edit %1 (%n dive(s))", "", num_dives).arg(fieldName())); | 		setText(tr("Edit %1 (%n dive(s))", "", num_dives).arg(fieldName())); | ||||||
| 
 | 
 | ||||||
| 	return num_dives; | 	return num_dives > 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| template<typename T> | template<typename T> | ||||||
|  | @ -74,11 +96,11 @@ void EditBase<T>::undo() | ||||||
| // don't have their own constructor. They simply delegate to the base
 | // don't have their own constructor. They simply delegate to the base
 | ||||||
| // class by virtue of a "using" declaration.
 | // class by virtue of a "using" declaration.
 | ||||||
| template | template | ||||||
| EditBase<QString>::EditBase(const QVector<dive *> &dives, QString oldValue, QString newValue); | EditBase<QString>::EditBase(QString newValue, bool currentDiveOnly); | ||||||
| template | template | ||||||
| EditBase<int>::EditBase(const QVector<dive *> &dives, int oldValue, int newValue); | EditBase<int>::EditBase(int newValue, bool currentDiveOnly); | ||||||
| template | template | ||||||
| EditBase<struct dive_site *>::EditBase(const QVector<dive *> &dives, struct dive_site *oldValue, struct dive_site *newValue); | EditBase<struct dive_site *>::EditBase(struct dive_site *newValue, bool currentDiveOnly); | ||||||
| 
 | 
 | ||||||
| // Undo and redo do the same as just the stored value is exchanged
 | // Undo and redo do the same as just the stored value is exchanged
 | ||||||
| template<typename T> | template<typename T> | ||||||
|  | @ -305,9 +327,10 @@ void EditDiveSite::redo() | ||||||
| 	EditDiveSite::undo(); // Undo and redo do the same
 | 	EditDiveSite::undo(); // Undo and redo do the same
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static struct dive_site *createDiveSite(const QString &name, struct dive_site *old) | static struct dive_site *createDiveSite(const QString &name) | ||||||
| { | { | ||||||
| 	struct dive_site *ds = alloc_dive_site(); | 	struct dive_site *ds = alloc_dive_site(); | ||||||
|  | 	struct dive_site *old = current_dive ? current_dive->dive_site : nullptr; | ||||||
| 	if (old) { | 	if (old) { | ||||||
| 		copy_dive_site(old, ds); | 		copy_dive_site(old, ds); | ||||||
| 		free(ds->name); // Free name, as we will overwrite it with our own version
 | 		free(ds->name); // Free name, as we will overwrite it with our own version
 | ||||||
|  | @ -316,8 +339,8 @@ static struct dive_site *createDiveSite(const QString &name, struct dive_site *o | ||||||
| 	return ds; | 	return ds; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| EditDiveSiteNew::EditDiveSiteNew(const QVector<dive *> &dives, const QString &newName, struct dive_site *oldValue) : | EditDiveSiteNew::EditDiveSiteNew(const QString &newName, bool currentDiveOnly) : | ||||||
| 	EditDiveSite(dives, createDiveSite(newName, oldValue), oldValue), | 	EditDiveSite(createDiveSite(newName), currentDiveOnly), | ||||||
| 	diveSiteToAdd(value), | 	diveSiteToAdd(value), | ||||||
| 	diveSiteToRemove(nullptr) | 	diveSiteToRemove(nullptr) | ||||||
| { | { | ||||||
|  | @ -353,8 +376,8 @@ void EditDiveSiteNew::redo() | ||||||
| //	- Not derive EditMode from EditBase.
 | //	- Not derive EditMode from EditBase.
 | ||||||
| //	- Change the semantics of the mode-editing.
 | //	- Change the semantics of the mode-editing.
 | ||||||
| // The future will tell.
 | // The future will tell.
 | ||||||
| EditMode::EditMode(const QVector<dive *> &dives, int indexIn, int newValue, int oldValue) | EditMode::EditMode(int indexIn, int newValue, bool currentDiveOnly) | ||||||
| 	: EditBase(dives, newValue, oldValue), index(indexIn) | 	: EditBase(newValue, currentDiveOnly), index(indexIn) | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -380,10 +403,10 @@ DiveField EditMode::fieldId() const | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // ***** Tag based commands *****
 | // ***** Tag based commands *****
 | ||||||
| EditTagsBase::EditTagsBase(const QVector<dive *> &divesIn, const QStringList &newListIn, struct dive *d): | EditTagsBase::EditTagsBase(const QStringList &newListIn, bool currentDiveOnly) : | ||||||
| 	dives(divesIn.toStdVector()), | 	dives(getSelectedDives(currentDiveOnly)), | ||||||
| 	newList(newListIn), | 	current(current_dive), | ||||||
| 	oldDive(d) | 	newList(newListIn) | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -412,8 +435,12 @@ bool EditTagsBase::workToBeDone() | ||||||
| 	// here's what I think... add the tags that were added to the displayed dive and remove the tags
 | 	// here's what I think... add the tags that were added to the displayed dive and remove the tags
 | ||||||
| 	// that were removed from it
 | 	// that were removed from it
 | ||||||
| 
 | 
 | ||||||
|  | 	// If there is no current dive, bail.
 | ||||||
|  | 	if (!current) | ||||||
|  | 		return false; | ||||||
|  | 
 | ||||||
| 	// Calculate tags to add and tags to remove
 | 	// Calculate tags to add and tags to remove
 | ||||||
| 	QStringList oldList = data(oldDive); | 	QStringList oldList = data(current); | ||||||
| 	for (const QString &s: newList) { | 	for (const QString &s: newList) { | ||||||
| 		if (!oldList.contains(s)) | 		if (!oldList.contains(s)) | ||||||
| 			tagsToAdd.push_back(s); | 			tagsToAdd.push_back(s); | ||||||
|  | @ -441,7 +468,7 @@ bool EditTagsBase::workToBeDone() | ||||||
| 		//: remove the part in parantheses for %n = 1
 | 		//: remove the part in parantheses for %n = 1
 | ||||||
| 		setText(tr("Edit %1 (%n dive(s))", "", num_dives).arg(fieldName())); | 		setText(tr("Edit %1 (%n dive(s))", "", num_dives).arg(fieldName())); | ||||||
| 
 | 
 | ||||||
| 	return num_dives; | 	return num_dives != 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void EditTagsBase::undo() | void EditTagsBase::undo() | ||||||
|  |  | ||||||
|  | @ -33,12 +33,10 @@ protected: | ||||||
| 	void redo() override; | 	void redo() override; | ||||||
| 	bool workToBeDone() override; | 	bool workToBeDone() override; | ||||||
| 
 | 
 | ||||||
| 	// Dives to be edited. For historical reasons, the *last* entry was
 | 	std::vector<dive *> dives; // Dives to be edited.
 | ||||||
| 	// the active dive when the user initialized the action. This dive
 | 	struct dive *current; // On undo, we set the current dive at the time of the operation.
 | ||||||
| 	// will be made the current dive on redo / undo.
 |  | ||||||
| 	std::vector<dive *> dives; |  | ||||||
| public: | public: | ||||||
| 	EditBase(const QVector<dive *> &dives, T newValue, T oldValue); | 	EditBase(T newValue, bool currentDiveOnly); | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	// Get and set functions to be overriden by sub-classes.
 | 	// Get and set functions to be overriden by sub-classes.
 | ||||||
|  | @ -139,7 +137,7 @@ class EditDiveSiteNew : public EditDiveSite { | ||||||
| public: | public: | ||||||
| 	OwningDiveSitePtr diveSiteToAdd; | 	OwningDiveSitePtr diveSiteToAdd; | ||||||
| 	struct dive_site *diveSiteToRemove; | 	struct dive_site *diveSiteToRemove; | ||||||
| 	EditDiveSiteNew(const QVector<dive *> &dives, const QString &newName, struct dive_site *oldValue); | 	EditDiveSiteNew(const QString &newName, bool currentDiveOnly); | ||||||
| 	void undo() override; | 	void undo() override; | ||||||
| 	void redo() override; | 	void redo() override; | ||||||
| }; | }; | ||||||
|  | @ -147,7 +145,7 @@ public: | ||||||
| class EditMode : public EditBase<int> { | class EditMode : public EditBase<int> { | ||||||
| 	int index; | 	int index; | ||||||
| public: | public: | ||||||
| 	EditMode(const QVector<dive *> &dives, int indexIn, int newValue, int oldValue); | 	EditMode(int indexIn, int newValue, bool currentDiveOnly); | ||||||
| 	void set(struct dive *d, int i) const override; | 	void set(struct dive *d, int i) const override; | ||||||
| 	int data(struct dive *d) const override; | 	int data(struct dive *d) const override; | ||||||
| 	QString fieldName() const override; | 	QString fieldName() const override; | ||||||
|  | @ -164,10 +162,10 @@ class EditTagsBase : public Base { | ||||||
| 	// the active dive when the user initialized the action. This dive
 | 	// the active dive when the user initialized the action. This dive
 | ||||||
| 	// will be made the current dive on redo / undo.
 | 	// will be made the current dive on redo / undo.
 | ||||||
| 	std::vector<dive *> dives; | 	std::vector<dive *> dives; | ||||||
|  | 	struct dive *current; | ||||||
| 	QStringList newList;	// Temporary until initialized
 | 	QStringList newList;	// Temporary until initialized
 | ||||||
| 	struct dive *oldDive;	// Temporary until initialized
 |  | ||||||
| public: | public: | ||||||
| 	EditTagsBase(const QVector<dive *> &dives, const QStringList &newList, struct dive *d); | 	EditTagsBase(const QStringList &newList, bool currentDiveOnly); | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	QStringList tagsToAdd; | 	QStringList tagsToAdd; | ||||||
|  |  | ||||||
|  | @ -737,13 +737,6 @@ static QVector<dive *> getSelectedDivesCurrentLast() | ||||||
| 	return res; | 	return res; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // When editing depth and duration, we only edit a single dive. Therefore, return the current dive as a list
 |  | ||||||
| static QVector<dive *> getCurrentAsList() |  | ||||||
| { |  | ||||||
| 	return current_dive ? QVector<dive *> { current_dive } |  | ||||||
| 			    : QVector<dive *> { }; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void MainTab::acceptChanges() | void MainTab::acceptChanges() | ||||||
| { | { | ||||||
| 	int i, addedId = -1; | 	int i, addedId = -1; | ||||||
|  | @ -1016,7 +1009,7 @@ void MainTab::on_buddy_editingFinished() | ||||||
| 	if (editMode == IGNORE || !current_dive) | 	if (editMode == IGNORE || !current_dive) | ||||||
| 		return; | 		return; | ||||||
| 
 | 
 | ||||||
| 	Command::editBuddies(getSelectedDivesCurrentLast(), stringToList(ui.buddy->toPlainText()), current_dive); | 	Command::editBuddies(stringToList(ui.buddy->toPlainText()), false); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void MainTab::on_divemaster_editingFinished() | void MainTab::on_divemaster_editingFinished() | ||||||
|  | @ -1024,7 +1017,7 @@ void MainTab::on_divemaster_editingFinished() | ||||||
| 	if (editMode == IGNORE || !current_dive) | 	if (editMode == IGNORE || !current_dive) | ||||||
| 		return; | 		return; | ||||||
| 
 | 
 | ||||||
| 	Command::editDiveMaster(getSelectedDivesCurrentLast(), stringToList(ui.divemaster->toPlainText()), current_dive); | 	Command::editDiveMaster(stringToList(ui.divemaster->toPlainText()), false); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void MainTab::on_duration_editingFinished() | void MainTab::on_duration_editingFinished() | ||||||
|  | @ -1033,7 +1026,7 @@ void MainTab::on_duration_editingFinished() | ||||||
| 		return; | 		return; | ||||||
| 
 | 
 | ||||||
| 	// Duration editing is special: we only edit the current dive.
 | 	// Duration editing is special: we only edit the current dive.
 | ||||||
| 	Command::editDuration(getCurrentAsList(), parseDurationToSeconds(ui.duration->text()), displayed_dive.dc.duration.seconds); | 	Command::editDuration(parseDurationToSeconds(ui.duration->text()), true); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void MainTab::on_depth_editingFinished() | void MainTab::on_depth_editingFinished() | ||||||
|  | @ -1042,32 +1035,28 @@ void MainTab::on_depth_editingFinished() | ||||||
| 		return; | 		return; | ||||||
| 
 | 
 | ||||||
| 	// Depth editing is special: we only edit the current dive.
 | 	// Depth editing is special: we only edit the current dive.
 | ||||||
| 	Command::editDepth(getCurrentAsList(),  parseLengthToMm(ui.depth->text()), current_dive->dc.maxdepth.mm); | 	Command::editDepth(parseLengthToMm(ui.depth->text()), true); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void MainTab::on_airtemp_editingFinished() | void MainTab::on_airtemp_editingFinished() | ||||||
| { | { | ||||||
| 	if (editMode == IGNORE || !current_dive) | 	if (editMode == IGNORE || !current_dive) | ||||||
| 		return; | 		return; | ||||||
| 	Command::editAirTemp(getSelectedDivesCurrentLast(), | 	Command::editAirTemp(parseTemperatureToMkelvin(ui.airtemp->text()), false); | ||||||
| 			     parseTemperatureToMkelvin(ui.airtemp->text()), current_dive->airtemp.mkelvin); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void MainTab::divetype_Changed(int index) | void MainTab::divetype_Changed(int index) | ||||||
| { | { | ||||||
| 	if (editMode == IGNORE || !current_dive) | 	if (editMode == IGNORE || !current_dive) | ||||||
| 		return; | 		return; | ||||||
| 	Command::editMode(getSelectedDivesCurrentLast(), dc_number, (enum divemode_t)index, | 	Command::editMode(dc_number, (enum divemode_t)index, false); | ||||||
| 			  get_dive_dc(current_dive, dc_number)->divemode); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void MainTab::on_watertemp_editingFinished() | void MainTab::on_watertemp_editingFinished() | ||||||
| { | { | ||||||
| 	if (editMode == IGNORE || !current_dive) | 	if (editMode == IGNORE || !current_dive) | ||||||
| 		return; | 		return; | ||||||
| 	Command::editWaterTemp(getSelectedDivesCurrentLast(), | 	Command::editWaterTemp(parseTemperatureToMkelvin(ui.watertemp->text()), false); | ||||||
| 			       parseTemperatureToMkelvin(ui.watertemp->text()), |  | ||||||
| 			       current_dive->watertemp.mkelvin); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Editing of the dive time is different. If multiple dives are edited,
 | // Editing of the dive time is different. If multiple dives are edited,
 | ||||||
|  | @ -1182,7 +1171,7 @@ void MainTab::on_tagWidget_editingFinished() | ||||||
| 	if (editMode == IGNORE || !current_dive) | 	if (editMode == IGNORE || !current_dive) | ||||||
| 		return; | 		return; | ||||||
| 
 | 
 | ||||||
| 	Command::editTags(getSelectedDivesCurrentLast(), ui.tagWidget->getBlockStringList(), current_dive); | 	Command::editTags(ui.tagWidget->getBlockStringList(), false); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void MainTab::on_location_diveSiteSelected() | void MainTab::on_location_diveSiteSelected() | ||||||
|  | @ -1192,9 +1181,9 @@ void MainTab::on_location_diveSiteSelected() | ||||||
| 
 | 
 | ||||||
| 	struct dive_site *newDs = ui.location->currDiveSite(); | 	struct dive_site *newDs = ui.location->currDiveSite(); | ||||||
| 	if (newDs == RECENTLY_ADDED_DIVESITE) | 	if (newDs == RECENTLY_ADDED_DIVESITE) | ||||||
| 		Command::editDiveSiteNew(getSelectedDivesCurrentLast(), ui.location->text(), current_dive->dive_site); | 		Command::editDiveSiteNew(ui.location->text(), false); | ||||||
| 	else | 	else | ||||||
| 		Command::editDiveSite(getSelectedDivesCurrentLast(), newDs, current_dive->dive_site); | 		Command::editDiveSite(newDs, false); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void MainTab::on_diveTripLocation_textEdited(const QString& text) | void MainTab::on_diveTripLocation_textEdited(const QString& text) | ||||||
|  | @ -1211,7 +1200,7 @@ void MainTab::on_suit_editingFinished() | ||||||
| 	if (editMode == IGNORE || !current_dive) | 	if (editMode == IGNORE || !current_dive) | ||||||
| 		return; | 		return; | ||||||
| 
 | 
 | ||||||
| 	Command::editSuit(getSelectedDivesCurrentLast(), ui.suit->text(), QString(current_dive->suit)); | 	Command::editSuit(ui.suit->text(), false); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void MainTab::on_notes_textChanged() | void MainTab::on_notes_textChanged() | ||||||
|  | @ -1235,7 +1224,7 @@ void MainTab::on_notes_editingFinished() | ||||||
| 	QString notes = ui.notes->toHtml().indexOf("<div") != -1 ? | 	QString notes = ui.notes->toHtml().indexOf("<div") != -1 ? | ||||||
| 		ui.notes->toHtml() : ui.notes->toPlainText(); | 		ui.notes->toHtml() : ui.notes->toPlainText(); | ||||||
| 
 | 
 | ||||||
| 	Command::editNotes(getSelectedDivesCurrentLast(), notes, QString(current_dive->notes)); | 	Command::editNotes(notes, false); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void MainTab::on_rating_valueChanged(int value) | void MainTab::on_rating_valueChanged(int value) | ||||||
|  | @ -1243,7 +1232,7 @@ void MainTab::on_rating_valueChanged(int value) | ||||||
| 	if (editMode == IGNORE || !current_dive) | 	if (editMode == IGNORE || !current_dive) | ||||||
| 		return; | 		return; | ||||||
| 
 | 
 | ||||||
| 	Command::editRating(getSelectedDivesCurrentLast(), value, current_dive->rating); | 	Command::editRating(value, false); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void MainTab::on_visibility_valueChanged(int value) | void MainTab::on_visibility_valueChanged(int value) | ||||||
|  | @ -1251,7 +1240,7 @@ void MainTab::on_visibility_valueChanged(int value) | ||||||
| 	if (editMode == IGNORE || !current_dive) | 	if (editMode == IGNORE || !current_dive) | ||||||
| 		return; | 		return; | ||||||
| 
 | 
 | ||||||
| 	Command::editVisibility(getSelectedDivesCurrentLast(), value, current_dive->visibility); | 	Command::editVisibility(value, false); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #undef MODIFY_DIVES | #undef MODIFY_DIVES | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue