src/download.cpp

changeset 526
b29b6fc45ba9
parent 514
d78fea0f664c
child 538
2f85d4d286e5
equal deleted inserted replaced
525:4f6e46a3bfc3 526:b29b6fc45ba9
159 partRegex += "\\.dat$"; 159 partRegex += "\\.dat$";
160 subpartRegex += "\\.dat$"; 160 subpartRegex += "\\.dat$";
161 161
162 if (QRegExp (subpartRegex).exactMatch (dest)) 162 if (QRegExp (subpartRegex).exactMatch (dest))
163 dest.prepend ("parts/s/"); 163 dest.prepend ("parts/s/");
164
165 elif (QRegExp (partRegex).exactMatch (dest)) 164 elif (QRegExp (partRegex).exactMatch (dest))
166 dest.prepend ("parts/"); 165 dest.prepend ("parts/");
167 elif (dest.left (6) != "parts/" && dest.left (2) != "p/") 166 elif (dest.left (6) != "parts/" && dest.left (2) != "p/")
168 dest.prepend ("p/"); 167 dest.prepend ("p/");
169 } 168 }
170 169
171 // ============================================================================= 170 // =============================================================================
172 // ----------------------------------------------------------------------------- 171 // -----------------------------------------------------------------------------
173 PartDownloader::Source PartDownloader::getSource() const 172 PartDownloader::Source PartDownloader::getSource() const
286 { typedef QDialogButtonBox QDBB; 285 { typedef QDialogButtonBox QDBB;
287 alias btnbox = ui->buttonBox; 286 alias btnbox = ui->buttonBox;
288 287
289 switch (i) 288 switch (i)
290 { case Download: 289 { case Download:
291 return m_downloadButton; 290 { return m_downloadButton;
291 }
292 292
293 case Abort: 293 case Abort:
294 return qobject_cast<QPushButton*> (btnbox->button (QDBB::Abort)); 294 { return qobject_cast<QPushButton*> (btnbox->button (QDBB::Abort));
295 }
295 296
296 case Close: 297 case Close:
297 return qobject_cast<QPushButton*> (btnbox->button (QDBB::Close)); 298 { return qobject_cast<QPushButton*> (btnbox->button (QDBB::Close));
299 }
298 } 300 }
299 301
300 return null; 302 return null;
301 } 303 }
302 304
345 QProgressBar* prog; 347 QProgressBar* prog;
346 348
347 switch (m_state) 349 switch (m_state)
348 { case Requesting: 350 { case Requesting:
349 case Downloading: 351 case Downloading:
350 prog = qobject_cast<QProgressBar*> (table->cellWidget (tableRow(), progcol)); 352 { prog = qobject_cast<QProgressBar*> (table->cellWidget (tableRow(), progcol));
351 353
352 if (!prog) 354 if (!prog)
353 { prog = new QProgressBar; 355 { prog = new QProgressBar;
354 table->setCellWidget (tableRow(), progcol, prog); 356 table->setCellWidget (tableRow(), progcol, prog);
355 } 357 }
356 358
357 prog->setRange (0, m_bytesTotal); 359 prog->setRange (0, m_bytesTotal);
358 prog->setValue (m_bytesRead); 360 prog->setValue (m_bytesRead);
359 break; 361 } break;
360 362
361 case Finished: 363 case Finished:
362 case Failed: 364 case Failed:
363 { QLabel* lb = new QLabel ( (m_state == Finished) ? "<b><span style=\"color: #080\">FINISHED</span></b>" : 365 { QLabel* lb = new QLabel ((m_state == Finished) ? "<b><span style=\"color: #080\">FINISHED</span></b>" :
364 "<b><span style=\"color: #800\">FAILED</span></b>"); 366 "<b><span style=\"color: #800\">FAILED</span></b>");
365 lb->setAlignment (Qt::AlignCenter); 367 lb->setAlignment (Qt::AlignCenter);
366 table->setCellWidget (tableRow(), progcol, lb); 368 table->setCellWidget (tableRow(), progcol, lb);
367 } 369 } break;
368 break;
369 } 370 }
370 371
371 QLabel* lb = qobject_cast<QLabel*> (table->cellWidget (tableRow(), labelcol)); 372 QLabel* lb = qobject_cast<QLabel*> (table->cellWidget (tableRow(), labelcol));
372 373
373 if (m_firstUpdate) 374 if (m_firstUpdate)
389 { if (m_primary && !m_prompt->aborted()) 390 { if (m_primary && !m_prompt->aborted())
390 critical (m_reply->errorString()); 391 critical (m_reply->errorString());
391 392
392 m_state = Failed; 393 m_state = Failed;
393 } elif (state() != Failed) 394 } elif (state() != Failed)
394 395 m_state = Finished;
395 m_state = Finished;
396 396
397 m_bytesRead = m_bytesTotal; 397 m_bytesRead = m_bytesTotal;
398 updateToTable(); 398 updateToTable();
399 399
400 if (m_fp) 400 if (m_fp)

mercurial