added saving list of downloaded files and they are displayed in red in the treeview
This commit is contained in:
parent
6a381c05c8
commit
ad3b44b3f4
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.14.2, 2023-03-09T22:37:54. -->
|
||||
<!-- Written by QtCreator 4.14.2, 2023-03-11T18:47:01. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user