Merge branch 'dev' of http://git.hivekion.com:3000/xuhai_cpp/EnergySpectrumAnalyer into dev_axl
This commit is contained in:
commit
3f9fe830ec
|
|
@ -118,6 +118,7 @@ void MainWindow::initMainWindow()
|
|||
|
||||
// Set central widget
|
||||
MeasureAnalysisHistoryForm* measure_analysis_history_form = new MeasureAnalysisHistoryForm;
|
||||
connect(this, &MainWindow::newProject, measure_analysis_history_form, &MeasureAnalysisHistoryForm::onUpdateNewHistoryProject);
|
||||
CDockWidget* central_dock_widget = _dock_manager->createDockWidget(QStringLiteral(u"测量分析记录"));
|
||||
central_dock_widget->setWidget(measure_analysis_history_form);
|
||||
// central_dock_widget->setFeature(ads::CDockWidget::AllDockWidgetFeatures, true);
|
||||
|
|
@ -156,6 +157,9 @@ void MainWindow::initAction()
|
|||
if (QDialog::Accepted == new_measure_analysis_dlg.exec()) {
|
||||
ProjectList* project_list_model = ProjectList::Instance();
|
||||
auto project_model = project_list_model->GetCurrentProjectModel();
|
||||
|
||||
emit newProject(project_model->GetProjectName());
|
||||
|
||||
const QString& all_channel_particle_data_filename = project_model->GetAllChannelParticleDataFilename();
|
||||
if (!all_channel_particle_data_filename.isEmpty()) {
|
||||
const QString& all_ch_count_dir = project_model->GetProjectDir();
|
||||
|
|
|
|||
|
|
@ -49,6 +49,9 @@ private:
|
|||
void applyStyleSheet();
|
||||
void closeProject(const QString &project_name);
|
||||
|
||||
signals:
|
||||
void newProject(const QString &project_name);
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent* event) override;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
#include <QFileSystemWatcher>
|
||||
#include "GlobalDefine.h"
|
||||
|
||||
MeasureAnalysisHistoryForm::MeasureAnalysisHistoryForm(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
|
|
@ -11,16 +13,19 @@ MeasureAnalysisHistoryForm::MeasureAnalysisHistoryForm(QWidget* parent)
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->linedit_query->setPlaceholderText(QStringLiteral(u"请输入查询测量分析项目名称的关键字"));
|
||||
|
||||
ui->tablew_history->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
ui->tablew_history->horizontalHeader()->setSectionResizeMode(
|
||||
ui->tablew_history->columnCount() - 1, QHeaderView::Stretch);
|
||||
ui->tablew_history->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
|
||||
connect(ui->btn_query, &QPushButton::clicked, this, &MeasureAnalysisHistoryForm::onQueryHistory);
|
||||
connect(ui->linedit_query, &QLineEdit::textChanged , this, &MeasureAnalysisHistoryForm::onQueryHistory);
|
||||
connect(ui->btn_remove, &QPushButton::clicked, this, &MeasureAnalysisHistoryForm::onRemoveSelectedProject);
|
||||
connect(ui->btn_select_all, &QPushButton::clicked, this, &MeasureAnalysisHistoryForm::onAllSelect);
|
||||
connect(ui->btn_reverse, &QPushButton::clicked, this, &MeasureAnalysisHistoryForm::onReverseSelect);
|
||||
connect(ui->tablew_history, &QTableWidget::cellDoubleClicked, this, &MeasureAnalysisHistoryForm::onTableCellDoubleClicked);
|
||||
connect(ProjectList::Instance(), &MeasureAnalysisProjectModelList::removedProjectModel, this, &MeasureAnalysisHistoryForm::onUpdateCloseHistoryProject);
|
||||
|
||||
loadHistoryInfo();
|
||||
}
|
||||
|
|
@ -64,6 +69,9 @@ void MeasureAnalysisHistoryForm::loadHistoryInfo()
|
|||
ui->tablew_history->setItem(row, 2, new QTableWidgetItem(spectrum_type_name));
|
||||
const QString& is_std_source = project_model.GetIsStdSource() ? QStringLiteral(u"是") : QStringLiteral(u"否");
|
||||
ui->tablew_history->setItem(row, 3, new QTableWidgetItem(is_std_source));
|
||||
ui->tablew_history->setItem(row, 4, new QTableWidgetItem());
|
||||
ui->tablew_history->setItem(row, 5, new QTableWidgetItem());
|
||||
ui->tablew_history->setItem(row, 6, new QTableWidgetItem());
|
||||
ui->tablew_history->setItem(row, 7, new QTableWidgetItem(project_model.GetDescriptionInfo()));
|
||||
}
|
||||
}
|
||||
|
|
@ -72,6 +80,13 @@ void MeasureAnalysisHistoryForm::loadHistoryInfo()
|
|||
void MeasureAnalysisHistoryForm::onQueryHistory()
|
||||
{
|
||||
const QString& query_text = ui->linedit_query->text();
|
||||
for (int row = 0; row < ui->tablew_history->rowCount(); ++row) {
|
||||
QTableWidgetItem* item = ui->tablew_history->item(row, 0);
|
||||
if (item) {
|
||||
bool b_match = item->text().contains(query_text);
|
||||
ui->tablew_history->setRowHidden(row, !b_match);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MeasureAnalysisHistoryForm::onAllSelect()
|
||||
|
|
@ -111,16 +126,29 @@ void MeasureAnalysisHistoryForm::onReverseSelect()
|
|||
|
||||
void MeasureAnalysisHistoryForm::onRemoveSelectedProject()
|
||||
{
|
||||
QMap<int, QString> selected_project_list;
|
||||
auto row_count = ui->tablew_history->rowCount();
|
||||
for (int row = row_count - 1; row >= 0; --row) {
|
||||
if (Qt::Checked == ui->tablew_history->item(row, 0)->checkState()) {
|
||||
const QString& project_filename = ui->tablew_history->item(row, 0)->data(Qt::UserRole).toString();
|
||||
QFileInfo project_file_info(project_filename);
|
||||
const QString& project_dir_path = project_file_info.absoluteDir().absolutePath();
|
||||
QDir(project_dir_path).removeRecursively();
|
||||
ui->tablew_history->removeRow(row);
|
||||
selected_project_list[row] = project_filename;
|
||||
}
|
||||
}
|
||||
if (selected_project_list.isEmpty()) {
|
||||
QMessageBox::information(this, QStringLiteral(u"确认"), QStringLiteral(u"请选择想要删除的测量分析项目!"));
|
||||
return;
|
||||
}
|
||||
if (QMessageBox::No == QMessageBox::question(this, QStringLiteral(u"确认"), QStringLiteral(u"是否删除选择的测量分析项目?"))) {
|
||||
return;
|
||||
}
|
||||
for (int row : selected_project_list.keys()) {
|
||||
QFileInfo project_file_info(selected_project_list.value(row));
|
||||
const QString& project_dir_path = project_file_info.absoluteDir().absolutePath();
|
||||
QDir(project_dir_path).removeRecursively();
|
||||
QDir(project_dir_path).rmdir(project_dir_path);
|
||||
ui->tablew_history->removeRow(row);
|
||||
LOG_INFO(QStringLiteral(u"测量分析项目\"%1\"已经删除.").arg(project_file_info.baseName()));
|
||||
}
|
||||
}
|
||||
|
||||
void MeasureAnalysisHistoryForm::onTableCellDoubleClicked(int row, int column)
|
||||
|
|
@ -152,12 +180,51 @@ void MeasureAnalysisHistoryForm::onTableCellDoubleClicked(int row, int column)
|
|||
bool loaded = ProjectList::Instance()->AddProjectModel(model);
|
||||
if (loaded) {
|
||||
item->setCheckState(Qt::Unchecked);
|
||||
item->setFlags(item->flags() & ~Qt::ItemIsUserCheckable);
|
||||
item->setFlags(item->flags() & ~(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable));
|
||||
int row = item->row();
|
||||
for (int col = 1; col < ui->tablew_history->columnCount(); ++col) {
|
||||
QTableWidgetItem* other_item = ui->tablew_history->item(row, col);
|
||||
if (other_item) {
|
||||
other_item->setFlags(other_item->flags() & ~(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
||||
item->setFlags(item->flags() | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
|
||||
int row = item->row();
|
||||
for (int col = 1; col < ui->tablew_history->columnCount(); ++col) {
|
||||
QTableWidgetItem* other_item = ui->tablew_history->item(row, col);
|
||||
if (other_item) {
|
||||
other_item->setFlags(other_item->flags() | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
emit openProject(project_filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MeasureAnalysisHistoryForm::onUpdateCloseHistoryProject(const QString &project_name)
|
||||
{
|
||||
for (int row = 0; row < ui->tablew_history->rowCount(); ++row) {
|
||||
QTableWidgetItem* item = ui->tablew_history->item(row, 0);
|
||||
if (item) {
|
||||
if (project_name == item->text()) {
|
||||
item->setFlags(item->flags() | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
|
||||
int row = item->row();
|
||||
for (int col = 1; col < ui->tablew_history->columnCount(); ++col) {
|
||||
QTableWidgetItem* other_item = ui->tablew_history->item(row, col);
|
||||
if (other_item) {
|
||||
other_item->setFlags(other_item->flags() | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MeasureAnalysisHistoryForm::onUpdateNewHistoryProject(const QString &project_name)
|
||||
{
|
||||
Q_UNUSED(project_name);
|
||||
loadHistoryInfo();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ private slots:
|
|||
void onReverseSelect();
|
||||
void onRemoveSelectedProject();
|
||||
void onTableCellDoubleClicked(int row, int column);
|
||||
void onUpdateCloseHistoryProject(const QString& project_name);
|
||||
public slots:
|
||||
void onUpdateNewHistoryProject(const QString& project_name);
|
||||
|
||||
signals:
|
||||
void openProject(const QString& project_filename);
|
||||
|
|
|
|||
|
|
@ -53,20 +53,36 @@
|
|||
<item>
|
||||
<widget class="QLabel" name="label_query_title">
|
||||
<property name="text">
|
||||
<string>模糊查询:</string>
|
||||
<string>测量分析查询:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="linedit_query"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_query">
|
||||
<property name="text">
|
||||
<string>查询</string>
|
||||
<widget class="QLineEdit" name="linedit_query">
|
||||
<property name="maxLength">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_select_all">
|
||||
<property name="text">
|
||||
|
|
@ -93,7 +109,7 @@
|
|||
<item>
|
||||
<widget class="QTableWidget" name="tablew_history">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::DefaultContextMenu</enum>
|
||||
|
|
|
|||
|
|
@ -517,6 +517,7 @@ bool MeasureAnalysisProjectModelList::RmProjectModel(const QString& project_name
|
|||
const QString& project_name = project_model->GetProjectName();
|
||||
SetCurrentProjectModel(project_name);
|
||||
}
|
||||
emit removedProjectModel(project_name);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -146,6 +146,9 @@ private slots:
|
|||
void onCoincidenceProcessFinished(bool ok, const QString& project_name, const QVariant& data);
|
||||
void onEnergyScaleCoincidenceDataFinished(bool ok, const QString& project_name, const QVariant& data);
|
||||
|
||||
signals:
|
||||
void removedProjectModel(const QString& project_name);
|
||||
|
||||
private:
|
||||
void intiProjectNodeStruce(MeasureAnalysisProjectModel *pro_model);
|
||||
|
||||
|
|
|
|||
|
|
@ -161,6 +161,7 @@ void NewMeasureAnalysisDlg::onNewProjectFromFileFinished(bool ok, const QString&
|
|||
}
|
||||
} else {
|
||||
project_dir.removeRecursively();
|
||||
project_dir.rmdir(project_dir_path);
|
||||
const QString& data_file_path = ui->lineEdit_filename->property("data_file_path").toString();
|
||||
QMessageBox::warning(this, QStringLiteral(u"警告"), QStringLiteral(u"粒子数据%1异常,创建测量分析项目失败!").arg(data_file_path));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user