代码拉取完成,页面将自动刷新
import QtQuick 2.0
import QtQuick.Controls 2.2
Item {
id:sdlogpage
width: 400
height: 400
property ListModel sdOnlineModel: ListModel{}
property ListModel sdOfflineModel: ListModel{}
property ListModel sdEmgModel: ListModel{
// ListElement{
// errorDevType:7
// errorStr:"Open"
// errorAddr:"Test Addr "
// datetime: new Date().toLocaleString(Qt.locale() , "yyyy-MM-dd hh:mm:ss")
// }
// ListElement{
// errorDevType:1
// errorStr:"Open"
// errorAddr:"Test Addr "
// datetime: new Date().toLocaleString(Qt.locale() , "yyyy-MM-dd hh:mm:ss")
// }
}
function sdEvent(error , addr , devType , type){
var model = sdOnlineModel
// switch(type){
// case "Online":
// model = sdOnlineModel
// break
// case "Offline":
// model = sdOfflineModel
// break
// case "Emg":
// model = sdEmgModel
// break
// default:
// return
// }
model.insert(0 , {"errorDevType":devType ,
"errorStr":error ,
"errorAddr":addr ,
"datetime":new Date().toLocaleString(Qt.locale() , "yyyy-MM-dd hh:mm:ss")
})
}
PieChartView{
id:devpiechart
width: parent.width
height: parent.height*0.5
}
Timer{
id:checSDWorkState
interval: 5000
repeat: true
running: true
onTriggered: {
var emgcnt , offlinecnt , onlinecnt
var cntinfo = SDController.getSDSateInfo()
console.log(cntinfo.split("*"))
emgcnt = parseInt(cntinfo.split("*")[0])
offlinecnt = parseInt(cntinfo.split("*")[1])
onlinecnt = parseInt(cntinfo.split("*")[2])
devpiechart.setDevCntInfo(emgcnt , offlinecnt , onlinecnt)
}
}
ListView {
id: sdOnlinelistView
width: parent.width
height: parent.height*0.5-40
anchors.left: parent.left
anchors.leftMargin: 0
anchors.top: devpiechart.bottom
anchors.topMargin: 0
clip: true
delegate: logdelegate
model: sdOnlineModel
Rectangle{anchors.fill: parent ; color: "#55fc51" ; opacity: 0.7; z:-1}
}
Button{
id:clearRecord
text: "清除记录"
anchors.top: sdOnlinelistView.bottom
anchors.left: parent.left
anchors.leftMargin: 0
onClicked: {
sdOnlineModel.clear()
}
}
Component{
id:logdelegate
Item {
width: parent.width
height: 40
Rectangle {
id: rectangle
color: Qt.rgba(1,1,1,0.5)
anchors.fill: parent
radius: 5
Text {
id: txtErrorTime
x: 16
y: 10
width: 203
height: 40
text: datetime
font.pixelSize: 22
}
Text {
id: txtErrorDevType
x: 260
y: 10
width: 184
height: 40
text: "设备类型:" + errorDevType
font.pixelSize: 22
}
Text {
id: text1
x: 600
y: 0
width: 800
height: 40
text: errorAddr+" "+errorStr
verticalAlignment: Text.AlignVCenter
clip: true
wrapMode: Text.WordWrap
// horizontalAlignment: Text.AlignHCenter
font.pixelSize: 30
}
}
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。