修复转码模块缺失问题
This commit is contained in:
parent
4cb44fc2fa
commit
fad539e127
|
|
@ -123,10 +123,10 @@ QString Uf2Interface::getModuleEName(const QString& moduleXmlPath)
|
||||||
QXmlStreamReader::TokenType token = xml.readNext();
|
QXmlStreamReader::TokenType token = xml.readNext();
|
||||||
if (token == QXmlStreamReader::StartElement) {
|
if (token == QXmlStreamReader::StartElement) {
|
||||||
QString elementName = xml.name().toString();
|
QString elementName = xml.name().toString();
|
||||||
if (elementName == "basic") {
|
if (elementName == "info") {
|
||||||
QXmlStreamAttributes attrs = xml.attributes();
|
QXmlStreamAttributes attrs = xml.attributes();
|
||||||
if (attrs.hasAttribute("englishName")) {
|
if (attrs.hasAttribute("ename")) {
|
||||||
return attrs.value("englishName").toString();
|
return attrs.value("ename").toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -144,18 +144,14 @@ bool Uf2Interface::shouldFilter(const QString& filePath,
|
||||||
QString fileName = fileInfo.fileName();
|
QString fileName = fileInfo.fileName();
|
||||||
|
|
||||||
if (completeNameList.contains(fileName)) {
|
if (completeNameList.contains(fileName)) {
|
||||||
LogManager::instance()->log(QString("过滤文件(文件名匹配): %1").arg(filePath));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const QString& name : containNameList) {
|
for (const QString& name : containNameList) {
|
||||||
if (filePath.contains(name, Qt::CaseInsensitive)) {
|
if (filePath.contains(name, Qt::CaseInsensitive)) {
|
||||||
LogManager::instance()->log(QString("过滤文件(路径包含): %1").arg(filePath));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LogManager::instance()->log(QString("保留文件: %1").arg(filePath));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -171,7 +167,8 @@ QMap<QString, InterfaceInfo> Uf2Interface::scanDir(const QString& dirPath,
|
||||||
QMap<QString, QString> moduleCodeMap;
|
QMap<QString, QString> moduleCodeMap;
|
||||||
moduleCodeMap["转融通"] = "ref";
|
moduleCodeMap["转融通"] = "ref";
|
||||||
|
|
||||||
auto scanModuleXml = [&](const QString& path) {
|
std::function<void(const QString&)> scanModuleXmlRecursive;
|
||||||
|
scanModuleXmlRecursive = [&](const QString& path) {
|
||||||
if (path.isEmpty()) return;
|
if (path.isEmpty()) return;
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
QStringList filters;
|
QStringList filters;
|
||||||
|
|
@ -191,26 +188,16 @@ QMap<QString, InterfaceInfo> Uf2Interface::scanDir(const QString& dirPath,
|
||||||
moduleCodeMap[modName] = modEName;
|
moduleCodeMap[modName] = modEName;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDir subDirs(path);
|
QFileInfoList dirList = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
QFileInfoList dirList = subDirs.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
|
||||||
for (const QFileInfo& dirInfo : dirList) {
|
for (const QFileInfo& dirInfo : dirList) {
|
||||||
QDir subDir(dirInfo.absoluteFilePath());
|
scanModuleXmlRecursive(dirInfo.absoluteFilePath());
|
||||||
QFileInfoList subFileList = subDir.entryInfoList(filters, QDir::Files);
|
|
||||||
for (const QFileInfo& fileInfo : subFileList) {
|
|
||||||
QString filePath = fileInfo.absoluteFilePath();
|
|
||||||
filePath.replace('\\', '/');
|
|
||||||
|
|
||||||
if (filePath.contains("/数据库/")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString modName = fileInfo.dir().dirName();
|
|
||||||
QString modEName = getModuleEName(filePath);
|
|
||||||
moduleCodeMap[modName] = modEName;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
auto scanModuleXml = [&](const QString& path) {
|
||||||
|
scanModuleXmlRecursive(path);
|
||||||
|
};
|
||||||
|
|
||||||
scanModuleXml(dirPath);
|
scanModuleXml(dirPath);
|
||||||
scanModuleXml(ufAcct20ProjectDir);
|
scanModuleXml(ufAcct20ProjectDir);
|
||||||
scanModuleXml(uftDbSett);
|
scanModuleXml(uftDbSett);
|
||||||
|
|
@ -237,10 +224,18 @@ QMap<QString, InterfaceInfo> Uf2Interface::scanDir(const QString& dirPath,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString modName = fileInfo.dir().dirName();
|
QString sFilePath = filePath;
|
||||||
|
int lastSlash = sFilePath.lastIndexOf('/');
|
||||||
|
QString pathWithoutFile = sFilePath.left(lastSlash);
|
||||||
|
int secondLastSlash = pathWithoutFile.lastIndexOf('/');
|
||||||
|
QString pathWithoutLastDir = pathWithoutFile.left(secondLastSlash);
|
||||||
|
int thirdLastSlash = pathWithoutLastDir.lastIndexOf('/');
|
||||||
|
QString modName = pathWithoutLastDir.mid(thirdLastSlash + 1);
|
||||||
|
|
||||||
InterfaceInfo interfaceInfo = loadInterface(filePath);
|
InterfaceInfo interfaceInfo = loadInterface(filePath);
|
||||||
interfaceInfo.moudle = modName;
|
interfaceInfo.moudle = modName;
|
||||||
interfaceInfo.moudleEName = moduleCodeMap.value(modName);
|
QString moudleEName = moduleCodeMap.value(modName);
|
||||||
|
interfaceInfo.moudleEName = moudleEName;
|
||||||
interfaceInfo.serverType = serverType;
|
interfaceInfo.serverType = serverType;
|
||||||
|
|
||||||
QString key = interfaceInfo.cname;
|
QString key = interfaceInfo.cname;
|
||||||
|
|
|
||||||
|
|
@ -61,12 +61,15 @@ void Uft3Table::parseTableFile(const QString& filePath, QMap<QString, QMap<QStri
|
||||||
sFilePath.replace('\\', '/');
|
sFilePath.replace('\\', '/');
|
||||||
|
|
||||||
QFile file(sFilePath);
|
QFile file(sFilePath);
|
||||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if (!file.open(QIODevice::ReadOnly)) {
|
||||||
LogManager::instance()->logError(QString("无法打开表结构文件: %1").arg(sFilePath));
|
LogManager::instance()->logError(QString("无法打开表结构文件: %1").arg(sFilePath));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QXmlStreamReader xml(&file);
|
QByteArray data = file.readAll();
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
QXmlStreamReader xml(data);
|
||||||
|
|
||||||
QString tableEngName = "";
|
QString tableEngName = "";
|
||||||
QString tablePath = "";
|
QString tablePath = "";
|
||||||
|
|
@ -96,12 +99,18 @@ void Uft3Table::parseTableFile(const QString& filePath, QMap<QString, QMap<QStri
|
||||||
QString elementName = xml.name().toString();
|
QString elementName = xml.name().toString();
|
||||||
QXmlStreamAttributes attrs = xml.attributes();
|
QXmlStreamAttributes attrs = xml.attributes();
|
||||||
|
|
||||||
if (elementName == "uftstructure") {
|
if (elementName == "Structure") {
|
||||||
chineseName = attrs.value("chineseName").toString();
|
if (attrs.hasAttribute("chineseName")) {
|
||||||
objectId = attrs.value("objectId").toString();
|
chineseName = attrs.value("chineseName").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attrs.hasAttribute("objectId")) {
|
||||||
|
objectId = attrs.value("objectId").toString();
|
||||||
|
}
|
||||||
|
|
||||||
if (attrs.hasAttribute("space")) {
|
if (attrs.hasAttribute("space")) {
|
||||||
spaceName = attrs.value("space").toString();
|
spaceName = attrs.value("space").toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (elementName == "properties") {
|
else if (elementName == "properties") {
|
||||||
QString fieldId = attrs.value("id").toString();
|
QString fieldId = attrs.value("id").toString();
|
||||||
|
|
@ -146,8 +155,6 @@ void Uft3Table::parseTableFile(const QString& filePath, QMap<QString, QMap<QStri
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
file.close();
|
|
||||||
|
|
||||||
QString sUser = "";
|
QString sUser = "";
|
||||||
if (spaceName == "HS_UFT_DATA") {
|
if (spaceName == "HS_UFT_DATA") {
|
||||||
sUser = "hs_uft";
|
sUser = "hs_uft";
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,8 @@ void BatchConvertPage::initUI()
|
||||||
layout->addWidget(progressBox);
|
layout->addWidget(progressBox);
|
||||||
|
|
||||||
QHBoxLayout *btnLayout = new QHBoxLayout;
|
QHBoxLayout *btnLayout = new QHBoxLayout;
|
||||||
m_startBtn = new ElaPushButton("开始转换");
|
m_startBtn = new QPushButton("开始转换");
|
||||||
|
m_startBtn->setStyleSheet("background-color: #1abc9c; color: white; padding: 10px 30px; font-size: 14px; border: none; border-radius: 4px;");
|
||||||
connect(m_startBtn, &QPushButton::clicked, this, &BatchConvertPage::onStartConvert);
|
connect(m_startBtn, &QPushButton::clicked, this, &BatchConvertPage::onStartConvert);
|
||||||
btnLayout->addStretch();
|
btnLayout->addStretch();
|
||||||
btnLayout->addWidget(m_startBtn);
|
btnLayout->addWidget(m_startBtn);
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
|
#include <QPushButton>
|
||||||
#include "ElaLineEdit.h"
|
#include "ElaLineEdit.h"
|
||||||
#include "ElaPushButton.h"
|
|
||||||
#include "ElaTableView.h"
|
#include "ElaTableView.h"
|
||||||
#include "ElaProgressBar.h"
|
#include "ElaProgressBar.h"
|
||||||
#include "ElaText.h"
|
#include "ElaText.h"
|
||||||
|
|
@ -50,7 +50,7 @@ private:
|
||||||
QStringList m_funcList;
|
QStringList m_funcList;
|
||||||
ElaProgressBar *m_progressBar;
|
ElaProgressBar *m_progressBar;
|
||||||
ElaText *m_progressLabel;
|
ElaText *m_progressLabel;
|
||||||
ElaPushButton *m_startBtn;
|
QPushButton *m_startBtn;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QStandardItem>
|
#include <QStandardItem>
|
||||||
|
#include <QLineEdit>
|
||||||
#include "ElaComboBox.h"
|
#include "ElaComboBox.h"
|
||||||
#include "ElaLineEdit.h"
|
#include "ElaLineEdit.h"
|
||||||
#include "ElaPushButton.h"
|
#include "ElaPushButton.h"
|
||||||
|
|
@ -38,6 +39,7 @@ void UF20FunctionSearchPage::initUI()
|
||||||
m_searchEdit = new ElaLineEdit;
|
m_searchEdit = new ElaLineEdit;
|
||||||
m_searchEdit->setPlaceholderText("输入查询内容");
|
m_searchEdit->setPlaceholderText("输入查询内容");
|
||||||
m_searchEdit->setMinimumWidth(300);
|
m_searchEdit->setMinimumWidth(300);
|
||||||
|
connect(m_searchEdit, &QLineEdit::returnPressed, this, &UF20FunctionSearchPage::onSearch);
|
||||||
searchLayout->addWidget(m_searchEdit);
|
searchLayout->addWidget(m_searchEdit);
|
||||||
|
|
||||||
ElaPushButton *searchBtn = new ElaPushButton("搜索");
|
ElaPushButton *searchBtn = new ElaPushButton("搜索");
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QStandardItem>
|
#include <QStandardItem>
|
||||||
|
#include <QLineEdit>
|
||||||
#include "ElaComboBox.h"
|
#include "ElaComboBox.h"
|
||||||
#include "ElaLineEdit.h"
|
#include "ElaLineEdit.h"
|
||||||
#include "ElaPushButton.h"
|
#include "ElaPushButton.h"
|
||||||
|
|
@ -37,6 +38,7 @@ void UFT3FunctionSearchPage::initUI()
|
||||||
m_searchEdit = new ElaLineEdit;
|
m_searchEdit = new ElaLineEdit;
|
||||||
m_searchEdit->setPlaceholderText("输入查询内容");
|
m_searchEdit->setPlaceholderText("输入查询内容");
|
||||||
m_searchEdit->setMinimumWidth(300);
|
m_searchEdit->setMinimumWidth(300);
|
||||||
|
connect(m_searchEdit, &QLineEdit::returnPressed, this, &UFT3FunctionSearchPage::onSearch);
|
||||||
searchLayout->addWidget(m_searchEdit);
|
searchLayout->addWidget(m_searchEdit);
|
||||||
|
|
||||||
ElaPushButton *searchBtn = new ElaPushButton("搜索");
|
ElaPushButton *searchBtn = new ElaPushButton("搜索");
|
||||||
|
|
@ -48,7 +50,7 @@ void UFT3FunctionSearchPage::initUI()
|
||||||
|
|
||||||
m_tableModel = new QStandardItemModel(this);
|
m_tableModel = new QStandardItemModel(this);
|
||||||
m_tableModel->setColumnCount(3);
|
m_tableModel->setColumnCount(3);
|
||||||
m_tableModel->setHorizontalHeaderLabels({"英文名", "功能编号", "功能名称"});
|
m_tableModel->setHorizontalHeaderLabels({"功能名称", "英文名", "功能编号"});
|
||||||
|
|
||||||
m_resultTable = new ElaTableView;
|
m_resultTable = new ElaTableView;
|
||||||
m_resultTable->setModel(m_tableModel);
|
m_resultTable->setModel(m_tableModel);
|
||||||
|
|
|
||||||
|
|
@ -245,12 +245,14 @@ void MetadataUpdatePage::onUpdateUFT3()
|
||||||
void MetadataUpdatePage::updateUf2Interfaces(const QStringList& items)
|
void MetadataUpdatePage::updateUf2Interfaces(const QStringList& items)
|
||||||
{
|
{
|
||||||
int itemCount = items.size();
|
int itemCount = items.size();
|
||||||
|
bool interfaceUpdated = false;
|
||||||
|
|
||||||
foreach (const QString& item, items) {
|
foreach (const QString& item, items) {
|
||||||
_processLabel->setText(QString("正在更新UF20 - %1").arg(item));
|
_processLabel->setText(QString("正在更新UF20 - %1").arg(item));
|
||||||
int currentIndex = items.indexOf(item);
|
int currentIndex = items.indexOf(item);
|
||||||
int progress = (itemCount == 1) ? 0 : (currentIndex * 100 / itemCount);
|
int progress = (itemCount == 1) ? 0 : (currentIndex * 100 / itemCount);
|
||||||
_progressBar->setValue(progress);
|
_progressBar->setValue(progress);
|
||||||
|
QCoreApplication::processEvents();
|
||||||
|
|
||||||
if (item == "标准字段") {
|
if (item == "标准字段") {
|
||||||
processUf2StdFields();
|
processUf2StdFields();
|
||||||
|
|
@ -261,9 +263,14 @@ void MetadataUpdatePage::updateUf2Interfaces(const QStringList& items)
|
||||||
} else if (item == "接口数据") {
|
} else if (item == "接口数据") {
|
||||||
QString basePath = QCoreApplication::applicationDirPath();
|
QString basePath = QCoreApplication::applicationDirPath();
|
||||||
processUf2Interface(basePath);
|
processUf2Interface(basePath);
|
||||||
|
interfaceUpdated = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (interfaceUpdated) {
|
||||||
|
_processLabel->setText("正在更新数据缓存...");
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
|
UF2ConfigReader::reloadUF20Config();
|
||||||
}
|
}
|
||||||
|
|
||||||
_progressBar->setValue(100);
|
_progressBar->setValue(100);
|
||||||
|
|
@ -275,12 +282,14 @@ void MetadataUpdatePage::updateUf2Interfaces(const QStringList& items)
|
||||||
void MetadataUpdatePage::updateUft3Interfaces(const QStringList& items)
|
void MetadataUpdatePage::updateUft3Interfaces(const QStringList& items)
|
||||||
{
|
{
|
||||||
int itemCount = items.size();
|
int itemCount = items.size();
|
||||||
|
bool interfaceUpdated = false;
|
||||||
|
|
||||||
foreach (const QString& item, items) {
|
foreach (const QString& item, items) {
|
||||||
_processLabel->setText(QString("正在更新UFT30 - %1").arg(item));
|
_processLabel->setText(QString("正在更新UFT30 - %1").arg(item));
|
||||||
int currentIndex = items.indexOf(item);
|
int currentIndex = items.indexOf(item);
|
||||||
int progress = (itemCount == 1) ? 0 : (currentIndex * 100 / itemCount);
|
int progress = (itemCount == 1) ? 0 : (currentIndex * 100 / itemCount);
|
||||||
_progressBar->setValue(progress);
|
_progressBar->setValue(progress);
|
||||||
|
QCoreApplication::processEvents();
|
||||||
|
|
||||||
if (item == "标准字段") {
|
if (item == "标准字段") {
|
||||||
processUft3StdFields();
|
processUft3StdFields();
|
||||||
|
|
@ -291,9 +300,14 @@ void MetadataUpdatePage::updateUft3Interfaces(const QStringList& items)
|
||||||
} else if (item == "接口数据") {
|
} else if (item == "接口数据") {
|
||||||
QString basePath = QCoreApplication::applicationDirPath();
|
QString basePath = QCoreApplication::applicationDirPath();
|
||||||
processUft3Interface(basePath);
|
processUft3Interface(basePath);
|
||||||
|
interfaceUpdated = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (interfaceUpdated) {
|
||||||
|
_processLabel->setText("正在更新数据缓存...");
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
|
UFT3ConfigReader::reloadUFT3Config();
|
||||||
}
|
}
|
||||||
|
|
||||||
_progressBar->setValue(100);
|
_progressBar->setValue(100);
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@
|
||||||
#include "ElaProgressBar.h"
|
#include "ElaProgressBar.h"
|
||||||
#include "ElaCheckBox.h"
|
#include "ElaCheckBox.h"
|
||||||
#include "metadataupdate/metadataprocessor.h"
|
#include "metadataupdate/metadataprocessor.h"
|
||||||
|
#include "utils/uf2configreader.h"
|
||||||
|
#include "utils/uft3configreader.h"
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
|
||||||
|
|
@ -105,8 +105,9 @@ bool DataCache::initDatabase()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_db.exec("PRAGMA synchronous = OFF");
|
QSqlQuery query(m_db);
|
||||||
m_db.exec("PRAGMA journal_mode = MEMORY");
|
query.exec("PRAGMA synchronous = OFF");
|
||||||
|
query.exec("PRAGMA journal_mode = MEMORY");
|
||||||
|
|
||||||
LogManager::instance()->log("数据缓存 - 数据库打开成功");
|
LogManager::instance()->log("数据缓存 - 数据库打开成功");
|
||||||
return createTables();
|
return createTables();
|
||||||
|
|
@ -122,16 +123,12 @@ void DataCache::setDataLoaded(bool loaded)
|
||||||
m_dataLoaded = loaded;
|
m_dataLoaded = loaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DataCache::saveUF20Config(const QString& fileName, const QJsonObject& data)
|
bool DataCache::saveUF20Config(const QJsonObject& data)
|
||||||
{
|
{
|
||||||
if (!m_db.isOpen()) {
|
if (!m_db.isOpen()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileName != "uf2.json") {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
QElapsedTimer timer;
|
QElapsedTimer timer;
|
||||||
timer.start();
|
timer.start();
|
||||||
|
|
||||||
|
|
@ -178,16 +175,12 @@ bool DataCache::saveUF20Config(const QString& fileName, const QJsonObject& data)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DataCache::saveUFT3Config(const QString& fileName, const QJsonObject& data)
|
bool DataCache::saveUFT3Config(const QJsonObject& data)
|
||||||
{
|
{
|
||||||
if (!m_db.isOpen()) {
|
if (!m_db.isOpen()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileName != "uft3.json") {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
QElapsedTimer timer;
|
QElapsedTimer timer;
|
||||||
timer.start();
|
timer.start();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@ public:
|
||||||
bool isDataLoaded() const;
|
bool isDataLoaded() const;
|
||||||
void setDataLoaded(bool loaded);
|
void setDataLoaded(bool loaded);
|
||||||
|
|
||||||
bool saveUF20Config(const QString& fileName, const QJsonObject& data);
|
bool saveUF20Config(const QJsonObject& data);
|
||||||
bool saveUFT3Config(const QString& fileName, const QJsonObject& data);
|
bool saveUFT3Config(const QJsonObject& data);
|
||||||
|
|
||||||
bool hasUF20Config(const QString& fileName);
|
bool hasUF20Config(const QString& fileName);
|
||||||
bool hasUFT3Config(const QString& fileName);
|
bool hasUFT3Config(const QString& fileName);
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,8 @@ bool UF2ConfigReader::loadAllUF20Config()
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject config = doc.object();
|
QJsonObject config = doc.object();
|
||||||
if (!DataCache::instance()->saveUF20Config("uf2.json", config)) {
|
if (!DataCache::instance()->saveUF20Config(config)) {
|
||||||
LogManager::instance()->logError("UF20配置加载失败 - 保存失败: uf2.json");
|
LogManager::instance()->logError("UF20配置加载失败 - 保存失败");
|
||||||
m_failedFiles.append("uf2.json");
|
m_failedFiles.append("uf2.json");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -93,7 +93,7 @@ bool UF2ConfigReader::reloadUF20Config()
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject config = doc.object();
|
QJsonObject config = doc.object();
|
||||||
if (!DataCache::instance()->saveUF20Config("uf2.json", config)) {
|
if (!DataCache::instance()->saveUF20Config(config)) {
|
||||||
LogManager::instance()->logError("UF20配置重新加载失败 - 保存失败: uf2.json");
|
LogManager::instance()->logError("UF20配置重新加载失败 - 保存失败: uf2.json");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ public:
|
||||||
explicit UF2ConfigReader(QObject *parent = nullptr);
|
explicit UF2ConfigReader(QObject *parent = nullptr);
|
||||||
|
|
||||||
bool loadAllUF20Config();
|
bool loadAllUF20Config();
|
||||||
bool reloadUF20Config();
|
static bool reloadUF20Config();
|
||||||
|
|
||||||
bool isUF20Loaded() const;
|
bool isUF20Loaded() const;
|
||||||
QStringList getFailedFiles() const;
|
QStringList getFailedFiles() const;
|
||||||
|
|
@ -26,7 +26,7 @@ public:
|
||||||
private:
|
private:
|
||||||
static bool loadCnameCache();
|
static bool loadCnameCache();
|
||||||
|
|
||||||
QString getBinPath();
|
static QString getBinPath();
|
||||||
|
|
||||||
QStringList m_failedFiles;
|
QStringList m_failedFiles;
|
||||||
bool m_loaded;
|
bool m_loaded;
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,8 @@ bool UFT3ConfigReader::loadAllUFT3Config()
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject config = doc.object();
|
QJsonObject config = doc.object();
|
||||||
if (!DataCache::instance()->saveUFT3Config("uft3.json", config)) {
|
if (!DataCache::instance()->saveUFT3Config(config)) {
|
||||||
LogManager::instance()->logError("UFT3配置加载失败 - 保存失败: uft3.json");
|
LogManager::instance()->logError("UFT3配置加载失败 - 保存失败");
|
||||||
m_failedFiles.append("uft3.json");
|
m_failedFiles.append("uft3.json");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -75,26 +75,45 @@ QStringList UFT3ConfigReader::getFailedFiles() const
|
||||||
bool UFT3ConfigReader::reloadUFT3Config()
|
bool UFT3ConfigReader::reloadUFT3Config()
|
||||||
{
|
{
|
||||||
QString binPath = getBinPath();
|
QString binPath = getBinPath();
|
||||||
QString filePath = binPath + "/uft3.json";
|
QString filePath1 = binPath + "/uft3.json";
|
||||||
|
QString filePath2 = binPath + "/uft3Trans.json";
|
||||||
|
|
||||||
QFile file(filePath);
|
QJsonObject mergedConfig;
|
||||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
|
||||||
LogManager::instance()->logError(QString("UFT3配置重新加载失败 - 无法打开文件: %1").arg(filePath));
|
QFile file1(filePath1);
|
||||||
|
if (file1.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
|
QByteArray data1 = file1.readAll();
|
||||||
|
QJsonDocument doc1 = QJsonDocument::fromJson(data1);
|
||||||
|
if (!doc1.isNull() && doc1.isObject()) {
|
||||||
|
mergedConfig = doc1.object();
|
||||||
|
}
|
||||||
|
file1.close();
|
||||||
|
} else {
|
||||||
|
LogManager::instance()->logWarning(QString("UFT3配置重新加载 - 无法打开文件: %1").arg(filePath1));
|
||||||
|
}
|
||||||
|
|
||||||
|
QFile file2(filePath2);
|
||||||
|
if (file2.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
|
QByteArray data2 = file2.readAll();
|
||||||
|
QJsonDocument doc2 = QJsonDocument::fromJson(data2);
|
||||||
|
if (!doc2.isNull() && doc2.isObject()) {
|
||||||
|
QJsonObject transConfig = doc2.object();
|
||||||
|
for (auto it = transConfig.begin(); it != transConfig.end(); ++it) {
|
||||||
|
mergedConfig[it.key()] = it.value();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file2.close();
|
||||||
|
} else {
|
||||||
|
LogManager::instance()->logWarning(QString("UFT3配置重新加载 - 无法打开文件: %1").arg(filePath2));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mergedConfig.isEmpty()) {
|
||||||
|
LogManager::instance()->logError("UFT3配置重新加载失败 - 两个JSON文件都无效");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray data = file.readAll();
|
if (!DataCache::instance()->saveUFT3Config(mergedConfig)) {
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(data);
|
LogManager::instance()->logError("UFT3配置重新加载失败 - 保存失败");
|
||||||
file.close();
|
|
||||||
|
|
||||||
if (doc.isNull() || !doc.isObject()) {
|
|
||||||
LogManager::instance()->logError(QString("UFT3配置重新加载失败 - JSON解析失败: %1").arg(filePath));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QJsonObject config = doc.object();
|
|
||||||
if (!DataCache::instance()->saveUFT3Config("uft3.json", config)) {
|
|
||||||
LogManager::instance()->logError("UFT3配置重新加载失败 - 保存失败: uft3.json");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ public:
|
||||||
explicit UFT3ConfigReader(QObject *parent = nullptr);
|
explicit UFT3ConfigReader(QObject *parent = nullptr);
|
||||||
|
|
||||||
bool loadAllUFT3Config();
|
bool loadAllUFT3Config();
|
||||||
bool reloadUFT3Config();
|
static bool reloadUFT3Config();
|
||||||
|
|
||||||
bool isUFT3Loaded() const;
|
bool isUFT3Loaded() const;
|
||||||
QStringList getFailedFiles() const;
|
QStringList getFailedFiles() const;
|
||||||
|
|
@ -26,7 +26,7 @@ public:
|
||||||
private:
|
private:
|
||||||
static bool loadCnameCache();
|
static bool loadCnameCache();
|
||||||
|
|
||||||
QString getBinPath();
|
static QString getBinPath();
|
||||||
|
|
||||||
QStringList m_failedFiles;
|
QStringList m_failedFiles;
|
||||||
bool m_loaded;
|
bool m_loaded;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue