新增功能查询页面,支持按名称和功能号查询
This commit is contained in:
parent
c097120ca3
commit
2af12b298c
Binary file not shown.
|
After Width: | Height: | Size: 4.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
|
|
@ -123,11 +123,21 @@ void MainWindow::initContent()
|
|||
QString helpKey;
|
||||
QString aboutKey;
|
||||
QString settingKey;
|
||||
addPageNode("转码业务", createBatchConvertPage(), ElaIconType::FileCode);
|
||||
//addPageNode("功能搜索", createFunctionSearchPage(), ElaIconType::MagnifyingGlass);
|
||||
QString funcSearchKey;
|
||||
QString funcConvertKey;
|
||||
|
||||
addExpanderNode("功能转码", funcConvertKey, ElaIconType::FileCode);
|
||||
addPageNode("业务转码", createBatchConvertPage(), funcConvertKey, ElaIconType::ArrowsRepeat);
|
||||
|
||||
addExpanderNode("功能查询", funcSearchKey, ElaIconType::MagnifyingGlass);
|
||||
addPageNode("UF20功能查询", createUF20FunctionSearchPage(), funcSearchKey, ElaIconType::FileCode);
|
||||
addPageNode("UFT3功能查询", createUFT3FunctionSearchPage(), funcSearchKey, ElaIconType::FileCode);
|
||||
|
||||
addFooterNode("帮助", createHelpPage(), helpKey, 0, ElaIconType::CircleQuestion);
|
||||
addFooterNode("关于", createAboutPage(), aboutKey, 0, ElaIconType::User);
|
||||
addFooterNode("设置", createSettingsPage(), settingKey, 0, ElaIconType::GearComplex);
|
||||
|
||||
expandNavigationNode(funcConvertKey);
|
||||
}
|
||||
|
||||
QWidget* MainWindow::createBatchConvertPage()
|
||||
|
|
@ -143,6 +153,16 @@ QWidget* MainWindow::createFunctionSearchPage()
|
|||
return new FunctionSearchPage;
|
||||
}
|
||||
|
||||
QWidget* MainWindow::createUF20FunctionSearchPage()
|
||||
{
|
||||
return new UF20FunctionSearchPage;
|
||||
}
|
||||
|
||||
QWidget* MainWindow::createUFT3FunctionSearchPage()
|
||||
{
|
||||
return new UFT3FunctionSearchPage;
|
||||
}
|
||||
|
||||
QWidget* MainWindow::createHelpPage()
|
||||
{
|
||||
return new HelpPage;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
#include "src/pythonrunner/PythonRunner.h"
|
||||
#include "src/pages/batchconvert/batchconvertpage.h"
|
||||
#include "src/pages/functionsearch/functionsearchpage.h"
|
||||
#include "src/pages/functionsearch/uf20functionsearchpage.h"
|
||||
#include "src/pages/functionsearch/uft3functionsearchpage.h"
|
||||
#include "src/pages/help/helppage.h"
|
||||
#include "src/pages/about/aboutpage.h"
|
||||
#include "src/pages/settings/settingspage.h"
|
||||
|
|
@ -25,6 +27,8 @@ private:
|
|||
|
||||
QWidget* createBatchConvertPage();
|
||||
QWidget* createFunctionSearchPage();
|
||||
QWidget* createUF20FunctionSearchPage();
|
||||
QWidget* createUFT3FunctionSearchPage();
|
||||
QWidget* createHelpPage();
|
||||
QWidget* createAboutPage();
|
||||
QWidget* createSettingsPage();
|
||||
|
|
|
|||
|
|
@ -1,13 +1,6 @@
|
|||
#include "functionsearchpage.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QHeaderView>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QCoreApplication>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QSet>
|
||||
#include <QLabel>
|
||||
|
||||
FunctionSearchPage::FunctionSearchPage(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
|
|
@ -21,133 +14,10 @@ FunctionSearchPage::~FunctionSearchPage()
|
|||
|
||||
void FunctionSearchPage::initUI()
|
||||
{
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
||||
mainLayout->setContentsMargins(30, 30, 30, 30);
|
||||
mainLayout->setSpacing(15);
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(30, 30, 30, 30);
|
||||
|
||||
m_tabWidget = new QTabWidget;
|
||||
|
||||
// ==========================================
|
||||
// Tab 1: UF20功能搜索
|
||||
// ==========================================
|
||||
QWidget *uf20Tab = new QWidget;
|
||||
QVBoxLayout *uf20Layout = new QVBoxLayout(uf20Tab);
|
||||
uf20Layout->setSpacing(15);
|
||||
|
||||
QHBoxLayout *uf20SearchLayout = new QHBoxLayout;
|
||||
m_uf20SearchEdit = new QLineEdit;
|
||||
m_uf20SearchEdit->setPlaceholderText("输入功能名称或关键词搜索...");
|
||||
m_uf20SearchBtn = new QPushButton("搜索");
|
||||
m_uf20SearchBtn->setStyleSheet("padding: 8px 25px;");
|
||||
connect(m_uf20SearchBtn, &QPushButton::clicked, this, &FunctionSearchPage::onSearchUF20);
|
||||
connect(m_uf20SearchEdit, &QLineEdit::returnPressed, this, &FunctionSearchPage::onSearchUF20);
|
||||
connect(m_uf20SearchEdit, &QLineEdit::textChanged, this, &FunctionSearchPage::onUF20SearchTextChanged);
|
||||
uf20SearchLayout->addWidget(m_uf20SearchEdit);
|
||||
uf20SearchLayout->addWidget(m_uf20SearchBtn);
|
||||
uf20Layout->addLayout(uf20SearchLayout);
|
||||
|
||||
m_uf20ResultTable = new QTableWidget;
|
||||
m_uf20ResultTable->setColumnCount(4);
|
||||
m_uf20ResultTable->setHorizontalHeaderLabels({"功能名称", "功能类型", "所属模块", "文件路径"});
|
||||
m_uf20ResultTable->horizontalHeader()->setStretchLastSection(true);
|
||||
m_uf20ResultTable->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
|
||||
m_uf20ResultTable->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
|
||||
m_uf20ResultTable->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
|
||||
m_uf20ResultTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
m_uf20ResultTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
m_uf20ResultTable->setAlternatingRowColors(true);
|
||||
uf20Layout->addWidget(m_uf20ResultTable);
|
||||
|
||||
m_uf20StatusLabel = new QLabel("请输入关键词搜索UF20功能");
|
||||
uf20Layout->addWidget(m_uf20StatusLabel);
|
||||
|
||||
m_tabWidget->addTab(uf20Tab, "UF20功能");
|
||||
|
||||
// ==========================================
|
||||
// Tab 2: UFT3功能搜索
|
||||
// ==========================================
|
||||
QWidget *uft3Tab = new QWidget;
|
||||
QVBoxLayout *uft3Layout = new QVBoxLayout(uft3Tab);
|
||||
uft3Layout->setSpacing(15);
|
||||
|
||||
QHBoxLayout *uft3SearchLayout = new QHBoxLayout;
|
||||
m_uft3SearchEdit = new QLineEdit;
|
||||
m_uft3SearchEdit->setPlaceholderText("输入功能名称或关键词搜索...");
|
||||
m_uft3SearchBtn = new QPushButton("搜索");
|
||||
m_uft3SearchBtn->setStyleSheet("padding: 8px 25px;");
|
||||
connect(m_uft3SearchBtn, &QPushButton::clicked, this, &FunctionSearchPage::onSearchUFT3);
|
||||
connect(m_uft3SearchEdit, &QLineEdit::returnPressed, this, &FunctionSearchPage::onSearchUFT3);
|
||||
connect(m_uft3SearchEdit, &QLineEdit::textChanged, this, &FunctionSearchPage::onUFT3SearchTextChanged);
|
||||
uft3SearchLayout->addWidget(m_uft3SearchEdit);
|
||||
uft3SearchLayout->addWidget(m_uft3SearchBtn);
|
||||
uft3Layout->addLayout(uft3SearchLayout);
|
||||
|
||||
m_uft3ResultTable = new QTableWidget;
|
||||
m_uft3ResultTable->setColumnCount(4);
|
||||
m_uft3ResultTable->setHorizontalHeaderLabels({"功能名称", "功能类型", "所属模块", "文件路径"});
|
||||
m_uft3ResultTable->horizontalHeader()->setStretchLastSection(true);
|
||||
m_uft3ResultTable->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
|
||||
m_uft3ResultTable->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
|
||||
m_uft3ResultTable->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
|
||||
m_uft3ResultTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
m_uft3ResultTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
m_uft3ResultTable->setAlternatingRowColors(true);
|
||||
uft3Layout->addWidget(m_uft3ResultTable);
|
||||
|
||||
m_uft3StatusLabel = new QLabel("请输入关键词搜索UFT3功能");
|
||||
uft3Layout->addWidget(m_uft3StatusLabel);
|
||||
|
||||
m_tabWidget->addTab(uft3Tab, "UFT3功能");
|
||||
|
||||
mainLayout->addWidget(m_tabWidget);
|
||||
}
|
||||
|
||||
void FunctionSearchPage::onSearchUF20()
|
||||
{
|
||||
QString keyword = m_uf20SearchEdit->text().trimmed();
|
||||
if (keyword.isEmpty()) {
|
||||
m_uf20StatusLabel->setText("请输入搜索关键词");
|
||||
return;
|
||||
}
|
||||
|
||||
m_uf20ResultTable->setRowCount(0);
|
||||
m_uf20StatusLabel->setText(QString("正在搜索 \"%1\"...").arg(keyword));
|
||||
|
||||
m_uf20ResultTable->insertRow(0);
|
||||
m_uf20ResultTable->setItem(0, 0, new QTableWidgetItem(keyword));
|
||||
m_uf20ResultTable->setItem(0, 1, new QTableWidgetItem("-"));
|
||||
m_uf20ResultTable->setItem(0, 2, new QTableWidgetItem("-"));
|
||||
m_uf20ResultTable->setItem(0, 3, new QTableWidgetItem("-"));
|
||||
|
||||
m_uf20StatusLabel->setText(QString("搜索完成,共找到 1 条结果"));
|
||||
}
|
||||
|
||||
void FunctionSearchPage::onSearchUFT3()
|
||||
{
|
||||
QString keyword = m_uft3SearchEdit->text().trimmed();
|
||||
if (keyword.isEmpty()) {
|
||||
m_uft3StatusLabel->setText("请输入搜索关键词");
|
||||
return;
|
||||
}
|
||||
|
||||
m_uft3ResultTable->setRowCount(0);
|
||||
m_uft3StatusLabel->setText(QString("正在搜索 \"%1\"...").arg(keyword));
|
||||
|
||||
m_uft3ResultTable->insertRow(0);
|
||||
m_uft3ResultTable->setItem(0, 0, new QTableWidgetItem(keyword));
|
||||
m_uft3ResultTable->setItem(0, 1, new QTableWidgetItem("-"));
|
||||
m_uft3ResultTable->setItem(0, 2, new QTableWidgetItem("-"));
|
||||
m_uft3ResultTable->setItem(0, 3, new QTableWidgetItem("-"));
|
||||
|
||||
m_uft3StatusLabel->setText(QString("搜索完成,共找到 1 条结果"));
|
||||
}
|
||||
|
||||
void FunctionSearchPage::onUF20SearchTextChanged(const QString &text)
|
||||
{
|
||||
Q_UNUSED(text);
|
||||
}
|
||||
|
||||
void FunctionSearchPage::onUFT3SearchTextChanged(const QString &text)
|
||||
{
|
||||
Q_UNUSED(text);
|
||||
QLabel *label = new QLabel("功能查询");
|
||||
label->setStyleSheet("font-size: 18px; font-weight: bold;");
|
||||
layout->addWidget(label);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,8 @@
|
|||
|
||||
#include <QWidget>
|
||||
#include <QLineEdit>
|
||||
#include <QTabWidget>
|
||||
#include <QTableWidget>
|
||||
#include <QPushButton>
|
||||
#include <QLabel>
|
||||
|
||||
class FunctionSearchPage : public QWidget
|
||||
{
|
||||
|
|
@ -16,26 +14,11 @@ public:
|
|||
explicit FunctionSearchPage(QWidget *parent = nullptr);
|
||||
~FunctionSearchPage();
|
||||
|
||||
private slots:
|
||||
void onSearchUF20();
|
||||
void onSearchUFT3();
|
||||
void onUF20SearchTextChanged(const QString &text);
|
||||
void onUFT3SearchTextChanged(const QString &text);
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
|
||||
QTabWidget *m_tabWidget;
|
||||
|
||||
QLineEdit *m_uf20SearchEdit;
|
||||
QPushButton *m_uf20SearchBtn;
|
||||
QTableWidget *m_uf20ResultTable;
|
||||
QLabel *m_uf20StatusLabel;
|
||||
|
||||
QLineEdit *m_uft3SearchEdit;
|
||||
QPushButton *m_uft3SearchBtn;
|
||||
QTableWidget *m_uft3ResultTable;
|
||||
QLabel *m_uft3StatusLabel;
|
||||
QLineEdit *m_searchEdit;
|
||||
QTableWidget *m_resultTable;
|
||||
};
|
||||
|
||||
#endif // FUNCTIONSEARCHPAGE_H
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -0,0 +1,95 @@
|
|||
#include "uf20functionsearchpage.h"
|
||||
#include "src/utils/datacache.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QTableWidgetItem>
|
||||
#include <QHeaderView>
|
||||
#include <QMessageBox>
|
||||
#include <QComboBox>
|
||||
|
||||
UF20FunctionSearchPage::UF20FunctionSearchPage(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
initUI();
|
||||
}
|
||||
|
||||
UF20FunctionSearchPage::~UF20FunctionSearchPage()
|
||||
{
|
||||
}
|
||||
|
||||
void UF20FunctionSearchPage::initUI()
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(30, 30, 30, 30);
|
||||
layout->setSpacing(20);
|
||||
|
||||
QHBoxLayout *searchLayout = new QHBoxLayout;
|
||||
searchLayout->setSpacing(10);
|
||||
|
||||
m_searchComboBox = new QComboBox;
|
||||
m_searchComboBox->addItem("功能名称", "cname");
|
||||
m_searchComboBox->addItem("功能编号", "function_no");
|
||||
searchLayout->addWidget(m_searchComboBox);
|
||||
|
||||
m_searchEdit = new QLineEdit;
|
||||
m_searchEdit->setPlaceholderText("输入查询内容");
|
||||
m_searchEdit->setMinimumWidth(300);
|
||||
searchLayout->addWidget(m_searchEdit);
|
||||
|
||||
QPushButton *searchBtn = new QPushButton("搜索");
|
||||
searchBtn->setStyleSheet("background-color: #3498db; color: white; padding: 6px 20px; border: none; border-radius: 4px;");
|
||||
connect(searchBtn, &QPushButton::clicked, this, &UF20FunctionSearchPage::onSearch);
|
||||
searchLayout->addWidget(searchBtn);
|
||||
|
||||
searchLayout->addStretch();
|
||||
layout->addLayout(searchLayout);
|
||||
|
||||
m_resultTable = new QTableWidget;
|
||||
m_resultTable->setColumnCount(3);
|
||||
m_resultTable->setHorizontalHeaderLabels({"英文名", "功能编号", "功能名称"});
|
||||
m_resultTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||
m_resultTable->setMinimumHeight(400);
|
||||
m_resultTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
m_resultTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
layout->addWidget(m_resultTable);
|
||||
}
|
||||
|
||||
void UF20FunctionSearchPage::onSearch()
|
||||
{
|
||||
QString keyword = m_searchEdit->text().trimmed();
|
||||
|
||||
m_resultTable->setRowCount(0);
|
||||
|
||||
if (keyword.isEmpty()) {
|
||||
QMessageBox::information(this, "提示", "请输入查询内容");
|
||||
return;
|
||||
}
|
||||
|
||||
QString field = m_searchComboBox->currentData().toString();
|
||||
QList<FunctionInfo> results = DataCache::instance()->searchUF20Functions(keyword, field);
|
||||
|
||||
if (results.isEmpty()) {
|
||||
QMessageBox::information(this, "提示", "未找到匹配的功能");
|
||||
return;
|
||||
}
|
||||
|
||||
int row = 0;
|
||||
for (const FunctionInfo& info : results) {
|
||||
m_resultTable->insertRow(row);
|
||||
|
||||
QTableWidgetItem *cnameItem = new QTableWidgetItem(info.cname);
|
||||
cnameItem->setFlags(cnameItem->flags() & ~Qt::ItemIsEditable);
|
||||
m_resultTable->setItem(row, 0, cnameItem);
|
||||
|
||||
QTableWidgetItem *eNameItem = new QTableWidgetItem(info.eName);
|
||||
eNameItem->setFlags(eNameItem->flags() & ~Qt::ItemIsEditable);
|
||||
m_resultTable->setItem(row, 1, eNameItem);
|
||||
|
||||
QTableWidgetItem *funcNoItem = new QTableWidgetItem(info.functionNo);
|
||||
funcNoItem->setFlags(funcNoItem->flags() & ~Qt::ItemIsEditable);
|
||||
m_resultTable->setItem(row, 2, funcNoItem);
|
||||
|
||||
row++;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef UF20FUNCTIONSEARCHPAGE_H
|
||||
#define UF20FUNCTIONSEARCHPAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLineEdit>
|
||||
#include <QTableWidget>
|
||||
#include <QPushButton>
|
||||
#include <QComboBox>
|
||||
|
||||
class UF20FunctionSearchPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit UF20FunctionSearchPage(QWidget *parent = nullptr);
|
||||
~UF20FunctionSearchPage();
|
||||
|
||||
private slots:
|
||||
void onSearch();
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
|
||||
QComboBox *m_searchComboBox;
|
||||
QLineEdit *m_searchEdit;
|
||||
QTableWidget *m_resultTable;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
#include "uft3functionsearchpage.h"
|
||||
#include "src/utils/datacache.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QTableWidgetItem>
|
||||
#include <QHeaderView>
|
||||
#include <QMessageBox>
|
||||
#include <QComboBox>
|
||||
|
||||
UFT3FunctionSearchPage::UFT3FunctionSearchPage(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
initUI();
|
||||
}
|
||||
|
||||
UFT3FunctionSearchPage::~UFT3FunctionSearchPage()
|
||||
{
|
||||
}
|
||||
|
||||
void UFT3FunctionSearchPage::initUI()
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(30, 30, 30, 30);
|
||||
layout->setSpacing(20);
|
||||
|
||||
QHBoxLayout *searchLayout = new QHBoxLayout;
|
||||
searchLayout->setSpacing(10);
|
||||
|
||||
m_searchComboBox = new QComboBox;
|
||||
m_searchComboBox->addItem("功能名称", "cname");
|
||||
m_searchComboBox->addItem("功能编号", "function_no");
|
||||
searchLayout->addWidget(m_searchComboBox);
|
||||
|
||||
m_searchEdit = new QLineEdit;
|
||||
m_searchEdit->setPlaceholderText("输入查询内容");
|
||||
m_searchEdit->setMinimumWidth(300);
|
||||
searchLayout->addWidget(m_searchEdit);
|
||||
|
||||
QPushButton *searchBtn = new QPushButton("搜索");
|
||||
searchBtn->setStyleSheet("background-color: #3498db; color: white; padding: 6px 20px; border: none; border-radius: 4px;");
|
||||
connect(searchBtn, &QPushButton::clicked, this, &UFT3FunctionSearchPage::onSearch);
|
||||
searchLayout->addWidget(searchBtn);
|
||||
|
||||
searchLayout->addStretch();
|
||||
layout->addLayout(searchLayout);
|
||||
|
||||
m_resultTable = new QTableWidget;
|
||||
m_resultTable->setColumnCount(3);
|
||||
m_resultTable->setHorizontalHeaderLabels({"英文名", "功能编号", "功能名称"});
|
||||
m_resultTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||
m_resultTable->setMinimumHeight(400);
|
||||
m_resultTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
m_resultTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
layout->addWidget(m_resultTable);
|
||||
}
|
||||
|
||||
void UFT3FunctionSearchPage::onSearch()
|
||||
{
|
||||
QString keyword = m_searchEdit->text().trimmed();
|
||||
|
||||
m_resultTable->setRowCount(0);
|
||||
|
||||
if (keyword.isEmpty()) {
|
||||
QMessageBox::information(this, "提示", "请输入查询内容");
|
||||
return;
|
||||
}
|
||||
|
||||
QString field = m_searchComboBox->currentData().toString();
|
||||
QList<FunctionInfo> results = DataCache::instance()->searchUFT3Functions(keyword, field);
|
||||
|
||||
if (results.isEmpty()) {
|
||||
QMessageBox::information(this, "提示", "未找到匹配的功能");
|
||||
return;
|
||||
}
|
||||
|
||||
int row = 0;
|
||||
for (const FunctionInfo& info : results) {
|
||||
m_resultTable->insertRow(row);
|
||||
|
||||
QTableWidgetItem *cnameItem = new QTableWidgetItem(info.cname);
|
||||
cnameItem->setFlags(cnameItem->flags() & ~Qt::ItemIsEditable);
|
||||
m_resultTable->setItem(row, 0, cnameItem);
|
||||
|
||||
QTableWidgetItem *eNameItem = new QTableWidgetItem(info.eName);
|
||||
eNameItem->setFlags(eNameItem->flags() & ~Qt::ItemIsEditable);
|
||||
m_resultTable->setItem(row, 1, eNameItem);
|
||||
|
||||
QTableWidgetItem *funcNoItem = new QTableWidgetItem(info.functionNo);
|
||||
funcNoItem->setFlags(funcNoItem->flags() & ~Qt::ItemIsEditable);
|
||||
m_resultTable->setItem(row, 2, funcNoItem);
|
||||
|
||||
row++;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef UFT3FUNCTIONSEARCHPAGE_H
|
||||
#define UFT3FUNCTIONSEARCHPAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLineEdit>
|
||||
#include <QTableWidget>
|
||||
#include <QPushButton>
|
||||
#include <QComboBox>
|
||||
|
||||
class UFT3FunctionSearchPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit UFT3FunctionSearchPage(QWidget *parent = nullptr);
|
||||
~UFT3FunctionSearchPage();
|
||||
|
||||
private slots:
|
||||
void onSearch();
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
|
||||
QComboBox *m_searchComboBox;
|
||||
QLineEdit *m_searchEdit;
|
||||
QTableWidget *m_resultTable;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -149,7 +149,7 @@ bool DataCache::saveUF20Config(const QString& fileName, const QJsonObject& data)
|
|||
if (!cname.isEmpty()) {
|
||||
cnames.append(cname);
|
||||
eNames.append(obj.value("eName").toString());
|
||||
functionNos.append(obj.value("function_no").toString());
|
||||
functionNos.append(obj.value("functionNo").toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -205,7 +205,7 @@ bool DataCache::saveUFT3Config(const QString& fileName, const QJsonObject& data)
|
|||
if (!cname.isEmpty()) {
|
||||
cnames.append(cname);
|
||||
eNames.append(obj.value("eName").toString());
|
||||
functionNos.append(obj.value("function_no").toString());
|
||||
functionNos.append(obj.value("functionNo").toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -313,6 +313,56 @@ QSet<QString> DataCache::getAllUF20Cnames()
|
|||
return result;
|
||||
}
|
||||
|
||||
QList<FunctionInfo> DataCache::searchUF20Functions(const QString& keyword, const QString& field)
|
||||
{
|
||||
QList<FunctionInfo> result;
|
||||
|
||||
if (!m_db.isOpen()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
QSqlQuery query(m_db);
|
||||
QString sql;
|
||||
|
||||
if (field == "cname") {
|
||||
sql = R"(
|
||||
SELECT cname, e_name, function_no
|
||||
FROM uf20_cname_table
|
||||
WHERE cname LIKE :keyword
|
||||
ORDER BY cname
|
||||
)";
|
||||
} else if (field == "function_no") {
|
||||
sql = R"(
|
||||
SELECT cname, e_name, function_no
|
||||
FROM uf20_cname_table
|
||||
WHERE function_no LIKE :keyword
|
||||
ORDER BY cname
|
||||
)";
|
||||
} else {
|
||||
sql = R"(
|
||||
SELECT cname, e_name, function_no
|
||||
FROM uf20_cname_table
|
||||
WHERE cname LIKE :keyword OR e_name LIKE :keyword OR function_no LIKE :keyword
|
||||
ORDER BY cname
|
||||
)";
|
||||
}
|
||||
|
||||
query.prepare(sql);
|
||||
query.bindValue(":keyword", "%" + keyword + "%");
|
||||
|
||||
if (query.exec()) {
|
||||
while (query.next()) {
|
||||
FunctionInfo info;
|
||||
info.cname = query.value(0).toString();
|
||||
info.eName = query.value(1).toString();
|
||||
info.functionNo = query.value(2).toString();
|
||||
result.append(info);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool DataCache::checkUFT3CnameExists(const QString& cname)
|
||||
{
|
||||
if (!m_db.isOpen()) {
|
||||
|
|
@ -352,6 +402,56 @@ QSet<QString> DataCache::getAllUFT3Cnames()
|
|||
return result;
|
||||
}
|
||||
|
||||
QList<FunctionInfo> DataCache::searchUFT3Functions(const QString& keyword, const QString& field)
|
||||
{
|
||||
QList<FunctionInfo> result;
|
||||
|
||||
if (!m_db.isOpen()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
QSqlQuery query(m_db);
|
||||
QString sql;
|
||||
|
||||
if (field == "cname") {
|
||||
sql = R"(
|
||||
SELECT cname, e_name, function_no
|
||||
FROM uft3_cname_table
|
||||
WHERE cname LIKE :keyword
|
||||
ORDER BY cname
|
||||
)";
|
||||
} else if (field == "function_no") {
|
||||
sql = R"(
|
||||
SELECT cname, e_name, function_no
|
||||
FROM uft3_cname_table
|
||||
WHERE function_no LIKE :keyword
|
||||
ORDER BY cname
|
||||
)";
|
||||
} else {
|
||||
sql = R"(
|
||||
SELECT cname, e_name, function_no
|
||||
FROM uft3_cname_table
|
||||
WHERE cname LIKE :keyword OR e_name LIKE :keyword OR function_no LIKE :keyword
|
||||
ORDER BY cname
|
||||
)";
|
||||
}
|
||||
|
||||
query.prepare(sql);
|
||||
query.bindValue(":keyword", "%" + keyword + "%");
|
||||
|
||||
if (query.exec()) {
|
||||
while (query.next()) {
|
||||
FunctionInfo info;
|
||||
info.cname = query.value(0).toString();
|
||||
info.eName = query.value(1).toString();
|
||||
info.functionNo = query.value(2).toString();
|
||||
result.append(info);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void DataCache::clearCache()
|
||||
{
|
||||
if (!m_db.isOpen()) {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,12 @@
|
|||
#include <QJsonObject>
|
||||
#include <QSet>
|
||||
|
||||
struct FunctionInfo {
|
||||
QString cname;
|
||||
QString eName;
|
||||
QString functionNo;
|
||||
};
|
||||
|
||||
class DataCache : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
@ -25,9 +31,11 @@ public:
|
|||
|
||||
bool checkUF20CnameExists(const QString& cname);
|
||||
QSet<QString> getAllUF20Cnames();
|
||||
QList<FunctionInfo> searchUF20Functions(const QString& keyword, const QString& field = "");
|
||||
|
||||
bool checkUFT3CnameExists(const QString& cname);
|
||||
QSet<QString> getAllUFT3Cnames();
|
||||
QList<FunctionInfo> searchUFT3Functions(const QString& keyword, const QString& field = "");
|
||||
|
||||
void clearCache();
|
||||
|
||||
|
|
|
|||
|
|
@ -152,3 +152,11 @@ void UF2ConfigReader::clearCnameCache()
|
|||
m_cnameCacheLoaded = false;
|
||||
LogManager::instance()->logInfo("Cname缓存已清空");
|
||||
}
|
||||
|
||||
QSet<QString> UF2ConfigReader::getAllCnamesStatic()
|
||||
{
|
||||
if (!m_cnameCacheLoaded) {
|
||||
loadCnameCache();
|
||||
}
|
||||
return m_cnameCache;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ public:
|
|||
bool checkFunctionExists(const QString& funcName);
|
||||
static bool checkFuncExistsStatic(const QString& funcName);
|
||||
static void clearCnameCache();
|
||||
static QSet<QString> getAllCnamesStatic();
|
||||
|
||||
private:
|
||||
static bool loadCnameCache();
|
||||
|
|
|
|||
|
|
@ -152,3 +152,11 @@ void UFT3ConfigReader::clearCnameCache()
|
|||
m_cnameCacheLoaded = false;
|
||||
LogManager::instance()->logInfo("UFT3 Cname缓存已清空");
|
||||
}
|
||||
|
||||
QSet<QString> UFT3ConfigReader::getAllCnamesStatic()
|
||||
{
|
||||
if (!m_cnameCacheLoaded) {
|
||||
loadCnameCache();
|
||||
}
|
||||
return m_cnameCache;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ public:
|
|||
bool checkFunctionExists(const QString& funcName);
|
||||
static bool checkFuncExistsStatic(const QString& funcName);
|
||||
static void clearCnameCache();
|
||||
static QSet<QString> getAllCnamesStatic();
|
||||
|
||||
private:
|
||||
static bool loadCnameCache();
|
||||
|
|
|
|||
Loading…
Reference in New Issue