|
@@ -0,0 +1,129 @@
|
|
|
+#include "ImportIndexWidget.h"
|
|
|
+
|
|
|
+#include <common/ProjectManager.h>
|
|
|
+#include <dbService/ClassSet.h>
|
|
|
+#include <dbService/CNodeDataService.h>
|
|
|
+
|
|
|
+#include <Widgets/Button.h>
|
|
|
+#include <QLabel>
|
|
|
+#include <QListWidget>
|
|
|
+#include <QBoxLayout>
|
|
|
+
|
|
|
+#include <QDebug>
|
|
|
+
|
|
|
+ImportIndexWidget::ImportIndexWidget(QWidget *parent) : QDialog(parent)
|
|
|
+{
|
|
|
+ initWindow();
|
|
|
+ initWidgets();
|
|
|
+ initLayout();
|
|
|
+ connectSignalsAndSlots();
|
|
|
+ loadIndex();
|
|
|
+}
|
|
|
+
|
|
|
+void ImportIndexWidget::initWindow()
|
|
|
+{
|
|
|
+ setWindowTitle("导入指标体系");
|
|
|
+ // setWindowFlags(Qt::Window);
|
|
|
+ // setWindowFlag(Qt::WindowMinMaxButtonsHint, false);
|
|
|
+
|
|
|
+ setModal(true);
|
|
|
+ setWindowFlags(Qt::Dialog);
|
|
|
+ setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
|
|
+ setFixedSize(400, 600);
|
|
|
+}
|
|
|
+
|
|
|
+void ImportIndexWidget::initWidgets()
|
|
|
+{
|
|
|
+ m_title = new QLabel("选择已有项目的指标体系");
|
|
|
+ m_tips = new QLabel("未找到指标体系!\n请重新创建");
|
|
|
+ m_tips->setHidden(true);
|
|
|
+ m_listWidget = new QListWidget();
|
|
|
+ m_listWidget->setMinimumHeight(450);
|
|
|
+ m_listWidget->setHidden(true);
|
|
|
+ m_confirm = new PushButton("导入");
|
|
|
+ m_cancel = new PushButton("取消");
|
|
|
+}
|
|
|
+
|
|
|
+void ImportIndexWidget::initLayout()
|
|
|
+{
|
|
|
+ m_layout = new QVBoxLayout(this);
|
|
|
+ m_layout->setMargin(20);
|
|
|
+ m_layout->setAlignment(Qt::AlignTop);
|
|
|
+ m_layout->addWidget(m_title);
|
|
|
+ m_layout->addSpacing(10);
|
|
|
+ m_layout->addWidget(m_tips);
|
|
|
+ m_layout->addWidget(m_listWidget);
|
|
|
+ m_layout->addSpacing(10);
|
|
|
+ m_layout->addStretch();
|
|
|
+
|
|
|
+ m_buttonLayout = new QHBoxLayout();
|
|
|
+ m_layout->addLayout(m_buttonLayout);
|
|
|
+
|
|
|
+ m_buttonLayout->addStretch();
|
|
|
+ m_buttonLayout->addWidget(m_confirm);
|
|
|
+ m_buttonLayout->addSpacing(10);
|
|
|
+ m_buttonLayout->addWidget(m_cancel);
|
|
|
+}
|
|
|
+
|
|
|
+void ImportIndexWidget::connectSignalsAndSlots()
|
|
|
+{
|
|
|
+ connect(m_confirm, &PushButton::clicked, this, &ImportIndexWidget::slotConfirm);
|
|
|
+ connect(m_cancel, &PushButton::clicked, this, &ImportIndexWidget::slotCancel);
|
|
|
+ connect(m_listWidget, &QListWidget::itemSelectionChanged, this, &ImportIndexWidget::slotCurrentChanged);
|
|
|
+}
|
|
|
+
|
|
|
+void ImportIndexWidget::showEvent(QShowEvent *)
|
|
|
+{
|
|
|
+ loadIndex();
|
|
|
+}
|
|
|
+
|
|
|
+void ImportIndexWidget::loadIndex()
|
|
|
+{
|
|
|
+ QList<ProjectInfo *> list;
|
|
|
+ bool ret = ProjectManager::queryProjects(&list);
|
|
|
+ bool hasProj = ret && list.size() > 0;
|
|
|
+ m_tips->setHidden(hasProj);
|
|
|
+ m_listWidget->setHidden(!hasProj);
|
|
|
+
|
|
|
+ m_indexSysList.clear();
|
|
|
+ for (ProjectInfo *proj : list) {
|
|
|
+ QList<ProjectManager::IndexType> indexList = ProjectManager::indexList(*proj);
|
|
|
+ for (ProjectManager::IndexType i : indexList) {
|
|
|
+ QList<CNodeData> nodeList;
|
|
|
+ bool indexRet = CNodeDataService().QueryAll(nodeList, proj->id, i);
|
|
|
+ if (indexRet && nodeList.size() > 0) {
|
|
|
+ IndexSystemInfo info = IndexSystemInfo { proj->id, i, proj->projectName };
|
|
|
+ m_indexSysList.append(info);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ showIndex();
|
|
|
+}
|
|
|
+
|
|
|
+void ImportIndexWidget::showIndex()
|
|
|
+{
|
|
|
+ m_listWidget->clear();
|
|
|
+ m_confirm->setEnabled(false);
|
|
|
+ for (IndexSystemInfo info : m_indexSysList) {
|
|
|
+ QListWidgetItem *item = new QListWidgetItem();
|
|
|
+ item->setText(info.projName);
|
|
|
+ m_listWidget->addItem(item);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void ImportIndexWidget::slotConfirm()
|
|
|
+{
|
|
|
+ IndexSystemInfo info = m_indexSysList[m_listWidget->currentRow()];
|
|
|
+ emit sigImport(info.projId, info.indexType);
|
|
|
+}
|
|
|
+
|
|
|
+void ImportIndexWidget::slotCancel()
|
|
|
+{
|
|
|
+ close();
|
|
|
+}
|
|
|
+
|
|
|
+void ImportIndexWidget::slotCurrentChanged()
|
|
|
+{
|
|
|
+ m_confirm->setEnabled(m_indexSysList.size() > 0 && m_listWidget->selectedItems().size() >= 0);
|
|
|
+}
|