From ad3b44b3f4c0844be23d883c652cbcd881c1714b Mon Sep 17 00:00:00 2001 From: Daniel Tartavel Date: Fri, 17 Mar 2023 13:04:03 +0100 Subject: [PATCH] added saving list of downloaded files and they are displayed in red in the treeview --- RsyncUI.pro.user | 2 +- mainwindow.cpp | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/RsyncUI.pro.user b/RsyncUI.pro.user index 9a0c6fa..1fdd734 100644 --- a/RsyncUI.pro.user +++ b/RsyncUI.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/mainwindow.cpp b/mainwindow.cpp index 148e668..8587862 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,5 +1,6 @@ #include "mainwindow.h" #include +#include using namespace std; @@ -691,6 +692,8 @@ void MainWindow::on_connectButton_clicked() // add parent in treeview void MainWindow::addTreeItem(QString name, QString fileSize, QString fullsize, QString type, QString date, bool isDir=false, QTreeWidgetItem *parent=nullptr) { + QFont * font = new QFont(); + QTreeWidgetItem *treeItem; if (parent != nullptr) { @@ -707,6 +710,22 @@ void MainWindow::addTreeItem(QString name, QString fileSize, QString fullsize, Q }else { // item is a file + if (QFile::exists(this->downloading.savePath + "/" + name)) + { + QBrush b (Qt::red); + treeItem->setForeground(0, b); + treeItem->setFont(0, *font); + }else + { + this->settings.beginGroup("Downloaded/"); + if (this->settings.contains(name)) + { + QBrush b (Qt::red); + treeItem->setForeground(0, b); + treeItem->setFont(0, *font); + } + this->settings.endGroup(); + } treeItem->setText(1,type); } treeItem->setText(0, name); @@ -1017,6 +1036,10 @@ void MainWindow::downloadFinished(int exitCode, QProcess::ExitStatus exitStatus) if (retry == false) { + QString filename = ui->listDownload->item(0)->text(); + pos = filename.contains(" => "); + filename.resize(pos); + this->settings.setValue("Downloaded/" + ui->listDownload->item(0)->text(), true); delete ui->listDownload->takeItem(0); } this->downloading.clear();