更新使用手册;修复滚动条问题;新增表映射关系查询
This commit is contained in:
@@ -210,6 +210,21 @@ void MappingTablePage::onModelItemChanged(QStandardItem *item)
|
||||
|
||||
void MappingTablePage::onSave()
|
||||
{
|
||||
QString errorMessage;
|
||||
const SaveResult result = saveToDisk(&errorMessage);
|
||||
if (result == SaveResult::Ok) {
|
||||
QMessageBox::information(this, "提示", "保存成功!");
|
||||
} else if (result == SaveResult::ValidationFailed) {
|
||||
QMessageBox::warning(this, "提示", errorMessage);
|
||||
} else {
|
||||
QMessageBox::critical(this, "错误", errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
MappingTablePage::SaveResult MappingTablePage::saveToDisk(QString *errorMessage)
|
||||
{
|
||||
if (errorMessage) errorMessage->clear();
|
||||
|
||||
// 开启保存窗口: 窗口期内监控事件直接忽略
|
||||
m_monitor->beginSaveWindow();
|
||||
|
||||
@@ -218,8 +233,8 @@ void MappingTablePage::onSave()
|
||||
QFile file(jsonPath);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
m_monitor->endSave(); // 早退必须关闭窗口,否则监控被永久抑制
|
||||
QMessageBox::critical(this, "错误", "无法读取 cust.json!");
|
||||
return;
|
||||
if (errorMessage) *errorMessage = "无法读取 cust.json!";
|
||||
return SaveResult::Error;
|
||||
}
|
||||
const QString rawJson = QString::fromUtf8(file.readAll());
|
||||
file.close();
|
||||
@@ -228,21 +243,21 @@ void MappingTablePage::onSave()
|
||||
QJsonDocument doc = QJsonDocument::fromJson(rawJson.toUtf8(), &error);
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
m_monitor->endSave();
|
||||
QMessageBox::critical(this, "错误", "cust.json 解析失败: " + error.errorString());
|
||||
return;
|
||||
if (errorMessage) *errorMessage = "cust.json 解析失败: " + error.errorString();
|
||||
return SaveResult::Error;
|
||||
}
|
||||
QJsonObject custJson = doc.object();
|
||||
|
||||
// 提取原始 key 顺序
|
||||
const QStringList keyOrder = CustJsonIo::extractTopLevelKeyOrder(rawJson);
|
||||
|
||||
// 子类校验并回填数据: 校验失败置 errorMessage, 弹警告不落盘
|
||||
QString errorMessage;
|
||||
const QHash<QString, QString> overrideRaw = collectMappingData(custJson, errorMessage);
|
||||
if (!errorMessage.isEmpty()) {
|
||||
// 子类校验并回填数据: 校验失败不落盘
|
||||
QString validateError;
|
||||
const QHash<QString, QString> overrideRaw = collectMappingData(custJson, validateError);
|
||||
if (!validateError.isEmpty()) {
|
||||
m_monitor->endSave();
|
||||
QMessageBox::warning(this, "提示", errorMessage);
|
||||
return;
|
||||
if (errorMessage) *errorMessage = validateError;
|
||||
return SaveResult::ValidationFailed;
|
||||
}
|
||||
|
||||
// endSave 以保存后的新 mtime 为基准(writeCustJsonOrdered 同步写完才返回),
|
||||
@@ -254,10 +269,15 @@ void MappingTablePage::onSave()
|
||||
if (writeOk) {
|
||||
m_dirty = false; // 保存成功后与磁盘内容一致
|
||||
LogManager::instance()->logInfo(saveLogText(m_model->rowCount()));
|
||||
QMessageBox::information(this, "提示", "保存成功!");
|
||||
} else {
|
||||
QMessageBox::critical(this, "错误", "保存到 cust.json 失败!");
|
||||
onSavedToDisk(); // 落盘成功钩子(表替换页覆写: 同步 table_mapping.json)
|
||||
return SaveResult::Ok;
|
||||
}
|
||||
if (errorMessage) *errorMessage = "保存到 cust.json 失败!";
|
||||
return SaveResult::Error;
|
||||
}
|
||||
|
||||
void MappingTablePage::onSavedToDisk()
|
||||
{
|
||||
}
|
||||
|
||||
void MappingTablePage::onReloadRequested()
|
||||
|
||||
Reference in New Issue
Block a user