This commit is contained in:
curtis
2024-11-25 17:15:44 +08:00
commit 32e5360a91
3749 changed files with 1432905 additions and 0 deletions

View File

@@ -0,0 +1,635 @@
#include "trainrecord.h"
#include "qdebug.h"
#include "ui_trainrecord.h"
#include "cdatabaseinterface.h"
#include "dataformate.h"
#include "dbforrmate.h"
#include <QDateTime>
#include <QRandomGenerator>
#include <QLabel>
#include "languagemanager.h"
TrainRecord::TrainRecord(QWidget *parent) :
QWidget(parent),
ui(new Ui::TrainRecord),
m_trainReport(NULL),
m_currentPage(1),
m_totalPage(1),
m_userID(100000)
{
ui->setupUi(this);
m_deleteReportDialog = new DeleteReportDialog();
initTrainRecordTable();
m_trainReport = new TrainReport();
m_trainReportThreeTwo = new TrainReportThreeTwo();
m_trainReportTwoTwo = new TrainReportTwoTwo();
m_trainReportTwoThree = new TrainReportTwoThree();
//设置输入框go的限制
QRegExp reg("^[0-9]*$");
ui->trainRecordDestPage_LineEdit->setValidator(new QRegExpValidator(reg, this));
}
TrainRecord::~TrainRecord()
{
if(m_trainReport != NULL)
{
delete m_trainReport;
m_trainReport = NULL;
}
if(m_trainReportThreeTwo != NULL)
{
delete m_trainReportThreeTwo;
m_trainReportThreeTwo = NULL;
}
if(m_trainReportTwoTwo != NULL)
{
delete m_trainReportTwoTwo;
m_trainReportTwoTwo = NULL;
}
if(m_trainReportTwoThree != NULL)
{
delete m_trainReportTwoThree;
m_trainReportTwoThree = NULL;
}
if(m_deleteReportDialog)
delete m_deleteReportDialog;
delete ui;
}
void TrainRecord::updateTableByID(int ID)
{
m_userID = ID;
//切换用户时切成首页
m_currentPage = 1;
QString queryNameStr(QString("select * from PatientTable where ID = '%1'").arg(ID));
if(CDatabaseInterface::getInstance()->exec(queryNameStr))
{
//填充用户信息
if(CDatabaseInterface::getInstance()->getValuesSize() > 0)
{
ST_PatientMsg st_patientMsg = variantMapToPatientMsg(CDatabaseInterface::getInstance()->getValues(0,1).at(0));
ui->name_Label->setText(st_patientMsg.name);
//下面填充性别
}
}
//根据ID查找用户
QString queryStr(QString("select * from TrainRecordTable where ID = '%1' order by startTime DESC").arg(ID));
if(CDatabaseInterface::getInstance()->exec(queryStr))
{
//最多显示500条
int fillTableNum = CDatabaseInterface::getInstance()->getValuesSize();
if(fillTableNum > 0)
{
//更新底部控制显示
updateBottomSetting(fillTableNum);
fillTableNum = (fillTableNum < MAXSHOWNUM ? fillTableNum : MAXSHOWNUM);
m_valueMapList = CDatabaseInterface::getInstance()->getValues(0,fillTableNum);
//填充首页
fillTrainReportTableByPage(1);
}
else
{
qDebug()<<"TrainRecord::updateTableByID未查询到符合要求的数据";
//return ;
m_displayNum = 0;
ui->trainRecord_TableWidget->clearContents();
m_totalPage = 1;
QString pageShow = QString("%1/%2").arg(m_currentPage).arg(m_totalPage);
ui->trainRecordIndexPage_Label->setText(pageShow);
ui->trainRecordDestPage_LineEdit->setText("1");
}
}
else
qDebug()<<"TrainRecord::updateTableByID"<<CDatabaseInterface::getInstance()->getLastError();
}
void TrainRecord::fillTrainReportTable(const int index,const int showRows)
{
//没有合适数据
if(showRows < 1)
return;
for(int row = 0;row < showRows;row++)
{
ST_TrainRecord st_trainRecord = variantMapToTrainRecord(m_valueMapList.at(index + row));
//第0列checkBox
QTableWidgetItem *checkItem = new QTableWidgetItem();
ui->trainRecord_TableWidget->setItem(row,0,checkItem);
QCheckBox *checkBox = new QCheckBox();
checkBox->setFixedWidth(40);
checkBox->setLayoutDirection(Qt::RightToLeft);
ui->trainRecord_TableWidget->setCellWidget(row,0,checkBox);
//第1列 训练时间
QTableWidgetItem *timeItem = new QTableWidgetItem(st_trainRecord.startTimeStr);
ui->trainRecord_TableWidget->setItem(row, 1, timeItem);
//第2列 训练时长
QTableWidgetItem *durationItem = new QTableWidgetItem(QString::number(st_trainRecord.trainTime));
ui->trainRecord_TableWidget->setItem(row, 2, durationItem);
/*
//第3列 得分
QTableWidgetItem *scoreItem = new QTableWidgetItem(QString::number(st_trainRecord.score));
ui->trainRecord_TableWidget->setItem(row, 3, scoreItem);
*/
//第3列 训练模式
QTableWidgetItem *trainModeItem = new QTableWidgetItem(st_trainRecord.trainMode);
//按照语言,刷新中英文
E_LANGUAGE language = LanguageManager::getInstance()->getCurrentLanguage();
if(language == English_E) { //数据库本身为的中文,要转到英文
QString tempMode;
if(st_trainRecord.trainMode == "主动")
tempMode = "Active",trainModeItem->setText(tempMode);
else if(st_trainRecord.trainMode == "被动")
tempMode = "Passive",trainModeItem->setText(tempMode);
else if(st_trainRecord.trainMode == "主被动")
tempMode = "Passive& Active",trainModeItem->setText(tempMode);
else if(st_trainRecord.trainMode == "等速")
tempMode = "Isokinetic",trainModeItem->setText(tempMode);
else if(st_trainRecord.trainMode == "助力")
tempMode = "Assisted",trainModeItem->setText(tempMode);
else if(st_trainRecord.trainMode == "Passive&Active")
tempMode = "Passive& Active",trainModeItem->setText(tempMode);
//换行显示
}
else if(language == Chinese_E) //数据库本身为英文,转化为中文
{
QString tempMode;
if(st_trainRecord.trainMode == "Active")
tempMode = "主动",trainModeItem->setText(tempMode);
else if(st_trainRecord.trainMode == "Passive")
tempMode = "被动",trainModeItem->setText(tempMode);
else if(st_trainRecord.trainMode == "Passive&Active")
tempMode = "主被动",trainModeItem->setText(tempMode);
else if(st_trainRecord.trainMode == "Isokinetic")
tempMode = "等速",trainModeItem->setText(tempMode);
else if(st_trainRecord.trainMode == "Assisted")
tempMode = "助力",trainModeItem->setText(tempMode);
}
ui->trainRecord_TableWidget->setItem(row, 3, trainModeItem);
//第4列 训练部位
QTableWidgetItem *bodyItem = new QTableWidgetItem(st_trainRecord.bodyPart);
if(language == English_E) {
QString tempPart;
if(st_trainRecord.bodyPart == "水平上肢")
tempPart = "Horizontal Limb",bodyItem->setText(tempPart);
else if(st_trainRecord.bodyPart == "下肢")
tempPart = "Lower Limb",bodyItem->setText(tempPart);
else if(st_trainRecord.bodyPart == "上下肢")
tempPart = "Upper and Lower",bodyItem->setText(tempPart);
else if(st_trainRecord.bodyPart == "垂直上肢")
tempPart = "Vertical Limb",bodyItem->setText(tempPart);
}
else if(language == Chinese_E) {
QString tempPart;
if(st_trainRecord.bodyPart == "Horizontal Limb")
tempPart = "水平上肢",bodyItem->setText(tempPart);
else if(st_trainRecord.bodyPart == "Lower Limb")
tempPart = "下肢",bodyItem->setText(tempPart);
else if(st_trainRecord.bodyPart == "Upper and Lower")
tempPart = "上下肢",bodyItem->setText(tempPart);
else if(st_trainRecord.bodyPart == "Vertical Limb")
tempPart = "垂直上肢",bodyItem->setText(tempPart);
}
ui->trainRecord_TableWidget->setItem(row, 4, bodyItem);
//第5列 查看--设置图片在表格中居中
#if 0
QTableWidgetItem *importItem = new QTableWidgetItem();
importItem->setIcon(QIcon(":/DependFile/Source/import.png"));
ui->trainRecord_TableWidget->setItem(row,5,importItem);
#else
QLabel *label = new QLabel();
label->setPixmap(QPixmap(":/DependFile/Source/User/import.png"));
label->setAlignment(Qt::AlignCenter);
ui->trainRecord_TableWidget->setCellWidget(row,5,label);
#endif
#if 0
//第6列 删除
QTableWidgetItem *deleteItem = new QTableWidgetItem();
deleteItem->setIcon(QIcon(":/DependFile/Source/delete.png"));
ui->trainRecord_TableWidget->setItem(row,6,deleteItem);
#else
QLabel *deletelabel = new QLabel();
deletelabel->setPixmap(QPixmap(":/DependFile/Source/User/delete.png"));
deletelabel->setAlignment(Qt::AlignCenter);
ui->trainRecord_TableWidget->setCellWidget(row,6,deletelabel);
#endif
//设置居中
for(int i = 1;i <= 4;i++)
ui->trainRecord_TableWidget->item(row,i)->setTextAlignment(Qt::AlignCenter);
}
qDebug() <<"index"<<index<<m_totalPage;
if(m_currentPage == m_totalPage) //最后一页的时候,填充颜色
{
for(int row = showRows;row < PAGENUM ;row++)
{
QTableWidgetItem *viewItem = new QTableWidgetItem("");
viewItem->setBackgroundColor(Qt::white);
QTableWidgetItem *deleteItem = new QTableWidgetItem("");
deleteItem->setBackgroundColor(Qt::white);
ui->trainRecord_TableWidget->setItem(row, 5, viewItem);
ui->trainRecord_TableWidget->setItem(row, 6, deleteItem);
}
}
}
void TrainRecord::fillTrainReportTableByPage(int pageIndex)
{
//判断页数下标的合法性
if(pageIndex > m_totalPage)
return;
//不是当前页则清空全选
ui->allSelect_CheckBox->setChecked(false);
//清空表格
ui->trainRecord_TableWidget->clearContents();
//当前页显示条数
int displayRow = m_valueMapList.size() - (pageIndex-1)*PAGENUM;
displayRow = displayRow > PAGENUM ? PAGENUM:displayRow;
//当页显示的条数
m_displayNum = displayRow;
//根据页下标获取要显示的数据条数
fillTrainReportTable((pageIndex-1)*PAGENUM,displayRow);
}
//初始化表格
void TrainRecord::initTrainRecordTable()
{
ui->trainRecord_TableWidget->horizontalHeader()->setVisible(false);
ui->trainRecord_TableWidget->verticalHeader()->setVisible(false);
//关闭右侧和下方滑条
ui->trainRecord_TableWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui->trainRecord_TableWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui->trainRecord_TableWidget->setColumnCount(7);
ui->trainRecord_TableWidget->setRowCount(8);
ui->trainRecord_TableWidget->setAlternatingRowColors(true);
ui->trainRecord_TableWidget->setShowGrid(false);
ui->trainRecord_TableWidget->setColumnWidth(0,60);
ui->trainRecord_TableWidget->setColumnWidth(1,300);
ui->trainRecord_TableWidget->setColumnWidth(2,150);
ui->trainRecord_TableWidget->setColumnWidth(3,150);
ui->trainRecord_TableWidget->setColumnWidth(4,250);
ui->trainRecord_TableWidget->setColumnWidth(5,150);
for(int i = 0;i < 8;i++)
{
ui->trainRecord_TableWidget->setRowHeight(i,80);
}
ui->trainRecord_TableWidget->setFont(QFont("黑体",15));
ui->trainRecord_TableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
//设置整行选中
ui->trainRecord_TableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
//设置不可选
ui->trainRecord_TableWidget->setSelectionMode(QAbstractItemView::NoSelection);
connect(ui->trainRecord_TableWidget,&QTableWidget::cellClicked,this,&TrainRecord::slotCellWidgetClicked);
//设置table隐藏边框通过测试以下两种方式都可行任选其一
//(1)方法一 设置不获取焦点
// ui->trainRecord_TableWidget->setFocusPolicy(Qt::NoFocus);
//(2)方法二 通过样式表设置
// ui->trainRecord_TableWidget->setStyleSheet("QTableWidget{outline:none;}"
// "QTableWidget::item{background:white;}");
//(3)方法三 自定义代理实现
}
void TrainRecord::slotCellWidgetClicked(int row,int cloumn)
{
if(row >= m_displayNum)
return;
//获取主键(时间)
QString startTimeStr = ui->trainRecord_TableWidget->item(row,1)->data(Qt::DisplayRole).toString();
switch(cloumn)
{
case 5: //查看报告
{
ST_TrainReport st_trainReport = m_trainReport->getReportDataByStartTime(startTimeStr);
//选择四种报告
int chooseReport = 0; //增加了垂直上肢等速、
if(st_trainReport.bodyIndex==3 && ( st_trainReport.trainMode==0 || st_trainReport.trainMode==3))
{
chooseReport = 1; //2*2=原来:(垂直上肢的助力模式和被动模式),现在 (垂直上肢的助力模式、被动模式、等速)
}
else if(st_trainReport.bodyIndex==3 && (st_trainReport.trainMode == 1 || st_trainReport.trainMode==10) || (st_trainReport.bodyIndex==3 && st_trainReport.trainMode==2))
{
chooseReport = 2; //3*2=原来:(垂直上肢的主动模式、等速模式和主被动),现在(垂直上肢的主动模式、主被动,助力模式)
}
else if((st_trainReport.bodyIndex==0 || st_trainReport.bodyIndex== 2|| st_trainReport.bodyIndex==1)
&& (st_trainReport.trainMode==0 || st_trainReport.trainMode==4)
|| (st_trainReport.bodyIndex==0 ||st_trainReport.bodyIndex == 1) && st_trainReport.trainMode==3)
{
chooseReport = 3;//2*3=原来水平上肢、上下肢和下肢的被动和助力现在水平上肢、上下肢和下肢的被动、水平上肢和下肢的等速模式上下肢被动模式是4不是0
}
if(chooseReport == 0) //显示3行3图片
m_trainReport->setReportData(st_trainReport,0);
else if(chooseReport == 1)
m_trainReportTwoTwo->setReportData(st_trainReport,0);
else if(chooseReport == 2)
m_trainReportThreeTwo->setReportData(st_trainReport,0);
else if(chooseReport == 3)
m_trainReportTwoThree->setReportData(st_trainReport,0);
//原版的m_trainReport->setReportData(st_trainReport,0);
}
break;
case 6: //删除记录
{
m_deleteReportDialog->exec();
if(!m_deleteReportDialog->isDeletedUser()) return;//不删除就退出
//删除记录条目
QString table("TrainRecordTable");
if(!CDatabaseInterface::getInstance()->deleteRowTable(table,"startTimeStr",startTimeStr))
qDebug()<<CDatabaseInterface::getInstance()->getLastError();
//删除该记录对应的报告数据
if(!m_trainReport->deleteReportByStartTime(startTimeStr))
{
qDebug()<<"删除报告失败";
}
if(1 == m_displayNum)//整页删除
{
if(m_currentPage >=2)
--m_currentPage;
}
QString queryStr(QString("select * from TrainRecordTable where ID = '%1' order by startTime DESC").arg(m_userID));
int fillTableNum = 0;
if(CDatabaseInterface::getInstance()->exec(queryStr))
{
//最多显示500条
fillTableNum = CDatabaseInterface::getInstance()->getValuesSize();
if(fillTableNum > 0)
{
fillTableNum = (fillTableNum < MAXSHOWNUM ? fillTableNum : MAXSHOWNUM);
m_valueMapList = CDatabaseInterface::getInstance()->getValues(0,fillTableNum);
}
else
{
//清空表格
ui->trainRecord_TableWidget->clearContents();
m_displayNum = 0;
qDebug()<<"所有数据都已删除";
return;
}
}
//更新底部控制显示
updateBottomSetting(fillTableNum);
//更新显示界面
fillTrainReportTableByPage(m_currentPage);
}
break;
}
}
void TrainRecord::on_allSelect_CheckBox_clicked(bool checked)
{
//要选中的条数m_displayNum
for(int i = 0;i < m_displayNum;++i)
{
QCheckBox *checkBox = static_cast<QCheckBox*>(ui->trainRecord_TableWidget->cellWidget(i,0));
checkBox->setChecked(checked);
}
}
//删除选中项
void TrainRecord::on_delete_Btn_clicked()
{
m_deleteReportDialog->exec();
if(!m_deleteReportDialog->isDeletedUser()) return;//不删除就退出
//删除条数计数
int deleteNum = 0;
for(int i = 0;i <m_displayNum;++i)
{
QCheckBox *checkBox = static_cast<QCheckBox*>(ui->trainRecord_TableWidget->cellWidget(i,0));
if(checkBox->isChecked())
{
QString startTimeStr = ui->trainRecord_TableWidget->item(i,1)->data(Qt::DisplayRole).toString();
if(!CDatabaseInterface::getInstance()->deleteRowTable("TrainRecordTable","startTimeStr",startTimeStr))
qDebug()<<"delete user failed"<<CDatabaseInterface::getInstance()->getLastError();
else
++deleteNum;
}
}
QString queryStr(QString("select * from TrainRecordTable where ID = '%1' order by startTime DESC").arg(m_userID));
int fillTableNum = 0;
if(CDatabaseInterface::getInstance()->exec(queryStr))
{
//最多显示500条
fillTableNum = CDatabaseInterface::getInstance()->getValuesSize();
if(fillTableNum > 0)
{
fillTableNum = (fillTableNum < MAXSHOWNUM ? fillTableNum : MAXSHOWNUM);
m_valueMapList = CDatabaseInterface::getInstance()->getValues(0,fillTableNum);
}
else
{
//清空表格
ui->trainRecord_TableWidget->clearContents();
m_displayNum = 0;
qDebug()<<"所有数据都已删除";
return;
}
}
//删除完成之后重新整理表格结构
if(deleteNum == m_displayNum)//整页删除
{
if(m_currentPage >=2)
--m_currentPage;
}
//更新底部控制显示
updateBottomSetting(fillTableNum);
//更新显示界面
fillTrainReportTableByPage(m_currentPage);
ui->allSelect_CheckBox->setChecked(false);
}
//前一页
void TrainRecord::on_trainRecordFrontPage_btn_clicked()
{
if(m_currentPage <= 1)
return;
fillTrainReportTableByPage(--m_currentPage);
QString pageShow = QString("%1/%2").arg(m_currentPage).arg(m_totalPage);
ui->trainRecordIndexPage_Label->setText(pageShow);
}
//后一页
void TrainRecord::on_trainRecordBackPage_btn_clicked()
{
if(m_currentPage >= m_totalPage)
return;
fillTrainReportTableByPage(++m_currentPage);
QString pageShow = QString("%1/%2").arg(m_currentPage).arg(m_totalPage);
ui->trainRecordIndexPage_Label->setText(pageShow);
}
void TrainRecord::on_trainRecordGo_btn_clicked()
{
//updateTableByID(m_userID);
int destPage = ui->trainRecordDestPage_LineEdit->text().toUInt();
if(destPage > m_totalPage || destPage < 0) //总页没有数据,也不跳转
return;
QString queryStr(QString("select * from TrainRecordTable where ID = '%1' order by startTime DESC").arg(m_userID));
int fillTableNum = 0;
if(CDatabaseInterface::getInstance()->exec(queryStr))
{
//最多显示500条
fillTableNum = CDatabaseInterface::getInstance()->getValuesSize();
}
qDebug() <<"该用户总记录数据:"<<fillTableNum;
if(fillTableNum <= 0) //如果没有任何数据,也不跳转
return ;
QString pageShow = QString("%1/%2").arg(destPage).arg(m_totalPage);
ui->trainRecordIndexPage_Label->setText(pageShow);
fillTrainReportTableByPage(destPage);
//如果插入了记录,重新更新表数据
//fillTrainReportTableByPage(m_totalPage);
}
void TrainRecord::updateBottomSetting(int num)
{
int pageNum = num/PAGENUM;
if(num%PAGENUM)
pageNum+=1;
//设置总页数
m_totalPage = pageNum;
QString pageShow = QString("%1/%2").arg(m_currentPage).arg(m_totalPage);
ui->trainRecordIndexPage_Label->setText(pageShow);
ui->trainRecordDestPage_LineEdit->setText("1");
}
//生成数据
void TrainRecord::on_createData_Btn_clicked()
{
int createNum = 10/*ui->createNum_LineEdit->text().toInt()*/;
//为当前每个ID生成五条数据
QString queryStr(QString("select * from PatientTable order by ID DESC"));
if(CDatabaseInterface::getInstance()->exec(queryStr))
{
int tempNum = CDatabaseInterface::getInstance()->getValuesSize();
int fillTableNum = tempNum < MAXSHOWNUM ? tempNum : MAXSHOWNUM;
if(fillTableNum > 0)
{
QList<QVariantMap> valueMapList;
valueMapList = CDatabaseInterface::getInstance()->getValues(0,fillTableNum);
for(int row = 0;row < valueMapList.size();++row)
{
ST_PatientMsg st_PatientMsg = variantMapToPatientMsg(valueMapList.at(row));
for(int i = 0;i < createNum;++i)
{
//生成记录数据表
ST_TrainRecord st_trainRecord;
st_trainRecord.ID = st_PatientMsg.ID;
quint32 x = QRandomGenerator::global()->generate();
st_trainRecord.bodyPart = QString::number(x%4);
st_trainRecord.score = x%100;
st_trainRecord.trainTime = x%60;
st_trainRecord.startTime = QDateTime::currentDateTime().addSecs(x%10000);
st_trainRecord.startTimeStr = st_trainRecord.startTime.toString("yyyy-MM-dd hh:mm:ss");
if(!CDatabaseInterface::getInstance()->insertRowTable("TrainRecordTable",trainRecordToVariantMap(st_trainRecord)))
{
qDebug()<<"TrainRecord::on_createData_Btn_clicked"<<CDatabaseInterface::getInstance()->getLastError();
}
//生成训练报告数据
ST_TrainReport st_trainReport;
st_trainReport.ID = st_PatientMsg.ID;
st_trainReport.name = st_PatientMsg.name;
st_trainReport.sex = st_PatientMsg.sex;
st_trainReport.phone = st_PatientMsg.phone;
st_trainReport.age = st_PatientMsg.age;
st_trainReport.trainMode = x%5;
st_trainReport.bodyIndex = st_PatientMsg.bodyIndex;
st_trainReport.markMsg = st_PatientMsg.markMsg;
st_trainReport.trainTime = st_trainRecord.trainTime;
st_trainReport.leftBalance = x%100;
st_trainReport.rightBalance = x%100;
st_trainReport.upLimpLength = x%1000;
st_trainReport.downLimpLength = x%1000;
st_trainReport.activeTime = x%100;
st_trainReport.passiveTime = x%100;
st_trainReport.spasmTimes = x%3;
st_trainReport.maxResistance = x%50;
st_trainReport.minResistance = x%10;
st_trainReport.averangeResistance = (st_trainReport.minResistance+st_trainReport.maxResistance)/2.f;
st_trainReport.startTimeStr = st_trainRecord.startTimeStr;
QString tableName("TrainReportTable");
if(!CDatabaseInterface::getInstance()->insertRowTable(tableName,trainReportToVariantMap(st_trainReport)))
qDebug()<<"训练报告存储失败"<<CDatabaseInterface::getInstance()->getLastError();
}
}
}
else
{
ui->trainRecord_TableWidget->clearContents();
qDebug()<<"updateUserTableWidget()未查询到符合条件的数据";
}
}
else
qDebug()<<CDatabaseInterface::getInstance()->getLastError();
}
void TrainRecord::slotCheckUserChanged(int ID)
{
//更新显示列表
updateTableByID(ID);
}
void TrainRecord::changeEvent(QEvent* event)
{
switch (event->type())
{
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
QWidget::changeEvent(event);
break;
}
}
void TrainRecord::showEvent(QShowEvent *event)
{
Q_UNUSED(event)
updateTableByID(m_userID);
//ui->trainRecordDestPage_LineEdit->clear(); //清空查询
}
//

