@@ -24,69 +24,89 @@ BatchJob::~BatchJob()
2424
2525bool BatchJob::addSubjob (ArchiveJob *job)
2626{
27+ qDebug () << " Adding subjob to BatchJob" ;
2728 if (nullptr == job || m_listSubjobs.contains (job)) {
29+ qWarning () << " Cannot add subjob - null job or already exists" ;
2830 return false ;
2931 }
3032
3133 job->setParent (this );
3234 m_listSubjobs.append (job);
35+ qDebug () << " Subjob added successfully, total subjobs:" << m_listSubjobs.count ();
3336 return true ;
3437}
3538
3639bool BatchJob::removeSubjob (ArchiveJob *job)
3740{
41+ qDebug () << " Removing subjob from BatchJob" ;
3842 if (m_listSubjobs.removeAll (job) > 0 ) {
3943 job->setParent (nullptr );
4044 delete job;
45+ qDebug () << " Subjob removed successfully, remaining subjobs:" << m_listSubjobs.count ();
4146 return true ;
4247 }
4348
49+ qWarning () << " Failed to remove subjob - not found" ;
4450 return false ;
4551}
4652
4753bool BatchJob::hasSubjobs () const
4854{
55+ qDebug () << " Checking if BatchJob has subjobs, count:" << m_listSubjobs.count ();
4956 return !m_listSubjobs.isEmpty ();
5057}
5158
5259const QList<ArchiveJob *> &BatchJob::subjobs () const
5360{
61+ // qDebug() << "Getting subjobs list, count:" << m_listSubjobs.count();
5462 return m_listSubjobs;
5563}
5664
5765void BatchJob::clearSubjobs ()
5866{
67+ qDebug () << " Clearing all subjobs, count:" << m_listSubjobs.count ();
5968 Q_FOREACH (ArchiveJob *job, m_listSubjobs) {
6069 job->setParent (nullptr );
6170 delete job;
6271 }
6372
6473 m_listSubjobs.clear ();
74+ qDebug () << " All subjobs cleared" ;
6575}
6676
6777void BatchJob::doPause ()
6878{
79+ qDebug () << " Pausing BatchJob" ;
6980 // 调用子job暂停接口
7081 if (m_pCurJob) {
82+ qDebug () << " Pausing current subjob" ;
7183 m_pCurJob->doPause ();
84+ } else {
85+ qWarning () << " No current subjob to pause" ;
7286 }
7387}
7488
7589void BatchJob::doContinue ()
7690{
91+ qDebug () << " Continuing BatchJob" ;
7792 // 调用子job继续接口
7893 if (m_pCurJob) {
94+ qDebug () << " Continuing current subjob" ;
7995 m_pCurJob->doContinue ();
96+ } else {
97+ qWarning () << " No current subjob to continue" ;
8098 }
8199}
82100
83101bool BatchJob::status ()
84102{
103+ qDebug () << " Getting BatchJob status" ;
85104 // 调用子job继续接口
86105 if (m_pCurJob) {
87106 return m_pCurJob->status ();
88107 }
89108
109+ qWarning () << " No current subjob to get status" ;
90110 return false ;
91111}
92112
@@ -99,7 +119,7 @@ BatchExtractJob::BatchExtractJob(QObject *parent)
99119
100120BatchExtractJob::~BatchExtractJob ()
101121{
102-
122+ // qDebug() << "BatchExtractJob instance destroyed";
103123}
104124
105125void BatchExtractJob::start ()
@@ -151,14 +171,17 @@ bool BatchExtractJob::setArchiveFiles(const QStringList &listFile)
151171
152172bool BatchExtractJob::addExtractItem (const QFileInfo &fileInfo)
153173{
174+ qDebug () << " Adding extract item for file:" << fileInfo.fileName ();
154175 QString strName = fileInfo.filePath ();
155176 UnCompressParameter::SplitType eType = UnCompressParameter::ST_No;
156177 UiTools::transSplitFileName (strName, eType);
157178 UiTools::AssignPluginType ePluginType = (UnCompressParameter::ST_Zip == eType) ?
158179 (UiTools::AssignPluginType::APT_Cli7z) : (UiTools::AssignPluginType::APT_Auto);
180+ qDebug () << " Creating interface for extract item" ;
159181 ReadOnlyArchiveInterface *pIface = UiTools::createInterface (fileInfo.filePath (), false , ePluginType);
160182
161183 if (pIface) {
184+ qDebug () << " Interface created successfully, setting up extraction options" ;
162185 // 创建解压参数
163186 ExtractionOptions stOptions;
164187 stOptions.strTargetPath = m_strExtractPath;
@@ -187,29 +210,34 @@ bool BatchExtractJob::addExtractItem(const QFileInfo &fileInfo)
187210 // tar.7z特殊处理,右键解压缩到当前文件夹使用cli7zplugin
188211 if (strName.endsWith (QLatin1String (" .tar.7z" ))
189212 && determineMimeType (strName).name () == QLatin1String (" application/x-7z-compressed" )) {
213+ qDebug () << " Detected tar.7z archive, using special handling" ;
190214 stOptions.bTar_7z = true ;
191215 ePluginType = UiTools::AssignPluginType::APT_Cli7z;
192216 }
193217
194218 pIface->setParent (this ); // 跟随BatchExtractJob释放
195219 if (!stOptions.bTar_7z ) {
220+ qDebug () << " Creating ExtractJob for regular archive" ;
196221 ExtractJob *pExtractJob = new ExtractJob (QList<FileEntry>(), pIface, stOptions);
197222 connect (pExtractJob, &ExtractJob::signalprogress, this , &BatchExtractJob::slotHandleSingleJobProgress);
198223 connect (pExtractJob, &ExtractJob::signalCurFileName, this , &BatchExtractJob::slotHandleSingleJobCurFileName);
199224 connect (pExtractJob, &ExtractJob::signalQuery, this , &BatchExtractJob::signalQuery);
200225 connect (pExtractJob, &ExtractJob::signalJobFinshed, this , &BatchExtractJob::slotHandleSingleJobFinished);
201226 addSubjob (pExtractJob);
202227 } else {
228+ qDebug () << " Creating StepExtractJob for tar.7z archive" ;
203229 StepExtractJob *pStepExtractJob = new StepExtractJob (fileInfo.absoluteFilePath (), stOptions);
204230 connect (pStepExtractJob, &StepExtractJob::signalprogress, this , &BatchExtractJob::slotHandleSingleJobProgress);
205231 connect (pStepExtractJob, &StepExtractJob::signalCurFileName, this , &BatchExtractJob::slotHandleSingleJobCurFileName);
206232 connect (pStepExtractJob, &StepExtractJob::signalQuery, this , &BatchExtractJob::signalQuery);
207233 connect (pStepExtractJob, &StepExtractJob::signalJobFinshed, this , &BatchExtractJob::slotHandleSingleJobFinished);
208234 addSubjob (pStepExtractJob);
209235 }
236+ qDebug () << " Extract item added successfully" ;
210237 return true ;
211238 }
212239
240+ qWarning () << " Failed to create interface for extract item" ;
213241 return false ;
214242}
215243
@@ -218,16 +246,19 @@ void BatchExtractJob::slotHandleSingleJobProgress(double dPercentage)
218246 QFileInfo fileInfo (m_listFiles[m_iCurArchiveIndex]);
219247 qint64 qCurSize = fileInfo.size (); // 当前解压的压缩包大小
220248 double dProgress = double (qCurSize) * dPercentage / m_qBatchTotalSize + m_dLastPercentage;
249+ qDebug () << " Batch job progress:" << dProgress << " %, current file:" << fileInfo.fileName ();
221250 emit signalprogress (dProgress);
222251}
223252
224253void BatchExtractJob::slotHandleSingleJobCurFileName (const QString &strName)
225254{
255+ qDebug () << " Current file being processed:" << strName;
226256 emit signalCurFileName (strName);
227257}
228258
229259void BatchExtractJob::slotHandleSingleJobFinished ()
230260{
261+ qDebug () << " Single job finished handler called" ;
231262 if (m_pCurJob != nullptr ) {
232263 qDebug () << " Single job finished - Type:" << m_pCurJob->m_eJobType
233264 << " Result:" << m_pCurJob->m_eFinishedType ;
@@ -245,6 +276,7 @@ void BatchExtractJob::slotHandleSingleJobFinished()
245276 }
246277
247278 // 移除当前job
279+ qDebug () << " Removing completed subjob" ;
248280 removeSubjob (m_pCurJob);
249281
250282 if (!hasSubjobs ()) {
@@ -263,5 +295,7 @@ void BatchExtractJob::slotHandleSingleJobFinished()
263295 m_pCurJob = subjobs ().at (0 );
264296 m_pCurJob->start ();
265297 }
298+ } else {
299+ qWarning () << " No current job to handle" ;
266300 }
267301}
0 commit comments