added date in qtreeview\nadded retry in case of download error
This commit is contained in:
+42
-23
@@ -70,11 +70,13 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
connect(config.comboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &MainWindow::on_comboBox_currentIndexChanged);
|
||||
connect(loginD.loginBox, SIGNAL(accepted()), this, SLOT(on_loginBox_accepted()));
|
||||
|
||||
loadSettings();
|
||||
|
||||
// init of widgets
|
||||
ui->ktreewidgetsearchline->setTreeWidget(ui->treeWidget); // attach search widget to treewidget
|
||||
ui->ktreewidgetsearchline->setCaseSensitivity(Qt::CaseInsensitive); // and set it case insensitive
|
||||
ui->treeWidget->setHeaderLabels({tr("Path"), tr("Type"), tr("Size"), "fullSize"} ); // set header of columns of tree widget
|
||||
|
||||
ui->treeWidget->setHeaderLabels({tr("Path"), tr("Type"), tr("Size"), tr("Date"), "fullSize"} ); // set header of columns of tree widget
|
||||
//ui->treeWidget->header()->setContextMenuPolicy();
|
||||
// setting arrowcursor for treeWidget, listWidget and listDownload to arrow
|
||||
ui->treeWidget->setCursor(Qt::ArrowCursor);
|
||||
ui->listWidget->setCursor(Qt::ArrowCursor);
|
||||
@@ -83,7 +85,6 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
// Hiding progress bar
|
||||
ui->progressBar->hide();
|
||||
|
||||
loadSettings();
|
||||
|
||||
// if last server exists in settings
|
||||
if (this->settings.contains("connexion/lastServer"))
|
||||
@@ -104,7 +105,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
config.UnitCombobox->addItems({tr("KB/s"), tr("MB/s"), tr("GB/s"), tr("TB/s"), tr("PB/s")});
|
||||
|
||||
// hide fullsize column of treeview
|
||||
ui->treeWidget->setColumnHidden(3, true);
|
||||
ui->treeWidget->setColumnHidden(4, true);
|
||||
|
||||
initSystemTrayIcon();
|
||||
}
|
||||
@@ -377,7 +378,7 @@ void MainWindow::listServices()
|
||||
bool flag = false;
|
||||
|
||||
cmd = "/usr/bin/rsync";
|
||||
param << "--contimeout=10" << "--port=" + QString::number(this->connexion.port) << this->connexion.server + "::";
|
||||
param << "--contimeout=20" << "--port=" + QString::number(this->connexion.port) << this->connexion.server + "::";
|
||||
myProcess = new QProcess(this);
|
||||
myProcess->start(cmd, param);
|
||||
|
||||
@@ -422,6 +423,7 @@ bool MainWindow::scanDir(QString server, int portN, QTreeWidgetItem *parent, QSt
|
||||
QString fullsize;
|
||||
QString filename;
|
||||
QString fileType;
|
||||
QString date;
|
||||
QProcess * myProcess;
|
||||
bool isDir = false;
|
||||
bool flag = false;
|
||||
@@ -448,7 +450,7 @@ bool MainWindow::scanDir(QString server, int portN, QTreeWidgetItem *parent, QSt
|
||||
}
|
||||
myProcess->setProcessEnvironment(env);
|
||||
cmd = "rsync";
|
||||
param << "--contimeout=10" << "--port=" + QString::number(portN) << server + "::" + path;
|
||||
param << "--contimeout=20" << "--port=" + QString::number(portN) << server + "::" + path;
|
||||
|
||||
|
||||
myProcess->start(cmd, param);
|
||||
@@ -493,9 +495,9 @@ bool MainWindow::scanDir(QString server, int portN, QTreeWidgetItem *parent, QSt
|
||||
{
|
||||
isDir = false;
|
||||
}
|
||||
|
||||
date = line.section(' ', 2, 2);
|
||||
fileType = getFileType(filename);
|
||||
addTreeItem(filename, size, fullsize, fileType, isDir, parent);
|
||||
addTreeItem(filename, size, fullsize, fileType, date, isDir, parent);
|
||||
}
|
||||
}
|
||||
flag = false;
|
||||
@@ -615,7 +617,7 @@ void MainWindow::on_connectButton_clicked()
|
||||
}
|
||||
|
||||
// add parent in treeview
|
||||
void MainWindow::addTreeItem(QString name, QString fileSize, QString fullsize, QString type, bool isDir=false, QTreeWidgetItem *parent=nullptr)
|
||||
void MainWindow::addTreeItem(QString name, QString fileSize, QString fullsize, QString type, QString date, bool isDir=false, QTreeWidgetItem *parent=nullptr)
|
||||
{
|
||||
QTreeWidgetItem *treeItem;
|
||||
if (parent != nullptr)
|
||||
@@ -637,7 +639,9 @@ void MainWindow::addTreeItem(QString name, QString fileSize, QString fullsize, Q
|
||||
}
|
||||
treeItem->setText(0, name);
|
||||
treeItem->setText(2, fileSize);
|
||||
treeItem->setText(3, fullsize);
|
||||
treeItem->setText(3, date);
|
||||
treeItem->setText(4, fullsize);
|
||||
|
||||
treeItem->setTextAlignment(2, Qt::AlignRight);
|
||||
|
||||
if (parent != nullptr)
|
||||
@@ -728,7 +732,7 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadD
|
||||
|
||||
// assembling path from treewidget
|
||||
path = item->text(0);
|
||||
sizeFromRsync = item->text(3).toUInt();
|
||||
sizeFromRsync = item->text(4).toUInt();
|
||||
|
||||
while(itemR->parent() != NULL)
|
||||
{
|
||||
@@ -738,7 +742,7 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadD
|
||||
};
|
||||
|
||||
cout << item->text(1).toStdString() <<endl;
|
||||
if (item->text(1) == tr("File") or downloadDir == true)
|
||||
if (item->text(1) != tr("Dir") or downloadDir == true)
|
||||
{
|
||||
// exists saving path in settings ?
|
||||
str = "Folder/" + this->connexion.server + "/" + this->connexion.service;
|
||||
@@ -861,6 +865,8 @@ void MainWindow::downloadFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
QString str;
|
||||
int pos;
|
||||
QString aborted = tr("finished");
|
||||
QMessageBox::StandardButton reply;
|
||||
bool retry = false;
|
||||
|
||||
// test if process crashed
|
||||
if (exitStatus == QProcess::CrashExit)
|
||||
@@ -871,19 +877,28 @@ void MainWindow::downloadFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
tr("Rsync process crashed"));
|
||||
}
|
||||
//test result code of command (if 20 then command stopped by user)
|
||||
if (exitCode != 0 and exitCode != 20)
|
||||
if (exitCode != 0)
|
||||
{
|
||||
if (exitCode == 20)
|
||||
{
|
||||
aborted = tr("stopped by user");
|
||||
}else if (exitCode == 5) // password asked
|
||||
{
|
||||
loginDialog.show();
|
||||
retry = true;
|
||||
}
|
||||
|
||||
// displaying warning with exit code
|
||||
QMessageBox::warning(
|
||||
NULL,
|
||||
reply = QMessageBox::warning(
|
||||
this,
|
||||
"RsyncUI",
|
||||
rsyncErrorStrings[exitCode]);
|
||||
}else if (exitCode == 20)
|
||||
{
|
||||
aborted = tr("stopped by user");
|
||||
}else if (exitCode == 5) // password asked
|
||||
{
|
||||
loginDialog.show();
|
||||
rsyncErrorStrings[exitCode] + tr("\nDo you want to retry?"),
|
||||
QMessageBox::Yes|QMessageBox::No,
|
||||
QMessageBox::Yes);
|
||||
if (reply == QMessageBox::Yes)
|
||||
{
|
||||
retry = true;
|
||||
}
|
||||
}
|
||||
|
||||
this->trayIcon->showMessage("RsyncUI", tr("Download ") + aborted + "\n" + this->downloading.path, QSystemTrayIcon::Information);
|
||||
@@ -894,7 +909,11 @@ void MainWindow::downloadFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||
// reset variables and window
|
||||
this->downloading.process->close();
|
||||
ui->progressBar->hide();
|
||||
delete ui->listDownload->takeItem(0);
|
||||
|
||||
if (retry == false)
|
||||
{
|
||||
delete ui->listDownload->takeItem(0);
|
||||
}
|
||||
this->downloading.clear();
|
||||
|
||||
// Some downloads staying in queue
|
||||
|
||||
Reference in New Issue
Block a user