优化查询链路的性能等
This commit is contained in:
@@ -472,7 +472,7 @@ void CodeSearchPage::buildSilentChain(const QList<int> &modes, int idx)
|
||||
CallChainAnalyzer *ca = m_analyzers[mode];
|
||||
ca->setRootPath(path);
|
||||
|
||||
// 后台线程构建,复用进度框;无弹窗(静默),完成后继续下一模式
|
||||
// 后台线程构建,静默无弹窗(转码完成后自动调用,不弹进度框),完成后继续下一模式
|
||||
runIndexBuild(ca, "正在刷新代码索引,请稍候...",
|
||||
[this, modes, idx, mode, path, ca](bool ok, const QString &message) {
|
||||
if (ok) {
|
||||
@@ -487,7 +487,8 @@ void CodeSearchPage::buildSilentChain(const QList<int> &modes, int idx)
|
||||
.arg(mode == 0 ? "转码业务" : "非转码业务", message));
|
||||
}
|
||||
buildSilentChain(modes, idx + 1);
|
||||
});
|
||||
},
|
||||
/*showProgress=*/false);
|
||||
}
|
||||
|
||||
void CodeSearchPage::onFunctionDoubleClicked(const QModelIndex &index)
|
||||
@@ -746,24 +747,31 @@ void CodeSearchPage::autoBuildIndexIfNeeded()
|
||||
|
||||
void CodeSearchPage::runAsync(CallChainAnalyzer *ca, const QString &title,
|
||||
std::function<QPair<bool, QString>(CallChainAnalyzer *)> task,
|
||||
std::function<void(bool, const QString &)> onDone)
|
||||
std::function<void(bool, const QString &)> onDone,
|
||||
bool showProgress)
|
||||
{
|
||||
// 模态进度框(不确定进度),后台任务期间维持界面响应
|
||||
auto *dlg = new QProgressDialog(title, QString(), 0, 0, this);
|
||||
dlg->setWindowTitle("请稍候");
|
||||
dlg->setWindowModality(Qt::WindowModal);
|
||||
dlg->setCancelButton(nullptr);
|
||||
dlg->setRange(0, 0); // 不确定进度
|
||||
dlg->setMinimumDuration(0);
|
||||
dlg->show();
|
||||
// 模态进度框(不确定进度),后台任务期间维持界面响应;
|
||||
// showProgress 为 false 时(如转码后自动刷新索引)完全静默,不弹任何框
|
||||
QProgressDialog *dlg = nullptr;
|
||||
if (showProgress) {
|
||||
dlg = new QProgressDialog(title, QString(), 0, 0, this);
|
||||
dlg->setWindowTitle("请稍候");
|
||||
dlg->setWindowModality(Qt::WindowModal);
|
||||
dlg->setCancelButton(nullptr);
|
||||
dlg->setRange(0, 0); // 不确定进度
|
||||
dlg->setMinimumDuration(0);
|
||||
dlg->show();
|
||||
}
|
||||
|
||||
using BuildResult = QPair<bool, QString>;
|
||||
auto *watcher = new QFutureWatcher<BuildResult>(this);
|
||||
connect(watcher, &QFutureWatcher<BuildResult>::finished, this, [=]() {
|
||||
const BuildResult r = watcher->result();
|
||||
watcher->deleteLater();
|
||||
dlg->close();
|
||||
dlg->deleteLater();
|
||||
if (dlg) {
|
||||
dlg->close();
|
||||
dlg->deleteLater();
|
||||
}
|
||||
if (onDone) {
|
||||
onDone(r.first, r.second);
|
||||
}
|
||||
@@ -777,13 +785,14 @@ void CodeSearchPage::runAsync(CallChainAnalyzer *ca, const QString &title,
|
||||
}
|
||||
|
||||
void CodeSearchPage::runIndexBuild(CallChainAnalyzer *ca, const QString &title,
|
||||
std::function<void(bool, const QString &)> onDone)
|
||||
std::function<void(bool, const QString &)> onDone,
|
||||
bool showProgress)
|
||||
{
|
||||
runAsync(ca, title, [](CallChainAnalyzer *ca) -> QPair<bool, QString> {
|
||||
QString msg;
|
||||
const bool ok = ca->buildIndex(&msg);
|
||||
return {ok, msg};
|
||||
}, onDone);
|
||||
}, onDone, showProgress);
|
||||
}
|
||||
|
||||
void CodeSearchPage::runCacheLoad(CallChainAnalyzer *ca, const QString &title, bool skipFingerprint,
|
||||
|
||||
@@ -89,13 +89,16 @@ private:
|
||||
void applyMode();
|
||||
CallChainAnalyzer *currentAnalyzer() const;
|
||||
|
||||
/// 后台线程异步执行索引任务(避免界面卡顿),期间显示模态进度框;完成后回调 onDone(ok, message)
|
||||
/// 后台线程异步执行索引任务(避免界面卡顿);showProgress 为 true 时显示模态进度框,
|
||||
/// 为 false 时完全静默(转码后自动刷新使用),完成后回调 onDone(ok, message)
|
||||
void runAsync(CallChainAnalyzer *ca, const QString &title,
|
||||
std::function<QPair<bool, QString>(CallChainAnalyzer *)> task,
|
||||
std::function<void(bool, const QString &)> onDone);
|
||||
/// 后台线程异步构建索引(扫描目录),完成后回调 onDone
|
||||
std::function<void(bool, const QString &)> onDone,
|
||||
bool showProgress = true);
|
||||
/// 后台线程异步构建索引(扫描目录),完成后回调 onDone;showProgress 控制是否显示进度框
|
||||
void runIndexBuild(CallChainAnalyzer *ca, const QString &title,
|
||||
std::function<void(bool, const QString &)> onDone);
|
||||
std::function<void(bool, const QString &)> onDone,
|
||||
bool showProgress = true);
|
||||
/// 后台线程异步从缓存加载索引;skipFingerprint 为 true 时跳过全量目录指纹校验
|
||||
void runCacheLoad(CallChainAnalyzer *ca, const QString &title, bool skipFingerprint,
|
||||
std::function<void(bool, const QString &)> onDone);
|
||||
|
||||
@@ -29,8 +29,8 @@ void UF20FunctionSearchPage::initUI()
|
||||
searchLayout->setSpacing(10);
|
||||
|
||||
m_searchComboBox = new ElaComboBox;
|
||||
m_searchComboBox->addItem("功能名称", "cname");
|
||||
m_searchComboBox->addItem("功能编号", "function_no");
|
||||
m_searchComboBox->addItem("函数名", "cname");
|
||||
m_searchComboBox->addItem("功能号", "function_no");
|
||||
searchLayout->addWidget(m_searchComboBox);
|
||||
|
||||
m_searchEdit = new ElaSearchEdit;
|
||||
@@ -47,7 +47,7 @@ void UF20FunctionSearchPage::initUI()
|
||||
|
||||
m_tableModel = new QStandardItemModel(this);
|
||||
m_tableModel->setColumnCount(3);
|
||||
m_tableModel->setHorizontalHeaderLabels({"功能名称", "英文名", "功能编号"});
|
||||
m_tableModel->setHorizontalHeaderLabels({"函数名", "英文名", "功能号"});
|
||||
|
||||
m_resultTable = new ElaTableView;
|
||||
m_resultTable->setModel(m_tableModel);
|
||||
|
||||
@@ -29,8 +29,8 @@ void UFT3FunctionSearchPage::initUI()
|
||||
searchLayout->setSpacing(10);
|
||||
|
||||
m_searchComboBox = new ElaComboBox;
|
||||
m_searchComboBox->addItem("功能名称", "cname");
|
||||
m_searchComboBox->addItem("功能编号", "function_no");
|
||||
m_searchComboBox->addItem("函数名", "cname");
|
||||
m_searchComboBox->addItem("功能号", "function_no");
|
||||
searchLayout->addWidget(m_searchComboBox);
|
||||
|
||||
m_searchEdit = new ElaSearchEdit;
|
||||
@@ -47,7 +47,7 @@ void UFT3FunctionSearchPage::initUI()
|
||||
|
||||
m_tableModel = new QStandardItemModel(this);
|
||||
m_tableModel->setColumnCount(3);
|
||||
m_tableModel->setHorizontalHeaderLabels({"功能名称", "英文名", "功能编号"});
|
||||
m_tableModel->setHorizontalHeaderLabels({"函数名", "英文名", "功能号"});
|
||||
|
||||
m_resultTable = new ElaTableView;
|
||||
m_resultTable->setModel(m_tableModel);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "metadatupdatepage.h"
|
||||
#include "utils/Constants.h"
|
||||
#include "utils/logmanager.h"
|
||||
#include "utils/business_strategy.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QGridLayout>
|
||||
@@ -429,11 +430,8 @@ void MetadataUpdatePage::onWorkerFinished()
|
||||
// 数据缓存重载必须在主线程执行(DataCache 单例与静态 cnameCache 非线程安全)
|
||||
if (r.needReload) {
|
||||
_processLabel->setText("正在更新数据缓存...");
|
||||
if (m_currentTaskName == "UF20") {
|
||||
UF2ConfigReader::reloadUF20Config();
|
||||
} else {
|
||||
UFT3ConfigReader::reloadUFT3Config();
|
||||
}
|
||||
// 通过业务策略工厂按当前任务选择对应版本的配置重载,取代 UF20/UFT3 if/else
|
||||
createBusinessStrategy(m_currentTaskName)->reloadConfig();
|
||||
}
|
||||
|
||||
onUpdateFinished(r.success, QString("%1更新完成").arg(m_currentTaskName));
|
||||
|
||||
Reference in New Issue
Block a user