From bbde72e1de0e52c47f79b2755e0b6d12c6d04f32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B5=B7?= Date: Wed, 25 Mar 2026 13:59:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B7=B2=E7=9F=A5BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MeasureAnalysisProjectModel.cpp | 89 ++++++++++++----------------- src/MeasureAnalysisProjectModel.h | 1 + 2 files changed, 38 insertions(+), 52 deletions(-) diff --git a/src/MeasureAnalysisProjectModel.cpp b/src/MeasureAnalysisProjectModel.cpp index 64a8b98..e7d2041 100644 --- a/src/MeasureAnalysisProjectModel.cpp +++ b/src/MeasureAnalysisProjectModel.cpp @@ -348,6 +348,7 @@ bool MeasureAnalysisProjectModel::LoadProjectModel(const QString& project_filena bool MeasureAnalysisProjectModel::SaveProjectModel() { + _save_mutex.lock(); auto ProjectRelativeFilename = [this](const QString& abs_filename) { QString project_relative_filename; if ( !abs_filename.isEmpty() ) { @@ -407,6 +408,8 @@ bool MeasureAnalysisProjectModel::SaveProjectModel() } json_file.write(json_doc.toJson()); json_file.close(); + + _save_mutex.unlock(); return true; } @@ -616,8 +619,10 @@ void MeasureAnalysisProjectModelList::SetNodeStatus(QStandardItem* item, const Q status_item->setText(status); status_item->setData(state_ok, Qt::UserRole); if (state_ok) { + item->setForeground(Qt::black); status_item->setForeground(Qt::black); } else { + item->setForeground(Qt::gray); status_item->setForeground(Qt::gray); } } @@ -640,14 +645,16 @@ void MeasureAnalysisProjectModelList::ApplyEnergyScale(const QString &project_na if (this->_project_models.contains(project_name)) { auto pro_model = this->_project_models[project_name]; const QString& energy_scale_filename = pro_model->GetEnergyScaleFilename(); + bool status_ok = false; QString status = QStringLiteral(u"未配置"); if (!energy_scale_filename.isEmpty()) { + status_ok = true; status = QStringLiteral(u"已配置"); auto& node_map = this->_project_node_items[project_name]; const QString& energy_scale_item_name = QStringLiteral(u"能量刻度"); if (node_map.contains(energy_scale_item_name)) { auto energy_scale_item = node_map[energy_scale_item_name]; - this->SetNodeStatus(energy_scale_item, status); + this->SetNodeStatus(energy_scale_item, status, status_ok); } pro_model->SaveProjectModel(); @@ -669,20 +676,22 @@ void MeasureAnalysisProjectModelList::onChannelAddressCountProcessFinished(bool if (this->_project_models.contains(project_name)) { auto pro_model = this->_project_models[project_name]; const QMap& filename_list = pro_model->GetChannelAddressCountDataFilenameList(); + bool status_ok = false; QString status = QStringLiteral(u"无效"); if (!filename_list.isEmpty()) { + status_ok = true; status = QStringLiteral(u"有效"); } auto& node_map = this->_project_node_items[project_name]; const QString& adrr_count_item_name = QStringLiteral(u"道址计数"); if (node_map.contains(adrr_count_item_name)) { auto adrr_count_item = node_map[adrr_count_item_name]; - this->SetNodeStatus(adrr_count_item, status); + this->SetNodeStatus(adrr_count_item, status, status_ok); for (auto it = filename_list.begin(); it != filename_list.end(); ++it) { uint ch_num = it.key(); QString item_name = QStringLiteral(u"通道%1道址计数").arg(ch_num); const QVariant& analys_type = QVariant::fromValue(AnalysisType::AddressCountData); - QStandardItem* node_item = AddChildNode(adrr_count_item, item_name, status, analys_type, true); + QStandardItem* node_item = AddChildNode(adrr_count_item, item_name, status, analys_type, true, status_ok); node_item->setData(project_name, ProjectName); node_item->setData(ch_num, ChannelNum); node_map[item_name] = node_item; @@ -691,7 +700,7 @@ void MeasureAnalysisProjectModelList::onChannelAddressCountProcessFinished(bool const QString& adrr_count_spec_item_name = QStringLiteral(u"道址计数谱"); if (node_map.contains(adrr_count_spec_item_name)) { auto adrr_count_spec_item = node_map[adrr_count_spec_item_name]; - this->SetNodeStatus(adrr_count_spec_item, status); + this->SetNodeStatus(adrr_count_spec_item, status, status_ok); } pro_model->SaveProjectModel(); } @@ -705,30 +714,31 @@ void MeasureAnalysisProjectModelList::onEnergyScaleParticleDataFinished(bool ok, if (this->_project_models.contains(project_name)) { auto pro_model = this->_project_models[project_name]; auto& node_map = this->_project_node_items[project_name]; + bool status_ok = false; QString status = QStringLiteral(u"无效"); - - const QString& energy_total_count_filename = pro_model->GetAllChannelEnergyTotalCountDataFilename(); - if (!energy_total_count_filename.isEmpty()) { + const QString& particle_energy_data_filename = pro_model->GetParticleEnergyDataFilename(); + if (!particle_energy_data_filename.isEmpty()) { + status_ok = true; status = QStringLiteral(u"有效"); - const QString& energy_total_count_item_name = QStringLiteral(u"能量计数"); - if (node_map.contains(energy_total_count_item_name)) { - auto energy_total_count_item = node_map[energy_total_count_item_name]; - this->SetNodeStatus(energy_total_count_item, status); - const QMap& channel_energy_count_filename_list = pro_model->GetChannelEnergyCountDataFilenameList(); - for (auto it = channel_energy_count_filename_list.constBegin(); it != channel_energy_count_filename_list.constEnd(); ++it) { - uint ch_num = it.key(); - QString item_name = QStringLiteral(u"通道%1能量计数").arg(ch_num); - const QVariant& analys_type = QVariant::fromValue(AnalysisType::EnergyCountData); - QStandardItem* node_item = AddChildNode(energy_total_count_item, item_name, status, analys_type, true); - node_item->setData(project_name, ProjectName); - node_item->setData(ch_num, ChannelNum); - node_map[item_name] = node_item; - } - const QString& adrr_count_spec_item_name = QStringLiteral(u"能量计数谱"); - if (node_map.contains(adrr_count_spec_item_name)) { - auto adrr_count_spec_item = node_map[adrr_count_spec_item_name]; - this->SetNodeStatus(adrr_count_spec_item, status); - } + const QString& count_rate_analysis_item_name = QStringLiteral(u"计数率分析"); + if (node_map.contains(count_rate_analysis_item_name)) { + auto energy_total_count_spec_item = node_map[count_rate_analysis_item_name]; + this->SetNodeStatus(energy_total_count_spec_item, status, status_ok); + } + const QString& peak_fit_analysis_item_name = QStringLiteral(u"峰拟合分析"); + if (node_map.contains(peak_fit_analysis_item_name)) { + auto energy_total_count_spec_item = node_map[peak_fit_analysis_item_name]; + this->SetNodeStatus(energy_total_count_spec_item, status, status_ok); + } + const QString& nuclide_analysis_item_name = QStringLiteral(u"核素分析"); + if (node_map.contains(nuclide_analysis_item_name)) { + auto energy_total_count_spec_item = node_map[nuclide_analysis_item_name]; + this->SetNodeStatus(energy_total_count_spec_item, status, status_ok); + } + const QString& particle_in_time_analysis_item_name = QStringLiteral(u"粒子入射时间分析"); + if (node_map.contains(particle_in_time_analysis_item_name)) { + auto energy_total_count_spec_item = node_map[particle_in_time_analysis_item_name]; + this->SetNodeStatus(energy_total_count_spec_item, status, status_ok); } } pro_model->SaveProjectModel(); @@ -773,36 +783,11 @@ void MeasureAnalysisProjectModelList::onEnergyCountProcessFinished(bool ok, cons const QString& adrr_count_spec_item_name = QStringLiteral(u"能量计数谱"); if (node_map.contains(adrr_count_spec_item_name)) { auto adrr_count_spec_item = node_map[adrr_count_spec_item_name]; - this->SetNodeStatus(adrr_count_spec_item, status); + this->SetNodeStatus(adrr_count_spec_item, status, status_ok); } } } } - const QString& particle_energy_data_filename = pro_model->GetParticleEnergyDataFilename(); - if (!particle_energy_data_filename.isEmpty()) { - status_ok = true; - status = QStringLiteral(u"有效"); - const QString& count_rate_analysis_item_name = QStringLiteral(u"计数率分析"); - if (node_map.contains(count_rate_analysis_item_name)) { - auto energy_total_count_spec_item = node_map[count_rate_analysis_item_name]; - this->SetNodeStatus(energy_total_count_spec_item, status, status_ok); - } - const QString& peak_fit_analysis_item_name = QStringLiteral(u"峰拟合分析"); - if (node_map.contains(peak_fit_analysis_item_name)) { - auto energy_total_count_spec_item = node_map[peak_fit_analysis_item_name]; - this->SetNodeStatus(energy_total_count_spec_item, status, status_ok); - } - const QString& nuclide_analysis_item_name = QStringLiteral(u"核素分析"); - if (node_map.contains(nuclide_analysis_item_name)) { - auto energy_total_count_spec_item = node_map[nuclide_analysis_item_name]; - this->SetNodeStatus(energy_total_count_spec_item, status, status_ok); - } - const QString& particle_in_time_analysis_item_name = QStringLiteral(u"粒子入射时间分析"); - if (node_map.contains(particle_in_time_analysis_item_name)) { - auto energy_total_count_spec_item = node_map[particle_in_time_analysis_item_name]; - this->SetNodeStatus(energy_total_count_spec_item, status, status_ok); - } - } pro_model->SaveProjectModel(); } } diff --git a/src/MeasureAnalysisProjectModel.h b/src/MeasureAnalysisProjectModel.h index 74801ab..bc0fcc5 100644 --- a/src/MeasureAnalysisProjectModel.h +++ b/src/MeasureAnalysisProjectModel.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "AnalysisTypeDefine.h" class MeasureAnalysisView;