|
|
@ -22,6 +22,7 @@ MainWidget::MainWidget(HttpService *httpService, |
|
|
|
m_wsConnectedStatus = 0; |
|
|
|
m_maxPatientNum = MainConfig::maxPatientNum.toInt(); |
|
|
|
m_switchPatientInterval = MainConfig::switchPatientInterval.toInt(); |
|
|
|
keyDownPInfo = Q_NULLPTR;//zhixiang kongzhizhen
|
|
|
|
|
|
|
|
//1s倒计时
|
|
|
|
m_countDownTimer.setInterval(1000); |
|
|
@ -46,6 +47,13 @@ MainWidget::MainWidget(HttpService *httpService, |
|
|
|
m_curX = 0; |
|
|
|
}); |
|
|
|
|
|
|
|
//LED闪烁
|
|
|
|
m_ledTurnTimer.setInterval(1000); |
|
|
|
connect(&m_ledTurnTimer, &QTimer::timeout,[=](){ |
|
|
|
m_deviceService->m_ledStatus ^= 1; |
|
|
|
m_deviceService->ledSet(m_deviceService->m_ledStatus); |
|
|
|
}); |
|
|
|
|
|
|
|
//显示连接状态
|
|
|
|
ui->statusLabel->setText("Not Connected"); |
|
|
|
|
|
|
@ -192,10 +200,7 @@ void MainWidget::onNewPatientMergencyInfo(QString firstAidId, QString name, QStr |
|
|
|
PatientEmergencyInfo *pInfo = new PatientEmergencyInfo(firstAidId,name,content,realCountDownInSeconds); |
|
|
|
addPatientToList(pInfo); |
|
|
|
qDebug() << "MainWidget::onNewPatientMergencyInfo " << firstAidId << name << content << realCountDownInSeconds; |
|
|
|
m_deviceService->timer1.start(); |
|
|
|
m_deviceService->m_ledStatus ^= 1; |
|
|
|
m_deviceService->ledSet(m_deviceService->m_ledStatus); |
|
|
|
|
|
|
|
m_ledTurnTimer.start(); |
|
|
|
} |
|
|
|
|
|
|
|
void MainWidget::onPatientMergencyStatusChanged(QString firstAidId,QString time, QString status) |
|
|
@ -231,19 +236,32 @@ void MainWidget::onKeyClicked() |
|
|
|
|
|
|
|
void MainWidget::onKeyDown() |
|
|
|
{ |
|
|
|
if(m_patientEmergencyInfos.length() > 0){ |
|
|
|
keyDownPInfo = m_patientEmergencyInfos[m_patientIndex]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void MainWidget::onKeyWorked(KeyFlag flag) |
|
|
|
{ |
|
|
|
m_deviceService->timer1.stop(); |
|
|
|
if(flag == Click){ |
|
|
|
m_ledTurnTimer.stop(); |
|
|
|
m_deviceService->m_ledStatus = 0; |
|
|
|
m_deviceService->ledSet(m_deviceService->m_ledStatus); |
|
|
|
onKeyClicked(); |
|
|
|
}else if(flag == Dbl_Click){ |
|
|
|
qDebug()<<"Key Dbl_Clicked"; |
|
|
|
//切换病人
|
|
|
|
if(++m_patientIndex >= m_patientEmergencyInfos.length()){ |
|
|
|
m_patientIndex = 0; |
|
|
|
} |
|
|
|
updateUi(); |
|
|
|
m_curX = 0; |
|
|
|
}else if(flag == Press){ |
|
|
|
qDebug()<<"Key Press"; |
|
|
|
if(keyDownPInfo != Q_NULLPTR){ |
|
|
|
deletePatientFromList(keyDownPInfo->id); |
|
|
|
keyDownPInfo = Q_NULLPTR; |
|
|
|
} |
|
|
|
m_deviceService->m_ledStatus = 1; |
|
|
|
m_deviceService->ledSet(m_deviceService->m_ledStatus); |
|
|
|
} |
|
|
@ -262,6 +280,8 @@ void MainWidget::addPatientToList(PatientEmergencyInfo *info) |
|
|
|
|
|
|
|
//3.加入链表
|
|
|
|
m_patientEmergencyInfos.push_back(info); |
|
|
|
|
|
|
|
onKeyDown();//模拟按键按下
|
|
|
|
} |
|
|
|
|
|
|
|
void MainWidget::deletePatientFromList(QString firstAidId) |
|
|
@ -275,12 +295,37 @@ void MainWidget::deletePatientFromList(QString firstAidId) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void MainWidget::mousePressEvent(QMouseEvent *event) |
|
|
|
{ |
|
|
|
|
|
|
|
if(event->button()==Qt::LeftButton){ |
|
|
|
//TODO
|
|
|
|
} |
|
|
|
else if(event->button()==Qt::RightButton){ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
//鼠标左键双击,代替按键一下
|
|
|
|
//鼠标右键双击,代替按键两下
|
|
|
|
void MainWidget::mouseDoubleClickEvent(QMouseEvent *event) |
|
|
|
{ |
|
|
|
if(event->button()==Qt::LeftButton){ |
|
|
|
//TODO
|
|
|
|
m_deviceService->key.flag = Click; |
|
|
|
onKeyWorked(m_deviceService->key.flag); |
|
|
|
} |
|
|
|
else if(event->button()==Qt::RightButton){ |
|
|
|
onKeyClicked(); |
|
|
|
m_deviceService->key.flag = Dbl_Click; |
|
|
|
onKeyWorked(m_deviceService->key.flag); |
|
|
|
} |
|
|
|
} |
|
|
|
//鼠标滚动,代替长按
|
|
|
|
void MainWidget::wheelEvent(QWheelEvent *event) |
|
|
|
{ // 当滚轮远离使用者时
|
|
|
|
if(event->delta() > 0){ |
|
|
|
//TODO
|
|
|
|
}else{//当滚轮向使用者方向旋转时
|
|
|
|
m_deviceService->key.flag = Press; |
|
|
|
onKeyWorked(m_deviceService->key.flag); |
|
|
|
} |
|
|
|
} |
|
|
|