From 238b14517958c334b503fa937c82a391dfa54a6f Mon Sep 17 00:00:00 2001 From: Dipper209 <3611691282@qq.com> Date: Wed, 10 Jul 2024 09:15:35 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=B5=8B=E8=AF=95cosclient?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cosclient.cpp | 4 ++-- cosclient.h | 2 +- main.cpp | 33 ++++++++++++++++++++++++--------- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/cosclient.cpp b/cosclient.cpp index e4e73ed..8f4b7b3 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) +QMap COSClient::headObject(const QString &path, const QString &localpath,const QString &versionId, headHeader &reqHeader) { preRequest request; if(!versionId.isEmpty()) { @@ -163,7 +163,7 @@ preResponse COSClient::headObject(const QString &path, const QString &localpath, request.customHeaders.insert("If-None-Match", reqHeader.ifNoneMatch); } preResponse response = invokeHeadRequest(path, request); - return response; + return response.headers; } bool COSClient::deleteObject(const QString &path, const QString &versionId) diff --git a/cosclient.h b/cosclient.h index 5d1fe67..1a5c769 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); + QMap headObject(const QString &path, const QString &localpath,const QString &versionId, headHeader &reqHeader); bool deleteObject(const QString &path, const QString &versionId); QString multiUpload(const QString &path, const QString &localpath, QMap metaDatas=QMap()); diff --git a/main.cpp b/main.cpp index 2a6ffbb..f1b8726 100644 --- a/main.cpp +++ b/main.cpp @@ -17,8 +17,9 @@ int main(int argc, char *argv[]) User loginuser("enrolluser@example.com","123456"); loginuser.enroll(); loginuser.login(); - /* - loginuser.addTask("E:/","home/",1,22,22); + + + //loginuser.addTask("E:/","home/",1,22,22); TaskToken tt=loginuser.getTaskTokenByRemote("home/"); //request: https://qsync-1320107701.cos.ap-nanjing.myqcloud.com/?prefix=home QNetworkRequest request(QUrl("https://qsync-1320107701.cos.ap-nanjing.myqcloud.com/?prefix=home")); @@ -31,12 +32,26 @@ int main(int argc, char *argv[]) QString token=tt.sessionToken; QDateTime expiredTime=tt.expiredTime; COSClient cosclient(bucketName,appId,region,secretId,secretKey,token,expiredTime); - QString xmlstr=cosclient.listObjects("home/",""); - qDebug()< myMap; + headHeader hh; + qDebug()<<"save to local:"< metaDatas; + QMap headers=cosclient.headObject("home/2.mp4","C:/Users/work123/Desktop/2.mp4","",hh); + for(auto it=headers.begin();it!=headers.end();it++){ + if(it.key().startsWith("x-cos-meta-")){ + metaDatas[it.key().mid(11)]=it.value(); + } + } + qDebug()<<"metaDatas:"<init(); MainWindow w; w.show(); From f725f8dda9d050e3298af21666faa182eac65135 Mon Sep 17 00:00:00 2001 From: kuiling <3110428854@qq.com> Date: Wed, 10 Jul 2024 09:44:13 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E6=96=B0=E6=96=87=E4=BB=B6=E5=A4=B9=E4=BA=91=E7=AB=AF?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E5=A4=B1=E7=84=A6=E5=90=8E=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E5=B9=B6=E6=8F=90=E7=A4=BA=E6=96=87=E5=AD=97=E7=9A=84=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=8C=E5=B9=B6=E4=BD=BF=E5=8B=BE=E4=B8=8B=E6=A1=86?= =?UTF-8?q?=E5=90=8E=E5=8F=AA=E7=95=99=E4=B8=8B/=E5=90=8E=E9=9D=A2?= =?UTF-8?q?=E7=9A=84=E6=96=87=E5=AD=97=E5=B9=B6=E5=86=8D=E5=8A=A0=E4=B8=8A?= =?UTF-8?q?/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- linknewfolder_window.cpp | 38 +++++++++++++++++++++++++++++++++++--- setexcludeditems_view.cpp | 2 ++ 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/linknewfolder_window.cpp b/linknewfolder_window.cpp index 09eb6e8..3f0b4ac 100644 --- a/linknewfolder_window.cpp +++ b/linknewfolder_window.cpp @@ -60,10 +60,41 @@ linkNewFolder_window::linkNewFolder_window(QWidget *parent) _checkBox->setFixedSize(130, 20); // 设置按钮的固定大小 lineEditLayout2->addWidget(folderName2, 1); // 将输入框添加到布局中 lineEditLayout2->addWidget(_checkBox); // 将按钮添加到布局中 - connect(_checkBox, &QCheckBox::stateChanged, [=](int state) { + // 首先,定义一个用于显示错误信息的标签 + QLabel* errorLabel = new QLabel(lineEditArea2); + errorLabel->setText("输入格式错误:只能包含大小写字母、数字、'-'和'/',且必须以'/'结尾"); + errorLabel->setStyleSheet("QLabel { color : red; }"); // 设置错误信息为红色字体 + //errorLabel->setAlignment(Qt::AlignCenter); // 设置文本居中显示 + errorLabel->setFixedSize(500,20); + errorLabel->hide(); // 默认隐藏错误信息标签 + // 然后,为folderName2添加失焦事件的处理 + connect(folderName2, &ElaLineEdit::focusOut, [=]() { + QString inputText = folderName2->text(); + QRegularExpression re("^[a-zA-Z0-9/-]+/$"); + if (!re.match(inputText).hasMatch()) { + // 如果输入不符合要求,显示错误信息标签 + errorLabel->show(); + } else { + // 如果输入符合要求,隐藏错误信息标签 + errorLabel->hide(); + } + }); + // 为checkBox添加状态改变事件的处理 + connect(_checkBox, &ElaCheckBox::stateChanged, [=](int state) { if (state == Qt::Checked) { - // 如果_checkBox被选中,复制folderName1的内容到folderName2 - folderName2->setText(folderName1->text()); + QString folderName1Text = folderName1->text(); + int lastSlashIndex = folderName1Text.lastIndexOf('/'); + // 如果找到了'/',则复制其后的内容到folderName2 + if (lastSlashIndex != -1) { + QString lastPart = folderName1Text.mid(lastSlashIndex + 1); // 包含最后一个'/'及其后的所有内容 + folderName2->setText(lastPart + "/"); // 在folderName2中设置文本,并在末尾加上一个'/' + QString inputText = folderName2->text(); + QRegularExpression re("^[a-zA-Z0-9/-]+/$"); + if (!re.match(inputText).hasMatch()) + errorLabel->show(); + else + errorLabel->hide(); + } } }); @@ -104,6 +135,7 @@ linkNewFolder_window::linkNewFolder_window(QWidget *parent) centerVLayout->addWidget(Title); centerVLayout->addWidget(lineEditArea1); + //centerVLayout->addWidget(errorLabel); centerVLayout->addWidget(lineEditArea2); centerVLayout->addWidget(_comboBox); centerVLayout->addWidget(buttonArea); diff --git a/setexcludeditems_view.cpp b/setexcludeditems_view.cpp index 3ecf126..61934a8 100644 --- a/setexcludeditems_view.cpp +++ b/setexcludeditems_view.cpp @@ -13,6 +13,8 @@ setExcludedItems_view::setExcludedItems_view(QWidget *parent) this->setWindowModality(Qt::ApplicationModal); // 设置窗口模态 this->hide(); // 初始隐藏当前窗口 this->setWindowButtonFlag(ElaAppBarType::StayTopButtonHint,false); + this->setWindowButtonFlag(ElaAppBarType::MinimizeButtonHint,false); + this->setWindowButtonFlag(ElaAppBarType::MaximizeButtonHint,false); QWidget*centerarea=new QWidget(); // 创建一个新的QWidget对象作为主区域 QVBoxLayout* centerVLayout = new QVBoxLayout(centerarea); // 为中心部件设置垂直布局 centerVLayout->setContentsMargins(60, 15, 60, 30); // 设置布局边距 From ceabda329b5a055b75df16e60c0d8970710af926 Mon Sep 17 00:00:00 2001 From: Dipper209 <3611691282@qq.com> Date: Wed, 10 Jul 2024 09:52:22 +0800 Subject: [PATCH 3/3] =?UTF-8?q?cosclient=E4=B8=8B=E8=BD=BD=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cosclient.cpp | 4 ++-- main.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cosclient.cpp b/cosclient.cpp index 44bd6e1..6d32c48 100644 --- a/cosclient.cpp +++ b/cosclient.cpp @@ -122,9 +122,9 @@ bool COSClient::save2Local(const QString &path, const QString &localpath, const { QMap tempHeaders; QByteArray data = getObject(path, versionId, tempHeaders); - + qDebug()< myMap; headHeader hh; - qDebug()<<"save to local:"< metaDatas; - QMap headers=cosclient.headObject("home/2.mp4","C:/Users/work123/Desktop/2.mp4","",hh); + //qDebug()<<"save to local:"< metaDatas; + QMap headers=cosclient.headObject("home/1.txt","C:/Users/work123/Desktop/1.txt","",hh); for(auto it=headers.begin();it!=headers.end();it++){ if(it.key().startsWith("x-cos-meta-")){ metaDatas[it.key().mid(11)]=it.value(); } } - qDebug()<<"metaDatas:"<