added date in qtreeview\nadded retry in case of download error

This commit is contained in:
Daniel Tartavel 2023-03-05 13:38:28 +01:00
parent 711ca7d1cd
commit 9d305b0b3b
6 changed files with 143 additions and 86 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.14.2, 2023-03-04T10:53:02. --> <!-- Written by QtCreator 4.14.2, 2023-03-05T10:17:18. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>

View File

@ -149,96 +149,99 @@
<translation>Cliquez pour ajouter à la file de téléchargement</translation> <translation>Cliquez pour ajouter à la file de téléchargement</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="338"/> <location filename="mainwindow.ui" line="329"/>
<source>Filter...</source>
<translation>Filtrer...</translation>
</message>
<message>
<location filename="mainwindow.ui" line="341"/>
<source>Click on file to stop downloading</source> <source>Click on file to stop downloading</source>
<translation>Cliquez sur le document pour arrêter le téléchargement et l&apos;enlever de la file</translation> <translation>Cliquez sur le document pour arrêter le téléchargement et l&apos;enlever de la file</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="364"/> <location filename="mainwindow.ui" line="367"/>
<source>%p%</source> <source>%p%</source>
<extracomment>Downloading</extracomment> <extracomment>Downloading</extracomment>
<translation>Téléchargement</translation> <translation>Téléchargement</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="375"/> <location filename="mainwindow.ui" line="378"/>
<source>toolBar</source> <source>toolBar</source>
<translation>Barre d&apos;outils</translation> <translation>Barre d&apos;outils</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="449"/> <location filename="mainwindow.ui" line="452"/>
<source>Download</source> <source>Download</source>
<translation>Télécharger</translation> <translation>Télécharger</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="452"/> <location filename="mainwindow.ui" line="455"/>
<source>Click on menu button to download the entire folder</source> <source>Click on menu button to download the entire folder</source>
<translation>Cliquer sur le bouton droit de la souris pour télécharger le dossier entier</translation> <translation>Cliquer sur le bouton droit de la souris pour télécharger le dossier entier</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="461"/> <location filename="mainwindow.ui" line="464"/>
<source>Exit</source> <source>Exit</source>
<translation>Quitter</translation> <translation>Quitter</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="464"/> <location filename="mainwindow.ui" line="467"/>
<source>Terminate the program</source> <source>Terminate the program</source>
<translation>Terminer le programme</translation> <translation>Terminer le programme</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="467"/> <location filename="mainwindow.ui" line="470"/>
<source>Ctrl+Q</source> <source>Ctrl+Q</source>
<translation>Ctrl+Q</translation> <translation>Ctrl+Q</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="475"/> <location filename="mainwindow.ui" line="479"/>
<source>hidden service</source> <source>hidden service</source>
<translation>entre <translation>Service caché</translation>
Service caché</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="414"/>
<location filename="mainwindow.ui" line="417"/> <location filename="mainwindow.ui" line="417"/>
<location filename="mainwindow.ui" line="420"/>
<source>Change save folder</source> <source>Change save folder</source>
<translation>Changer le dossier de destination</translation> <translation>Changer le dossier de destination</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="426"/> <location filename="mainwindow.ui" line="429"/>
<source>About</source> <source>About</source>
<translation>À propos</translation> <translation>À propos</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="435"/> <location filename="mainwindow.ui" line="438"/>
<source>About Qt</source> <source>About Qt</source>
<translation>À propos de Qt</translation> <translation>À propos de Qt</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="444"/> <location filename="mainwindow.ui" line="447"/>
<source>Settings</source> <source>Settings</source>
<translation>Paramètres</translation> <translation>Paramètres</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="107"/> <location filename="mainwindow.h" line="123"/>
<source>KB</source> <source>KB</source>
<translation>Ko</translation> <translation>Ko</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="107"/> <location filename="mainwindow.h" line="124"/>
<source>MB</source> <source>MB</source>
<translation>Mo</translation> <translation>Mo</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="107"/> <location filename="mainwindow.h" line="125"/>
<source>GB</source> <source>GB</source>
<translation>Go</translation> <translation>Go</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="107"/> <location filename="mainwindow.h" line="126"/>
<source>TB</source> <source>TB</source>
<translation>To</translation> <translation>To</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="107"/> <location filename="mainwindow.h" line="127"/>
<source>PB</source> <source>PB</source>
<translation>Po</translation> <translation>Po</translation>
</message> </message>
@ -275,10 +278,6 @@ Cliquez sur un fichier pour le supprimer de la file et une fenêtre de confirmat
&lt;b&gt;5ème icône: Quitter&lt;/b&gt;&lt;br&gt; &lt;b&gt;5ème icône: Quitter&lt;/b&gt;&lt;br&gt;
Permet de quitter le programme</translation> Permet de quitter le programme</translation>
</message> </message>
<message>
<source>&lt;h2&gt;Client for rsync server&lt;2&gt;&lt;br&gt;&lt;br&gt;</source>
<translation type="vanished">&lt;h2&gt;Client pour serveur rsync&lt;2&gt;&lt;br&gt;&lt;br&gt;éaa</translation>
</message>
<message> <message>
<location filename="mainwindow.cpp" line="78"/> <location filename="mainwindow.cpp" line="78"/>
<source>Path</source> <source>Path</source>
@ -295,106 +294,140 @@ Cliquez sur un fichier pour le supprimer de la file et une fenêtre de confirmat
<translation>Type</translation> <translation>Type</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="122"/> <location filename="mainwindow.cpp" line="78"/>
<source>Date</source>
<translation>Date</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="105"/>
<source>KB/s</source>
<translation>Ko/s</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="105"/>
<source>MB/s</source>
<translation>Mo/s</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="105"/>
<source>GB/s</source>
<translation>Go/s</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="105"/>
<source>TB/s</source>
<translation>To/s</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="105"/>
<source>PB/s</source>
<translation>Po/s</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="123"/>
<source>A list of interrupted downloads exists, do you want to continue downloading ? if not the list will be cleared</source> <source>A list of interrupted downloads exists, do you want to continue downloading ? if not the list will be cleared</source>
<translation>Une liste de téléchargement existe, voulez-vous utiliser cette liste ? si non, elle sera effacée</translation> <translation>Une liste de téléchargement existe, voulez-vous utiliser cette liste ? si non, elle sera effacée</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="151"/> <location filename="mainwindow.cpp" line="152"/>
<source>&amp;Quit</source> <source>&amp;Quit</source>
<translation>&amp;Quitter</translation> <translation>&amp;Quitter</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="208"/> <location filename="mainwindow.cpp" line="209"/>
<source>Clicking Save button, You can save the list of downloads <source>Clicking Save button, You can save the list of downloads
</source> </source>
<translation>Vous pouvez enregistrer la liste des téléchargements en cliquant sur &quot;enregister&quot; <translation>Vous pouvez enregistrer la liste des téléchargements en cliquant sur &quot;enregister&quot;
</translation> </translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="214"/> <location filename="mainwindow.cpp" line="215"/>
<source>Exiting will stop downloading, and will clear the download queue. <source>Exiting will stop downloading, and will clear the download queue.
Do you want to exit ?</source> Do you want to exit ?</source>
<translation>Si vous sortez, les téléchargements seront arrêter. <translation>Si vous sortez, les téléchargements seront arrêter.
Voulez-vous vraiment sortir ?</translation> Voulez-vous vraiment sortir ?</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="252"/> <location filename="mainwindow.cpp" line="253"/>
<source>The program will keep running in the system tray. To terminate the program, choose &lt;b&gt;Quit&lt;/b&gt; in the context menu of the system tray entry.</source> <source>The program will keep running in the system tray. To terminate the program, choose &lt;b&gt;Quit&lt;/b&gt; in the context menu of the system tray entry.</source>
<translation>Le programme continue dans la boîte à miniatures. Pour quitter le programme cliquez sur l&apos;icône &lt;b&gt;Quitter&lt;/b&gt; ou dans les menu contextuel.</translation> <translation>Le programme continue dans la boîte à miniatures. Pour quitter le programme cliquez sur l&apos;icône &lt;b&gt;Quitter&lt;/b&gt; ou dans les menu contextuel.</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="501"/> <location filename="mainwindow.cpp" line="513"/>
<source>The processus does&apos;nt respond: </source> <source>The processus does&apos;nt respond: </source>
<translation>Le processus ne répond pas: </translation> <translation>Le processus ne répond pas: </translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="587"/> <location filename="mainwindow.cpp" line="599"/>
<source>server does not exists</source> <source>server does not exists</source>
<translation>Le serveur n&apos;existe pas</translation> <translation>Le serveur n&apos;existe pas</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="615"/> <location filename="mainwindow.cpp" line="633"/>
<location filename="mainwindow.cpp" line="637"/> <location filename="mainwindow.cpp" line="745"/>
<source>Dir</source> <source>Dir</source>
<translation>dossier</translation> <translation>dossier</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="620"/>
<location filename="mainwindow.cpp" line="642"/>
<location filename="mainwindow.cpp" line="743"/>
<source>File</source> <source>File</source>
<translation>Doc</translation> <translation type="vanished">Doc</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="771"/> <location filename="mainwindow.cpp" line="773"/>
<source>File is partially downloaded. Do you want to resume download ? if no, the file will be deleted from destination directory</source> <source>File is partially downloaded. Do you want to resume download ? if no, the file will be deleted from destination directory</source>
<translation>Le document est déjà partiellement téléchargé. Voulez vous continuer le téléchargemnt ? Si non, il sera supprimer du dossier de destination</translation> <translation>Le document est déjà partiellement téléchargé. Voulez vous continuer le téléchargemnt ? Si non, il sera supprimer du dossier de destination</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="788"/> <location filename="mainwindow.cpp" line="790"/>
<source>File is already downloaded. Do you want to reload it ? The old file will be deleted</source> <source>File is already downloaded. Do you want to reload it ? The old file will be deleted</source>
<translation>Le document est déjà téléchargé. Voulez-vous le télécharger à nouveau ? L&apos;ancien fichier sera effacé</translation> <translation>Le document est déjà téléchargé. Voulez-vous le télécharger à nouveau ? L&apos;ancien fichier sera effacé</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="825"/> <location filename="mainwindow.cpp" line="827"/>
<source>File is already downloading</source> <source>File is already downloading</source>
<translation>Le document est déjà en téléchargement</translation> <translation>Le document est déjà en téléchargement</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="850"/> <location filename="mainwindow.cpp" line="852"/>
<source>Starting downloading <source>Starting downloading
</source> </source>
<translation>Démarrage du téléchargement <translation>Démarrage du téléchargement
</translation> </translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="865"/> <location filename="mainwindow.cpp" line="867"/>
<source>finished</source> <source>finished</source>
<translation>Terminé</translation> <translation>Terminé</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="873"/> <location filename="mainwindow.cpp" line="877"/>
<source>Rsync process crashed</source> <source>Rsync process crashed</source>
<translation>Le processus rsync à planté</translation> <translation>Le processus rsync à planté</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="885"/> <location filename="mainwindow.cpp" line="884"/>
<source>stopped by user</source> <source>stopped by user</source>
<translation>stoppé par l&apos;utilisateur</translation> <translation>stoppé par l&apos;utilisateur</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="891"/> <location filename="mainwindow.cpp" line="895"/>
<source>
Do you want to retry?</source>
<translation>
Voulez-vous -essayer?</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="904"/>
<source>Download </source> <source>Download </source>
<translation>Téléchargement </translation> <translation>Téléchargement </translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="1240"/> <location filename="mainwindow.cpp" line="1257"/>
<source>RsyncUI Request</source> <source>RsyncUI Request</source>
<translation>Requête RsyncUI</translation> <translation>Requête RsyncUI</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="1241"/> <location filename="mainwindow.cpp" line="1258"/>
<source>Hidden service name</source> <source>Hidden service name</source>
<translation>Nom du servcice caché</translation> <translation>Nom du servcice caché</translation>
</message> </message>
@ -429,52 +462,57 @@ Voulez-vous vraiment sortir ?</translation>
<translation>Code source</translation> <translation>Code source</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="1056"/> <location filename="mainwindow.cpp" line="1073"/>
<source>Since the save path is linked to service, you need to select a service before you can select a folder</source> <source>Since the save path is linked to service, you need to select a service before you can select a folder</source>
<translation>Vous devez sélectionnez un service pour pouvoir sélectionnez un dossier par défaut</translation> <translation>Vous devez sélectionnez un service pour pouvoir sélectionnez un dossier par défaut</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="1061"/> <location filename="mainwindow.cpp" line="1078"/>
<source>Choose folder where to save file</source> <source>Choose folder where to save file</source>
<translation>Choisissez un dossier enregistrer le document</translation> <translation>Choisissez un dossier enregistrer le document</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="952"/> <location filename="mainwindow.cpp" line="969"/>
<source>Do you want to stop downloading and delete this file from download queue ?</source> <source>Do you want to stop downloading and delete this file from download queue ?</source>
<translation>Voulez-vous arrêter le téléchargement et enlever ce fichier de la file de téléchargement ?</translation> <translation>Voulez-vous arrêter le téléchargement et enlever ce fichier de la file de téléchargement ?</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="966"/> <location filename="mainwindow.cpp" line="983"/>
<source>Do you want to delete this file from download queue ?</source> <source>Do you want to delete this file from download queue ?</source>
<translation>Voulez-vous enlever ce fichier de la file de téléchargement ?</translation> <translation>Voulez-vous enlever ce fichier de la file de téléchargement ?</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.h" line="137"/> <location filename="mainwindow.h" line="122"/>
<source>B</source>
<translation>o</translation>
</message>
<message>
<location filename="mainwindow.h" line="139"/>
<source>The process failed to start. Either the invoked program is missing, or you may have insufficient permissions or resources to invoke the program.</source> <source>The process failed to start. Either the invoked program is missing, or you may have insufficient permissions or resources to invoke the program.</source>
<translation>Le processus échoué, soit le programme est manquant, soit vous n&apos;avez pas l&apos;autorisation de l&apos;exécuter.</translation> <translation>Le processus échoué, soit le programme est manquant, soit vous n&apos;avez pas l&apos;autorisation de l&apos;exécuter.</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.h" line="138"/> <location filename="mainwindow.h" line="140"/>
<source>The process crashed some time after starting successfully.</source> <source>The process crashed some time after starting successfully.</source>
<translation>Le processus à planté après avoir démarré avec succès.</translation> <translation>Le processus à planté après avoir démarré avec succès.</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.h" line="139"/> <location filename="mainwindow.h" line="141"/>
<source>The last waitFor...() function timed out. The state of QProcess is unchanged, and you can try calling waitFor...() again.</source> <source>The last waitFor...() function timed out. The state of QProcess is unchanged, and you can try calling waitFor...() again.</source>
<translation>La fonction waitFor...() a dépassé la limite de temps, you pouvez essayer de la relancer.</translation> <translation>La fonction waitFor...() a dépassé la limite de temps, you pouvez essayer de la relancer.</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.h" line="140"/> <location filename="mainwindow.h" line="142"/>
<source>An error occurred when attempting to write to the process. For example, the process may not be running, or it may have closed its input channel.</source> <source>An error occurred when attempting to write to the process. For example, the process may not be running, or it may have closed its input channel.</source>
<translation>Une erreur est survenue lors de l&apos;envoi des données vers le processus. Le processus est peut être arrté ou il a fermé son canal d&apos;entrée.</translation> <translation>Une erreur est survenue lors de l&apos;envoi des données vers le processus. Le processus est peut être arrté ou il a fermé son canal d&apos;entrée.</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.h" line="141"/> <location filename="mainwindow.h" line="143"/>
<source>An error occurred when attempting to read from the process. For example, the process may not be running.</source> <source>An error occurred when attempting to read from the process. For example, the process may not be running.</source>
<translation>Une erreur est survenue lors de la lecturee de données, le processus est probablement arrêté.</translation> <translation>Une erreur est survenue lors de la lecturee de données, le processus est probablement arrêté.</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.h" line="142"/> <location filename="mainwindow.h" line="144"/>
<source>An unknown error occurred. This is the default return value of error().</source> <source>An unknown error occurred. This is the default return value of error().</source>
<translation>Une erreur inconnue est survenue. C&apos;est la valeur de retour par défaut de error().</translation> <translation>Une erreur inconnue est survenue. C&apos;est la valeur de retour par défaut de error().</translation>
</message> </message>

