代码拉取完成,页面将自动刷新
#include "bblistscreen.h"
#include "ui_bblistscreen.h"
BBListScreen::BBListScreen(QWidget *parent) :
QWidget(parent),
ui(new Ui::BBListScreen)
{
ui->setupUi(this);
this->hide();
QStringList headerLabels = QStringList()<<QObject::tr("发现时间")
<<QObject::tr("设备号")
<<QObject::tr("对方回转值");
//ui->ListWidget->setRowCount(15);
ui->ListWidget->setColumnCount(3);
ui->ListWidget->setColumnWidth(0,350);
ui->ListWidget->setColumnWidth(1,250);
ui->ListWidget->setColumnWidth(2,200);
ui->ListWidget->setShowGrid(false);
//ui->ListWidget->setColumnWidth(4,115);
ui->ListWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->ListWidget->setHorizontalHeaderLabels(headerLabels);
ui->ListWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui->ListWidget->setFrameShape(QFrame::NoFrame);
ui->ListWidget->setRowHeight(0, 40);
ui->ListWidget->setShowGrid(true);
ui->ListWidget->verticalHeader()->setHidden(true);
ui->ListWidget->verticalScrollBar();
ui->ListWidget->horizontalHeader()->setFont(QFont("song", 24));
ui->ListWidget->setStyleSheet("QTableWidget::item{border:1px solid ;\
border-bottom-color:rgb(255,255,255);\
color:rgb(255,255,255)}");
QFont font = ui->ListWidget->horizontalHeader()->font();
font.setBold(true);
ui->ListWidget->horizontalHeader()->setFont(font);
ui->ListWidget->horizontalHeader()->setStyleSheet("QHeaderView::section{background:rgb(85, 87, 83);}");
CleanListItem();
m_SearchTimer = new QTimer;
m_SearchTimer->setInterval(3000);
m_DataDictionary = DataDictionary::GetInstance();
connect(m_DataDictionary,SIGNAL(MisDataChange(MisDataIndex_t)),\
this,SLOT(MisDataChange(MisDataIndex_t)));
connect(m_SearchTimer,SIGNAL(timeout()),\
this,SLOT(SearchTimeout()));
}
BBListScreen::~BBListScreen()
{
delete ui;
}
void BBListScreen::showEvent(QShowEvent *event)
{
on_SearchButton_clicked();
}
void BBListScreen::CleanListItem()
{
for(int i = 0 ;i < ui->ListWidget->rowCount() ;i++)
{
ui->ListWidget->removeRow(i);
}
}
void BBListScreen::on_QuiteButton_clicked()
{
this->hide();
}
void BBListScreen::MisDataChange(MisDataIndex_t Index)
{
switch (Index) {
case MIS_BLKBOX_SEARCH_TOWER_RES:
{
QList<struct SearchData> List;
m_DataDictionary->GetMisData(Index,List);
if(List.count() != 0){
AddListItem(List);
ui->Info->setText("");
}else{
ui->Info->setText("未搜索到设备");
}
m_SearchTimer->stop();
}
break;
default:
break;
}
}
void BBListScreen::SearchTimeout()
{
m_SearchTimer->stop();
ui->Info->setText("搜索超时");
}
void BBListScreen::AddListItem(QList<struct SearchData> &list)
{
for (int i = 0;i < list.size();i++) {
struct SearchData Info = list.at(i);
QString Time = QDateTime::fromSecsSinceEpoch(Info.Time).toString("yyyy-MM-dd hh:mm:ss");
AddListItem(Time,\
QString().number(Info.DevId),\
QString().number(Info.CurAng));
}
}
void BBListScreen::AddListItem(QString Time,QString Id,QString Ang)
{
//QString Time = QDateTime::fromMSecsSinceEpoch(Date.toLongLong()).toString("yyyy-MM-dd hh:mm:ss");
int32_t CurRow = ui->ListWidget->rowCount();
ui->ListWidget->setRowCount(CurRow + 1);
QTableWidgetItem* item0 = new QTableWidgetItem(Time);
item0->setFlags(Qt::NoItemFlags);
item0->setFont(QFont("song", 20));
QFont font = item0->font();
font.setBold(true);
item0->setFont(font);
QTableWidgetItem* item1 = new QTableWidgetItem(Id,5);
item1->setFlags(Qt::NoItemFlags);
item1->setFont(QFont("song", 20));
font = item1->font();
font.setBold(true);
item1->setFont(font);
QTableWidgetItem* item2 = new QTableWidgetItem(Ang,5);
item2->setFlags(Qt::NoItemFlags);
item2->setFont(QFont("song", 20));
font = item2->font();
font.setBold(true);
item2->setFont(font);
ui->ListWidget->setItem(CurRow, 0, item0);
ui->ListWidget->setItem(CurRow, 1, item1);
ui->ListWidget->setItem(CurRow, 2, item2);
ui->ListWidget->setRowHeight(CurRow,50);
ui->ListWidget->item(CurRow, 0)->setTextAlignment(Qt::AlignCenter);
}
void BBListScreen::ClearAllListItem()
{
//QString Time = QDateTime::fromMSecsSinceEpoch(Date.toLongLong()).toString("yyyy-MM-dd hh:mm:ss");
while(ui->ListWidget->rowCount())
{
QTableWidgetItem* item0 = ui->ListWidget->itemAt(0,0);
delete item0;
QTableWidgetItem* item1 = ui->ListWidget->itemAt(0,1);
delete item1;
QTableWidgetItem* item2 = ui->ListWidget->itemAt(0,2);
delete item2;
ui->ListWidget->removeRow(0);
}
}
void BBListScreen::on_SearchButton_clicked()
{
ui->Info->setText("搜索中 ... ...");
ClearAllListItem();
m_SearchTimer->start();
m_DataDictionary->SetMisData(MIS_BLKBOX_SEARCH_TOWER,1);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。