View File

@@ -0,0 +1,75 @@
#ifndef TRAINRECORD_H
#define TRAINRECORD_H
#include <QWidget>
#include "trainreport.h"
#include "DeleteReportDialog.h"
#include "trainreporttwotwo.h"
#include "trainreportthreetwo.h"
#include "trainreporttwothree.h"
namespace Ui {
class TrainRecord;
}
class TrainRecord : public QWidget
{
Q_OBJECT
public:
explicit TrainRecord(QWidget *parent = nullptr);
~TrainRecord();
//根据用户ID来更新表格
void updateTableByID(int ID);
public slots:
void slotCheckUserChanged(int);
protected:
virtual void changeEvent(QEvent* event);
virtual void showEvent(QShowEvent *event);
private slots:
void on_allSelect_CheckBox_clicked(bool checked);
void on_delete_Btn_clicked();
void on_trainRecordFrontPage_btn_clicked();
void on_trainRecordBackPage_btn_clicked();
void on_trainRecordGo_btn_clicked();
void on_createData_Btn_clicked();
void slotCellWidgetClicked(int row,int cloumn);
private:
//更新底部控制列表@int num数据条数
void updateBottomSetting(int num);
//根据页填充表格 从1开始
void fillTrainReportTableByPage(int pageIndex);
/*****
*说名:填充表格
*参数@const int index数据读取的下标
* @const int showRows读取数据的条数
****/
void fillTrainReportTable(const int index,const int showRows);
//初始化表格
void initTrainRecordTable();
private:
Ui::TrainRecord *ui;
TrainReport *m_trainReport;
TrainReportThreeTwo *m_trainReportThreeTwo;
TrainReportTwoTwo *m_trainReportTwoTwo;
TrainReportTwoThree *m_trainReportTwoThree;
DeleteReportDialog *m_deleteReportDialog;
QList<QVariantMap> m_valueMapList;
quint16 m_currentPage; //当前页 从1开始
quint16 m_totalPage; //总页数
quint16 m_displayNum; //当前页显示的条数
int m_userID;
};
#endif // TRAINRECORD_H

