125 lines
4.6 KiB
C++
125 lines
4.6 KiB
C++
#include "MeasureAnalysisActions.h"
|
|
#include "MeasureAnalysisTreeItem.h"
|
|
#include <QAction>
|
|
|
|
namespace MeasureAnalysisTree {
|
|
|
|
MeasureAnalysisActions::MeasureAnalysisActions(QObject* parent)
|
|
: QObject(parent)
|
|
{
|
|
_act_add_measure_analysis_project = new QAction(QStringLiteral(u"新建测量分析"), this);
|
|
_act_add_measure_analysis_project->setStatusTip(QStringLiteral(u"新建测量分析"));
|
|
_act_add_measure_analysis_project->setDisabled(false);
|
|
connect(_act_add_measure_analysis_project, &QAction::triggered, [this]() {
|
|
emit addMeasureAnalysisProject();
|
|
});
|
|
|
|
_act_rm_measure_analysis_project = new QAction(QStringLiteral(u"删除测量分析"), this);
|
|
_act_rm_measure_analysis_project->setStatusTip(QStringLiteral(u"删除测量分析"));
|
|
_act_rm_measure_analysis_project->setDisabled(true);
|
|
connect(_act_rm_measure_analysis_project, &QAction::triggered, [this]() {
|
|
emit rmMeasureAnalysisProject();
|
|
});
|
|
|
|
_act_modify_measure_analysis_project = new QAction(QStringLiteral(u"修改测量分析"), this);
|
|
_act_modify_measure_analysis_project->setStatusTip(QStringLiteral(u"修改测量分析"));
|
|
_act_modify_measure_analysis_project->setDisabled(true);
|
|
connect(_act_modify_measure_analysis_project, &QAction::triggered, [this]() {
|
|
emit modifyMeasureAnalysisProject();
|
|
});
|
|
|
|
_act_group_measure_analysis_project = new QActionGroup(this);
|
|
_act_group_measure_analysis_project->addAction(_act_add_measure_analysis_project);
|
|
_act_group_measure_analysis_project->addAction(_act_rm_measure_analysis_project);
|
|
_act_group_measure_analysis_project->addAction(_act_modify_measure_analysis_project);
|
|
|
|
_act_add_analyze_view = new QAction(QStringLiteral(u"添加分析视图"), this);
|
|
_act_add_analyze_view->setStatusTip(QStringLiteral(u"添加分析视图"));
|
|
_act_add_analyze_view->setDisabled(true);
|
|
connect(_act_add_analyze_view, &QAction::triggered, [this]() {
|
|
emit addAnalyzeView();
|
|
});
|
|
|
|
_act_rm_analyze_view = new QAction(QStringLiteral(u"删除分析视图"), this);
|
|
_act_rm_analyze_view->setStatusTip(QStringLiteral(u"删除分析视图"));
|
|
_act_rm_analyze_view->setDisabled(true);
|
|
connect(_act_rm_analyze_view, &QAction::triggered, [this]() {
|
|
emit rmAnalyzeView();
|
|
});
|
|
|
|
_act_modify_analyze_view = new QAction(QStringLiteral(u"修改分析视图"), this);
|
|
_act_modify_analyze_view->setStatusTip(QStringLiteral(u"修改分析视图"));
|
|
_act_modify_analyze_view->setDisabled(true);
|
|
connect(_act_modify_analyze_view, &QAction::triggered, [this]() {
|
|
emit modifyAnalyzeView();
|
|
});
|
|
|
|
_act_group_analyze_view = new QActionGroup(this);
|
|
_act_group_analyze_view->addAction(_act_add_analyze_view);
|
|
_act_group_analyze_view->addAction(_act_rm_analyze_view);
|
|
_act_group_analyze_view->addAction(_act_modify_analyze_view);
|
|
}
|
|
|
|
QList<QActionGroup*> MeasureAnalysisActions::GetActionGroups()
|
|
{
|
|
QList<QActionGroup*> list_act_group;
|
|
list_act_group.append(_act_group_measure_analysis_project);
|
|
list_act_group.append(_act_group_analyze_view);
|
|
return list_act_group;
|
|
}
|
|
|
|
QActionGroup* MeasureAnalysisActions::GetProjectActionGroups()
|
|
{
|
|
return _act_group_measure_analysis_project;
|
|
}
|
|
|
|
QActionGroup* MeasureAnalysisActions::GetViewActionGroups()
|
|
{
|
|
return _act_group_analyze_view;
|
|
}
|
|
|
|
void MeasureAnalysisActions::SetActionsAvailable(const TreeItemType &item_type)
|
|
{
|
|
for (QActionGroup* act_group : this->GetActionGroups()) {
|
|
for (QAction* act_item : act_group->actions()) {
|
|
act_item->setDisabled(true);
|
|
}
|
|
}
|
|
_act_add_measure_analysis_project->setEnabled(true);
|
|
|
|
switch (item_type) {
|
|
case TreeItemType::MeasureAnalysisProject:
|
|
for (QAction* act_item : _act_group_measure_analysis_project->actions()) {
|
|
act_item->setEnabled(true);
|
|
}
|
|
break;
|
|
case TreeItemType::ParticleData:
|
|
_act_add_analyze_view->setEnabled(true);
|
|
break;
|
|
case TreeItemType::AnalyzeDataGroup:
|
|
_act_add_analyze_view->setEnabled(true);
|
|
break;
|
|
case TreeItemType::ParticleCountData:
|
|
_act_add_analyze_view->setEnabled(true);
|
|
break;
|
|
case TreeItemType::ConformParticleData:
|
|
_act_add_analyze_view->setEnabled(true);
|
|
break;
|
|
case TreeItemType::AnalyzeViewGroup:
|
|
_act_add_analyze_view->setEnabled(true);
|
|
break;
|
|
case TreeItemType::AnalyzeView:
|
|
for (QAction* act_item : _act_group_analyze_view->actions()) {
|
|
act_item->setEnabled(true);
|
|
}
|
|
break;
|
|
case TreeItemType::None:
|
|
break;
|
|
default:
|
|
_act_add_measure_analysis_project->setEnabled(true);
|
|
break;
|
|
}
|
|
}
|
|
|
|
}
|