mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	mobile/undo: compile undo commands and call undo command for deletion.
First steps towards full undo on mobile. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									5601104ba5
								
							
						
					
					
						commit
						c0095f690f
					
				
					 4 changed files with 18 additions and 26 deletions
				
			
		| 
						 | 
				
			
			@ -314,6 +314,7 @@ if (SUBSURFACE_TARGET_EXECUTABLE MATCHES "MobileExecutable")
 | 
			
		|||
		subsurface_mapwidget
 | 
			
		||||
		subsurface_backend_shared
 | 
			
		||||
		subsurface_models_mobile
 | 
			
		||||
		subsurface_commands_mobile
 | 
			
		||||
		subsurface_corelib
 | 
			
		||||
		${SUBSURFACE_LINK_LIBRARIES}
 | 
			
		||||
	)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,7 +18,7 @@ set(SUBSURFACE_GENERIC_COMMANDS_SRCS
 | 
			
		|||
if (SUBSURFACE_TARGET_EXECUTABLE MATCHES "DesktopExecutable")
 | 
			
		||||
	add_library(subsurface_commands_desktop STATIC ${SUBSURFACE_GENERIC_COMMANDS_SRCS})
 | 
			
		||||
	target_link_libraries(subsurface_commands_desktop ${QT_LIBRARIES})
 | 
			
		||||
#elseif (SUBSURFACE_TARGET_EXECUTABLE MATCHES "MobileExecutable")
 | 
			
		||||
#	add_library(subsurface_commands_mobile STATIC ${SUBSURFACE_GENERIC_COMMANDS_SRCS})
 | 
			
		||||
#	target_link_libraries(subsurface_commands_mobile ${QT_LIBRARIES})
 | 
			
		||||
elseif (SUBSURFACE_TARGET_EXECUTABLE MATCHES "MobileExecutable")
 | 
			
		||||
	add_library(subsurface_commands_mobile STATIC ${SUBSURFACE_GENERIC_COMMANDS_SRCS})
 | 
			
		||||
	target_link_libraries(subsurface_commands_mobile ${QT_LIBRARIES})
 | 
			
		||||
endif()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -49,7 +49,7 @@
 | 
			
		|||
#include "core/worldmap-save.h"
 | 
			
		||||
#include "core/uploadDiveLogsDE.h"
 | 
			
		||||
#include "core/uploadDiveShare.h"
 | 
			
		||||
 | 
			
		||||
#include "commands/command.h"
 | 
			
		||||
 | 
			
		||||
QMLManager *QMLManager::m_instance = NULL;
 | 
			
		||||
bool noCloudToCloud = false;
 | 
			
		||||
| 
						 | 
				
			
			@ -1429,28 +1429,7 @@ void QMLManager::deleteDive(int id)
 | 
			
		|||
		appendTextToLog("trying to delete non-existing dive");
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	// create the storage for the deleted dive and trip (if applicable)
 | 
			
		||||
	if (!deletedDive)
 | 
			
		||||
		deletedDive = alloc_dive();
 | 
			
		||||
	copy_dive(d, deletedDive);
 | 
			
		||||
	if (!deletedTrip) {
 | 
			
		||||
		deletedTrip = alloc_trip();
 | 
			
		||||
	} else {
 | 
			
		||||
		free(deletedTrip->location);
 | 
			
		||||
		free(deletedTrip->notes);
 | 
			
		||||
		memset(deletedTrip, 0, sizeof(struct dive_trip));
 | 
			
		||||
	}
 | 
			
		||||
	// if this is the last dive in that trip, remember the trip as well
 | 
			
		||||
	if (d->divetrip && d->divetrip->dives.nr == 1) {
 | 
			
		||||
		*deletedTrip = *d->divetrip;
 | 
			
		||||
		deletedTrip->location = copy_string(d->divetrip->location);
 | 
			
		||||
		deletedTrip->notes = copy_string(d->divetrip->notes);
 | 
			
		||||
		deletedTrip->dives.nr = 0;
 | 
			
		||||
		deletedDive->divetrip = deletedTrip;
 | 
			
		||||
	}
 | 
			
		||||
	DiveListModel::instance()->removeDiveById(id);
 | 
			
		||||
	delete_single_dive(get_idx_by_uniq_id(id));
 | 
			
		||||
	DiveListModel::instance()->resetInternalData();
 | 
			
		||||
	Command::deleteDive(QVector<dive *>{ d });
 | 
			
		||||
	changesNeedSaving();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,6 +15,12 @@ QTQUICK_COMPILER_SKIPPED_RESOURCES +=
 | 
			
		|||
SOURCES += ../../subsurface-mobile-main.cpp \
 | 
			
		||||
	../../subsurface-helper.cpp \
 | 
			
		||||
	../../map-widget/qmlmapwidgethelper.cpp \
 | 
			
		||||
	../../commands/command_base.cpp \
 | 
			
		||||
	../../commands/command.cpp \
 | 
			
		||||
	../../commands/command_divelist.cpp \
 | 
			
		||||
	../../commands/command_divesite.cpp \
 | 
			
		||||
	../../commands/command_edit.cpp \
 | 
			
		||||
	../../commands/command_edit_trip.cpp \
 | 
			
		||||
	../../core/cloudstorage.cpp \
 | 
			
		||||
	../../core/configuredivecomputerthreads.cpp \
 | 
			
		||||
	../../core/devicedetails.cpp \
 | 
			
		||||
| 
						 | 
				
			
			@ -174,6 +180,12 @@ INCLUDEPATH += ../../../install-root/ios/include/ \
 | 
			
		|||
	/usr/include/libxml2
 | 
			
		||||
 | 
			
		||||
HEADERS += \
 | 
			
		||||
	../../commands/command_base.h \
 | 
			
		||||
	../../commands/command.h \
 | 
			
		||||
	../../commands/command_divelist.h \
 | 
			
		||||
	../../commands/command_divesite.h \
 | 
			
		||||
	../../commands/command_edit.h \
 | 
			
		||||
	../../commands/command_edit_trip.h \
 | 
			
		||||
	../../core/libdivecomputer.h \
 | 
			
		||||
	../../core/cloudstorage.h \
 | 
			
		||||
	../../core/configuredivecomputerthreads.h \
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue