import QtQuick import QtQuick.Controls import QtQuick.Dialogs import "./common" // import "./Style" Rectangle { id: self property var cmdLstmodel: ListModel{} property var rowHeight : 30 signal deleteEditLstClick(var row) property alias _tfLstName: tfLstName property alias _tfLstLoop: tfLstLoop property alias _tfLstDelay: tfLstDelay property alias _tfLstRemark: tfLstRemark clip: true Column { anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom anchors.topMargin: 5 spacing: 5 Column { id: inputCol visible: !_readonly width: parent.width spacing: 2 height: (rowHeight *4)+(spacing *3) Item{ width: parent.width height: rowHeight QxText{x:5;text: "队列名称";anchors.verticalCenter: parent.verticalCenter} QxTextField{id: tfLstName; readOnly:_readonly;anchors.left: parent.left;anchors.right: parent.right;anchors.rightMargin: 5;anchors.leftMargin: 120;width: 500;height: 30} } Item{ width: parent.width height: rowHeight QxText{x:5;text: "循环次数";anchors.verticalCenter: parent.verticalCenter} QxTextField{id: tfLstLoop; readOnly:_readonly;anchors.left: parent.left;anchors.right: parent.right;anchors.rightMargin: 5;anchors.leftMargin: 120;width: 500;height: 30} } Item{ width: parent.width height: rowHeight QxText{x:5;text: "间隔时间(ms)";anchors.verticalCenter: parent.verticalCenter} QxTextField{id: tfLstDelay; readOnly:_readonly;anchors.left: parent.left;anchors.right: parent.right;anchors.rightMargin: 5;anchors.leftMargin: 120;width: 500;height: 30} } Item{ width: parent.width height: rowHeight QxText{x:5;text: "备注";anchors.verticalCenter: parent.verticalCenter} QxTextField{id: tfLstRemark; readOnly:_readonly;anchors.left: parent.left;anchors.right: parent.right;anchors.rightMargin: 5;anchors.leftMargin: 120;width: 500;height: 30} } } TableView{ id: editLstTableView width: parent.width-10 height: inputCol.visible ? parent.height - inputCol.height : parent.height anchors.horizontalCenter: parent.horizontalCenter property bool isClicked: false; property int fromIndex: 0; property int toIndex: 0; // headerDelegate: Rectangle{ // anchors.top: parent.top // width: parent.width // height: 25 // color: "white" // Text { // anchors.centerIn: parent // text: styleData.value // } // Rectangle{ // width: 1 // height: parent.height // visible: styleData.value !== "序号" // color: "lightgray" // } // Rectangle{ // y: parent.height // width: parent.width // height: 1 // color: "lightgray" // } // } // rowDelegate: Rectangle{ // height: 20 // color : styleData.row === editLstTableView.currentRow ? "#beebff": ( (styleData.row %2 == 0) ? "#f2f2f2": "white" ) // } // itemDelegate: Item { // clip: true // QxText { // visible: styleData.role === "id" // anchors.centerIn: parent // color: "#999999" // elide: styleData.elideMode // font.pointSize: 10 // text: styleData.row+1 // } // QxText { // visible: styleData.role !== "id" && styleData.role !== "delay" && styleData.role !== "loop" // x: 5 // anchors.verticalCenter: parent.verticalCenter // color: "black" // elide: styleData.elideMode // font.pointSize: 10 // text: styleData.value // } // QxTextInput{ // z: 2 // readOnly:_readonly; // visible: styleData.role !== "id" && styleData.role !== "name" // text: styleData.value // onTextChanged: { // if(text != "") // { // if(styleData.role === "delay") // model.delay = text // if(styleData.role === "loop") // model.loop = text // } // } // } // Rectangle{ // width: 1 // height: parent.height // visible: styleData.role !== "id" // color: "lightgray" // } // } Rectangle{ width: parent.width height: 1 color: "lightgray" } // TableViewColumn { // id: lstNoCol // title: "序号" // role: "id" // width: 60 // } // TableViewColumn { // id: lstNameCol // title: "名称" // role: "name" // width: (editLstTableView.width - 40 ) /2 // } // TableViewColumn { // id: lstDelayCol // title: "间隔时间(ms)" // role: "delay" // width: (editLstTableView.width - 82 ) /4 // } // TableViewColumn { // id: lstLoopCol // title: "循环次数" // role: "loop" // width: (editLstTableView.width - 82 ) /4 // } MouseArea{ visible: !_readonly anchors.top: parent.top anchors.bottom: parent.bottom acceptedButtons: Qt.AllButtons width: lstNoCol.width + lstNameCol.width onPressed: { editLstTableView.currentRow = editLstTableView.rowAt(mouseX , mouseY ) if(mouse.buttons == Qt.RightButton) { if(editLstTableView.currentRow > -1) { menuEditLstCmd.popup() } } else { if(editLstTableView.currentRow > -1) { parent.fromIndex = editLstTableView.currentRow; editLstTableView.isClicked = true; } } } onReleased: { editLstTableView.isClicked = false; } onPositionChanged: { var lastIndex = editLstTableView.rowAt(mouseX , mouseY ) if ((lastIndex < 0) || (lastIndex > cmdLstmodel.count)) return ; if (editLstTableView.currentRow !== lastIndex){ cmdLstmodel.move(editLstTableView.currentRow, lastIndex, 1); } parent.toIndex = lastIndex; } } model: cmdLstmodel } } Menu{ id: menuEditLstCmd MenuItem { id: delEditCmdLstMt visible: editLstTableView.currentRow > -1 text: "删除" onTriggered: deleteEditLstClick(editLstTableView.currentRow) } } }