From 466b012b4fc1ace9174bc1b050a3a7d06f638cf0 Mon Sep 17 00:00:00 2001 From: taynpg Date: Sun, 16 Nov 2025 16:43:40 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E5=A4=84=E7=90=86=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E8=BF=87=E5=A4=9A=E6=97=B6=E7=9A=84=E5=8D=A1=E9=A1=BF?= =?UTF-8?q?=E7=9A=84=E6=83=85=E5=86=B5=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gui/Control/FileControl.cpp | 17 +++++++++++++++-- Gui/Control/FileControl.h | 1 + Note/version.md | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Gui/Control/FileControl.cpp b/Gui/Control/FileControl.cpp index 6b9d54f..d3acc68 100644 --- a/Gui/Control/FileControl.cpp +++ b/Gui/Control/FileControl.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -107,6 +108,7 @@ void FileManager::InitControl() auto* line = ui->comboBox->lineEdit(); connect(line, &QLineEdit::returnPressed, this, [this]() { ui->btnVisit->click(); }); + connect(ui->tableWidget->verticalScrollBar(), &QScrollBar::actionTriggered, this, [this]() { userScrol_ = true; }); } void FileManager::InitMenu() @@ -239,9 +241,13 @@ void FileManager::SortFileInfo(SortMethod method) void FileManager::RefreshTab() { + userScrol_ = false; + ui->tableWidget->clearContents(); ui->tableWidget->setRowCount(0); - ui->tableWidget->setRowCount(currentShowInfo_.vec.size()); + for (int i = 0; i < currentShowInfo_.vec.size(); ++i) { + + ui->tableWidget->insertRow(ui->tableWidget->rowCount()); const DirFileInfo& fileInfo = currentShowInfo_.vec[i]; // *********************************************************************************** @@ -306,8 +312,15 @@ void FileManager::RefreshTab() } item->setFlags(item->flags() & ~Qt::ItemIsEditable); ui->tableWidget->setItem(i, 4, item); + + if (i % 10 == 0) { + QGuiApplication::processEvents(); + } + } + + if (!userScrol_) { + ui->tableWidget->scrollToTop(); } - ui->tableWidget->scrollToTop(); } void FileManager::HeaderClicked(int column) diff --git a/Gui/Control/FileControl.h b/Gui/Control/FileControl.h index 4710359..010d921 100644 --- a/Gui/Control/FileControl.h +++ b/Gui/Control/FileControl.h @@ -78,6 +78,7 @@ private: ClientCore* cliCore_; QMutex cbMut_; QMutex tbMut_; + bool userScrol_{}; QVector drivers_; QSet fileTypes_; QSet curSelectTypes_; diff --git a/Note/version.md b/Note/version.md index f9ed626..85f03e7 100644 --- a/Note/version.md +++ b/Note/version.md @@ -8,6 +8,7 @@ | 序号 | 类型 | 内容 | 说明 | 基于版本 | 完成版本 | | :--: | :--: | ------------------------------------------------------------ | :----: | :------: | :------: | +| 42 | 优化 | 访问文件过多时,界面有卡顿情况。 | | 0.2.3 | 0.2.4 | | 41 | 问题 | 主动中断检查等待后,软件崩溃。 | | 0.2.3 | 0.2.4 | | 40 | 问题 | 上传方完成后,接收端未接收完毕不能退出的问题。 | | 0.2.3 | 0.2.4 | | 39 | 优化 | Console端断联后应当自动退出。 | | 0.2.3 | 0.2.4 |