mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	The copy/pasting of dive-sites was fundamentally broken in at least two ways: 1) The dive-site pointer in struct dive was simply overwritten, which breaks internal consistency. Also, no dive-site changed signals where sent. 2) The copied dive-site was stored as a pointer in a struct dive. Thus, the user could copy a dive, then delete the dive-site and paste. This would lead to a dangling pointer and ultimately crash the application. Fix this by storing the UUID of the dive-site, not a pointer. To do that, don't store a copy of the dive, but collect all the data in a `dive_paste_data` structure. If the dive site has been deleted on paste, do nothing. Send the appropriate signals on pasting. The mobile version had an additional bug: It kept a pointer to the dive to be copied, which might become stale by undo. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
		
			
				
	
	
		
			138 lines
		
	
	
	
		
			3.5 KiB
		
	
	
	
		
			QML
		
	
	
	
	
	
			
		
		
	
	
			138 lines
		
	
	
	
		
			3.5 KiB
		
	
	
	
		
			QML
		
	
	
	
	
	
| // SPDX-License-Identifier: GPL-2.0
 | |
| import QtQuick 2.6
 | |
| import QtQuick.Controls 2.2 as Controls
 | |
| import QtQuick.Window 2.2
 | |
| import QtQuick.Dialogs 1.2
 | |
| import QtQuick.Layouts 1.2
 | |
| import org.kde.kirigami 2.4 as Kirigami
 | |
| import org.subsurfacedivelog.mobile 1.0
 | |
| 
 | |
| Kirigami.ScrollablePage {
 | |
| 	objectName: "CopySettings"
 | |
| 	id: settingsCopy
 | |
| 
 | |
| 	title: qsTr("Copy Settings")
 | |
| 	background: Rectangle { color: subsurfaceTheme.backgroundColor }
 | |
| 
 | |
| 	property real gridWidth: settingsCopy.width - Kirigami.Units.gridUnit
 | |
| 
 | |
| 	ColumnLayout {
 | |
| 		width: gridWidth
 | |
| 
 | |
| 		GridLayout {
 | |
| 			id: copy_settings
 | |
| 			columns: 2
 | |
| 			Controls.Label {
 | |
| 				text: qsTr("Selection for copy-paste")
 | |
| 				font.pointSize: subsurfaceTheme.headingPointSize
 | |
| 				font.weight: Font.Light
 | |
| 				color: subsurfaceTheme.textColor
 | |
| 				Layout.topMargin: Kirigami.Units.largeSpacing
 | |
| 				Layout.bottomMargin: Kirigami.Units.largeSpacing / 2
 | |
| 				Layout.columnSpan: 2
 | |
| 			}
 | |
| 
 | |
| 			Controls.Label {
 | |
| 				text: qsTr("Dive site")
 | |
| 				font.pointSize: subsurfaceTheme.regularPointSize
 | |
| 				Layout.preferredWidth: gridWidth * 0.75
 | |
| 			}
 | |
| 			SsrfSwitch {
 | |
| 				checked: manager.pasteDiveSite
 | |
| 				Layout.preferredWidth: gridWidth * 0.25
 | |
| 			}
 | |
| 			Controls.Label {
 | |
| 				text: qsTr("Notes")
 | |
| 				font.pointSize: subsurfaceTheme.regularPointSize
 | |
| 				Layout.preferredWidth: gridWidth * 0.75
 | |
| 			}
 | |
| 			SsrfSwitch {
 | |
| 				checked: manager.pasteNotes
 | |
| 				Layout.preferredWidth: gridWidth * 0.25
 | |
| 			}
 | |
| 			Controls.Label {
 | |
| 				text: qsTr("Dive guide")
 | |
| 				font.pointSize: subsurfaceTheme.regularPointSize
 | |
| 				Layout.preferredWidth: gridWidth * 0.75
 | |
| 			}
 | |
| 			SsrfSwitch {
 | |
| 				checked: manager.pasteDiveGuide
 | |
| 				Layout.preferredWidth: gridWidth * 0.25
 | |
| 			}
 | |
| 			Controls.Label {
 | |
| 				text: qsTr("Buddy")
 | |
| 				font.pointSize: subsurfaceTheme.regularPointSize
 | |
| 				Layout.preferredWidth: gridWidth * 0.75
 | |
| 			}
 | |
| 			SsrfSwitch {
 | |
| 				checked: manager.pasteBuddy
 | |
| 				Layout.preferredWidth: gridWidth * 0.25
 | |
| 			}
 | |
| 			Controls.Label {
 | |
| 				text: qsTr("Suit")
 | |
| 				font.pointSize: subsurfaceTheme.regularPointSize
 | |
| 				Layout.preferredWidth: gridWidth * 0.75
 | |
| 			}
 | |
| 			SsrfSwitch {
 | |
| 				checked: manager.pasteSuit
 | |
| 				Layout.preferredWidth: gridWidth * 0.25
 | |
| 			}
 | |
| 			Controls.Label {
 | |
| 				text: qsTr("Rating")
 | |
| 				font.pointSize: subsurfaceTheme.regularPointSize
 | |
| 				Layout.preferredWidth: gridWidth * 0.75
 | |
| 			}
 | |
| 			SsrfSwitch {
 | |
| 				checked: manager.pasteRating
 | |
| 				Layout.preferredWidth: gridWidth * 0.25
 | |
| 			}
 | |
| 			Controls.Label {
 | |
| 				text: qsTr("Visibility")
 | |
| 				font.pointSize: subsurfaceTheme.regularPointSize
 | |
| 				Layout.preferredWidth: gridWidth * 0.75
 | |
| 			}
 | |
| 			SsrfSwitch {
 | |
| 				checked: manager.pasteVisibility
 | |
| 				Layout.preferredWidth: gridWidth * 0.25
 | |
| 			}
 | |
| 			Controls.Label {
 | |
| 				text: qsTr("Tags")
 | |
| 				font.pointSize: subsurfaceTheme.regularPointSize
 | |
| 				Layout.preferredWidth: gridWidth * 0.75
 | |
| 			}
 | |
| 			SsrfSwitch {
 | |
| 				checked: manager.pasteTags
 | |
| 				Layout.preferredWidth: gridWidth * 0.25
 | |
| 			}
 | |
| 			Controls.Label {
 | |
| 				text: qsTr("Cylinders")
 | |
| 				font.pointSize: subsurfaceTheme.regularPointSize
 | |
| 				Layout.preferredWidth: gridWidth * 0.75
 | |
| 			}
 | |
| 			SsrfSwitch {
 | |
| 				checked: manager.pasteCylinders
 | |
| 				Layout.preferredWidth: gridWidth * 0.25
 | |
| 			}
 | |
| 			Controls.Label {
 | |
| 				text: qsTr("Weights")
 | |
| 				font.pointSize: subsurfaceTheme.regularPointSize
 | |
| 				Layout.preferredWidth: gridWidth * 0.75
 | |
| 			}
 | |
| 			SsrfSwitch {
 | |
| 				checked: manager.pasteWeights
 | |
| 				Layout.preferredWidth: gridWidth * 0.25
 | |
| 			}
 | |
| 		}
 | |
| 
 | |
| 		Rectangle {
 | |
| 			color: subsurfaceTheme.darkerPrimaryColor
 | |
| 			height: 1
 | |
| 			opacity: 0.5
 | |
| 			Layout.fillWidth: true
 | |
| 		}
 | |
| 
 | |
| 		Item {
 | |
| 			height: Kirigami.Units.gridUnit * 6
 | |
| 		}
 | |
| 	}
 | |
| }
 |