1 Star 3 Fork 1

老苏打/QT

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
LogPage.qml 25.58 KB
一键复制 编辑 原始数据 按行查看 历史
老苏打 提交于 2024-09-12 18:45 +08:00 . QT项目
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811
import QtQuick 2.12
import QtQuick.Controls 1.4
import QtQuick.Controls 2.5
import QtQuick.Dialogs 1.3
ScrollView { //日志页面
property int pageCnt: 0
property int logCnt: 0
property int showFlag: 0 //为0显示的是所有日志,为1显示的是筛选的日志
property alias e_historyModel: historyModel
//property alias e_rtcTime: rtcTime.e_input
property int startYear: 0
property int stopYear: 0
property int startMon: 0
property int stopMon: 0
property alias e_startTime: startTime.text
property alias e_stopTime: stopTime.text
property alias e_deleteAllLogBtn_Down: deleteAllLogBtn.down
width: 1020
height: 806
contentWidth:1000
contentHeight:987
ScrollBar.vertical.policy: ScrollBar.AlwaysOn
clip: true
Image{ //日志区
x:0
y:0
source: "icon/image2/logback.jpg"
MyButton{//读取日志信息
x:25
y:92
e_btnBackColor: "#00B5AC"
e_text: qsTr("读取日志信息")
e_btnBackW: 130
e_btnBackH: 30
onClicked: {
if(isSerialOpen){
//读取日志数量,并清空已读的以及显示的日志信息
//logInfoModel.clear();
pageCnt=0;
logCnt=0;
showFlag=0;
bms.getLogCnt();
}
else{
msg.text="未打开串口!"
msg.open();
}
}
}
MyButton{//清除显示
x:175
y:92
e_btnBackColor: "#040404"
e_text: qsTr("清除显示")
e_btnBackW: 100
e_btnBackH: 30
onClicked: {
pageCnt=0;
logCnt=0;
logInfoModel.clearShow();
}
}
Text{
id:timeSelect
x:337
y:92
font.family: "微软雅黑"
font.pixelSize: 18
text:qsTr("时间筛选:")
color:"#333333"
}
Rectangle{
id:rec
x:427
anchors.verticalCenter: timeSelect.verticalCenter
width:381
height: 30
color:"#F2F7FE"
border.color: "#C3C8D0"
border.width: 1
radius: 5
Row{
x:10
anchors.verticalCenter: parent.verticalCenter
spacing: 10
Image{
x:10
anchors.verticalCenter: parent.verticalCenter
source: "icon/image2/iconcalendar.png"
MouseArea{
anchors.fill: parent
onClicked: {
selectTime.e_flag=0;
//得到年、月、日
// selectTime.e_yearModel.clear();
// startYear=logInfoModel.getStartYear();
// stopYear=logInfoModel.getStopYear();
// for(var i=startYear;i<=stopYear;i++){
// selectTime.e_yearModel.append({"modelData":i});
// }
// if(selectTime.e_yearModel.count==1){
// selectTime.e_yearModel.append({"modelData":0});
// }
selectTime.show()
}
}
}
TextInput {
id: startTime
text: qsTr("0000-00-00 00:00:00")
width: 136
font.family: "微软雅黑"
font.pixelSize: 14
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
Text {
text: qsTr("To")
font.family: "微软雅黑"
font.pixelSize: 14
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
Image{
anchors.verticalCenter: parent.verticalCenter
source: "icon/image2/iconcalendar.png"
MouseArea{
anchors.fill: parent
onClicked: {
selectTime.e_flag=1;
//得到年、月、日
// selectTime.e_yearModel.clear();
// startYear=logInfoModel.getStartYear();
// stopYear=logInfoModel.getStopYear();
// for(var i=startYear;i<=stopYear;i++){
// selectTime.e_yearModel.append({"modelData":i});
// }
// if(selectTime.e_yearModel.count==1){
// selectTime.e_yearModel.append({"modelData":0});
// }
selectTime.show()
}
}
}
TextInput {
id: stopTime
text: qsTr("0000-00-00 00:00:00")
width: 136
font.family: "微软雅黑"
font.pixelSize: 14
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
}
}
MyButton{
anchors.left: rec.right
anchors.leftMargin: 15
anchors.verticalCenter: timeSelect.verticalCenter
e_btnBackColor:down?"gray":"#00B5AC"
e_text: down?qsTr("返回"):qsTr("筛选")
e_btnBackW: 100
e_btnBackH: 30
onClicked: {
if(down){
//返回,显示全部
down=false;
pageCnt=0;
logCnt=0;
showFlag=0;
logInfoModel.getRxLog();
indicator.currentIndex=0;
}
else{
//筛选
down=true;
console.log("----------按下筛选按钮--------------")
pageCnt=0;
logCnt=0;
showFlag=1;
logInfoModel.getNeedLog(startTime.text,stopTime.text);
indicator.currentIndex=0;
}
}
}
// ParamConfigInput{
// id:rtcTime
// x:25
// y:43
// e_text: qsTr("当前RTC时间:")
// e_recX: 116
// e_recWidth: 164
// e_recHeight: 30
// }
// MyButton{//读取rtc时间
// x:338
// anchors.verticalCenter: rtcTime.verticalCenter
// e_btnBackColor: "#00B5AC"
// e_text: qsTr("读取")
// e_btnBackW: 100
// e_btnBackH: 30
// onClicked: {
// if(isSerialOpen){
// bms.getRtcTime();
// }
// else{
// msg.text="未打开串口!"
// msg.open();
// }
// }
// }
TableView{
id:logTable
anchors.horizontalCenter: parent.horizontalCenter
y:151
width: 926
height:451
backgroundVisible: false
frameVisible: false
focus: false
horizontalScrollBarPolicy:Qt.ScrollBarAlwaysOff
verticalScrollBarPolicy : Qt.ScrollBarAlwaysOff
clip:true
headerDelegate:Rectangle{
anchors.centerIn: parent
height: 41
Text{
anchors.centerIn: parent
text:styleData.value
font.family: "微软雅黑"
font.pixelSize: 16
color:"#333333"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
}
itemDelegate:Loader{
id:loader
anchors.centerIn: parent
property var getValue
property var colNo: styleData.column
property var rowNo:styleData.row
property int pageNo: indicator.currentIndex
property string viewName: "删除日志"
sourceComponent: {
if(styleData.column===0)
{
getValue=styleData.row+1+indicator.currentIndex*10;
}
else{
if(styleData.column===3 || styleData.column===4){
getValue=digit(styleData.value);
}
else
getValue=styleData.value;
}
return dispText
}
}
onRowCountChanged:{
console.log("rowCount",rowCount);
deleteSelectModel.clear();
for(var i=0;i<rowCount;i++){
deleteSelectModel.append({"value":logInfoModel.getDeleteLog(i,indicator.currentIndex,showFlag)})
}
}
rowDelegate: Rectangle{
width:944
height:41
color:"white"
}
TableViewColumn {
role: "deleteRole"
title:qsTr("序号")
width: 58
}
TableViewColumn {
role: "eventTypeRole"
title: qsTr("事件类型")
width: 91
}
TableViewColumn {
role: "dateRole"
title:qsTr("时间")
width: 163
}
TableViewColumn {
role: "totalVRole"
title: qsTr("总电压V")
width: 85
}
TableViewColumn {
role: "totalIRole"
title: qsTr("总电流A")
width: 85
}
TableViewColumn {
role: "tempRole"
title: qsTr("最高温度℃")
width: 104
}
TableViewColumn {
role: "capRole"
title: qsTr("满充容量mAh")
width: 113
}
TableViewColumn {
role: "leftCapRole"
title: qsTr("剩余容量mAh")
width: 114
}
TableViewColumn {
role: "bmsStatusRole"
title: qsTr("电池状态H")
width: 113
}
model: logInfoModel
Component.onCompleted: {
bms.setLogInfoModel(logInfoModel)
}
}
ListView{
id:deleteSelectList
anchors.left: logTable.left
anchors.leftMargin: -10
y:191
width:20
height:410
model:deleteSelectModel
delegate: Rectangle{
width:20
height:41
Image{
id:img
source:value?"/icon/image2/select.png": "/icon/image2/noselect.png";
anchors.centerIn: parent
MouseArea{
anchors.fill: parent
onClicked: {
if(value){
console.log("取消",index,indicator.currentIndex)
logInfoModel.recordDeleteLog(index,indicator.currentIndex,false,showFlag);
img.source= "/icon/image2/noselect.png";
value=false;
}
else{
//img.source= "/icon/image2/select.png";
console.log("按下",index,indicator.currentIndex)
logInfoModel.recordDeleteLog(index,indicator.currentIndex,true,showFlag);
img.source= "/icon/image2/select.png";
value=true;
}
}
}
}
}
}
ListModel{
id:deleteSelectModel
}
Canvas{
x:37
y:151
width:926
height:451
onPaint: {
var ctx = getContext("2d");
ctx.fillStyle = "#EFF3F8"
for(var i=0;i<11;i++)
ctx.fillRect(0,40+i*41, 926, 1);
}
}
Component{
id:pageText
Rectangle{
width: 30
height:30
Text{
font.family: "微软雅黑"
font.pixelSize: 16
text:pageNo
color:((indicator.currentIndex+1)==pageNo)?"#00B5AC":"black"
anchors.centerIn: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment:Text.AlignVCenter
}
MouseArea{
anchors.fill:parent
onClicked: {
console.log(pageNo-1)
logInfoModel.getPage(pageNo-1,showFlag);
indicator.currentIndex=(pageNo-1);
}
}
}
}
Component{
id:pageOmit
Rectangle{
width: 30
height:30
Text{
font.family: "微软雅黑"
font.pixelSize: 16
text:""
anchors.centerIn: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment:Text.AlignVCenter
}
}
}
Component{
id:pageBlank
Rectangle{
width: 0
height:0
}
}
Button{
id:nextPageBtn
x:961
y:634
width:10
height:16
enabled:(indicator.currentIndex==(indicator.count-1))?false:true
background:Image {
source: (indicator.currentIndex==(indicator.count-1))?"icon/image2/nextpagedis":"icon/image2/nextpage"
}
onClicked: {
indicator.currentIndex=indicator.currentIndex+1;
logInfoModel.getPage(indicator.currentIndex,showFlag);
}
}
PageIndicator {
id: indicator
anchors.verticalCenter: nextPageBtn.verticalCenter
anchors.right: nextPageBtn.left
anchors.rightMargin: 10
count:pageCnt
currentIndex: 0
delegate:Loader{
property int pageNo:(index+1);
sourceComponent: {
if(indicator.currentIndex<3 || (indicator.currentIndex+1)==indicator.count){
if(index<=3 || (index+1)==indicator.count){
return pageText
}
else if(index==4){
return pageOmit
}
else
return pageBlank;
}
else if((indicator.count-1-indicator.currentIndex)<=2){
var l=indicator.count-1-indicator.currentIndex;
if(index<(4-l) || index>=indicator.currentIndex)
return pageText
else if(index==(4-l))
return pageOmit
else
return pageBlank
}
else {
if(index==0||index==indicator.currentIndex||index==(indicator.currentIndex+1) || (index+1)==indicator.count){
return pageText
}
else if(index==(indicator.currentIndex-1)||index==(indicator.currentIndex+2)){
return pageOmit
}
else
return pageBlank;
}
}
}
}
Button{
id:previousPageBtn
anchors.verticalCenter: nextPageBtn.verticalCenter
anchors.right: indicator.left
anchors.rightMargin: 10
width:10
height:16
enabled: (indicator.currentIndex==0)?false:true
background:Image {
source: (indicator.currentIndex==0)?"icon/image2/previouspagedis":"icon/image2/previouspage"
}
onClicked: {
indicator.currentIndex=indicator.currentIndex-1;
logInfoModel.getPage(indicator.currentIndex,showFlag);
}
}
Button{
id:deleteAllLogBtn
x:27
y:634
onClicked:{
if(down)
down=false;
else
down=true;
}
background: Image{
source:deleteAllLogBtn.down? "icon/image2/select.png":"icon/image2/noselect.png"
}
}
Button{ //删除选中的按钮
x:60
width:100
height:30
anchors.verticalCenter: deleteAllLogBtn.verticalCenter
background: Rectangle{
width:100
height:30
color:"#F84712"
Text{
anchors.centerIn: parent
font.family: "微软雅黑"
font.pixelSize: 16
color:"white"
text:qsTr("删除选中")
}
}
onClicked: {
tipsWin.e_pageNo=indicator.currentIndex
tipsWin.e_showFlag=showFlag
tipsWin.e_deleteAll=deleteAllLogBtn.down
tipsWin.show();
}
}
Image{
x:174
anchors.verticalCenter: deleteAllLogBtn.verticalCenter
source: "icon/image2/object.png"
visible: deleteAllLogBtn.down?true:false
}
Text{
x:197
anchors.verticalCenter: deleteAllLogBtn.verticalCenter
text:qsTr("清空所有")
font.family: "微软雅黑"
font.pixelSize: 16
color:"#F84712"
visible: deleteAllLogBtn.down?true:false
}
Button{ //删除选中的按钮
x:271
width:120
height:30
anchors.verticalCenter: deleteAllLogBtn.verticalCenter
background: Rectangle{
width:120
height:30
color:"#F84712"
Text{
anchors.centerIn: parent
font.family: "微软雅黑"
font.pixelSize: 16
color:"white"
text:qsTr("删除ROM日志")
}
}
onClicked: {
tips.text=qsTr("将清空下位机上的所有日志,确定清空?")
tips.open();
}
}
MessageDialog{
id:tips
standardButtons:StandardButton.Cancel|StandardButton.Ok
onAccepted: {
bms.deleteRomLog();
}
onRejected: {
tips.close();
}
}
Text{
x:435
anchors.verticalCenter: deleteAllLogBtn.verticalCenter
text:qsTr("本页")+logTable.rowCount+qsTr("条,共")+logCnt+qsTr("")
font.family: "微软雅黑"
font.pixelSize: 16
color:"#999999"
}
}
Image{ //历史保护计数及最大值背景
x:0
y:700
source: "icon/image2/historyback.jpg"
Text{
id:title
x:25
y:29
text:qsTr("历史保护计数及最大值")
font.family: "微软雅黑"
font.pixelSize: 16
}
MyButton{
x:220
anchors.verticalCenter: title.verticalCenter
e_btnBackColor: "#1AB2A1"
e_text: qsTr("得到统计数值")
e_btnBackW: 150
e_btnBackH: 36
onClicked: {
if(isSerialOpen){
bms.getNo101_115();
}
else{
msg.text=qsTr("串口未打开!")
msg.open();
}
}
}
ListView{
id:historyList
x:5
y:62
width:989
height:205
model:historyModel
delegate: Control{
x:0
y:0
width:989
height: 41
onHoveredChanged: {
if(hovered)
historyRec.color="#D6EAFE"
else
historyRec.color="white"
}
Rectangle{
anchors.fill: parent
id:historyRec
ParamConfigInput{
x:38
e_recX:137;
anchors.verticalCenter: parent.verticalCenter
e_recWidth: 70
e_recHeight: 30
e_text: name
e_unit: ""
e_input: ""+value
}
ParamConfigInput{
x:377
anchors.verticalCenter: parent.verticalCenter
e_recWidth: 70
e_recHeight: 30
e_recX: 137
e_text: name2
e_input: ""+value2
e_unit: {
if(index<4)
return "";
else
return "A";
}
}
ParamConfigInput{
x:693
anchors.verticalCenter: parent.verticalCenter
e_recWidth: 70
e_recHeight: 30
e_recX: 137
e_text: name3
e_input: ""+value3
e_unit: {
if(index<4)
return "";
else
return "A";
}
}
}
}
}
Canvas{
x:0
y:0
width:999
height:287
onPaint: {
var ctx = getContext("2d");
ctx.fillStyle = "#EFF3F8"
for(var i=0;i<5;i++)
ctx.fillRect(27,102+i*41, 944, 1);
ctx.fillRect(341,62, 1,204);
ctx.fillRect(656,62, 1,204);
}
}
ListModel{
id:historyModel
}
}
property var nameInHistoryModel: ["短路次数","充电过流次数","放电过流次数","单体过压次数","单体欠压次数"]
property var name2InHistoryModel: ["高温充电次数","低温充电次数","高温放电次数","低温放电次数","最大充电电流"]
property var name3InHistoryModel: ["电芯充电最高温","电芯充电最低温","电芯放电最高温","电芯放电最低温","最大放电电流"]
Component.onCompleted: {
console.log("坐标",logTable.x,logTable.y)
for(var i=0;i<5;i++){
historyModel.append({name:nameInHistoryModel[i],name2:name2InHistoryModel[i],name3:name3InHistoryModel[i],
value:0,value2:0,value3:0})
}
}
function prefixInteger(num, length) {
return ( "0000" + num ).substr( -length );
}
Connections{
target: bms
onReadLogOnePage:{
pageCnt++;
console.log("bms pageCnt++",pageCnt)
}
//showLogCnt(cnt)
onShowLogCnt:{
logCnt=cnt;
}
}
Connections{
target: logInfoModel
onReadLogOnePage:{
pageCnt++;
console.log("logInfoModel pageCnt++",pageCnt)
}
onShowLogCnt:{
logCnt=cnt;
}
onReadLogTotalPage:{
pageCnt=cnt;
console.log("logInfoModel pageCnt++",pageCnt)
}
}
function digit(i){
return parseFloat(i).toFixed(2);
}
function btnList(){
for(var i=0;i<logTable.currentRow;i++){
deleteSelectModel.append({value:false});
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhang-jia_lin/qt.git
[email protected]:zhang-jia_lin/qt.git
zhang-jia_lin
qt
QT
master

搜索帮助