added saving list of downloaded files and they are displayed in red in the treeview

This commit is contained in:
2023-03-17 13:04:03 +01:00
parent 6a381c05c8
commit ad3b44b3f4
2 changed files with 24 additions and 1 deletions
+23
View File
@@ -1,5 +1,6 @@
#include "mainwindow.h"
#include <QComboBox>
#include <QTextBlock>
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();