359 |
359 |
360 case Close: |
360 case Close: |
361 return qobject_cast<QPushButton*> (form()->buttonBox->button (QDialogButtonBox::Close)); |
361 return qobject_cast<QPushButton*> (form()->buttonBox->button (QDialogButtonBox::Close)); |
362 } |
362 } |
363 |
363 |
364 return null; |
364 return nullptr; |
365 } |
365 } |
366 |
366 |
367 // ============================================================================= |
367 // ============================================================================= |
368 // |
368 // |
369 PartDownloadRequest::PartDownloadRequest (QString url, QString dest, bool primary, PartDownloader* parent) : |
369 PartDownloadRequest::PartDownloadRequest (QString url, QString dest, bool primary, PartDownloader* parent) : |
374 m_destinaton (dest), |
374 m_destinaton (dest), |
375 m_filePath (parent->getDownloadPath() + DIRSLASH + dest), |
375 m_filePath (parent->getDownloadPath() + DIRSLASH + dest), |
376 m_networkManager (new QNetworkAccessManager), |
376 m_networkManager (new QNetworkAccessManager), |
377 m_isFirstUpdate (true), |
377 m_isFirstUpdate (true), |
378 m_isPrimary (primary), |
378 m_isPrimary (primary), |
379 m_filePointer (null) |
379 m_filePointer (nullptr) |
380 { |
380 { |
381 // Make sure that we have a valid destination. |
381 // Make sure that we have a valid destination. |
382 QString dirpath = Dirname (filePath()); |
382 QString dirpath = Dirname (filePath()); |
383 |
383 |
384 QDir dir (dirpath); |
384 QDir dir (dirpath); |
493 } |
493 } |
494 |
494 |
495 // Try to load this file now. |
495 // Try to load this file now. |
496 LDDocument* f = OpenDocument (filePath(), false, not isPrimary()); |
496 LDDocument* f = OpenDocument (filePath(), false, not isPrimary()); |
497 |
497 |
498 if (f == null) |
498 if (f == nullptr) |
499 return; |
499 return; |
500 |
500 |
501 // Iterate through this file and check for errors. If there's any that stems |
501 // Iterate through this file and check for errors. If there's any that stems |
502 // from unknown file references, try resolve that by downloading the reference. |
502 // from unknown file references, try resolve that by downloading the reference. |
503 // This is why downloading a part may end up downloading multiple files, as |
503 // This is why downloading a part may end up downloading multiple files, as |
504 // it resolves dependencies. |
504 // it resolves dependencies. |
505 for (LDObject* obj : f->objects()) |
505 for (LDObject* obj : f->objects()) |
506 { |
506 { |
507 LDError* err = dynamic_cast<LDError*> (obj); |
507 LDError* err = dynamic_cast<LDError*> (obj); |
508 |
508 |
509 if (err == null or err->fileReferenced().isEmpty()) |
509 if (err == nullptr or err->fileReferenced().isEmpty()) |
510 continue; |
510 continue; |
511 |
511 |
512 QString dest = err->fileReferenced(); |
512 QString dest = err->fileReferenced(); |
513 prompt()->downloadFromPartsTracker (dest); |
513 prompt()->downloadFromPartsTracker (dest); |
514 } |
514 } |
546 void PartDownloadRequest::readyRead() |
546 void PartDownloadRequest::readyRead() |
547 { |
547 { |
548 if (state() == State::Failed) |
548 if (state() == State::Failed) |
549 return; |
549 return; |
550 |
550 |
551 if (filePointer() == null) |
551 if (filePointer() == nullptr) |
552 { |
552 { |
553 m_filePath.replace ("\\", "/"); |
553 m_filePath.replace ("\\", "/"); |
554 |
554 |
555 // We have already asked the user whether we can overwrite so we're good |
555 // We have already asked the user whether we can overwrite so we're good |
556 // to go here. |
556 // to go here. |