diff --git a/softwareDirectory/AutoVerScheme/checkdevice.cpp b/softwareDirectory/AutoVerScheme/checkdevice.cpp index 5111c11..437b7ef 100644 --- a/softwareDirectory/AutoVerScheme/checkdevice.cpp +++ b/softwareDirectory/AutoVerScheme/checkdevice.cpp @@ -3,6 +3,7 @@ #include "basecommonapi.h" #include #include +#include "PageControl.h" CheckDevice::CheckDevice(QWidget *parent) : QWidget(parent), @@ -66,10 +67,6 @@ void CheckDevice::getStandardDevice() { bizDeviceList.clear(); - ui->tableWidget_4->clearContents(); - ui->tableWidget_4->setRowCount(0); - int rowCount=0; - int row=0; bizDeviceList = BaseCommonApi::getBizDeviceManage(); QString sFilterName = ui->lineEdit_10->text(); QString sFilterModel = ui->lineEdit_11->text(); @@ -89,7 +86,29 @@ bizDeviceList.removeAt(i); } } - for (const BizDevice& bizDevice : bizDeviceList) { + page=20; + pageIndex=-1; + PagedTableWidget *pagedTable = new PagedTableWidget(this, ui->HBoxPageLayout); + pagedTable->setData(bizDeviceList.count(), page); // 每页10行 + connect(pagedTable, SIGNAL(pageChanged(int)), this,SLOT(onpageChanged(int))); + this->onpageChanged(0); +} + +void CheckDevice::onpageChanged(int currPage) +{ + if(pageIndex==currPage) + return; + qDebug() << currPage; + pageIndex =currPage; + // 计算当前页的开始和结束索引 + int start = pageIndex * page; + int end = std::min(start + page, bizDeviceList.size()); + ui->tableWidget_4->clearContents(); + ui->tableWidget_4->setRowCount(0); + int rowCount=0; + int row=0; + for (int i=start;itableWidget_4->rowCount(); ui->tableWidget_4->insertRow(rowCount); //QCheckBox *checkBox = new QCheckBox; @@ -117,12 +136,13 @@ checkIds+=","+testedDeviceList[i].id; } }*/ + int start = pageIndex * page; for(int i=0;itableWidget_4->rowCount();i++){ if(ui->tableWidget_4->item(i,0)->checkState()==Qt::Checked){ if(bizIds=="") - bizIds = bizDeviceList[i].id; + bizIds = bizDeviceList[i+start].id; else - bizIds+=","+bizDeviceList[i].id; + bizIds+=","+bizDeviceList[i+start].id; } } /*if(checkIds==""){ diff --git a/softwareDirectory/AutoVerScheme/checkdevice.cpp b/softwareDirectory/AutoVerScheme/checkdevice.cpp index 5111c11..437b7ef 100644 --- a/softwareDirectory/AutoVerScheme/checkdevice.cpp +++ b/softwareDirectory/AutoVerScheme/checkdevice.cpp @@ -3,6 +3,7 @@ #include "basecommonapi.h" #include #include +#include "PageControl.h" CheckDevice::CheckDevice(QWidget *parent) : QWidget(parent), @@ -66,10 +67,6 @@ void CheckDevice::getStandardDevice() { bizDeviceList.clear(); - ui->tableWidget_4->clearContents(); - ui->tableWidget_4->setRowCount(0); - int rowCount=0; - int row=0; bizDeviceList = BaseCommonApi::getBizDeviceManage(); QString sFilterName = ui->lineEdit_10->text(); QString sFilterModel = ui->lineEdit_11->text(); @@ -89,7 +86,29 @@ bizDeviceList.removeAt(i); } } - for (const BizDevice& bizDevice : bizDeviceList) { + page=20; + pageIndex=-1; + PagedTableWidget *pagedTable = new PagedTableWidget(this, ui->HBoxPageLayout); + pagedTable->setData(bizDeviceList.count(), page); // 每页10行 + connect(pagedTable, SIGNAL(pageChanged(int)), this,SLOT(onpageChanged(int))); + this->onpageChanged(0); +} + +void CheckDevice::onpageChanged(int currPage) +{ + if(pageIndex==currPage) + return; + qDebug() << currPage; + pageIndex =currPage; + // 计算当前页的开始和结束索引 + int start = pageIndex * page; + int end = std::min(start + page, bizDeviceList.size()); + ui->tableWidget_4->clearContents(); + ui->tableWidget_4->setRowCount(0); + int rowCount=0; + int row=0; + for (int i=start;itableWidget_4->rowCount(); ui->tableWidget_4->insertRow(rowCount); //QCheckBox *checkBox = new QCheckBox; @@ -117,12 +136,13 @@ checkIds+=","+testedDeviceList[i].id; } }*/ + int start = pageIndex * page; for(int i=0;itableWidget_4->rowCount();i++){ if(ui->tableWidget_4->item(i,0)->checkState()==Qt::Checked){ if(bizIds=="") - bizIds = bizDeviceList[i].id; + bizIds = bizDeviceList[i+start].id; else - bizIds+=","+bizDeviceList[i].id; + bizIds+=","+bizDeviceList[i+start].id; } } /*if(checkIds==""){ diff --git a/softwareDirectory/AutoVerScheme/checkdevice.h b/softwareDirectory/AutoVerScheme/checkdevice.h index a305fc5..f8dddb3 100644 --- a/softwareDirectory/AutoVerScheme/checkdevice.h +++ b/softwareDirectory/AutoVerScheme/checkdevice.h @@ -27,6 +27,8 @@ void on_pushButton_17_clicked(); void on_pushButton_18_clicked(); + void onpageChanged(int currPage); + private: void getCheckDevice(); @@ -38,6 +40,9 @@ Ui::CheckDevice *ui; QList testedDeviceList; QList bizDeviceList; + int page; + int totalcount; + int pageIndex; }; #endif // CHECKDEVICE_H diff --git a/softwareDirectory/AutoVerScheme/checkdevice.cpp b/softwareDirectory/AutoVerScheme/checkdevice.cpp index 5111c11..437b7ef 100644 --- a/softwareDirectory/AutoVerScheme/checkdevice.cpp +++ b/softwareDirectory/AutoVerScheme/checkdevice.cpp @@ -3,6 +3,7 @@ #include "basecommonapi.h" #include #include +#include "PageControl.h" CheckDevice::CheckDevice(QWidget *parent) : QWidget(parent), @@ -66,10 +67,6 @@ void CheckDevice::getStandardDevice() { bizDeviceList.clear(); - ui->tableWidget_4->clearContents(); - ui->tableWidget_4->setRowCount(0); - int rowCount=0; - int row=0; bizDeviceList = BaseCommonApi::getBizDeviceManage(); QString sFilterName = ui->lineEdit_10->text(); QString sFilterModel = ui->lineEdit_11->text(); @@ -89,7 +86,29 @@ bizDeviceList.removeAt(i); } } - for (const BizDevice& bizDevice : bizDeviceList) { + page=20; + pageIndex=-1; + PagedTableWidget *pagedTable = new PagedTableWidget(this, ui->HBoxPageLayout); + pagedTable->setData(bizDeviceList.count(), page); // 每页10行 + connect(pagedTable, SIGNAL(pageChanged(int)), this,SLOT(onpageChanged(int))); + this->onpageChanged(0); +} + +void CheckDevice::onpageChanged(int currPage) +{ + if(pageIndex==currPage) + return; + qDebug() << currPage; + pageIndex =currPage; + // 计算当前页的开始和结束索引 + int start = pageIndex * page; + int end = std::min(start + page, bizDeviceList.size()); + ui->tableWidget_4->clearContents(); + ui->tableWidget_4->setRowCount(0); + int rowCount=0; + int row=0; + for (int i=start;itableWidget_4->rowCount(); ui->tableWidget_4->insertRow(rowCount); //QCheckBox *checkBox = new QCheckBox; @@ -117,12 +136,13 @@ checkIds+=","+testedDeviceList[i].id; } }*/ + int start = pageIndex * page; for(int i=0;itableWidget_4->rowCount();i++){ if(ui->tableWidget_4->item(i,0)->checkState()==Qt::Checked){ if(bizIds=="") - bizIds = bizDeviceList[i].id; + bizIds = bizDeviceList[i+start].id; else - bizIds+=","+bizDeviceList[i].id; + bizIds+=","+bizDeviceList[i+start].id; } } /*if(checkIds==""){ diff --git a/softwareDirectory/AutoVerScheme/checkdevice.h b/softwareDirectory/AutoVerScheme/checkdevice.h index a305fc5..f8dddb3 100644 --- a/softwareDirectory/AutoVerScheme/checkdevice.h +++ b/softwareDirectory/AutoVerScheme/checkdevice.h @@ -27,6 +27,8 @@ void on_pushButton_17_clicked(); void on_pushButton_18_clicked(); + void onpageChanged(int currPage); + private: void getCheckDevice(); @@ -38,6 +40,9 @@ Ui::CheckDevice *ui; QList testedDeviceList; QList bizDeviceList; + int page; + int totalcount; + int pageIndex; }; #endif // CHECKDEVICE_H diff --git a/softwareDirectory/AutoVerScheme/checkdevice.ui b/softwareDirectory/AutoVerScheme/checkdevice.ui index e790ff2..5127c0b 100644 --- a/softwareDirectory/AutoVerScheme/checkdevice.ui +++ b/softwareDirectory/AutoVerScheme/checkdevice.ui @@ -273,6 +273,31 @@ + + + + + + + + + + + + Qt::Horizontal + + + + 900 + 20 + + + + + + + +