From dbb1bf996e1a5691237b2d3d934241deaeab6765 Mon Sep 17 00:00:00 2001 From: Alexander-Porter Date: Wed, 10 Jul 2024 11:33:19 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E9=93=BE=E6=8E=A5=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=B9=E4=BC=9A=E4=BF=9D=E5=AD=98=E5=88=B0=E4=BA=91=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- filemange_view.cpp | 3 --- filemange_view.h | 3 ++- linknewfolder_window.cpp | 11 +++++++---- linknewfolder_window.h | 5 ++++- mainwindow.cpp | 27 ++++++++++++++++++++++++++- mainwindow.h | 6 +++++- synctask.h | 3 +++ user.cpp | 4 ++-- 8 files changed, 49 insertions(+), 13 deletions(-) diff --git a/filemange_view.cpp b/filemange_view.cpp index 595ae2d..5865d6a 100644 --- a/filemange_view.cpp +++ b/filemange_view.cpp @@ -44,7 +44,6 @@ FileManagePage::FileManagePage(QWidget* parent):ElaScrollPage(parent) // 将进度条文本标签和进度条控件添加到布局中 progressBarLayout->addWidget(progressBarText); progressBarLayout->addWidget(_progressBar); - // 创建一个 ElaToggleButton 对象,设置其标签为 "Head" 并指定其父对象 _pushButton1 = new ElaPushButton("解除绑定", this); _pushButton1->setFixedSize(100, 40); // 设置按钮的固定大小 @@ -123,8 +122,6 @@ FileManagePage::FileManagePage(QWidget* parent):ElaScrollPage(parent) connect(DirCardArea8,&DirCard::relieve,this,&FileManagePage::removeDirCard); connect(DirCardArea9,&DirCard::relieve,this,&FileManagePage::removeDirCard); connect(DirCardArea10,&DirCard::relieve,this,&FileManagePage::removeDirCard); - - QWidget* filesWidget=new QWidget(); filesLayout=new QVBoxLayout(filesWidget); filesLayout->addWidget(DirCardArea1); diff --git a/filemange_view.h b/filemange_view.h index 80001c8..e824cd3 100644 --- a/filemange_view.h +++ b/filemange_view.h @@ -18,6 +18,7 @@ class FileManagePage:public ElaScrollPage void addDirCard(QString filename,QString datasize,QString bingtime); void removeDirCard(); QVBoxLayout*filesLayout; + linkNewFolder_window* linknewfolderwindow=new linkNewFolder_window(); private: ElaProgressBar* _progressBar{nullptr}; @@ -25,7 +26,7 @@ class FileManagePage:public ElaScrollPage ElaPushButton* _pushButton2{nullptr}; ElaPushButton* _pushButton3{nullptr}; ElaToggleButton* _toggleButton{nullptr}; - linkNewFolder_window* linknewfolderwindow=new linkNewFolder_window(); + setExcludedItems_view* setexcludeditemsview=new setExcludedItems_view(); }; diff --git a/linknewfolder_window.cpp b/linknewfolder_window.cpp index b3456ea..91ff2b7 100644 --- a/linknewfolder_window.cpp +++ b/linknewfolder_window.cpp @@ -10,6 +10,7 @@ #include "ElaText.h" #include "ElaComboBox.h" #include "ElaMessageBar.h" +#include "synctask.h" linkNewFolder_window::linkNewFolder_window(QWidget *parent) : ElaWidget(parent,900,400) @@ -104,9 +105,9 @@ linkNewFolder_window::linkNewFolder_window(QWidget *parent) _comboBox->setFixedWidth(140); // 创建一个映射,将文本选项映射到数字 QMap comboOptionToNumber; - comboOptionToNumber["仅上传"] = 0; - comboOptionToNumber["仅下载"] = 1; - comboOptionToNumber["同步上传与下载"] = 2; + comboOptionToNumber["仅上传"] = 2; + comboOptionToNumber["仅下载"] = 3; + comboOptionToNumber["同步上传与下载"] = 1; QWidget* buttonArea = new QWidget(); buttonArea->setWindowFlags(Qt::FramelessWindowHint); // 去除窗口边框 @@ -137,7 +138,9 @@ linkNewFolder_window::linkNewFolder_window(QWidget *parent) qDebug() << "本地文件夹地址:" << folderName1->text(); qDebug() << "云端文件夹地址:" << folderName2->text(); int syncOption = comboOptionToNumber[_comboBox->currentText()]; - qDebug() << "同步方式:" << syncOption;//["仅上传"] = 0;["仅下载"] = 1;["同步上传与下载"] = 2; + qDebug() << "同步方式:" << syncOption;//["仅上传"] = 2;["仅下载"] = 3;["同步上传与下载"] = 1; + SyncTask task(folderName1->text(), folderName2->text(), syncOption); + emit onNewTask(task); } }); diff --git a/linknewfolder_window.h b/linknewfolder_window.h index e1f99a7..84210e2 100644 --- a/linknewfolder_window.h +++ b/linknewfolder_window.h @@ -3,15 +3,18 @@ #include #include "ElaWidget.h" - +#include "synctask.h" class ElaPushButton; class ElaCheckBox; class ElaComboBox; class linkNewFolder_window : public ElaWidget { + Q_OBJECT public: linkNewFolder_window(QWidget *parent = nullptr); ~linkNewFolder_window(); +signals: + void onNewTask(const SyncTask &task); private: ElaPushButton* _pushButton1{nullptr}; ElaPushButton* _pushButton2{nullptr}; diff --git a/mainwindow.cpp b/mainwindow.cpp index 59f850b..aec9f41 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -13,6 +13,7 @@ #include "ElaMessageBar.h" #include "ElaWidget.h" #include "homeView.h" +#include "linknewfolder_window.h" #include "DirCard.h" #include "loginwin.h" #include "syncing_view.h" @@ -53,6 +54,7 @@ MainWindow::MainWindow(QWidget *parent) connect(login,&loginwin::needPassword,this,&MainWindow::onNeedPassword); connect(signin, &signinwin::on_signin_complete, this, &MainWindow::insertUserToDatabase); qDebug()<channel,&MessageChannel::message,this,&MainWindow::onMessage); + connect(_filemanagePage->linknewfolderwindow,&linkNewFolder_window::onNewTask,this,&MainWindow::onUserAddNewTask); // GraphicsView ElaGraphicsScene *scene = new ElaGraphicsScene(this); scene->setSceneRect(0, 0, 1500, 1500); @@ -128,6 +130,7 @@ MainWindow::MainWindow(QWidget *parent) widget->show(); } }); addFooterNode("Setting", new QWidget(this), _settingKey, 0, ElaIconType::GearComplex); + //connect(_filemanagePage,&FileManagePage::linkFolder,this,&MainWindow::onUserAddNewTask); /* connect(this, &MainWindow::userInfoCardClicked, this, [=]() { this->navigation(_homePage->property("ElaPageKey").toString()); }); @@ -164,7 +167,8 @@ void MainWindow::onUserLoggedIn(User user) db->insertUser(user.getEmail(),user.gethashedPassword()); setUserInfoCardTitle(user.getUsername()); setUserInfoCardSubTitle(user.getEmail()); - + _syncCore=new SyncCore(this); + _syncTaskDatabaseManager=new SyncTaskDatabaseManager(CurrentUser); QString url=user.avatarpath; QNetworkAccessManager *manager = new QNetworkAccessManager(); QNetworkRequest request; @@ -237,6 +241,27 @@ void MainWindow::onMessage( QString message, QString type) } } +void MainWindow::onUserAddNewTask(const SyncTask &task) +{ + if(CurrentUser==nullptr) + { + onMessage("请先登录","Error"); + return; + } + if( + CurrentUser->addTask(task.getLocalPath(),task.getRemotePath(),task.getSyncStatus(),1,1)){ + if(_syncCore!=nullptr) + { + SyncTask mytask(task); + _syncCore->addTask(&mytask); + } + if(_syncTaskDatabaseManager!=nullptr) + { + _syncTaskDatabaseManager->addTask(task); + } + } +} + void MainWindow::onCloseButtonClicked() { ElaContentDialog *dialag = new ElaContentDialog(this); diff --git a/mainwindow.h b/mainwindow.h index e3701f8..3020200 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -12,6 +12,8 @@ #include "user.h" #include"signinwin.h" #include +#include "synctask.h" +#include "synccore.h" class HomePage; class SyncingPage; class FileManagePage; @@ -40,6 +42,7 @@ public slots: void insertUserToDatabase(User user); void onLoginResponse(const int &code,const QJsonObject &data,const QString &message); void onMessage( QString message,QString type); + void onUserAddNewTask(const SyncTask &task); signals: void dbPassword(const QString &); @@ -59,6 +62,7 @@ public slots: QString _settingKey{""}; ElaCheckBox* _checkBox{nullptr}; UserInfoPage* _userinfopage{nullptr}; - + SyncTaskDatabaseManager* _syncTaskDatabaseManager=nullptr; + SyncCore* _syncCore=nullptr; }; #endif // MAINWINDOW_H diff --git a/synctask.h b/synctask.h index 7debcc9..f5d57cf 100644 --- a/synctask.h +++ b/synctask.h @@ -33,6 +33,9 @@ class SyncTask syncStatus = task.syncStatus; lastSyncTime = task.lastSyncTime; } + QString getLocalPath() const { return localPath.absolutePath(); } + QString getRemotePath() const { return remotePath; } + int getSyncStatus() const { return syncStatus; } friend class SyncTaskDatabaseManager; friend class SyncCore; }; diff --git a/user.cpp b/user.cpp index 02fc965..47b2ae6 100644 --- a/user.cpp +++ b/user.cpp @@ -23,8 +23,8 @@ User::User(const User &user) hashedPassword = user.hashedPassword; avatarpath = user.avatarpath; isLogin = user.isLogin; - apiRequest = new ApiRequest(this); - apiRequest->setBaseUrl("https://syncapi.snakekiss.com"); + apiRequest = user.apiRequest; + //apiRequest->setBaseUrl("https://syncapi.snakekiss.com"); channel = new MessageChannel(this); } From 2b37b608d7cc1728d60d92a4522a92f72ff87ba5 Mon Sep 17 00:00:00 2001 From: Dipper209 <3611691282@qq.com> Date: Wed, 10 Jul 2024 11:34:45 +0800 Subject: [PATCH 2/6] =?UTF-8?q?filefunc=E5=86=99=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- filefunc.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/filefunc.h b/filefunc.h index cdd01a6..bb20354 100644 --- a/filefunc.h +++ b/filefunc.h @@ -2,6 +2,8 @@ #define FILEFUNC_H #include "qthread.h" +#include "synctask.h" +#include "cosclient.h" #include #include #include @@ -14,14 +16,19 @@ class Filefunc : public QThread public: QString path; - Filefunc(QString path):path(path){}; + COSClient* cosclient; + SyncTask* task; + Filefunc(QString pathi,COSClient* cosclienti,SyncTask* taski):path(pathi),cosclient(cosclienti),task(taski){}; void run() override { readDirectory(path); } void readDirectory(const QString &path); void recursiveRead(const QString &path); - QFileInfoList fileInfoList; + + void addSynctask(const QString &path);//添加同步任务,把本地未上传文件添加入任务 + void deleteSynctask(const QString &path);//删除同步任务,把本地已上传文件删除任务 + void updateSynctask(const QString &path);//更新同步任务,把本地已上传文件更新任务 }; From 0bee453a808535bd8eb3146305911815a8484b4c Mon Sep 17 00:00:00 2001 From: Alexander-Porter Date: Wed, 10 Jul 2024 11:36:48 +0800 Subject: [PATCH 3/6] Refactor mainwindow.h to include SyncCore and SyncTaskDatabaseManager --- mainwindow.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mainwindow.h b/mainwindow.h index 52766e4..291ce1d 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -66,6 +66,8 @@ public slots: UserInfoPage* _userinfopage{nullptr}; modifyInfor_win* _modifyInfor_win{nullptr}; cancelaccount_win* _cancelaccount_win{nullptr}; + SyncCore* _syncCore{nullptr}; + SyncTaskDatabaseManager* _syncTaskDatabaseManager{nullptr}; }; #endif // MAINWINDOW_H From 2b7dc1d4e6998e1a87caee23f6fe1076f87c59e3 Mon Sep 17 00:00:00 2001 From: Dipper209 <3611691282@qq.com> Date: Wed, 10 Jul 2024 11:50:33 +0800 Subject: [PATCH 4/6] filefunc --- filefunc.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/filefunc.cpp b/filefunc.cpp index 481d78a..e4171fc 100644 --- a/filefunc.cpp +++ b/filefunc.cpp @@ -4,9 +4,6 @@ //用多线程遍历本地文件夹 void Filefunc::readDirectory(const QString &path) { - // 清空之前的文件列表 - fileInfoList.clear(); - // 递归读取文件夹和子文件夹 recursiveRead(path); } @@ -22,10 +19,15 @@ void Filefunc::recursiveRead(const QString &path) recursiveRead(info.filePath()); } else { // 如果是文件,添加到文件信息列表 - fileInfoList.append(info); + addSynctask(info.absoluteFilePath()); qDebug()< Date: Wed, 10 Jul 2024 11:53:45 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=B9=E7=AE=A1=E7=90=86=E4=B8=AD=E7=9A=84=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 2 + dircardproxy.cpp | 37 ++++++++++++ dircardproxy.h | 24 ++++++++ filemange_view.cpp | 66 ++++++--------------- filemange_view.h | 5 +- thirdParty/ElaWidgetTools/DirCard.cpp | 5 +- thirdParty/ElaWidgetTools/include/DirCard.h | 6 +- 7 files changed, 93 insertions(+), 52 deletions(-) create mode 100644 dircardproxy.cpp create mode 100644 dircardproxy.h diff --git a/CMakeLists.txt b/CMakeLists.txt index e76f093..667e2b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,6 +78,8 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) xmlprocesser.h xmlprocesser.cpp bucket.h bucket.cpp messagechannel.h messagechannel.cpp + dircardproxy.h dircardproxy.cpp + ) # Define target properties for Android with Qt 6 as: diff --git a/dircardproxy.cpp b/dircardproxy.cpp new file mode 100644 index 0000000..90dc70a --- /dev/null +++ b/dircardproxy.cpp @@ -0,0 +1,37 @@ +#include "dircardproxy.h" + +#include"DirCard.h" +#include + +DirCardProxy::DirCardProxy(QWidget *parent) : QWidget(parent) { + parentWidget = qobject_cast(parent); + filesLayout=new QVBoxLayout(this); +} + +DirCardProxy::~DirCardProxy() { + cardMap.clear(); +} + +void DirCardProxy::addDirCard(DirCard *card, const QString &id) { + if (card && parentWidget && !cardMap.contains(id)) { + cardMap[id] = card; + // 在这里可以将card添加到UI中,例如使用布局管理器 + /*QVBoxLayout *layout = qobject_cast(parentWidget->layout()); + layout->setAlignment(Qt::AlignTop); + if (layout) { + layout->addWidget(card); + }*/ + filesLayout->addWidget(card); + filesLayout->setAlignment(Qt::AlignTop); + } +} + +void DirCardProxy::removeDirCard(const QString &id) { + if (cardMap.contains(id)) { + DirCard *card = cardMap.take(id); + // 在这里可以从UI中移除card + filesLayout->removeWidget(card); + card->setParent(nullptr); + card->deleteLater(); + } +} diff --git a/dircardproxy.h b/dircardproxy.h new file mode 100644 index 0000000..cafded0 --- /dev/null +++ b/dircardproxy.h @@ -0,0 +1,24 @@ +#ifndef DIRCARDPROXY_H +#define DIRCARDPROXY_H + +#include +#include + +class DirCard; +class QVBoxLayout; +class DirCardProxy : public QWidget { + Q_OBJECT +public: + explicit DirCardProxy(QWidget *parent = nullptr); + ~DirCardProxy() override; + + void addDirCard(DirCard *card, const QString &id); + void removeDirCard(const QString &id); + QVBoxLayout*filesLayout; + +private: + QMap cardMap; + QWidget *parentWidget; +}; + +#endif // DIRCARDPROXY_H diff --git a/filemange_view.cpp b/filemange_view.cpp index 595ae2d..b3a6eb4 100644 --- a/filemange_view.cpp +++ b/filemange_view.cpp @@ -8,6 +8,7 @@ #include"ElaScrollArea.h" #include"DirCard.h" +#include"dircardproxy.h" FileManagePage::FileManagePage(QWidget* parent):ElaScrollPage(parent) { @@ -102,44 +103,20 @@ FileManagePage::FileManagePage(QWidget* parent):ElaScrollPage(parent) // 创建QScrollArea用于包裹files ElaScrollArea* scrollArea = new ElaScrollArea(); scrollArea->viewport()->setStyleSheet("background:transparent;");//设置背景透明 - DirCard*DirCardArea1=new DirCard("文件1","1.0GB","2024.7.1"); - DirCard*DirCardArea2=new DirCard("文件2","2.0GB","2024.7.2"); - DirCard*DirCardArea3=new DirCard("文件3","3.0GB","2024.7.3"); - DirCard*DirCardArea4=new DirCard("文件4","4.0GB","2024.7.4"); - DirCard*DirCardArea5=new DirCard("文件5","5.0GB","2024.7.5"); - DirCard*DirCardArea6=new DirCard("文件6","6.0GB","2024.7.6"); - DirCard*DirCardArea7=new DirCard("文件7","7.0GB","2024.7.7"); - DirCard*DirCardArea8=new DirCard("文件8","8.0GB","2024.7.8"); - DirCard*DirCardArea9=new DirCard("文件9","9.0GB","2024.7.9"); - DirCard*DirCardArea10=new DirCard("文件10","10.0GB","2024.7.10"); - - connect(DirCardArea1,&DirCard::relieve,this,&FileManagePage::removeDirCard); - connect(DirCardArea2,&DirCard::relieve,this,&FileManagePage::removeDirCard); - connect(DirCardArea3,&DirCard::relieve,this,&FileManagePage::removeDirCard); - connect(DirCardArea4,&DirCard::relieve,this,&FileManagePage::removeDirCard); - connect(DirCardArea5,&DirCard::relieve,this,&FileManagePage::removeDirCard); - connect(DirCardArea6,&DirCard::relieve,this,&FileManagePage::removeDirCard); - connect(DirCardArea7,&DirCard::relieve,this,&FileManagePage::removeDirCard); - connect(DirCardArea8,&DirCard::relieve,this,&FileManagePage::removeDirCard); - connect(DirCardArea9,&DirCard::relieve,this,&FileManagePage::removeDirCard); - connect(DirCardArea10,&DirCard::relieve,this,&FileManagePage::removeDirCard); - - - QWidget* filesWidget=new QWidget(); - filesLayout=new QVBoxLayout(filesWidget); - filesLayout->addWidget(DirCardArea1); - filesLayout->addWidget(DirCardArea2); - filesLayout->addWidget(DirCardArea3); - filesLayout->addWidget(DirCardArea4); - filesLayout->addWidget(DirCardArea5); - filesLayout->addWidget(DirCardArea6); - filesLayout->addWidget(DirCardArea7); - filesLayout->addWidget(DirCardArea8); - filesLayout->addWidget(DirCardArea9); - filesLayout->addWidget(DirCardArea10); - filesLayout->setAlignment(Qt::AlignTop); - - scrollArea->setWidget(filesWidget); // 设置scrollArea的内容部件 + + _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"); + + scrollArea->setWidget(_dircardProxy); scrollArea->setWidgetResizable(true); // 允许scrollArea根据内容自动调整大小 centerVLayout->addWidget(progressBarArea); // 将上方固定区域添加到布局中 @@ -158,16 +135,11 @@ FileManagePage::~FileManagePage() void FileManagePage::addDirCard(QString filename,QString datasize,QString bingtime) { DirCard*newDir=new DirCard(filename,datasize,bingtime); - connect(newDir,&DirCard::relieve,this,&FileManagePage::removeDirCard); - filesLayout->addWidget(newDir); + qDebug()<addDirCard(newDir,filename+datasize+bingtime); } -void FileManagePage::removeDirCard() +void FileManagePage::removeDirCard(QString id) { - DirCard *card = qobject_cast(sender()); - if (card) - { - layout()->removeWidget(card); - card->setVisible(false); - } + _dircardProxy->removeDirCard(id); } diff --git a/filemange_view.h b/filemange_view.h index 80001c8..a823c40 100644 --- a/filemange_view.h +++ b/filemange_view.h @@ -10,14 +10,15 @@ class ElaToggleButton; class ElaPushButton; class DirCard; class QVBoxLayout; +class DirCardProxy; class FileManagePage:public ElaScrollPage { public: FileManagePage(QWidget* parent = nullptr); ~FileManagePage(); void addDirCard(QString filename,QString datasize,QString bingtime); - void removeDirCard(); - QVBoxLayout*filesLayout; + void removeDirCard(QString id); + DirCardProxy*_dircardProxy; private: ElaProgressBar* _progressBar{nullptr}; diff --git a/thirdParty/ElaWidgetTools/DirCard.cpp b/thirdParty/ElaWidgetTools/DirCard.cpp index 7eb1c0e..223a23d 100644 --- a/thirdParty/ElaWidgetTools/DirCard.cpp +++ b/thirdParty/ElaWidgetTools/DirCard.cpp @@ -12,10 +12,10 @@ DirCard::DirCard(QString f, QString d,QString b) { - filename=new ElaText(f); datasize=new ElaText(d); bindtime=new ElaText(b); + id=filename->text()+datasize->text()+bindtime->text(); _checkBox = new ElaCheckBox(filename->text(), this); QVBoxLayout*checkBoxArea=new QVBoxLayout(); @@ -57,5 +57,6 @@ DirCard::DirCard(QString f, QString d,QString b) void DirCard::on_relieveBtn_clicked() { - emit relieve(); + qDebug()<<"发出前的id"< Date: Wed, 10 Jul 2024 12:08:44 +0800 Subject: [PATCH 6/6] filefunc synclogic update --- cosclient.cpp | 2 +- cosclient.h | 2 +- filefunc.cpp | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cosclient.cpp b/cosclient.cpp index 6355ee5..c697823 100644 --- a/cosclient.cpp +++ b/cosclient.cpp @@ -144,7 +144,7 @@ bool COSClient::save2Local(const QString &path, const QString &localpath, const return true; } -preResponse COSClient::headObject(const QString &path, const QString &localpath,const QString &versionId, headHeader &reqHeader) +preResponse COSClient::headObject(const QString &path,const QString &versionId, headHeader &reqHeader) { preRequest request; if(!versionId.isEmpty()) { diff --git a/cosclient.h b/cosclient.h index 922be06..1fb53de 100644 --- a/cosclient.h +++ b/cosclient.h @@ -70,7 +70,7 @@ class COSClient : public QObject QString completeMultipartUpload(QString path, QString uploadId, QMap partEtagMap); QByteArray getObject(const QString &path,const QString &versionId, QMap &respHeaders); bool save2Local(const QString &path, const QString &localpath,const QString &versionId, QMap &respMetaDatas); - preResponse headObject(const QString &path, const QString &localpath,const QString &versionId, headHeader &reqHeader); + preResponse headObject(const QString &path,const QString &versionId, headHeader &reqHeader); preResponse deleteObject(const QString &path, const QString &versionId); QString multiUpload(const QString &path, const QString &localpath, QMap metaDatas=QMap()); bool isExist(preResponse &response);//和headobject一起使用,判断文件是否存在 diff --git a/filefunc.cpp b/filefunc.cpp index e4171fc..65ff697 100644 --- a/filefunc.cpp +++ b/filefunc.cpp @@ -20,14 +20,18 @@ void Filefunc::recursiveRead(const QString &path) } else { // 如果是文件,添加到文件信息列表 addSynctask(info.absoluteFilePath()); - qDebug()<getLocalPath()相同的部分去掉 + QString relativePath=path.mid(task->getLocalPath().length()+1); + QString cloudPath=task->getRemotePath()+relativePath; + headHeader tmpHeaders; + preResponse response=cosclient->headObject(cloudPath,"",tmpHeaders); + response.getMetaDatas().isEmpty(); }