添加文件夹传输进度更新。

This commit is contained in:
2026-03-24 22:25:00 +08:00
parent 5843332980
commit 0e397ace7d
12 changed files with 290 additions and 165 deletions

View File

@@ -511,6 +511,34 @@ void FileManager::UpDown()
QMessageBox::information(this, tr("提示"), tr("请选择完整的行。"));
return;
}
//
WaitOperOwn wo(this);
auto getAllItems = [this, &datas, &wo]() {
wo.infoMsg_.list.clear();
for (int i = 0; i < (datas.size() / 5); ++i) {
const auto& curType = datas[i * 5 + 3]->text();
if (curType == "File") {
wo.infoMsg_.list << datas[i * 5 + 1]->text();
} else {
QVector<QString> fs;
DirFileHelper::GetAllFiles(datas[i * 5 + 1]->text(), fs);
if (!fs.isEmpty()) {
wo.infoMsg_.list << fs;
}
}
}
};
wo.func_ = getAllItems;
LoadingDialog checking(this);
checking.setTipsText("正在获取文件列表...");
checking.setCanCancel(false);
connect(&wo, &WaitOperOwn::sigOver, &checking, &LoadingDialog::cancelBtnClicked);
wo.start();
checking.exec();
QVector<TransTask> tasks;
for (int i = 0; i < (datas.size() / 5); ++i) {
if (datas[i * 5 + 3]->text() != "File") {
@@ -569,7 +597,7 @@ void FileManager::OperNewFolder()
if (!isRemote_) {
QString ret = Util::NewDir(folder);
if (ret.isEmpty()) {
//QMessageBox::information(this, tr("提示"), tr("创建%1成功").arg(folder));
// QMessageBox::information(this, tr("提示"), tr("创建%1成功").arg(folder));
DirFileInfo nf;
nf.size = 0;
nf.type = Dir;
@@ -609,7 +637,7 @@ void FileManager::OperNewFolder()
if (msg.msg == STR_NONE || !msg.msg.isEmpty()) {
QMessageBox::information(this, tr("提示"), QString(tr("新建失败=>%1")).arg(msg.msg));
} else {
//QMessageBox::information(this, tr("提示"), QString(tr("新建%1成功。")).arg(folder));
// QMessageBox::information(this, tr("提示"), QString(tr("新建%1成功。")).arg(folder));
DirFileInfo nf;
nf.size = 0;
nf.type = Dir;
@@ -642,7 +670,7 @@ void FileManager::OperDelete()
if (!isRemote_) {
QString ret = Util::Delete(name);
if (ret.isEmpty()) {
//QMessageBox::information(this, tr("提示"), tr("删除成功"));
// QMessageBox::information(this, tr("提示"), tr("删除成功"));
int row = datas[0]->row();
ui->tableWidget->removeRow(row);
} else {
@@ -676,7 +704,7 @@ void FileManager::OperDelete()
if (msg.msg == STR_NONE || !msg.msg.isEmpty()) {
QMessageBox::information(this, tr("提示"), QString(tr("删除失败=>%1")).arg(msg.msg));
} else {
//QMessageBox::information(this, tr("提示"), QString(tr("删除成功。")));
// QMessageBox::information(this, tr("提示"), QString(tr("删除成功。")));
ui->tableWidget->removeRow(datas[0]->row());
}
}
@@ -824,81 +852,4 @@ void FileManager::doubleClick(int row, int column)
QDir dir(GetRoot());
QString np = dir.filePath(item->text());
fileHelper_->GetDirFile(np);
}
WaitOper::WaitOper(QObject* parent) : WaitThread(parent)
{
}
void WaitOper::run()
{
isAlreadyInter_ = false;
infoMsg_.msg = STR_NONE;
isRun_ = true;
recvMsg_ = false;
InfoMsg msg;
msg.command = sendStrType_;
msg.fromPath = stra_;
msg.toPath = strb_;
msg.type = type_;
auto f = cli_->GetBuffer<InfoMsg>(msg, FBT_MSGINFO_ASK, cli_->GetRemoteID());
if (!ClientCore::syncInvoke(cli_, f)) {
auto errMsg = QString(tr("向%1发送%2请求失败。")).arg(cli_->GetRemoteID()).arg(sendStrType_);
emit sigCheckOver();
qCritical() << errMsg;
return;
}
while (isRun_) {
QThread::msleep(1);
if (isAlreadyInter_) {
qInfo() << tr("线程中断文件操作等待......");
return;
}
if (!recvMsg_) {
continue;
}
break;
}
isAlreadyInter_ = true;
emit sigCheckOver();
auto n = QString(tr("向%1的请求%2处理结束。")).arg(cli_->GetRemoteID()).arg(sendStrType_);
qInfo() << n;
}
void WaitOper::SetType(const QString& sendType, const QString& ansType)
{
sendStrType_ = sendType;
ansStrType_ = ansType;
}
void WaitOper::SetPath(const QString& stra, const QString& strb, const QString& type)
{
stra_ = stra;
strb_ = strb;
type_ = type;
}
InfoMsg WaitOper::GetMsg() const
{
return infoMsg_;
}
void WaitOper::interrupCheck()
{
qWarning() << QString(tr("中断请求处理%1......")).arg(sendStrType_);
WaitThread::interrupCheck();
}
void WaitOper::recvFrame(QSharedPointer<FrameBuffer> frame)
{
InfoMsg info = infoUnpack<InfoMsg>(frame->data);
if (info.command == ansStrType_) {
infoMsg_ = info;
recvMsg_ = true;
return;
}
auto n = tr("收到未知Oper的回复信息:") + info.command;
qInfo() << n;
}
}