mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	More multi-edit fixes
This time for values that aren't simply text. For normal integers this is rather straight forward. For the 'when' timestamp we simply assume that this is a shift in time. What is still missing is consistent handling of the three fields that are implemented as tags: tags, buddy and divemaster. We have special code for tags that makes no sense in a multi-edit scenario. And we treat divemaster and buddy as a single string - which kinda works but treats "Bill, Joe" and "Joe, Bill" as different. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									20595ac0d7
								
							
						
					
					
						commit
						024420a60d
					
				
					 1 changed files with 19 additions and 8 deletions
				
			
		|  | @ -864,6 +864,11 @@ void MainTab::rejectChanges() | |||
| 		mydive->what = strdup(textByteArray.data());                                         \ | ||||
| 	} | ||||
| 
 | ||||
| #define EDIT_VALUE(what, value)                      \ | ||||
| 	if (mydive->what == current_dive->what) {    \ | ||||
| 		mydive->what = value;                \ | ||||
| 	} | ||||
| 
 | ||||
| #define EDIT_TRIP_TEXT(what, text)                   \ | ||||
| 	QByteArray textByteArray = text.toUtf8();    \ | ||||
| 	free(what);                                  \ | ||||
|  | @ -900,14 +905,14 @@ void MainTab::on_divemaster_textChanged() | |||
| 
 | ||||
| void MainTab::on_airtemp_textChanged(const QString &text) | ||||
| { | ||||
| 	EDIT_SELECTED_DIVES(mydive->airtemp.mkelvin = parseTemperatureToMkelvin(text)); | ||||
| 	EDIT_SELECTED_DIVES(EDIT_VALUE(airtemp.mkelvin, parseTemperatureToMkelvin(text))); | ||||
| 	markChangedWidget(ui.airtemp); | ||||
| 	validate_temp_field(ui.airtemp, text); | ||||
| } | ||||
| 
 | ||||
| void MainTab::on_watertemp_textChanged(const QString &text) | ||||
| { | ||||
| 	EDIT_SELECTED_DIVES(mydive->watertemp.mkelvin = parseTemperatureToMkelvin(text)); | ||||
| 	EDIT_SELECTED_DIVES(EDIT_VALUE(watertemp.mkelvin, parseTemperatureToMkelvin(text))); | ||||
| 	markChangedWidget(ui.watertemp); | ||||
| 	validate_temp_field(ui.watertemp, text); | ||||
| } | ||||
|  | @ -939,14 +944,18 @@ void MainTab::validate_temp_field(QLineEdit *tempField,const QString &text) | |||
| 		missing_precision = false; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| // changing the time stamp on multiple dives really needs to be a relative shift
 | ||||
| void MainTab::on_dateTimeEdit_dateTimeChanged(const QDateTime &datetime) | ||||
| { | ||||
| 	QDateTime dateTimeUtc(datetime); | ||||
| 	dateTimeUtc.setTimeSpec(Qt::UTC); | ||||
| 	EDIT_SELECTED_DIVES(mydive->when = dateTimeUtc.toTime_t()); | ||||
| 	time_t offset = current_dive->when - dateTimeUtc.toTime_t(); | ||||
| 	EDIT_SELECTED_DIVES(mydive->when -= offset); | ||||
| 	markChangedWidget(ui.dateTimeEdit); | ||||
| } | ||||
| 
 | ||||
| // changing the tags on multiple dives is semantically strange - what's the right thing to do?
 | ||||
| void MainTab::saveTags() | ||||
| { | ||||
| 	EDIT_SELECTED_DIVES( | ||||
|  | @ -1017,9 +1026,6 @@ void MainTab::on_notes_textChanged() | |||
| 	markChangedWidget(ui.notes); | ||||
| } | ||||
| 
 | ||||
| #undef EDIT_TEXT | ||||
| #undef EDIT_TRIP_TEXT | ||||
| 
 | ||||
| void MainTab::on_coordinates_textChanged(const QString &text) | ||||
| { | ||||
| 	bool gpsChanged = false; | ||||
|  | @ -1036,14 +1042,19 @@ void MainTab::on_coordinates_textChanged(const QString &text) | |||
| 
 | ||||
| void MainTab::on_rating_valueChanged(int value) | ||||
| { | ||||
| 	EDIT_SELECTED_DIVES(mydive->rating = value); | ||||
| 	EDIT_SELECTED_DIVES(EDIT_VALUE(rating, value)); | ||||
| } | ||||
| 
 | ||||
| void MainTab::on_visibility_valueChanged(int value) | ||||
| { | ||||
| 	EDIT_SELECTED_DIVES(mydive->visibility = value); | ||||
| 	EDIT_SELECTED_DIVES(EDIT_VALUE(visibility, value)); | ||||
| } | ||||
| 
 | ||||
| #undef EDIT_SELECTED_DIVES | ||||
| #undef EDIT_TEXT | ||||
| #undef EDIT_TRIP_TEXT | ||||
| #undef EDIT_VALUE | ||||
| 
 | ||||
| void MainTab::editCylinderWidget(const QModelIndex &index) | ||||
| { | ||||
| 	if (cylindersModel->changed && editMode == NONE) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue