-corrected bug
- added warning when selecting a file which is already in download queue
This commit is contained in:
+33
-19
@@ -524,25 +524,12 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadD
|
||||
cout << "no directory selectioned, ignoring download request";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (QFile::exists(this->downloading.savePath + "/" + path))
|
||||
}else
|
||||
{
|
||||
reply = QMessageBox::question(
|
||||
this,
|
||||
"RsyncUI",
|
||||
tr("File is already downloaded. Do you want to reload it ? The old file will be deleted"),
|
||||
QMessageBox::Yes|QMessageBox::No,
|
||||
QMessageBox::No);
|
||||
|
||||
if (reply == QMessageBox::No)
|
||||
{
|
||||
return;
|
||||
}else
|
||||
{
|
||||
QFile::remove(this->downloading.savePath + "/" + path);
|
||||
}
|
||||
this->downloading.savePath = this->settings.value(str).toString();
|
||||
}
|
||||
|
||||
|
||||
while(itemR->parent() != NULL)
|
||||
{
|
||||
itemR = itemR->parent();
|
||||
@@ -553,6 +540,25 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadD
|
||||
if (item->text(1) == tr("File") or downloadDir == true)
|
||||
{
|
||||
// Item is a file
|
||||
// searching if file exists in savepath
|
||||
if (QFile::exists(this->downloading.savePath + "/" + path))
|
||||
{
|
||||
reply = QMessageBox::question(
|
||||
this,
|
||||
"RsyncUI",
|
||||
tr("File is already downloaded. Do you want to reload it ? The old file will be deleted"),
|
||||
QMessageBox::Yes|QMessageBox::No,
|
||||
QMessageBox::No);
|
||||
|
||||
if (reply == QMessageBox::No)
|
||||
{
|
||||
return;
|
||||
}else
|
||||
{
|
||||
QFile::remove(this->downloading.savePath + "/" + path);
|
||||
}
|
||||
}
|
||||
|
||||
if(ui->listDownload->findItems(path, Qt::MatchStartsWith).empty())
|
||||
{
|
||||
// is there a downloading process ?
|
||||
@@ -570,6 +576,13 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadD
|
||||
// Adding download in download list
|
||||
str = path + " => " + this->connexion.server + "/" + this->connexion.service;
|
||||
ui->listDownload->addItem(str);
|
||||
}else
|
||||
{
|
||||
QMessageBox::warning(
|
||||
this,
|
||||
"RsyncUI",
|
||||
tr("File is already downloading" )
|
||||
);
|
||||
}
|
||||
}else
|
||||
{
|
||||
@@ -628,7 +641,7 @@ void MainWindow::downloadFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
disconnect(this->downloading.process, 0, 0, 0);
|
||||
|
||||
// reset variables and window
|
||||
this->downloading.process= nullptr;
|
||||
this->downloading.process = nullptr;
|
||||
ui->progressBar->hide();
|
||||
delete ui->listDownload->takeItem(0);
|
||||
this->downloading.clear();
|
||||
@@ -653,7 +666,7 @@ void MainWindow::downloadFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
path.resize(pos);
|
||||
this->downloading.path = path;
|
||||
|
||||
// save path exists in settings ?
|
||||
// savepath exists in settings ?
|
||||
str = "Folder/" + this->downloading.server + "/" + this->downloading.service;
|
||||
if (this->settings.contains(str))
|
||||
{
|
||||
@@ -671,6 +684,7 @@ void MainWindow::downloadFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
}
|
||||
}
|
||||
}
|
||||
saveDownloadList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user