View File

@@ -0,0 +1,527 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TrainRecord</class>
<widget class="QWidget" name="TrainRecord">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1316</width>
<height>980</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QStackedWidget" name="stackedWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>156</y>
<width>1301</width>
<height>821</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);</string>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page">
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>40</x>
<y>0</y>
<width>1226</width>
<height>51</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background: #F1F9FD;
border:none;</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>100</x>
<y>10</y>
<width>181</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>训练日期</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>300</x>
<y>10</y>
<width>221</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>训练时长(min)</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>540</x>
<y>10</y>
<width>101</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>训练模式</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>690</x>
<y>10</y>
<width>201</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>训练部位</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_5">
<property name="geometry">
<rect>
<x>930</x>
<y>10</y>
<width>111</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>查看</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_6">
<property name="geometry">
<rect>
<x>1080</x>
<y>10</y>
<width>91</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>删除</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_7">
<property name="geometry">
<rect>
<x>0</x>
<y>10</y>
<width>91</width>
<height>30</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="text">
<string>选择</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</widget>
<widget class="QTableWidget" name="trainRecord_TableWidget">
<property name="geometry">
<rect>
<x>40</x>
<y>60</y>
<width>1225</width>
<height>630</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">#trainRecord_TableWidget{border:none;}</string>
</property>
</widget>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>30</x>
<y>710</y>
<width>1221</width>
<height>80</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border:none;border-radius:1px;background:white;</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QLineEdit" name="trainRecordDestPage_LineEdit">
<property name="geometry">
<rect>
<x>990</x>
<y>20</y>
<width>91</width>
<height>40</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">width: 90px;
height: 50px;
background: #FFFFFF;
border-radius: 4px;
border: 1px solid #EBEBEB;</string>
</property>
<property name="text">
<string>1</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QPushButton" name="trainRecordBackPage_btn">
<property name="geometry">
<rect>
<x>780</x>
<y>15</y>
<width>50</width>
<height>50</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/User/next.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="delete_Btn">
<property name="geometry">
<rect>
<x>120</x>
<y>19</y>
<width>40</width>
<height>40</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/User/delete.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="label_18">
<property name="geometry">
<rect>
<x>890</x>
<y>22</y>
<width>81</width>
<height>35</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>跳转到</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QCheckBox" name="allSelect_CheckBox">
<property name="geometry">
<rect>
<x>30</x>
<y>22</y>
<width>80</width>
<height>35</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>全选</string>
</property>
</widget>
<widget class="QPushButton" name="trainRecordFrontPage_btn">
<property name="geometry">
<rect>
<x>700</x>
<y>15</y>
<width>50</width>
<height>50</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/User/last.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="trainRecordIndexPage_Label">
<property name="geometry">
<rect>
<x>580</x>
<y>29</y>
<width>100</width>
<height>25</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>1/23</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QPushButton" name="trainRecordGo_btn">
<property name="geometry">
<rect>
<x>1140</x>
<y>15</y>
<width>50</width>
<height>50</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background: #FFFFFF;
border-radius: 4px;
border: 1px solid #EBEBEB;</string>
</property>
<property name="text">
<string>GO</string>
</property>
</widget>
<widget class="QLabel" name="label_13">
<property name="geometry">
<rect>
<x>1090</x>
<y>24</y>
<width>35</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>页</string>
</property>
</widget>
</widget>
</widget>
<widget class="QWidget" name="page_2"/>
</widget>
<widget class="QGroupBox" name="groupBox_3">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1316</width>
<height>980</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">#groupBox_3{background:white;}</string>
</property>
<property name="title">
<string/>
</property>
<widget class="QLabel" name="portrait_Label">
<property name="geometry">
<rect>
<x>40</x>
<y>30</y>
<width>50</width>
<height>50</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/DependFile/Source/User/user.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="name_Label">
<property name="geometry">
<rect>
<x>110</x>
<y>34</y>
<width>101</width>
<height>41</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="trainRecord_Btn">
<property name="geometry">
<rect>
<x>40</x>
<y>102</y>
<width>206</width>
<height>54</height>
</rect>
</property>
<property name="font">
<font>
<family>黑体</family>
<pointsize>15</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background: #05A6EC;
border-radius: 1px;
color:white;</string>
</property>
<property name="text">
<string>训练记录</string>
</property>
</widget>
</widget>
<zorder>groupBox_3</zorder>
<zorder>stackedWidget</zorder>
</widget>
<resources/>
<connections/>
</ui>