mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	The way inheritance is implemented for the undo commands confuses the Qt translation tooling - with the result that the context assumed by the tools used to extract the strings doesn't match the context calculated at runtime - so all the translations for the strings in undo commands fail (including creating proper numerus forms). This change forces a consistant context tag, at the price of creating a significant delta for the source strings (the strings themselves stay the same, but the context for a lot of them changes). I am hoping that Transifex is smart enough to automagically add the correct translations for these, but I guess I won't know until I try. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
		
			
				
	
	
		
			83 lines
		
	
	
	
		
			1.5 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			83 lines
		
	
	
	
		
			1.5 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| // SPDX-License-Identifier: GPL-2.0
 | |
| 
 | |
| #include "command_edit_trip.h"
 | |
| #include "core/qthelper.h"
 | |
| #include "core/selection.h"
 | |
| 
 | |
| namespace Command {
 | |
| 
 | |
| EditTripBase::EditTripBase(dive_trip *tripIn, const QString &newValue) : trip(tripIn),
 | |
| 	value(newValue)
 | |
| {
 | |
| }
 | |
| 
 | |
| // Note: Virtual functions cannot be called in the constructor.
 | |
| // Therefore, setting of the title is done here.
 | |
| bool EditTripBase::workToBeDone()
 | |
| {
 | |
| 	setText(Command::Base::tr("Edit %1").arg(fieldName()));
 | |
| 	return data(trip) != value;
 | |
| }
 | |
| 
 | |
| void EditTripBase::undo()
 | |
| {
 | |
| 	QString old = data(trip);
 | |
| 	set(trip, value);
 | |
| 	value = old;
 | |
| 
 | |
| 	emit diveListNotifier.tripChanged(trip, fieldId());
 | |
| }
 | |
| 
 | |
| // Undo and redo do the same as just the stored value is exchanged
 | |
| void EditTripBase::redo()
 | |
| {
 | |
| 	undo();
 | |
| }
 | |
| 
 | |
| // Implementation of virtual functions
 | |
| 
 | |
| // ***** Location *****
 | |
| void EditTripLocation::set(dive_trip *t, const QString &s) const
 | |
| {
 | |
| 	free(t->location);
 | |
| 	t->location = copy_qstring(s);
 | |
| }
 | |
| 
 | |
| QString EditTripLocation::data(dive_trip *t) const
 | |
| {
 | |
| 	return QString(t->location);
 | |
| }
 | |
| 
 | |
| QString EditTripLocation::fieldName() const
 | |
| {
 | |
| 	return Command::Base::tr("trip location");
 | |
| }
 | |
| 
 | |
| TripField EditTripLocation::fieldId() const
 | |
| {
 | |
| 	return TripField::LOCATION;
 | |
| }
 | |
| 
 | |
| // ***** Notes *****
 | |
| void EditTripNotes::set(dive_trip *t, const QString &s) const
 | |
| {
 | |
| 	free(t->notes);
 | |
| 	t->notes = copy_qstring(s);
 | |
| }
 | |
| 
 | |
| QString EditTripNotes::data(dive_trip *t) const
 | |
| {
 | |
| 	return QString(t->notes);
 | |
| }
 | |
| 
 | |
| QString EditTripNotes::fieldName() const
 | |
| {
 | |
| 	return Command::Base::tr("trip notes");
 | |
| }
 | |
| 
 | |
| TripField EditTripNotes::fieldId() const
 | |
| {
 | |
| 	return TripField::NOTES;
 | |
| }
 | |
| 
 | |
| } // namespace Command
 |