mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Mobile: Display used cylinders on edit page
This displays the used cylinders in a dive so that they can be edited. Currently limited to 5 as a POC. Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
This commit is contained in:
		
							parent
							
								
									914b061d8a
								
							
						
					
					
						commit
						6b93e5fe27
					
				
					 2 changed files with 292 additions and 23 deletions
				
			
		|  | @ -33,16 +33,20 @@ Kirigami.Page { | |||
| 	property alias suitText: detailsEdit.suitText | ||||
| 	property alias suitModel: detailsEdit.suitModel | ||||
| 	property alias weight: detailsEdit.weightText | ||||
| 	property alias startpressure: detailsEdit.startpressureText | ||||
| 	property alias endpressure: detailsEdit.endpressureText | ||||
| 	property alias cylinderIndex: detailsEdit.cylinderIndex | ||||
| 	property alias cylinderText: detailsEdit.cylinderText | ||||
| 	property alias cylinderModel: detailsEdit.cylinderModel | ||||
| 	property alias gasmix: detailsEdit.gasmixText | ||||
| 	property alias startpressure0: detailsEdit.startpressureText0 | ||||
| 	property alias endpressure0: detailsEdit.endpressureText0 | ||||
| 	property alias cylinderIndex0: detailsEdit.cylinderIndex0 | ||||
| 	property alias cylinderIndex1: detailsEdit.cylinderIndex1 | ||||
| 	property alias cylinderIndex2: detailsEdit.cylinderIndex2 | ||||
| 	property alias cylinderIndex3: detailsEdit.cylinderIndex3 | ||||
| 	property alias cylinderIndex4: detailsEdit.cylinderIndex4 | ||||
| 	property alias gasmix0: detailsEdit.gasmixText0 | ||||
| 	property alias gpsCheckbox: detailsEdit.gpsCheckbox | ||||
| 	property int updateCurrentIdx: manager.updateSelectedDive | ||||
| 	property alias rating: detailsEdit.rating | ||||
| 	property alias visibility: detailsEdit.visibility | ||||
| 	property alias usedCyl: detailsEdit.usedCyl | ||||
| 	property alias cylinderModel: detailsEdit.cylinderModel | ||||
| 
 | ||||
| 	title: currentItem && currentItem.modelData ? currentItem.modelData.dive.location : qsTr("Dive details") | ||||
| 	state: "view" | ||||
|  | @ -258,10 +262,15 @@ Kirigami.Page { | |||
| 			// careful when translating, this text is "magic" in DiveDetailsEdit.qml | ||||
| 			weight = "cannot edit multiple weight systems" | ||||
| 		} | ||||
| 		startpressure = currentItem.modelData.dive.startPressure | ||||
| 		endpressure = currentItem.modelData.dive.endPressure | ||||
| 		gasmix = currentItem.modelData.dive.firstGas | ||||
| 		cylinderIndex = currentItem.modelData.dive.cylinderList.indexOf(currentItem.modelData.dive.getCylinder) | ||||
| 		startpressure0 = currentItem.modelData.dive.startPressure | ||||
| 		endpressure0 = currentItem.modelData.dive.endPressure | ||||
| 		gasmix0 = currentItem.modelData.dive.firstGas | ||||
| 		usedCyl = currentItem.modelData.dive.getCylinder | ||||
| 		cylinderIndex0 = currentItem.modelData.dive.cylinderList.indexOf(usedCyl[0]) | ||||
| 		cylinderIndex1 = currentItem.modelData.dive.cylinderList.indexOf(usedCyl[1]) | ||||
| 		cylinderIndex2 = currentItem.modelData.dive.cylinderList.indexOf(usedCyl[2]) | ||||
| 		cylinderIndex3 = currentItem.modelData.dive.cylinderList.indexOf(usedCyl[3]) | ||||
| 		cylinderIndex4 = currentItem.modelData.dive.cylinderList.indexOf(usedCyl[4]) | ||||
| 		rating = currentItem.modelData.dive.rating | ||||
| 		visibility = currentItem.modelData.dive.visibility | ||||
| 
 | ||||
|  |  | |||
|  | @ -22,23 +22,27 @@ Item { | |||
| 	property alias buddyText: buddyBox.editText | ||||
| 	property alias divemasterIndex: divemasterBox.currentIndex | ||||
| 	property alias divemasterText: divemasterBox.editText | ||||
| 	property alias cylinderIndex: cylinderBox.currentIndex | ||||
| 	property alias cylinderText: cylinderBox.editText | ||||
| 	property alias cylinderIndex0: cylinderBox0.currentIndex | ||||
| 	property alias cylinderIndex1: cylinderBox1.currentIndex | ||||
| 	property alias cylinderIndex2: cylinderBox2.currentIndex | ||||
| 	property alias cylinderIndex3: cylinderBox3.currentIndex | ||||
| 	property alias cylinderIndex4: cylinderBox4.currentIndex | ||||
| 	property alias notesText: txtNotes.text | ||||
| 	property alias durationText: txtDuration.text | ||||
| 	property alias depthText: txtDepth.text | ||||
| 	property alias weightText: txtWeight.text | ||||
| 	property alias startpressureText: txtStartPressure.text | ||||
| 	property alias endpressureText: txtEndPressure.text | ||||
| 	property alias gasmixText: txtGasMix.text | ||||
| 	property alias startpressureText0: txtStartPressure0.text | ||||
| 	property alias endpressureText0: txtEndPressure0.text | ||||
| 	property alias gasmixText0: txtGasMix0.text | ||||
| 	property alias gpsCheckbox: checkboxGPS.checked | ||||
| 	property alias suitModel: suitBox.model | ||||
| 	property alias divemasterModel: divemasterBox.model | ||||
| 	property alias buddyModel: buddyBox.model | ||||
| 	property alias cylinderModel: cylinderBox.model | ||||
| 	property alias cylinderModel: cylinderBox0.model | ||||
| 	property alias locationModel: locationBox.model | ||||
| 	property int rating | ||||
| 	property int visibility | ||||
| 	property var usedCyl: [] | ||||
| 
 | ||||
| 	function clearDetailsEdit() { | ||||
| 		detailsEdit.dive_id = 0 | ||||
|  | @ -54,7 +58,11 @@ Item { | |||
| 		suitBox.currentIndex = -1 | ||||
| 		buddyBox.currentIndex = -1 | ||||
| 		divemasterBox.currentIndex = -1 | ||||
| 		cylinderBox.currentIndex = -1 | ||||
| 		cylinderBox0.currentIndex = -1 | ||||
| 		cylinderBox1.currentIndex = -1 | ||||
| 		cylinderBox2.currentIndex = -1 | ||||
| 		cylinderBox3.currentIndex = -1 | ||||
| 		cylinderBox4.currentIndex = -1 | ||||
| 		detailsEdit.notesText = "" | ||||
| 		detailsEdit.rating = 0 | ||||
| 		detailsEdit.visibility = 0 | ||||
|  | @ -311,14 +319,15 @@ Item { | |||
| 					focus = false | ||||
| 				} | ||||
| 			} | ||||
| 
 | ||||
| // all cylinder info should be able to become dynamic instead of this blob of code. | ||||
| // first cylinder | ||||
| 			Controls.Label { | ||||
| 				Layout.alignment: Qt.AlignRight | ||||
| 				text: qsTr("Cylinder:") | ||||
| 				text: qsTr("Cylinder1:") | ||||
| 				font.pointSize: subsurfaceTheme.smallPointSize | ||||
| 			} | ||||
| 			Controls.ComboBox { | ||||
| 				id: cylinderBox | ||||
| 				id: cylinderBox0 | ||||
| 				flat: true | ||||
| 				model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ? | ||||
| 					diveDetailsListView.currentItem.modelData.dive.cylinderList : null | ||||
|  | @ -332,7 +341,7 @@ Item { | |||
| 				font.pointSize: subsurfaceTheme.smallPointSize | ||||
| 			} | ||||
| 			Controls.TextField { | ||||
| 				id: txtGasMix | ||||
| 				id: txtGasMix0 | ||||
| 				Layout.fillWidth: true | ||||
| 				validator: RegExpValidator { regExp: /(EAN100|EAN\d\d|AIR|100|\d{1,2}|\d{1,2}\/\d{1,2})/i } | ||||
| 				onEditingFinished: { | ||||
|  | @ -346,7 +355,7 @@ Item { | |||
| 				font.pointSize: subsurfaceTheme.smallPointSize | ||||
| 			} | ||||
| 			Controls.TextField { | ||||
| 				id: txtStartPressure | ||||
| 				id: txtStartPressure0 | ||||
| 				Layout.fillWidth: true | ||||
| 				onEditingFinished: { | ||||
| 					focus = false | ||||
|  | @ -359,7 +368,258 @@ Item { | |||
| 				font.pointSize: subsurfaceTheme.smallPointSize | ||||
| 			} | ||||
| 			Controls.TextField { | ||||
| 				id: txtEndPressure | ||||
| 				id: txtEndPressure0 | ||||
| 				Layout.fillWidth: true | ||||
| 				onEditingFinished: { | ||||
| 					focus = false | ||||
| 				} | ||||
| 			} | ||||
| //second cylinder | ||||
| 			Controls.Label { | ||||
| 				visible: usedCyl[1] != null ? true : false | ||||
| 				Layout.alignment: Qt.AlignRight | ||||
| 				text: qsTr("Cylinder2:") | ||||
| 				font.pointSize: subsurfaceTheme.smallPointSize | ||||
| 			} | ||||
| 			Controls.ComboBox { | ||||
| 				visible: usedCyl[1] != null ? true : false | ||||
| 				id: cylinderBox1 | ||||
| 				flat: true | ||||
| 				model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ? | ||||
| 					diveDetailsListView.currentItem.modelData.dive.cylinderList : null | ||||
| 				inputMethodHints: Qt.ImhNoPredictiveText | ||||
| 				Layout.fillWidth: true | ||||
| 			} | ||||
| 
 | ||||
| 			Controls.Label { | ||||
| 				visible: usedCyl[1] != null ? true : false | ||||
| 				Layout.alignment: Qt.AlignRight | ||||
| 				text: qsTr("Gas mix:") | ||||
| 				font.pointSize: subsurfaceTheme.smallPointSize | ||||
| 			} | ||||
| 			Controls.TextField { | ||||
| 				visible: usedCyl[1] != null ? true : false | ||||
| 				id: txtGasMix1 | ||||
| 				Layout.fillWidth: true | ||||
| 				validator: RegExpValidator { regExp: /(EAN100|EAN\d\d|AIR|100|\d{1,2}|\d{1,2}\/\d{1,2})/i } | ||||
| 				onEditingFinished: { | ||||
| 					focus = false | ||||
| 				} | ||||
| 			} | ||||
| 
 | ||||
| 			Controls.Label { | ||||
| 				visible: usedCyl[1] != null ? true : false | ||||
| 				Layout.alignment: Qt.AlignRight | ||||
| 				text: qsTr("Start Pressure:") | ||||
| 				font.pointSize: subsurfaceTheme.smallPointSize | ||||
| 			} | ||||
| 			Controls.TextField { | ||||
| 				visible: usedCyl[1] != null ? true : false | ||||
| 				id: txtStartPressure1 | ||||
| 				Layout.fillWidth: true | ||||
| 				onEditingFinished: { | ||||
| 					focus = false | ||||
| 				} | ||||
| 			} | ||||
| 
 | ||||
| 			Controls.Label { | ||||
| 				visible: usedCyl[1] != null ? true : false | ||||
| 				Layout.alignment: Qt.AlignRight | ||||
| 				text: qsTr("End Pressure:") | ||||
| 				font.pointSize: subsurfaceTheme.smallPointSize | ||||
| 			} | ||||
| 			Controls.TextField { | ||||
| 				visible: usedCyl[1] != null ? true : false | ||||
| 				id: txtEndPressure1 | ||||
| 				Layout.fillWidth: true | ||||
| 				onEditingFinished: { | ||||
| 					focus = false | ||||
| 				} | ||||
| 			} | ||||
| // third cylinder | ||||
| 			Controls.Label { | ||||
| 				visible: usedCyl[2] != null ? true : false | ||||
| 				Layout.alignment: Qt.AlignRight | ||||
| 				text: qsTr("Cylinder3:") | ||||
| 				font.pointSize: subsurfaceTheme.smallPointSize | ||||
| 			} | ||||
| 			Controls.ComboBox { | ||||
| 				visible: usedCyl[2] != null ? true : false | ||||
| 				id: cylinderBox2 | ||||
| 				currentIndex: find(usedCyl[2]) | ||||
| 				flat: true | ||||
| 				model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ? | ||||
| 					diveDetailsListView.currentItem.modelData.dive.cylinderList : null | ||||
| 				inputMethodHints: Qt.ImhNoPredictiveText | ||||
| 				Layout.fillWidth: true | ||||
| 			} | ||||
| 
 | ||||
| 			Controls.Label { | ||||
| 				visible: usedCyl[2] != null ? true : false | ||||
| 				Layout.alignment: Qt.AlignRight | ||||
| 				text: qsTr("Gas mix:") | ||||
| 				font.pointSize: subsurfaceTheme.smallPointSize | ||||
| 			} | ||||
| 			Controls.TextField { | ||||
| 				visible: usedCyl[2] != null ? true : false | ||||
| 				id: txtGasMix2 | ||||
| 				Layout.fillWidth: true | ||||
| 				validator: RegExpValidator { regExp: /(EAN100|EAN\d\d|AIR|100|\d{1,2}|\d{1,2}\/\d{1,2})/i } | ||||
| 				onEditingFinished: { | ||||
| 					focus = false | ||||
| 				} | ||||
| 			} | ||||
| 
 | ||||
| 			Controls.Label { | ||||
| 				visible: usedCyl[2] != null ? true : false | ||||
| 				Layout.alignment: Qt.AlignRight | ||||
| 				text: qsTr("Start Pressure:") | ||||
| 				font.pointSize: subsurfaceTheme.smallPointSize | ||||
| 			} | ||||
| 			Controls.TextField { | ||||
| 				visible: usedCyl[2] != null ? true : false | ||||
| 				id: txtStartPressure2 | ||||
| 				Layout.fillWidth: true | ||||
| 				onEditingFinished: { | ||||
| 					focus = false | ||||
| 				} | ||||
| 			} | ||||
| 
 | ||||
| 			Controls.Label { | ||||
| 				visible: usedCyl[2] != null ? true : false | ||||
| 				Layout.alignment: Qt.AlignRight | ||||
| 				text: qsTr("End Pressure:") | ||||
| 				font.pointSize: subsurfaceTheme.smallPointSize | ||||
| 			} | ||||
| 			Controls.TextField { | ||||
| 				visible: usedCyl[2] != null ? true : false | ||||
| 				id: txtEndPressure2 | ||||
| 				Layout.fillWidth: true | ||||
| 				onEditingFinished: { | ||||
| 					focus = false | ||||
| 				} | ||||
| 			} | ||||
| // fourth cylinder | ||||
| 			Controls.Label { | ||||
| 				visible: usedCyl[3] != null ? true : false | ||||
| 				Layout.alignment: Qt.AlignRight | ||||
| 				text: qsTr("Cylinder4:") | ||||
| 				font.pointSize: subsurfaceTheme.smallPointSize | ||||
| 			} | ||||
| 			Controls.ComboBox { | ||||
| 				visible: usedCyl[3] != null ? true : false | ||||
| 				id: cylinderBox3 | ||||
| 				currentIndex: find(usedCyl[3]) | ||||
| 				flat: true | ||||
| 				model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ? | ||||
| 					diveDetailsListView.currentItem.modelData.dive.cylinderList : null | ||||
| 				inputMethodHints: Qt.ImhNoPredictiveText | ||||
| 				Layout.fillWidth: true | ||||
| 			} | ||||
| 
 | ||||
| 			Controls.Label { | ||||
| 				visible: usedCyl[3] != null ? true : false | ||||
| 				Layout.alignment: Qt.AlignRight | ||||
| 				text: qsTr("Gas mix:") | ||||
| 				font.pointSize: subsurfaceTheme.smallPointSize | ||||
| 			} | ||||
| 			Controls.TextField { | ||||
| 				visible: usedCyl[3] != null ? true : false | ||||
| 				id: txtGasMix3 | ||||
| 				Layout.fillWidth: true | ||||
| 				validator: RegExpValidator { regExp: /(EAN100|EAN\d\d|AIR|100|\d{1,2}|\d{1,2}\/\d{1,2})/i } | ||||
| 				onEditingFinished: { | ||||
| 					focus = false | ||||
| 				} | ||||
| 			} | ||||
| 
 | ||||
| 			Controls.Label { | ||||
| 				visible: usedCyl[3] != null ? true : false | ||||
| 				Layout.alignment: Qt.AlignRight | ||||
| 				text: qsTr("Start Pressure:") | ||||
| 				font.pointSize: subsurfaceTheme.smallPointSize | ||||
| 			} | ||||
| 			Controls.TextField { | ||||
| 				visible: usedCyl[3] != null ? true : false | ||||
| 				id: txtStartPressure3 | ||||
| 				Layout.fillWidth: true | ||||
| 				onEditingFinished: { | ||||
| 					focus = false | ||||
| 				} | ||||
| 			} | ||||
| 
 | ||||
| 			Controls.Label { | ||||
| 				visible: usedCyl[3] != null ? true : false | ||||
| 				Layout.alignment: Qt.AlignRight | ||||
| 				text: qsTr("End Pressure:") | ||||
| 				font.pointSize: subsurfaceTheme.smallPointSize | ||||
| 			} | ||||
| 			Controls.TextField { | ||||
| 				visible: usedCyl[3] != null ? true : false | ||||
| 				id: txtEndPressure3 | ||||
| 				Layout.fillWidth: true | ||||
| 				onEditingFinished: { | ||||
| 					focus = false | ||||
| 				} | ||||
| 			} | ||||
| // fifth cylinder | ||||
| 			Controls.Label { | ||||
| 				visible: usedCyl[4] != null ? true : false | ||||
| 				Layout.alignment: Qt.AlignRight | ||||
| 				text: qsTr("Cylinder5:") | ||||
| 				font.pointSize: subsurfaceTheme.smallPointSize | ||||
| 			} | ||||
| 			Controls.ComboBox { | ||||
| 				visible: usedCyl[4] != null ? true : false | ||||
| 				id: cylinderBox4 | ||||
| 				currentIndex: find(usedCyl[4]) | ||||
| 				flat: true | ||||
| 				model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ? | ||||
| 					diveDetailsListView.currentItem.modelData.dive.cylinderList : null | ||||
| 				inputMethodHints: Qt.ImhNoPredictiveText | ||||
| 				Layout.fillWidth: true | ||||
| 			} | ||||
| 
 | ||||
| 			Controls.Label { | ||||
| 				visible: usedCyl[4] != null ? true : false | ||||
| 				Layout.alignment: Qt.AlignRight | ||||
| 				text: qsTr("Gas mix:") | ||||
| 				font.pointSize: subsurfaceTheme.smallPointSize | ||||
| 			} | ||||
| 			Controls.TextField { | ||||
| 				visible: usedCyl[4] != null ? true : false | ||||
| 				id: txtGasMix4 | ||||
| 				Layout.fillWidth: true | ||||
| 				validator: RegExpValidator { regExp: /(EAN100|EAN\d\d|AIR|100|\d{1,2}|\d{1,2}\/\d{1,2})/i } | ||||
| 				onEditingFinished: { | ||||
| 					focus = false | ||||
| 				} | ||||
| 			} | ||||
| 
 | ||||
| 			Controls.Label { | ||||
| 				visible: usedCyl[4] != null ? true : false | ||||
| 				Layout.alignment: Qt.AlignRight | ||||
| 				text: qsTr("Start Pressure:") | ||||
| 				font.pointSize: subsurfaceTheme.smallPointSize | ||||
| 			} | ||||
| 			Controls.TextField { | ||||
| 				visible: usedCyl[4] != null ? true : false | ||||
| 				id: txtStartPressure4 | ||||
| 				Layout.fillWidth: true | ||||
| 				onEditingFinished: { | ||||
| 					focus = false | ||||
| 				} | ||||
| 			} | ||||
| 
 | ||||
| 			Controls.Label { | ||||
| 				visible: usedCyl[4] != null ? true : false | ||||
| 				Layout.alignment: Qt.AlignRight | ||||
| 				text: qsTr("End Pressure:") | ||||
| 				font.pointSize: subsurfaceTheme.smallPointSize | ||||
| 			} | ||||
| 			Controls.TextField { | ||||
| 				visible: usedCyl[4] != null ? true : false | ||||
| 				id: txtEndPressure4 | ||||
| 				Layout.fillWidth: true | ||||
| 				onEditingFinished: { | ||||
| 					focus = false | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue