代码拉取完成,页面将自动刷新
#include "facesetting.h"
#include "ui_facesetting.h"
FaceSetting::FaceSetting(QWidget *parent) :
QWidget(parent),
ui(new Ui::FaceSetting)
{
ui->setupUi(this);
this->hide();
QStringList headerLabels = QStringList()<<QObject::tr("姓名")
<<QObject::tr("注册时间")
<<QObject::tr("图像质量")
//<<QObject::tr("改操作")
<<QObject::tr("删操作");
//ui->ListWidget->setRowCount(15);
ui->ListWidget->setColumnCount(4);
ui->ListWidget->setColumnWidth(0,200);
ui->ListWidget->setColumnWidth(1,255);
ui->ListWidget->setColumnWidth(2,230);
ui->ListWidget->setColumnWidth(3,230);
//ui->ListWidget->setColumnWidth(4,115);
ui->ListWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
//ui->FaceList->setRowCount(10);
//ui->FaceList->setColumnCount(4);
ui->ListWidget->setHorizontalHeaderLabels(headerLabels);
// ui->FaceList->setModel(m_StandardItemModel);
// ui->FaceList->setColumnWidth(0,200);
// ui->FaceList->setColumnWidth(1,255);
// ui->FaceList->setColumnWidth(2,230);
// ui->FaceList->setColumnWidth(3,230);
// ui->FaceList->setEditTriggers(QAbstractItemView::NoEditTriggers);
// ui->FaceList->horizontalHeader()->setDefaultAlignment(Qt::AlignCenter);
// QTableWidgetItem *Name = new QTableWidgetItem(QString("Li"));
// QTableWidgetItem *Time = new QTableWidgetItem(QString("21-08-15"));
// QTableWidgetItem *Pic = new QTableWidgetItem(15);
// QTableWidgetItem *Op = new QTableWidgetItem(QString("21-08-15"));
// for(int i = 0;i < 15;i++)
// {
//// m_StandardItemModel->setColumnCount(4);
//// m_StandardItemModel->setItem(i,0,new QStandardItem("Li"));
//// m_StandardItemModel->setItem(i,1,new QStandardItem("21-08-15"));
//// m_StandardItemModel->setItem(i,2,new QStandardItem("15"));
//// m_StandardItemModel->setItem(i,3,new QStandardItem("21-08-15"));
//// ui->FaceList->setModel(m_StandardItemModel);
// ui->ListWidget->setRowHeight(i,50);
// }
m_CurPage = 1;
m_CurPageRowCnt = 0;
CleanListItem();
ui->ListWidget->setShowGrid(true);
ui->ListWidget->verticalHeader()->setHidden(true);
ui->ListWidget->verticalScrollBar();
SetQRadioButtonStyleSheet();
m_FaceRegister = new FaceRegister;
m_PicShow = new PicShow(this);
connect(ui->ListWidget,SIGNAL(itemClicked(QTableWidgetItem *)),
this,SLOT(NameItemClicked(QTableWidgetItem *)));
}
FaceSetting::~FaceSetting()
{
delete ui;
}
void FaceSetting::showEvent(QShowEvent *event)
{
ScreenSwitchButton::GetInstance()->Show(this);
ui->FaceIdTimeout->setText(DataDictionary::GetInstance()->GetMisData(MIS_FACEID_TIMEOUT));
//qDebug() << List;
m_CurPage = 1;
m_CurPageRowCnt = 0;
ShowCurPage(m_CurPage);
PersonInfoChange();
DevParamDataChange(D_FACEID_CTL);
// ui->FaceIdValue->setText(DataDictionary::GetInstance()->GetMisData(MIS_FACEID_CMP_VALUE));
// ShowSyncTime(DataDictionary::GetInstance()->GetSystemData(SYS_HTTP_SYNC_TIME));
// connect(DataDictionary::GetInstance(),SIGNAL(PersonInfoChange()),\
// this,SLOT(PersonInfoChange()));
// connect(DataDictionary::GetInstance(),SIGNAL(SystemDataChange(SystemDataIndex_t)),\
// this,SLOT(SystemDataChange(SystemDataIndex_t)));
// connect(DataDictionary::GetInstance(),SIGNAL(DevParamDataChange(DevParamDataIndex_t)),\
// this,SLOT(DevParamDataChange(DevParamDataIndex_t)));
}
void FaceSetting::hideEvent(QHideEvent *event)
{
disconnect(DataDictionary::GetInstance(),SIGNAL(PersonInfoChange()),\
this,SLOT(PersonInfoChange()));
disconnect(DataDictionary::GetInstance(),SIGNAL(SystemDataChange(SystemDataIndex_t)),\
this,SLOT(SystemDataChange(SystemDataIndex_t)));
disconnect(DataDictionary::GetInstance(),SIGNAL(DevParamDataChange(DevParamDataIndex_t)),\
this,SLOT(DevParamDataChange(DevParamDataIndex_t)));
}
void FaceSetting::SetQRadioButtonStyleSheet(QRadioButton *button,bool s)
{
if(s)
{
button->setStyleSheet("QRadioButton\
{\
color: rgb(115, 210, 22);\
image-position:left;\
padding-left:10px;\
font: 24px 'Ubuntu';\
font: bold;\
border:0px solid;\
padding-left: 0px; \
}\
QRadioButton::indicator\
{\
width:30px;\
height:30px;\
}");
}
else {
button->setStyleSheet("QRadioButton\
{\
color: rgb(204, 0, 0);\
image-position:left;\
padding-left:10px;\
font: 24px 'Ubuntu';\
font: bold;\
border:0px solid;\
padding-left: 0px; \
}\
QRadioButton::indicator\
{\
width:30px;\
height:30px;\
}");
}
}
void FaceSetting::SetQRadioButtonStyleSheet()
{
SetQRadioButtonStyleSheet(ui->FaceIdLinkEnable,true);
SetQRadioButtonStyleSheet(ui->FaceIdLinkUnable,false);
}
void FaceSetting::on_PhotoEntryButton_clicked()
{
m_FaceRegister->show();
}
void FaceSetting::SetFaceCnt(int32_t Cnt)
{
ui->FaceCnt->setText(QString().number(Cnt));
}
void FaceSetting::CleanListItem()
{
while(ui->ListWidget->rowCount())
{
ui->ListWidget->removeRow(0);
}
}
void FaceSetting::AddListItem(QList<PersonInfo_t> &list)
{
m_CurPageRowCnt = 0;
for (int i = 0;i < list.size() && ((m_CurPage-1)*15+i) < list.size();i++) {
PersonInfo_t Info = list.at((m_CurPage-1)*15+i);
m_CurPageRowCnt = i;
AddListItem(Info.Name,Info.Time,QString().number(100));
}
}
void FaceSetting::AddListItem(QString Name,QString Date,QString V)
{
QString Time = QDateTime::fromMSecsSinceEpoch(Date.toLongLong()).toString("yyyy-MM-dd hh:mm:ss");
ui->ListWidget->setRowCount(m_CurPageRowCnt+1);
QTableWidgetItem* item0 = new QTableWidgetItem(Name,5);
QTableWidgetItem* item1 = new QTableWidgetItem(Time,6);
QTableWidgetItem* item2 = new QTableWidgetItem(V,7);
// QPushButton* dialBtn = new QPushButton;
// dialBtn->setText("修改");
// dialBtn->setStyleSheet("QPushButton{\
// background-color: rgb(251, 160, 57);\
// font: 24px 'Ubuntu';\
// font:bold;\
// color: rgb(255, 255, 255);}");
// connect(dialBtn, SIGNAL(clicked()), this, SLOT(ModifyItem()));
// //connect(delBtn, SIGNAL(clicked()), this, SLOT(onBtnClicked()));
// dialBtn->setIcon(QIcon(QObject::tr(":/icons/dial.png")));
QPushButton* delBtn = new QPushButton;
delBtn->setText("删除");
delBtn->setStyleSheet("QPushButton{\
background-color: rgb(251, 160, 57);\
font: 24px 'Ubuntu';\
font:bold;\
color: rgb(255, 255, 255);}");
connect(delBtn, SIGNAL(clicked()), this, SLOT(RemoveRow()),Qt::QueuedConnection);
//connect(delBtn, SIGNAL(clicked()), this, SLOT(onBtnClicked()));
//delBtn->setIcon(QIcon(QObject::tr(":/icons/delete.png")));
delBtn->resize(180,50);
ui->ListWidget->setItem(m_CurPageRowCnt, 0, item0);
ui->ListWidget->setItem(m_CurPageRowCnt, 1, item1);
ui->ListWidget->setItem(m_CurPageRowCnt, 2, item2);
//ui->ListWidget->setCellWidget(m_CurPageRowCnt, 3, dialBtn);
ui->ListWidget->setCellWidget(m_CurPageRowCnt, 3, delBtn);
ui->ListWidget->setRowHeight(m_CurPageRowCnt,50);
}
void FaceSetting::ModifyItem()
{
QPushButton *pushBtn = dynamic_cast<QPushButton*>(this->sender());
if(pushBtn == nullptr)
return;
int x = pushBtn->frameGeometry().x();
int y = pushBtn->frameGeometry().y();
QModelIndex index = ui->ListWidget->indexAt(QPoint(x, y));
int row = index.row();
int colum = index.column();
qDebug() << QObject::tr("Dial, row: %1, colum: %2").arg(row).arg(colum);
}
void FaceSetting::RemoveRow()
{
QPushButton *pushBtn = dynamic_cast<QPushButton*>(this->sender());
if(pushBtn == nullptr)
return;
int x = pushBtn->frameGeometry().x();
int y = pushBtn->frameGeometry().y();
QModelIndex index = ui->ListWidget->indexAt(QPoint(x, y));
int row = index.row();
int colum = index.column();
qDebug() << QObject::tr("Remove row, row: %1, colum: %2").arg(row).arg(colum);
ui->ListWidget->removeRow(row);
int ListIndex = (m_CurPage - 1) * 15 + row;
DataDictionary::GetInstance()->CleanPersonInfo(List[ListIndex].Uuid);
PersonInfoChange();
}
void FaceSetting::ShowCurPage(int32_t Page)
{
ui->CurPage->setText(QString().number(Page));
}
void FaceSetting::ShowSyncTime(QString SyncTime)
{
if(SyncTime.toUInt() == 0)
return ;
QString Time = QDateTime::fromMSecsSinceEpoch(SyncTime.toLongLong()).toString("yyyy-MM-dd hh:mm:ss");
ui->SyncTime->setText(Time);
}
void FaceSetting::on_DownButton_clicked()
{
if(List.size() < (m_CurPage*15))
return ;
m_CurPage++;
ShowCurPage(m_CurPage);
CleanListItem();
AddListItem(List);
}
void FaceSetting::on_UpButton_clicked()
{
if(m_CurPage == 1)
return ;
m_CurPage--;
ShowCurPage(m_CurPage);
CleanListItem();
AddListItem(List);
}
void FaceSetting::PersonInfoChange()
{
CleanListItem();
List = DataDictionary::GetInstance()->GetPersonList();
AddListItem(List);
SetFaceCnt(List.size());
if(List.count() == 0)
m_CurPage = 1;
}
void FaceSetting::SystemDataChange(SystemDataIndex_t Index)
{
switch (Index) {
case SYS_HTTP_SYNC_TIME:
ShowSyncTime(DataDictionary::GetInstance()->GetSystemData(SYS_HTTP_SYNC_TIME));
break;
default:
break;
}
}
void FaceSetting::DevParamDataChange(DevParamDataIndex_t Index)
{
switch (Index) {
case D_FACEID_CTL:
{
QString V = DataDictionary::GetInstance()->GetDevParamData(Index);
FaceIdLinkEnableButton(V.toUInt());
}
break;
default:
break;
}
}
void FaceSetting::on_FaceIdTimeout_returnPressed()
{
DataDictionary::GetInstance()->SetMisData(MIS_FACEID_TIMEOUT,ui->FaceIdTimeout->text());
}
void FaceSetting::NameItemClicked(QTableWidgetItem *item)
{
if(item->type() == 5)
{
//qDebug() << __func__ << " : name :" << item->text();
int row = ui->ListWidget->currentRow();
PersonInfo_t Info;
QImage Img;
Info.Pic.clear();
row += (m_CurPage - 1) * 15;
if(row < List.size())
{
Info = List[row];
}
if(Info.Pic.isEmpty())
{
m_PicShow->SetText("照片异常,请重新录入 ... ...");
}
else
{
Img = QImage::fromData(QByteArray::fromBase64(Info.Pic.toLocal8Bit()));
m_PicShow->SetImage(Img);
}
m_PicShow->show();
m_PicShow->raise();
}
}
void FaceSetting::on_FaceIdLinkEnable_clicked()
{
DataDictionary::GetInstance()->SetDevParamData(D_FACEID_CTL,1);
FaceIdLinkEnableButton(true);
}
void FaceSetting::on_FaceIdLinkUnable_clicked()
{
DataDictionary::GetInstance()->SetDevParamData(D_FACEID_CTL,0);
FaceIdLinkEnableButton(false);
}
void FaceSetting::FaceIdLinkEnableButton(bool s)
{
if(s)
{
ui->FaceIdLinkEnable->setChecked(true);
ui->FaceIdLinkUnable->setChecked(false);
}
else
{
ui->FaceIdLinkEnable->setChecked(false);
ui->FaceIdLinkUnable->setChecked(true);
}
}
void FaceSetting::on_FaceIdValue_returnPressed()
{
DataDictionary::GetInstance()->SetMisData(MIS_FACEID_CMP_VALUE,ui->FaceIdValue->text());
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。