From f65b0fa98eabfdc6ad9ce86e06e9a7d2de2ae970 Mon Sep 17 00:00:00 2001 From: Firefly-29710 <2235501805@qq.com> Date: Wed, 10 Jul 2024 15:12:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dircardproxy.cpp | 10 ++++++++ dircardproxy.h | 1 + filemange_view.cpp | 28 ++++++++++----------- filemange_view.h | 2 +- thirdParty/ElaWidgetTools/DirCard.cpp | 4 +-- thirdParty/ElaWidgetTools/include/DirCard.h | 2 +- 6 files changed, 29 insertions(+), 18 deletions(-) diff --git a/dircardproxy.cpp b/dircardproxy.cpp index bb875ff..004d3cf 100644 --- a/dircardproxy.cpp +++ b/dircardproxy.cpp @@ -20,6 +20,16 @@ void DirCardProxy::addDirCard(DirCard *card, const QString &id) { } } +void DirCardProxy::addDirCard(QString filename,QString datasize,QString bindtime,const QString &id) +{ + DirCard*card=new DirCard(filename,datasize,bindtime,id); + if (card && parentWidget && !cardMap.contains(id)) { + cardMap[id] = card; + filesLayout->addWidget(card); + filesLayout->setAlignment(Qt::AlignTop); + } +} + void DirCardProxy::removeDirCard(const QString &id) { if (cardMap.contains(id)) { DirCard *card = cardMap.take(id); diff --git a/dircardproxy.h b/dircardproxy.h index c544337..ee62c62 100644 --- a/dircardproxy.h +++ b/dircardproxy.h @@ -13,6 +13,7 @@ class DirCardProxy : public QWidget { ~DirCardProxy() override; void addDirCard(DirCard *card, const QString &id); + void addDirCard(QString filename,QString datasize,QString bindtime,const QString &id); void removeDirCard(const QString &id); void removeChecked(); QVBoxLayout*filesLayout; diff --git a/filemange_view.cpp b/filemange_view.cpp index 3a07407..e8afc1c 100644 --- a/filemange_view.cpp +++ b/filemange_view.cpp @@ -107,16 +107,16 @@ FileManagePage::FileManagePage(QWidget* parent):ElaScrollPage(parent) scrollArea->viewport()->setStyleSheet("background:transparent;");//设置背景透明 _dircardProxy=new DirCardProxy(this); - addDirCard("文件1","1.0GB","2024.7.1"); - addDirCard("文件2","2.0GB","2024.7.2"); - addDirCard("文件3","3.0GB","2024.7.3"); - addDirCard("文件4","4.0GB","2024.7.4"); - addDirCard("文件5","5.0GB","2024.7.5"); - addDirCard("文件6","6.0GB","2024.7.6"); - addDirCard("文件7","7.0GB","2024.7.7"); - addDirCard("文件8","8.0GB","2024.7.8"); - addDirCard("文件9","9.0GB","2024.7.9"); - addDirCard("文件10","10.0GB","2024.7.10"); + addDirCard("文件1","1.0GB","2024.7.1","1"); + addDirCard("文件2","2.0GB","2024.7.2","2"); + addDirCard("文件3","3.0GB","2024.7.3","3"); + addDirCard("文件4","4.0GB","2024.7.4","4"); + addDirCard("文件5","5.0GB","2024.7.5","5"); + addDirCard("文件6","6.0GB","2024.7.6","6"); + addDirCard("文件7","7.0GB","2024.7.7","7"); + addDirCard("文件8","8.0GB","2024.7.8","8"); + addDirCard("文件9","9.0GB","2024.7.9","9"); + addDirCard("文件10","10.0GB","2024.7.10","10"); scrollArea->setWidget(_dircardProxy); scrollArea->setWidgetResizable(true); // 允许scrollArea根据内容自动调整大小 @@ -134,11 +134,11 @@ FileManagePage::~FileManagePage() } -void FileManagePage::addDirCard(QString filename,QString datasize,QString bingtime) +void FileManagePage::addDirCard(QString filename,QString datasize,QString bindtime,QString id) { - DirCard*newDir=new DirCard(filename,datasize,bingtime); - qDebug()<addDirCard(newDir,filename+datasize+bingtime); + DirCard*newDir=new DirCard(filename,datasize,bindtime,id); + connect(newDir,&DirCard::relieve,this,&FileManagePage::removeDirCard); + _dircardProxy->addDirCard(newDir,id); } void FileManagePage::removeDirCard(QString id) diff --git a/filemange_view.h b/filemange_view.h index d7d6544..f1026ca 100644 --- a/filemange_view.h +++ b/filemange_view.h @@ -16,7 +16,7 @@ class FileManagePage:public ElaScrollPage public: FileManagePage(QWidget* parent = nullptr); ~FileManagePage(); - void addDirCard(QString filename,QString datasize,QString bingtime); + void addDirCard(QString filename,QString datasize,QString bindtime,QString id); void removeDirCard(QString id); DirCardProxy*_dircardProxy; linkNewFolder_window* linknewfolderwindow=new linkNewFolder_window(); diff --git a/thirdParty/ElaWidgetTools/DirCard.cpp b/thirdParty/ElaWidgetTools/DirCard.cpp index 918edeb..0df0be7 100644 --- a/thirdParty/ElaWidgetTools/DirCard.cpp +++ b/thirdParty/ElaWidgetTools/DirCard.cpp @@ -10,12 +10,12 @@ #include"ElaPushButton.h" #include"ElaToggleButton.h" -DirCard::DirCard(QString f, QString d,QString b) +DirCard::DirCard(QString f, QString d,QString b,QString Id) { filename=new ElaText(f); datasize=new ElaText(d); bindtime=new ElaText(b); - id=filename->text()+datasize->text()+bindtime->text(); + id=Id; _checkBox = new ElaCheckBox(filename->text(), this); QVBoxLayout*checkBoxArea=new QVBoxLayout(); diff --git a/thirdParty/ElaWidgetTools/include/DirCard.h b/thirdParty/ElaWidgetTools/include/DirCard.h index e1d4b14..8f33817 100644 --- a/thirdParty/ElaWidgetTools/include/DirCard.h +++ b/thirdParty/ElaWidgetTools/include/DirCard.h @@ -14,7 +14,7 @@ class ELA_EXPORT DirCard : public ElaScrollPageArea { Q_OBJECT public: - explicit DirCard(QString f, QString d,QString b); + explicit DirCard(QString f, QString d,QString b,QString Id); ElaCheckBox* _checkBox{nullptr}; ElaToggleButton*pauseBtn;