import QtQuick 2.6 import QtQuick.Controls 2.5 import QtQuick.Layouts 1.3 import QtQuick.Templates 2.5 import QtQuick.Dialogs 1.2 import QtGraphicalEffects 1.0 import Qt.labs.calendar 1.0 import QtQuick.Dialogs.qml 1.0 import QtQuick.Window 2.10 import "MissionManager" Rectangle { id:root visible: true x:0 y:0 width: 280 height: 320 color: "#fbfdca" antialiasing: true property int number : 1 property bool isSettingCategory: false property bool isFirst: true property var json: { "comment": "", "id": 0, "rawName": "", "friendlyName": "null", "description": "", "specifiesCoordinate": true, "friendlyEdit": true, "category": "", "param1": { "label": "", "units": "", "default": 0, "decimalPlaces": 0 }, "param2": { "label": "", "units": "", "default": 3, "decimalPlaces": 2 }, "param3": { "label": "", "units": "", "default": 0, "decimalPlaces": 0 }, "param4": { "label": "", "units": "", "nanUnchanged": true, "default": 0, "decimalPlaces": 0 }, "param5": { "label": "", "default": 0, "decimalPlaces": 0 }, "param6": { "label": "", "default": 0, "decimalPlaces": 0 }, "param7": { "label": "", "default": 0, "decimalPlaces": 0 } } onJsonChanged: { if(isFirst == true) { //jsonModel.remove(0) jsonModel.clear() jsonModel.set(0,json) isFirst = false } else { jsonModel.append(json) //console.log(json) } } property ListModel model : ListModel { id: jsonModel }//总的模型 property var paraJson: { "label": "", "units": "", "defaultValue": 3, "decimalPlaces": 2 } onParaJsonChanged: { paramModel.append(paraJson) } property ListModel _paramModel : ListModel { id: paramModel }//参数的模型 Rectangle { id: last x: 8 y: 8 width: 32 height: 27 color: "#bbf4b6" radius: 5 clip: true antialiasing: true MouseArea { clip: true hoverEnabled: true anchors.fill: parent onEntered: { parent.color = "#22fd0e" } onExited: { parent.color = "#bbf4b6" } //请求读取上一个航点的属性 } Triangle { x: 5 y: 4 width: 20 height: 20 direction: "reverse" color: "#b344fb" clip: true border: 0 } } Rectangle { id: next x: 238 y: 8 width: 32 height: 27 color: "#bbf4b6" radius: 5 clip: true antialiasing: true MouseArea { clip: true hoverEnabled: true anchors.fill: parent onEntered: { parent.color = "#22fd0e" } onExited: { parent.color = "#bbf4b6" } //请求读取下一个航点的属性 } Triangle { id: triangle x: 7 y: 4 width: 20 height: 20 color: "#b344fb" clip: true } } Rectangle { id: seq x: 46 y: 8 width: 54 height: 27 color: "#b7f3f0" radius: 5 clip: true antialiasing: true Text { id: seq_text text: number font.family: "Arial" clip: true verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter anchors.fill: parent font.pixelSize: 12 } MouseArea { id: mouseArea clip: true hoverEnabled: true anchors.fill: parent onEntered: { parent.color = "#48fcf2" } onExited: { parent.color = "#b7f3f0" } } } Rectangle { id: mav_cmd x: 106 y: 8 width: 126 height: 27 color: "#bae5b4" radius: 5 clip: true antialiasing: true Text { id: mav_cmd_text text: "" clip: true anchors.rightMargin: 0 anchors.bottomMargin: 0 anchors.leftMargin: 0 anchors.topMargin: 0 verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter anchors.fill: parent font.pixelSize: 12 onTextChanged: { //console.log(text) //console.log(jsonModel.get(0).friendlyName) } } MouseArea { clip: true hoverEnabled: true anchors.fill: parent onEntered: { cursorShape = Qt.PointingHandCursor parent.color = "#e0fb88" } onExited: { cursorShape = Qt.ArrowCursor parent.color = "#bae5b4" } onClicked: { //请求所有CMD,并显示 isSettingCategory = true //console.log(json.toString()) } } } Rectangle { x: 106 y: 41 width: 167 height: 147 color: "#ffffff" radius: 9 clip: true Rectangle { id: rectangle color: "#eedbfe" radius: 10 anchors.bottomMargin: 8 anchors.topMargin: 8 anchors.rightMargin: 8 anchors.leftMargin: 8 anchors.fill: parent visible: isSettingCategory?(false):(true) ListView { id : param_listView anchors.bottomMargin: 8 anchors.topMargin: 8 anchors.rightMargin: 8 anchors.leftMargin: 8 anchors.fill: parent model: paramModel delegate: paramDelegate spacing: 5 clip: true focus: true RadioButton { id: radioButton x: 0 y: 15 width: 172 height: 61 text: qsTr("Radio Button") } } Component { id: paramDelegate Rectangle { id: rect_param1 x: 8 y: 8 width: 233 height: 34 color: "#ffffff" radius: 6 Label { x: 3 y: 7 width: 47 height: 21 text: label font.pointSize: 12 font.family: "Arial" } Label { x: 180 y: 8 text: units font.pointSize: 12 font.family: "Arial" } TextEdit { id: textEdit x: 56 y: 7 width: 129 height: 21 text: defaultValue visible: true clip: false cursorVisible: false overwriteMode: false persistentSelection: true selectByMouse: true antialiasing: true font.family: "Arial" font.bold: true verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter font.pixelSize: 13 } } } } ListView { id : m_listView anchors.bottomMargin: 8 anchors.topMargin: 8 anchors.rightMargin: 8 anchors.leftMargin: 8 anchors.fill: parent model: jsonModel delegate: numberDelegate spacing: 5 clip: true focus: true visible: isSettingCategory } Component { id: numberDelegate Rectangle { width: ListView.view.width height: ListView.isCurrentItem?100:40 color: ListView.isCurrentItem?"#157efb":"#53d769" border.color: Qt.lighter(color, 1.1) radius: 10 Text { id:friendlyNameText anchors.top: parent.top anchors.horizontalCenter: parent.horizontalCenter anchors.topMargin: 10 font.pixelSize: 10 text: (friendlyName == null)?(rawName):(friendlyName) } TextArea { id:descriptionText anchors.top:friendlyNameText.bottom anchors.horizontalCenter: parent.horizontalCenter anchors.left: parent.left anchors.topMargin: 10 anchors.leftMargin: 10 anchors.rightMargin: 10 width: parent.width height: parent.height - friendlyNameText.height visible: (parent.height == 100)?true:false font.pixelSize: 10 text: (description == null)?(""):(description) } MouseArea { anchors.rightMargin: -50 hoverEnabled: true anchors.fill: parent onClicked:{ m_listView.currentIndex = index //实现item切换 isSettingCategory = false mav_cmd_text.text = friendlyNameText.text paraJson = jsonModel.get(index) } onEntered: { descriptionText.visible = true m_listView.currentIndex = index //实现item切换 mav_cmd_text.text = friendlyNameText.text } onExited: { descriptionText.visible = false mav_cmd_text.text = friendlyNameText.text } } } } } RadioButton { id: radioButton1 x: 32 y: 223 width: 51 height: 42 text: qsTr("Radio Button") } }