| 639 | |
| 640 | |
| 641 | bool UpdateApplication::createFile() |
| 642 | // ---------------------------------------------------------------------------- |
| 643 | // Create the update file |
| 644 | // ---------------------------------------------------------------------------- |
| 645 | { |
| 646 | Q_ASSERT(!file); |
| 647 | |
| 648 | // Keep the name of the remote file in the URL |
| 649 | QString fileName = QFileInfo(url.path()).fileName(); |
| 650 | |
| 651 | // Choose folder |
| 652 | #if QT_VERSION >= 0x050000 |
| 653 | // Thank you Qt5 for this insanity, just in case we have several ~/Desktop |
| 654 | QString desktop = ""; |
| 655 | QStringList desktops = QStandardPaths::standardLocations( |
| 656 | QStandardPaths::DesktopLocation); |
| 657 | if (desktops.size() >= 1) |
| 658 | desktop = desktops[0]; |
| 659 | #else |
| 660 | QString desktop = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation); |
| 661 | #endif |
| 662 | |
| 663 | QString folder = QFileDialog::getExistingDirectory(NULL, |
| 664 | tr("Select destination folder"), |
| 665 | desktop); |
| 666 | |
| 667 | if (!folder.isEmpty()) |
| 668 | { |
| 669 | // Set complete filename |
| 670 | QString completeFileName = folder + "/" + fileName; |
| 671 | |
| 672 | file = new QFile(completeFileName); |
| 673 | |
| 674 | if (file->exists()) |
| 675 | { |
| 676 | QString msg = tr("<h3>File exists</h3>"); |
| 677 | QString info = tr("<p>The selected folder already contains a file " |
| 678 | "called <b>%1</b>.</p>" |
| 679 | "<p>Save anyway?</p>").arg(fileName); |
| 680 | QMessageBox box(TaoApp->windowWidget()); |
| 681 | setBoxMinimumWidth(box, 400); |
| 682 | box.setIcon(QMessageBox::Warning); |
| 683 | box.setWindowTitle(dialogTitle); |
| 684 | box.setText(msg); |
| 685 | box.setInformativeText(info); |
| 686 | box.setStandardButtons(QMessageBox::Yes | QMessageBox::No); |
| 687 | box.setDefaultButton(QMessageBox::No); |
| 688 | |
| 689 | if (box.exec() == QMessageBox::No) |
| 690 | { |
| 691 | delete file; |
| 692 | file = NULL; |
| 693 | return false; |
| 694 | } |
| 695 | } |
| 696 | |
| 697 | if (!file->open(QIODevice::WriteOnly | QIODevice::Truncate)) |
| 698 | { |
nothing calls this directly
no test coverage detected