View File

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

View File

@ -58,6 +58,7 @@ class Connexion
public: public:
int bandwidthLimit = 0; int bandwidthLimit = 0;
int bandwidthLimitUnit; int bandwidthLimitUnit;
int contimeout = 20;
QString server; QString server;
QString service; QString service;
QString user; QString user;
@ -149,8 +150,7 @@ class MainWindow : public QMainWindow
void listServices(); void listServices();
bool validateServer(QString server); bool validateServer(QString server);
bool isIpAddress(QString server); bool isIpAddress(QString server);
void addTreeItem(QString name, QString fileSize, QString fullsize, QString type, bool isDir, QTreeWidgetItem *parent); void addTreeItem(QString name, QString fileSize, QString fullsize, QString type, QString date, bool isDir, QTreeWidgetItem *parent);
//QTreeWidgetItem * addTreeRoot(QString name, QString size, QString fullsize, bool isDir); //QTreeWidgetItem * addTreeRoot(QString name, QString size, QString fullsize, bool isDir);
//QTreeWidgetItem * addTreeChild(QTreeWidgetItem *parent, QString name, QString size, QString fullsize, bool isDir); //QTreeWidgetItem * addTreeChild(QTreeWidgetItem *parent, QString name, QString size, QString fullsize, bool isDir);
bool scanDir(QString server, int portN, QTreeWidgetItem *parent = NULL, QString path = "" ); bool scanDir(QString server, int portN, QTreeWidgetItem *parent = NULL, QString path = "" );
@ -220,7 +220,7 @@ class MainWindow : public QMainWindow
void on_actionHiddenService_triggered(); void on_actionHiddenService_triggered();
signals: signals:
void stopDownloading(QProcess *); void stopDownloading(QProcess *);
void progressSignal(int); void progressSignal(int);
void speed(QString); void speed(QString);

View File

@ -75,6 +75,6 @@ QString getFileType(QString filename)
{ {
QMimeDatabase db; QMimeDatabase db;
QMimeType mime = db.mimeTypeForFile(filename); QMimeType mime = db.mimeTypeForFile(filename);
QString returnValue = mime.name().section('/',1 ,1); QString returnValue = mime.name().section('/',0 ,0);
return returnValue; return returnValue;
} }