0 Star 0 Fork 3

fujingyuan/AutoVehTypeMon

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
formsrv.cpp 23.19 KB
一键复制 编辑 原始数据 按行查看 历史
惊险一血 提交于 2014-10-28 10:39 . 首次提交
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
#include "formsrv.h"
#include "ui_formsrv.h"
#include <QStringList>
#include <QDateTime>
#include <QTextCodec>
#include <QSettings>
#include <QFile>
#include <QDesktopWidget>
#include "logmsg.h"
#include "dealexcelfile.h"
#include <QPainter>
#include <QImage>
#include <QSplashScreen>
QString gb2312ToUtf8(const char *szString, int nSize)
{
if(nSize == -1)
{
return QTextCodec::codecForName("GB2312")->toUnicode(szString);
}
else
{
return QTextCodec::codecForName("GB2312")->toUnicode(szString, nSize);
}
}
FormSrv::FormSrv(QWidget *parent) :
QWidget(parent),
ui(new Ui::FormSrv)
{
ui->setupUi(this);
//m_Srv = new MyServer(this);
//不显示当前车道ip(占空太大)
ui->label_5->setVisible(false);
ui->label_CurLaneIP->setVisible(false);
//记录界面size
mainSize = this->size();
panelSize = ui->groupBox_6->size();
m_nCurrentSocket = 0;
m_nCurrentRowNum = -1;
m_excelIsOpen = false;
m_Ip2RowNumMap.clear();
QStringList list;
list<<"连接编号"<<"车道IP"<<"车道"<<"实时消息"<<"网络状态"<<"设备状态"<<"车牌纠错"<<"超时检测"<<"多车检测";
ui->tableWidget->setColumnCount(9);
ui->tableWidget->setHorizontalHeaderLabels(list);
//不可编辑
ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
//头单元最后补全
ui->tableWidget->horizontalHeader()->setStretchLastSection(true);
ui->tableWidget->resizeColumnsToContents();
//单元格平分
ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
//默认行高
ui->tableWidget->verticalHeader()->setDefaultSectionSize(70);
//设置选中状态
//ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
//ui->tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
ui->tableWidget->setSelectionMode(QTableWidget::NoSelection);
ui->treeWidget_2->setSelectionMode(QTreeWidget::NoSelection);
//实时消息显示最多行数
ui->text_Display->document()->setMaximumBlockCount(200);
//ui->but_Send->setEnabled(false);
ui->tableWidget->setStyleSheet("selection-background-color: rgba(72,61,139,255)");
ui->tableWidget->setColumnHidden(0,true);
ui->tableWidget->setFrameShape(QFrame::NoFrame);
ui->tableWidget->verticalHeader()->setHidden(true);
//初始设置关闭监控与路段视图按钮不可用,只有启动监控后可用
ui->pushButton->setEnabled(false);
ui->but_RoadInfo->setEnabled(false);
//加载路段excel表格
//slot_LoadRoadInfo();
}
FormSrv::~FormSrv()
{
delete ui;
//delete m_Srv;
}
FormSrv* getForm()
{
static FormSrv* form = NULL;
if(form == NULL)
{
form = new FormSrv();
}
return form;
}
void FormSrv::on_but_StartSrv_clicked()
{
//m_Srv->StartServer();
QSettings setting("./Server.ini",QSettings::IniFormat);
quint16 port = setting.value("ListenPort/Port",19999).toUInt();
if(!QFile::exists("./Server.ini"))
{
qDebug()<<"file did not exist";
}
if(getServer()->StartServer(port))
{
ui->but_StartSrv->setEnabled(false);
ui->pushButton->setEnabled(true);
if(m_excelIsOpen)
{
ui->but_RoadInfo->setEnabled(true);
}else
{
ui->but_RoadInfo->setEnabled(false);
}
//isStart = true;
getLogMsg()->iLogMsg("监控事件:启动监控成功");
}
else
{
getLogMsg()->iLogMsg("监控事件:启动监控失败");
}
}
void FormSrv::on_pushButton_clicked()
{
// if(!isStart)
// {
// return;
// }
getServer()->StopServer();
ui->but_StartSrv->setEnabled(true);
ui->pushButton->setEnabled(false);
ui->but_RoadInfo->setEnabled(false);
//清空已选择车道信息
ui->label_CurLaneIP->clear();
ui->label_CurLaneNum->clear();
ResetVehQueue();
ResetCurVeh();
getLogMsg()->iLogMsg("监控事件:关闭监控");
}
void FormSrv::closeEvent(QCloseEvent * event)
{
getLogMsg()->iLogMsg("监控事件:监控程序关闭");
getServer()->StopServer();
getDealExecl()->Close();
}
void FormSrv::paintEvent(QPaintEvent *event)
{
QPalette pal;
QPixmap image(":/Picture/bg");
pal.setBrush(QPalette::Background,QBrush(image));
setPalette(pal);
}
void FormSrv::ResetVehQueue()
{
QMutexLocker lock(&m_ResetMutex);
ui->label_Veh_1->setText("无车");
ui->label_Veh_2->setText("无车");
ui->label_Veh_3->setText("无车");
ui->label_Veh_4->setText("无车");
ui->label_Veh_5->setText("无车");
ui->groupBox_3->setTitle(tr("车队信息"));
ui->label_Veh_P1->clear();
ui->label_Veh_P2->clear();
ui->label_Veh_P3->clear();
ui->label_Veh_P4->clear();
ui->label_Veh_P5->clear();
}
void FormSrv::ResetCurVeh()
{
QMutexLocker lock(&m_ResetMutex);
//清空当前取卡车辆显示信息
ui->label_CurPic->clear();
ui->label_curVehType->clear();
ui->label_curVehPlate->clear();
ui->label_curVehTime->clear();
}
void FormSrv::ResetUseState(int rowNum)
{
ui->tableWidget->item(rowNum,5)->setText("未知");
ui->tableWidget->item(rowNum,6)->setText("未知");
ui->tableWidget->item(rowNum,7)->setText("未知");
ui->tableWidget->item(rowNum,8)->setText("未知");
ui->tableWidget->item(rowNum,8)->setIcon(QIcon(":/Picture/weizhi"));
ui->tableWidget->item(rowNum,7)->setIcon(QIcon(":/Picture/weizhi"));
ui->tableWidget->item(rowNum,6)->setIcon(QIcon(":/Picture/weizhi"));
ui->tableWidget->item(rowNum,5)->setIcon(QIcon(":/Picture/weizhi"));
ui->tableWidget->item(rowNum,4)->setIcon(QIcon(":/Picture/netabnormal"));
SetRowColor(rowNum,offLine);
}
void FormSrv::SetRowColor(int rowNum,RowState state)
{
QMutexLocker lock(&m_SetColMutex);
QColor color;
switch(state)
{
case onLine:
//color.setRgb(123,104,238,255);
color.setRgb(255,255,255,100);
//color.set
break;
case offLine:
//color.setRgb(236,218,106,180);
color.setRgb(255,255,0,130);
getDealExecl()->SetPointStatue(ui->tableWidget->item(rowNum,1)->text(),r_offLine);
break;
case selected:
//color.setRgb(0,181,73,130);
color.setRgb(0,0,255,130);
//getDealExecl()->SetPointStatue(ui->tableWidget->item(rowNum,1)->text(),r_select);
break;
}
for(int i = 0;i <= 8;i++)
{
ui->tableWidget->item(rowNum,i)->setBackgroundColor(color);
}
}
QString FormSrv::GetDisplayStr(int vehType,QPixmap &img)
{
QString veh = "未知车型";
QPixmap map("weizhi");
int width = ui->label_Veh_P1->rect().width();
int high = ui->label_Veh_P1->rect().height();
if(vehType <= 0)
{
map.load(":/Picture/weizhi");
veh = "未知车型";
img = map.scaled(width,high,Qt::KeepAspectRatio);
return veh;
}
if(vehType > 10)
{
veh = "货 "+QString::number(vehType-10);
map.load(":/Picture/huo"+QString::number(vehType));
}else
{
veh = "客 "+QString::number(vehType);
map.load(":/Picture/ke"+QString::number(vehType));
}
img = map.scaled(width,high,Qt::KeepAspectRatio);
return veh;
//return (vehType > 10)? ("货 "+QString::number(vehType-10)):("客 "+QString::number(vehType));
}
//void FormSrv::on_but_Send_clicked()
//{
//if(ui->text_SendMsg->toPlainText().length()>0)
//emit sig_SendMsg(m_nCurrentSocket,ui->text_SendMsg->toPlainText());
//m_Srv->slot_SendMsg(m_nCurrentSocket,ui->text_SendMsg->toPlainText());
//}
void FormSrv::slot_InsertClient(int Id,QString ip,QString laneNum,QString msg,int &rowNum)
{
QMutexLocker lock(&mutex);
int rowCount = ui->tableWidget->rowCount();
ui->tableWidget->insertRow(rowCount);
ui->tableWidget->setItem(rowCount,0,new QTableWidgetItem(QString::number(Id)));
ui->tableWidget->setItem(rowCount,1,new QTableWidgetItem(ip));
ui->tableWidget->setItem(rowCount,2,new QTableWidgetItem(laneNum));
ui->tableWidget->setItem(rowCount,3,new QTableWidgetItem(msg));
ui->tableWidget->setItem(rowCount,4,new QTableWidgetItem("已连接"));
ui->tableWidget->setItem(rowCount,5,new QTableWidgetItem(""));
ui->tableWidget->setItem(rowCount,6,new QTableWidgetItem(""));
ui->tableWidget->setItem(rowCount,7,new QTableWidgetItem(""));
ui->tableWidget->setItem(rowCount,8,new QTableWidgetItem(""));
ui->tableWidget->item(rowCount,2)->setTextAlignment(Qt::AlignCenter);
ui->tableWidget->item(rowCount,3)->setTextAlignment(Qt::AlignCenter);
ui->tableWidget->item(rowCount,4)->setIcon(QIcon(":/Picture/netnormal"));
SetRowColor(rowCount,onLine);
rowNum = rowCount;
}
void FormSrv::slot_UpdateClientID(int rowNum, int ID)
{
QMutexLocker lock(&mutex);
ui->tableWidget->item(rowNum,0)->setText(QString::number(ID));
}
void FormSrv::slot_UpdateVehQueue(int disSocket, myQueue vehQue, int vehCount)
{
QMutexLocker lock(&mutex);
if(disSocket != m_nCurrentSocket) return;
//if(updateRow != m_nCurrentRowNum) return;
ResetVehQueue();
ui->groupBox_3->setTitle(tr("车队信息:%1").arg(vehCount));
QPixmap image(":/Picture/ke4");
switch(vehQue.count())
{
case 1:
ui->label_Veh_1->setText(GetDisplayStr(((vehTypeInfo)vehQue.at(0)).vehType,image)+ "\n" +QDateTime::fromTime_t(((vehTypeInfo)vehQue.at(0)).vehTime).toString("hh:mm:ss"));
ui->label_Veh_P1->setPixmap(image);
break;
case 2:
ui->label_Veh_1->setText(GetDisplayStr(((vehTypeInfo)vehQue.at(0)).vehType,image)+ "\n" +QDateTime::fromTime_t(((vehTypeInfo)vehQue.at(0)).vehTime).toString("hh:mm:ss"));
ui->label_Veh_P1->setPixmap(image);
ui->label_Veh_2->setText(GetDisplayStr(((vehTypeInfo)vehQue.at(1)).vehType,image)+ + "\n" +QDateTime::fromTime_t(((vehTypeInfo)vehQue.at(1)).vehTime).toString("hh:mm:ss"));
ui->label_Veh_P2->setPixmap(image);
break;
case 3:
ui->label_Veh_1->setText(GetDisplayStr(((vehTypeInfo)vehQue.at(0)).vehType,image)+ "\n" +QDateTime::fromTime_t(((vehTypeInfo)vehQue.at(0)).vehTime).toString("hh:mm:ss"));
ui->label_Veh_P1->setPixmap(image);
ui->label_Veh_2->setText(GetDisplayStr(((vehTypeInfo)vehQue.at(1)).vehType,image)+ "\n" +QDateTime::fromTime_t(((vehTypeInfo)vehQue.at(1)).vehTime).toString("hh:mm:ss"));
ui->label_Veh_P2->setPixmap(image);
ui->label_Veh_3->setText(GetDisplayStr(((vehTypeInfo)vehQue.at(2)).vehType,image)+ "\n" +QDateTime::fromTime_t(((vehTypeInfo)vehQue.at(2)).vehTime).toString("hh:mm:ss"));
ui->label_Veh_P3->setPixmap(image);
break;
case 4:
ui->label_Veh_1->setText(GetDisplayStr(((vehTypeInfo)vehQue.at(0)).vehType,image)+ "\n" +QDateTime::fromTime_t(((vehTypeInfo)vehQue.at(0)).vehTime).toString("hh:mm:ss"));
ui->label_Veh_P1->setPixmap(image);
ui->label_Veh_2->setText(GetDisplayStr(((vehTypeInfo)vehQue.at(1)).vehType,image)+ "\n" +QDateTime::fromTime_t(((vehTypeInfo)vehQue.at(1)).vehTime).toString("hh:mm:ss"));
ui->label_Veh_P2->setPixmap(image);
ui->label_Veh_3->setText(GetDisplayStr(((vehTypeInfo)vehQue.at(2)).vehType,image)+ "\n" +QDateTime::fromTime_t(((vehTypeInfo)vehQue.at(2)).vehTime).toString("hh:mm:ss"));
ui->label_Veh_P3->setPixmap(image);
ui->label_Veh_4->setText(GetDisplayStr(((vehTypeInfo)vehQue.at(3)).vehType,image)+ "\n" +QDateTime::fromTime_t(((vehTypeInfo)vehQue.at(3)).vehTime).toString("hh:mm:ss"));
ui->label_Veh_P4->setPixmap(image);
break;
case 5:
ui->label_Veh_1->setText(GetDisplayStr(((vehTypeInfo)vehQue.at(0)).vehType,image)+ "\n" +QDateTime::fromTime_t(((vehTypeInfo)vehQue.at(0)).vehTime).toString("hh:mm:ss"));
ui->label_Veh_P1->setPixmap(image);
ui->label_Veh_2->setText(GetDisplayStr(((vehTypeInfo)vehQue.at(1)).vehType,image)+ "\n" +QDateTime::fromTime_t(((vehTypeInfo)vehQue.at(1)).vehTime).toString("hh:mm:ss"));
ui->label_Veh_P2->setPixmap(image);
ui->label_Veh_3->setText(GetDisplayStr(((vehTypeInfo)vehQue.at(2)).vehType,image)+ "\n" +QDateTime::fromTime_t(((vehTypeInfo)vehQue.at(2)).vehTime).toString("hh:mm:ss"));
ui->label_Veh_P3->setPixmap(image);
ui->label_Veh_4->setText(GetDisplayStr(((vehTypeInfo)vehQue.at(3)).vehType,image)+ "\n" +QDateTime::fromTime_t(((vehTypeInfo)vehQue.at(3)).vehTime).toString("hh:mm:ss"));
ui->label_Veh_P4->setPixmap(image);
ui->label_Veh_5->setText(GetDisplayStr(((vehTypeInfo)vehQue.at(4)).vehType,image)+ "\n" +QDateTime::fromTime_t(((vehTypeInfo)vehQue.at(4)).vehTime).toString("hh:mm:ss"));
ui->label_Veh_P5->setPixmap(image);
break;
default:
ResetVehQueue();
break;
}
}
void FormSrv::slot_UpdateCurVeh(int disSocket, myVehInfo curVeh)
{
QMutexLocker lock(&mutex);
//qDebug()<<"车辆取卡"<<curVeh.finalVehType<<curVeh.vehPlate;
if(disSocket != m_nCurrentSocket) return;
QPixmap map;
ui->label_curVehType->setText(GetDisplayStr(curVeh.finalVehType,map));
ui->label_CurPic->setPixmap(QPixmap(map));
int plateLen = qstrlen(curVeh.vehPlate);
if(plateLen > 0)
{
//ui->label_curVehPlate->setText(gb2312ToUtf8(curVeh.vehPlate));
ui->label_curVehPlate->setText(QString::fromLocal8Bit(curVeh.vehPlate,plateLen));
}
else
{
ui->label_curVehPlate->setText("无车牌");
}
ui->label_curVehTime->setText(QDateTime::fromTime_t(curVeh.curTime).toString("hh:mm:ss"));
}
void FormSrv::slot_UpdateClientMsg(int rowNum, QString msg)
{
QMutexLocker lock(&mutex);
ui->tableWidget->item(rowNum,3)->setText(msg);
}
void FormSrv::slot_InsetNewIpAndRow(const QString &ip, int rowNum)
{
//QMutexLocker lock(&m_IpAndRowMutex);
m_Ip2RowNumMap.insert(ip,rowNum);
//qDebug()<<tr("插入IP:%1至map").arg(ip);
}
bool FormSrv::CheckexistIp(const QString &ip, int &rowNum,const int &socketDes)
{
QMutexLocker lock(&m_IpAndRowMutex);
if(!m_Ip2RowNumMap.contains(ip))
{
//qDebug()<<tr("mpa 中不存在该ip:%1").arg(ip);
slot_InsertClient(socketDes,ip,"","车道连接成功",rowNum);
m_Ip2RowNumMap.insert(ip,rowNum);
//qDebug()<<tr("插入IP:%1至map").arg(ip);
return false;
}
else
{
rowNum = m_Ip2RowNumMap.value(ip);
//qDebug()<<tr("mpa 中已存在该ip:%1行号:%2").arg(ip).arg(rowNum);
return true;
}
}
void FormSrv::slot_SelectToShowDetail(const int &rowNum)
{
QMutexLocker lock(&mutex);
if(ui->tableWidget->item(rowNum,4)->text() == "未连接")
{
ui->text_Display->append(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss")+"无当前车道信息,请重新选择");
return;
}
if(m_nCurrentRowNum != -1)
{
if(rowNum == m_nCurrentRowNum)
{
SetRowColor(m_nCurrentRowNum,selected);
return;
}
//将前一选中行颜色重置
else
{
if(ui->tableWidget->item(m_nCurrentRowNum,4)->text() == "已连接")
{
SetRowColor(m_nCurrentRowNum,onLine);
}
else
{
SetRowColor(m_nCurrentRowNum,offLine);
}
}
}
//qDebug()<<"select Socket:"<<ui->tableWidget->item(rowNum,0)->text();
m_nCurrentSocket = ui->tableWidget->item(rowNum,0)->text().toInt();
m_nCurrentRowNum = rowNum;
QString curNum = ui->tableWidget->item(rowNum,2)->text();
QString curIP = ui->tableWidget->item(rowNum,1)->text();
ui->label_CurLaneNum->setText(curNum);
ui->label_CurLaneIP->setText(curIP);
//ui->but_Send->setEnabled(true);
ui->text_Display->clear();
SetRowColor(rowNum,selected);
ResetCurVeh();
ResetVehQueue();
}
void FormSrv::slot_LoadRoadInfo()
{
if(!getDealExecl()->createTree(0,0,ui->treeWidget_2))
{
m_excelIsOpen = false;
return;
}
m_excelIsOpen = true;
}
void FormSrv::slot_UpdateClientNetState(int rowNum,const QString state)
{
QMutexLocker lock(&mutex);
ui->tableWidget->item(rowNum,4)->text().clear();
ui->tableWidget->item(rowNum,4)->setText(state);
//qDebug()<<"update state"<< ui->tableWidget->item(rowNum,1)->text()<<rowNum<<ui->tableWidget->item(rowNum,4)->text()<<state;
if(state == "未连接")
{
//qDebug()<<"update netstate abnormal";
ResetUseState(rowNum);
//getDealExecl()->SetPointStatue(ui->tableWidget->item(rowNum,1)->text(),r_offLine);
if(m_nCurrentRowNum == rowNum)
{
m_nCurrentRowNum = -1;
}
}
else
{
//qDebug()<<"update netstate normal";
//ui->tableWidget->setStyleSheet("QTableView::Item{background-color:#ADD8E6}");
ui->tableWidget->item(rowNum,4)->setIcon(QIcon(":/Picture/netnormal"));
SetRowColor(rowNum,onLine);
}
//qDebug()<<"update netstate end"<<rowNum<<ui->tableWidget->item(rowNum,1)->text()<<state<<ui->tableWidget->item(rowNum,4)->text();
}
void FormSrv::slot_UpdateClientInitState(int rowNum, QString laneNum,QString deviceState, QString useVpr, QString checkTimeOut, QString h5Limit)
{
QMutexLocker lock(&mutex);
QString laneName = "";
QString firstName="";
if(laneNum.length()==1)
{
laneNum="0"+laneNum;
}
if(getDealExecl()->GetNameByIP(ui->tableWidget->item(rowNum,1)->text(),laneName,firstName))
{
laneNum = firstName+"\n"+laneName +" "+laneNum+"车道";
}
ui->tableWidget->item(rowNum,2)->setText(laneNum);
ui->tableWidget->item(rowNum,5)->setText(deviceState);
ui->tableWidget->item(rowNum,6)->setText(useVpr);
ui->tableWidget->item(rowNum,7)->setText(checkTimeOut);
ui->tableWidget->item(rowNum,8)->setText(h5Limit);
if(deviceState == "连接")
{
ui->tableWidget->item(rowNum,5)->setIcon(QIcon(":/Picture/devnormal"));
getDealExecl()->SetPointStatue(ui->tableWidget->item(rowNum,1)->text(),r_onLine);
}
else
{
ui->tableWidget->item(rowNum,5)->setIcon(QIcon(":/Picture/devabnormal"));
getDealExecl()->SetPointStatue(ui->tableWidget->item(rowNum,1)->text(),r_error);
}
if(useVpr == "启用")
{
ui->tableWidget->item(rowNum,6)->setIcon(QIcon(":/Picture/normal"));
}else
{
ui->tableWidget->item(rowNum,6)->setIcon(QIcon(":/Picture/abnormal"));
}
if(checkTimeOut == "启用")
{
ui->tableWidget->item(rowNum,7)->setIcon(QIcon(":/Picture/normal"));
}else
{
ui->tableWidget->item(rowNum,7)->setIcon(QIcon(":/Picture/abnormal"));
}
if(h5Limit == "启用")
{
ui->tableWidget->item(rowNum,8)->setIcon(QIcon(":/Picture/normal"));
}else
{
ui->tableWidget->item(rowNum,8)->setIcon(QIcon(":/Picture/abnormal"));
}
}
int FormSrv::getClientID(int rowNum)
{
QMutexLocker lock(&mutex);
return ui->tableWidget->item(rowNum,0)->text().toInt();
}
void FormSrv::setTableVisible(bool state)
{
ui->tableWidget->setVisible(state);
}
void FormSrv::SetLogInfo(QString LogName, QString logTime)
{
ui->label_Oper->setText(LogName);
ui->label_OperTime->setText(logTime);
}
QString FormSrv::getClientNetState(int rowNum)
{
QMutexLocker lock(&mutex);
return ui->tableWidget->item(rowNum,4)->text();
}
void FormSrv::slot_DisplayLogMsg(int disSocket,QString msg)
{
QMutexLocker lock(&mutex);
if(disSocket == m_nCurrentSocket)
{
ui->text_Display->append(/*QDateTime::currentDateTime().toString("hh:mm:ss")+":"+*/msg);
}
}
void FormSrv::on_tableWidget_doubleClicked(const QModelIndex &index)
{
// if(ui->tableWidget->item(index.row(),4)->text() == "未连接")
// {
// ui->text_Display->append(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss")+"无当前车道信息,请重新选择");
// return;
// }
// if(m_nCurrentRowNum != -1)
// {
// if(index.row() == m_nCurrentRowNum)
// {
// SetRowColor(m_nCurrentRowNum,selected);
// return;
// }
// //将前一选中行颜色重置
// else
// {
// if(ui->tableWidget->item(m_nCurrentRowNum,4)->text() == "已连接")
// {
// SetRowColor(m_nCurrentRowNum,onLine);
// }
// else
// {
// SetRowColor(m_nCurrentRowNum,offLine);
// }
// }
// }
// qDebug()<<"select Socket:"<<ui->tableWidget->item(index.row(),0)->text();
// m_nCurrentSocket = ui->tableWidget->item(index.row(),0)->text().toInt();
// m_nCurrentRowNum = index.row();
// QString curNum = ui->tableWidget->item(index.row(),2)->text();
// QString curIP = ui->tableWidget->item(index.row(),1)->text();
// ui->label_CurLaneNum->setText(curNum);
// ui->label_CurLaneIP->setText(curIP);
// //ui->but_Send->setEnabled(true);
// ui->text_Display->clear();
// SetRowColor(index.row(),selected);
//ResetVehQueue();
slot_SelectToShowDetail(index.row());
}
void FormSrv::on_but_ControlView_clicked()
{
if(ui->but_ControlView->text() == "隐藏视图")
{
ui->stackedWidget_2->setVisible(false);
ui->gridLayout_10->setColumnStretch(0,0);
ui->gridLayout_10->setColumnStretch(1,0);
ui->but_ControlView->setText("显示视图");
this->showNormal();
this->resize(panelSize);
this->move((QApplication::desktop()->width() -getForm()->width())/2,(QApplication::desktop()->height() - getForm()->height())/2);
return;
}
if(ui->but_ControlView->text() == "显示视图")
{
ui->stackedWidget_2->setVisible(true);
ui->gridLayout_10->setColumnStretch(0,7);
ui->gridLayout_10->setColumnStretch(1,3);
ui->but_ControlView->setText("隐藏视图");
this->showNormal();
this->resize(mainSize);
this->move((QApplication::desktop()->width() -getForm()->width())/2,(QApplication::desktop()->height() - getForm()->height())/2);
return;
}
}
void FormSrv::on_but_RoadInfo_clicked()
{
//ui->stackedWidget->setCurrentIndex(1);
if(ui->but_RoadInfo->text() == "路段视图")
{
ui->stackedWidget_2->setCurrentIndex(1);
if(!m_excelIsOpen)
{
getDealExecl()->createTree(0,0,ui->treeWidget_2);
m_excelIsOpen = true;
}
ui->but_RoadInfo->setText("列表视图");
return;
}
if(ui->but_RoadInfo->text() == "列表视图")
{
ui->stackedWidget_2->setCurrentIndex(0);
ui->but_RoadInfo->setText("路段视图");
return;
}
}
//双击路段视图车道
void FormSrv::on_treeWidget_2_doubleClicked(const QModelIndex &index)
{
if(ui->treeWidget_2->currentItem()->childCount() == 0)
{
QString ip = "";
//qDebug()<<"double click tree"<<ui->treeWidget_2->currentItem()->text(0);
//通过item获取所选车道的ip (已存入map中)
if(getDealExecl()->GetIPByItem(ui->treeWidget_2->currentItem(),ip))
{
//通过ip获取车道所在行号 (已存入map中)
if(m_Ip2RowNumMap.contains(ip))
{
//ResetVehQueue();
slot_SelectToShowDetail(m_Ip2RowNumMap.value(ip));
ui->stackedWidget_2->setCurrentIndex(0);
ui->but_RoadInfo->setText(tr("路段视图"));
}
}
}
return;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fujingyuan/AutoVehTypeMon.git
git@gitee.com:fujingyuan/AutoVehTypeMon.git
fujingyuan
AutoVehTypeMon
AutoVehTypeMon
master

搜索帮助