#include "wexportprogramitem.h" #include #include 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; } bool wExportProgramItem::ExportPro(QString strDestPath,QString strSourceDir) { strSourceDir= strSourceDir+MACRO_FENGEFU+text(); strSourceDir.replace(MACRO_DANYINFANXIEGAN, MACRO_DANYINXIEGAN); strDestPath=strDestPath+MACRO_FENGEFU+text(); strDestPath.replace(MACRO_DANYINFANXIEGAN, MACRO_DANYINXIEGAN); int iAllSize=dirFileSize(strSourceDir); progress->setRange(0,iAllSize); progress->setValue(0); pThread->SetSourceDirAndDestDir(strSourceDir,strDestPath); QDir DirDest(strDestPath); if(DirDest.exists()) { X_UIMsgBoxOkCancel *dlg = new X_UIMsgBoxOkCancel(tr("Tip Info"),text()+tr(":solution(s) already exist.are you sure you want to overwrite the existing solution(s)?"), m_parent); if(dlg->exec() == QDialog::Accepted) { pThread->start(); } else { return false; } } else { pThread->start(); } return true; } void wExportProgramItem::OnProgressSet(float num) { progress->setValue(num); } void wExportProgramItem::OnCopyDirOver() { progress->setValue(100); } void wExportProgramItem::OnSendExportProgressValue(int iValue) { progress->setValue(iValue); }