qt/LedOK/wProgramManager/wexportprogramitem.cpp

65 lines
2.5 KiB
C++
Raw Normal View History

2022-01-04 18:11:48 +08:00
#include "wexportprogramitem.h"
2022-08-25 18:37:24 +08:00
#include <cfg.h>
#include "globaldefine.h"
#include <QMessageBox>
2022-01-04 18:11:48 +08:00
wExportProgramItem::wExportProgramItem(QTableWidget *parent,QString strProgramName,int iIndex):
QObject(parent),
QTableWidgetItem(UserType)
{
/*上面用到的两个枚举中:~Qt::ItemIsEnabled可以保证单击该Item时不会被选中但是在启用Ctrl + A时全选操作会导致Item被选中。
* ~Qt::ItemIsSelectable的使用可以保证全选状态下也不会被选中使线*/
m_parent=parent;
m_iIndex=iIndex;
setFlags(flags() & ~Qt::ItemIsEnabled & ~Qt::ItemIsSelectable);
progress= new QProgressBar(parent);
progress->setValue(0);
setData(0,strProgramName);
parent->setCellWidget(iIndex, 1, progress);
//ThreadExportProgramPro *pThread = new ThreadExportProgramPro(strSourceDir,strDestPath);
//connect(pItem)
pThread = new ThreadExportProgramPro();
// connect(pThread,SIGNAL(sigCopyDirStation(float)),this,SLOT(OnProgressSet(float)));
// connect(pThread,SIGNAL(sigCopyDirOver()),this,SLOT(OnCopyDirOver()));
connect(pThread,SIGNAL(sigSendExportProgressValue(int)),this,SLOT(OnSendExportProgressValue(int)));
}
wExportProgramItem::~wExportProgramItem()
{
if(pThread!=nullptr)
delete pThread;
m_parent->removeCellWidget(m_iIndex,1);
// delete progress;
}
2022-08-25 18:37:24 +08:00
extern QWidget *gMainWin;
2022-01-04 18:11:48 +08:00
bool wExportProgramItem::ExportPro(QString strDestPath,QString strSourceDir)
{
strSourceDir= strSourceDir+MACRO_FENGEFU+text();
strDestPath=strDestPath+MACRO_FENGEFU+text();
int iAllSize=dirFileSize(strSourceDir);
progress->setRange(0,iAllSize);
progress->setValue(0);
pThread->SetSourceDirAndDestDir(strSourceDir,strDestPath);
QDir DirDest(strDestPath);
2022-08-25 18:37:24 +08:00
if(DirDest.exists()) {
auto res = QMessageBox::information(gMainWin, tr("Tip Info"), text()+tr(":solution(s) already exist.are you sure you want to overwrite the existing solution(s)?"), QMessageBox::Ok, QMessageBox::Cancel);
if(res == QMessageBox::Ok) pThread->start();
else return false;
2022-01-04 18:11:48 +08:00
}
2022-08-25 18:37:24 +08:00
else pThread->start();
2022-01-04 18:11:48 +08:00
return true;
}
void wExportProgramItem::OnProgressSet(float num)
{
progress->setValue(num);
}
void wExportProgramItem::OnCopyDirOver()
{
progress->setValue(100);
}
void wExportProgramItem::OnSendExportProgressValue(int iValue)
{
progress->setValue(iValue);
}