|
@@ -5,7 +5,9 @@
|
|
|
|
|
|
#include <Widgets/Button.h>
|
|
|
#include <Widgets/Menu.h>
|
|
|
+#include <Widgets/CheckBox.h>
|
|
|
|
|
|
+#include <QLabel>
|
|
|
#include <QLayout>
|
|
|
#include <QMetaEnum>
|
|
|
|
|
@@ -46,49 +48,99 @@ EvalSchemeWidget::EvalSchemeWidget(ProjectInfo *proj, int type, QWidget *parent)
|
|
|
setTitle("评估方案规划");
|
|
|
|
|
|
initWidgets();
|
|
|
+ initLayout();
|
|
|
+ connectSignalsAndSlots();
|
|
|
|
|
|
testData();
|
|
|
}
|
|
|
|
|
|
void EvalSchemeWidget::initWidgets()
|
|
|
{
|
|
|
- m_buttonLayout = new QHBoxLayout();
|
|
|
+ m_schemeBtn = new PushButton("加载方案", this);
|
|
|
+ m_index = new CheckBox("指标体系", this);
|
|
|
+ m_data = new CheckBox("收集数据", this);
|
|
|
+ m_algBtn = new PushButton("数据处理", this);
|
|
|
+ m_clear = new PushButton("清空");
|
|
|
|
|
|
// 按照方案枚举值添加按钮
|
|
|
- QMetaEnum sch = QMetaEnum::fromType<Scheme>();
|
|
|
- for (int i = 0; i < sch.keyCount(); i++) {
|
|
|
- Scheme s = Scheme(sch.value(i));
|
|
|
- PushButton *btn = new PushButton(nameOfScheme(s), this);
|
|
|
- btn->setMinimumWidth(80);
|
|
|
- m_buttonLayout->addWidget(btn);
|
|
|
- connect(btn, &PushButton::clicked, [this, s, btn]() { slotSelectScheme(s, btn); });
|
|
|
- }
|
|
|
- m_buttonLayout->setSpacing(15);
|
|
|
- m_buttonLayout->addStretch();
|
|
|
+ // QMetaEnum sch = QMetaEnum::fromType<Scheme>();
|
|
|
+ // for (int i = 0; i < sch.keyCount(); i++) {
|
|
|
+ // Scheme s = Scheme(sch.value(i));
|
|
|
+ // PushButton *btn = new PushButton(nameOfScheme(s), this);
|
|
|
+ // btn->setMinimumWidth(80);
|
|
|
+ // m_buttonLayout->addWidget(btn);
|
|
|
+ // connect(btn, &PushButton::clicked, [this, s, btn]() { slotSelectScheme(s, btn); });
|
|
|
+ // }
|
|
|
+ // m_buttonLayout->setSpacing(15);
|
|
|
+ // m_buttonLayout->addStretch();
|
|
|
|
|
|
- m_clear = new PushButton("清空");
|
|
|
- m_buttonLayout->addWidget(m_clear);
|
|
|
- connect(m_clear, &PushButton::clicked, this, &EvalSchemeWidget::slotClearScheme);
|
|
|
+ m_schemeView = new CSchemeView(this);
|
|
|
+ m_schemeSep = new QWidget(this);
|
|
|
+ m_schemeSep->setFixedWidth(1);
|
|
|
+ m_description = new QLabel("description", this);
|
|
|
+ m_description->setFixedWidth(150);
|
|
|
+
|
|
|
+ QMap<QString, SchemeAndAlg> schemes;
|
|
|
+ schemes["指标体系"] = { Index | Process | Output, Alg1 };
|
|
|
+ schemes["收集数据"] = { Collect | Process | Output, Alg1 };
|
|
|
+ schemes["指标体系和收集数据"] = { Index | Collect | Process | Output, Alg1 };
|
|
|
+ m_schemeMenu = new RoundMenu("scheme", this);
|
|
|
+ m_schemeMenu->addAction(new QAction("方案一"));
|
|
|
+ m_schemeMenu->addAction(new QAction("方案二"));
|
|
|
+ m_schemeMenu->addAction(new QAction("方案三"));
|
|
|
|
|
|
// 按照算法枚举值添加算法选项
|
|
|
- m_menu = new RoundMenu("menu", this);
|
|
|
+ m_algMenu = new RoundMenu("alg", this);
|
|
|
QMetaEnum alg = QMetaEnum::fromType<Algorithm>();
|
|
|
for (int i = 0; i < alg.keyCount(); i++) {
|
|
|
Algorithm t = Algorithm(alg.value(i));
|
|
|
QAction *act = new QAction(nameOfAlgorithm(t));
|
|
|
- m_menu->addAction(act);
|
|
|
+ m_algMenu->addAction(act);
|
|
|
connect(act, &QAction::triggered, [this, t]() { slotSelectAlgorithm(t); });
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
- m_schemeView = new CSchemeView(this);
|
|
|
-
|
|
|
+void EvalSchemeWidget::initLayout()
|
|
|
+{
|
|
|
+ // 总体布局
|
|
|
+ m_buttonLayout = new QHBoxLayout();
|
|
|
m_contentLayout->addLayout(m_buttonLayout);
|
|
|
- m_contentLayout->addWidget(m_schemeView);
|
|
|
+ m_schemeLayout = new QHBoxLayout();
|
|
|
+ m_contentLayout->addLayout(m_schemeLayout);
|
|
|
+
|
|
|
+ m_buttonLayout->addWidget(m_schemeBtn);
|
|
|
+ m_buttonLayout->addSpacing(20);
|
|
|
+ m_buttonLayout->addWidget(m_index);
|
|
|
+ m_buttonLayout->addSpacing(20);
|
|
|
+ m_buttonLayout->addWidget(m_data);
|
|
|
+ m_buttonLayout->addSpacing(20);
|
|
|
+ m_buttonLayout->addWidget(m_algBtn);
|
|
|
+ m_buttonLayout->addSpacing(20);
|
|
|
+ m_buttonLayout->addWidget(m_clear);
|
|
|
+ m_buttonLayout->addStretch();
|
|
|
+
|
|
|
+ m_schemeLayout->addWidget(m_schemeView);
|
|
|
+ m_schemeLayout->addWidget(m_seperator);
|
|
|
+ m_schemeLayout->addWidget(m_description);
|
|
|
+}
|
|
|
+
|
|
|
+void EvalSchemeWidget::connectSignalsAndSlots()
|
|
|
+{
|
|
|
+ connect(m_schemeBtn, &PushButton::clicked, this, &EvalSchemeWidget::slotShowSchemeMenu);
|
|
|
+ connect(m_index, &CheckBox::clicked, this, &EvalSchemeWidget::slotIndexClicked);
|
|
|
+ connect(m_data, &CheckBox::clicked, this, &EvalSchemeWidget::slotDataClicked);
|
|
|
+ connect(m_algBtn, &PushButton::clicked, this, &EvalSchemeWidget::slotAlgBtnClicked);
|
|
|
+ connect(m_clear, &PushButton::clicked, this, &EvalSchemeWidget::slotClearClicked);
|
|
|
}
|
|
|
|
|
|
void EvalSchemeWidget::refreshSchemeView()
|
|
|
{
|
|
|
+ qDebug() << __FUNCTION__ << __LINE__ << m_scheme << endl;
|
|
|
+
|
|
|
m_schemeView->clear();
|
|
|
+ if (m_scheme > 0) {
|
|
|
+ m_scheme |= Output;
|
|
|
+ }
|
|
|
QMetaEnum sch = QMetaEnum::fromType<Scheme>();
|
|
|
for (int i = 0; i < sch.keyCount(); i++) {
|
|
|
Scheme s = Scheme(sch.value(i));
|
|
@@ -114,29 +166,43 @@ void EvalSchemeWidget::testData()
|
|
|
refreshSchemeView();
|
|
|
}
|
|
|
|
|
|
-void EvalSchemeWidget::slotSelectScheme(EvalSchemeWidget::Scheme sch, PushButton *btn)
|
|
|
+void EvalSchemeWidget::slotShowSchemeMenu()
|
|
|
{
|
|
|
- if (sch == Process) {
|
|
|
- QPoint pos = btn->mapToGlobal(QPoint()) + QPoint(btn->width(), -10);
|
|
|
- m_menu->exec(pos, true);
|
|
|
- } else {
|
|
|
- m_scheme |= sch;
|
|
|
- refreshSchemeView();
|
|
|
- }
|
|
|
+ QPoint pos = m_schemeBtn->mapToGlobal(QPoint()) + QPoint(m_schemeBtn->width(), -10);
|
|
|
+ m_schemeMenu->exec(pos, true);
|
|
|
}
|
|
|
|
|
|
-void EvalSchemeWidget::slotSelectAlgorithm(EvalSchemeWidget::Algorithm alg)
|
|
|
+void EvalSchemeWidget::slotIndexClicked()
|
|
|
{
|
|
|
- if (m_algs.contains(alg)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- m_algs.append(alg);
|
|
|
+ m_scheme ^= Index;
|
|
|
refreshSchemeView();
|
|
|
}
|
|
|
|
|
|
-void EvalSchemeWidget::slotClearScheme()
|
|
|
+void EvalSchemeWidget::slotDataClicked()
|
|
|
+{
|
|
|
+ m_scheme ^= Collect;
|
|
|
+ refreshSchemeView();
|
|
|
+}
|
|
|
+
|
|
|
+void EvalSchemeWidget::slotAlgBtnClicked()
|
|
|
+{
|
|
|
+ QPoint pos = m_algBtn->mapToGlobal(QPoint()) + QPoint(m_algBtn->width(), -10);
|
|
|
+ m_algMenu->exec(pos, true);
|
|
|
+}
|
|
|
+
|
|
|
+void EvalSchemeWidget::slotClearClicked()
|
|
|
{
|
|
|
m_scheme = 0;
|
|
|
m_algs.clear();
|
|
|
refreshSchemeView();
|
|
|
}
|
|
|
+
|
|
|
+void EvalSchemeWidget::slotSelectAlgorithm(EvalSchemeWidget::Algorithm alg)
|
|
|
+{
|
|
|
+ if (m_algs.contains(alg)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ m_algs.clear();
|
|
|
+ m_algs.append(alg);
|
|
|
+ refreshSchemeView();
|
|
|
+}
|