|
@@ -12,6 +12,7 @@
|
|
|
#include <QLayout>
|
|
|
#include <QMenu>
|
|
|
#include <QContextMenuEvent>
|
|
|
+#include <QTabWidget>
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
@@ -23,40 +24,19 @@ IndexSystemWidget::IndexSystemWidget(ProjectInfo *proj, QWidget *parent) : EvalW
|
|
|
connectSignalsAndSlots();
|
|
|
}
|
|
|
|
|
|
-void IndexSystemWidget::initWidgets()
|
|
|
-{
|
|
|
- m_mindView = new CMindView(this);
|
|
|
-}
|
|
|
-
|
|
|
-void IndexSystemWidget::initLayout()
|
|
|
-{
|
|
|
- m_contentLayout->addWidget(m_mindView);
|
|
|
-}
|
|
|
-
|
|
|
-void IndexSystemWidget::connectSignalsAndSlots()
|
|
|
-{
|
|
|
- connect(m_mindView, &CMindView::sigAddSubNode, this, &IndexSystemWidget::slotAddSubNode);
|
|
|
- connect(m_mindView->mind(), &CMind::sigRemoveNode, this, &IndexSystemWidget::slotRemoveNode);
|
|
|
- connect(m_mindView, &CMindView::sigNodeChanged, this, &IndexSystemWidget::slotUpdateNode);
|
|
|
-}
|
|
|
-
|
|
|
void IndexSystemWidget::setType(int type)
|
|
|
{
|
|
|
EvalWidget::setType(type);
|
|
|
-
|
|
|
- QList<CNodeData> list;
|
|
|
-
|
|
|
- bool ret = CNodeDataService().QueryAll(list, proj()->id, type);
|
|
|
- if (ret) {
|
|
|
- m_mindView->setNodeList(list);
|
|
|
- }
|
|
|
+ setupTabWidget();
|
|
|
}
|
|
|
|
|
|
void IndexSystemWidget::contextMenuEvent(QContextMenuEvent *event)
|
|
|
{
|
|
|
RoundMenu *menu = new RoundMenu();
|
|
|
|
|
|
- if (m_mindView->root() == nullptr) {
|
|
|
+ CMindView *m = (CMindView *)m_tab->currentWidget();
|
|
|
+
|
|
|
+ if (m->root() == nullptr) {
|
|
|
QAction *act3 = new QAction("创建根节点");
|
|
|
menu->addAction(act3);
|
|
|
connect(act3, &QAction::triggered, this, &IndexSystemWidget::slotCreateRootNode);
|
|
@@ -71,31 +51,65 @@ void IndexSystemWidget::contextMenuEvent(QContextMenuEvent *event)
|
|
|
QWidget::contextMenuEvent(event);
|
|
|
}
|
|
|
|
|
|
+void IndexSystemWidget::setupTabWidget()
|
|
|
+{
|
|
|
+ m_tab->clear();
|
|
|
+ for (int i : m_indexList) {
|
|
|
+ CMindView *m = new CMindView(this);
|
|
|
+ ProjectManager::IndexType t = (ProjectManager::IndexType)i;
|
|
|
+ QString s = ProjectManager::nameOfIndexType(t);
|
|
|
+ m_tab->addTab(m, s);
|
|
|
+
|
|
|
+ QList<CNodeData> list;
|
|
|
+ bool ret = CNodeDataService().QueryAll(list, proj()->id, t);
|
|
|
+ if (ret) {
|
|
|
+ m->setNodeList(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ connect(m, &CMindView::sigAddSubNode, this, &IndexSystemWidget::slotAddSubNode);
|
|
|
+ connect(m->mind(), &CMind::sigRemoveNode, this, &IndexSystemWidget::slotRemoveNode);
|
|
|
+ connect(m, &CMindView::sigNodeChanged, this, &IndexSystemWidget::slotUpdateNode);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void IndexSystemWidget::initWidgets() { }
|
|
|
+
|
|
|
+void IndexSystemWidget::initLayout() { }
|
|
|
+
|
|
|
+void IndexSystemWidget::connectSignalsAndSlots()
|
|
|
+{
|
|
|
+ connect(m_tab, &QTabWidget::currentChanged, this, &IndexSystemWidget::slotTabCurrentChanged);
|
|
|
+}
|
|
|
+
|
|
|
void IndexSystemWidget::addNode(CNodeData node)
|
|
|
{
|
|
|
- qDebug() << __FUNCTION__ << __LINE__ << node.number << endl;
|
|
|
- if (m_mindView->mind()->canAddNode(node)) {
|
|
|
+ CMindView *m = (CMindView *)m_tab->currentWidget();
|
|
|
+ if (m->mind()->canAddNode(node)) {
|
|
|
int id = CNodeDataService().AddCNodeData(node);
|
|
|
if (id >= 0) {
|
|
|
node.id = id;
|
|
|
- m_mindView->addNode(node);
|
|
|
+ m->addNode(node);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void IndexSystemWidget::slotSelectAllNodes()
|
|
|
+void IndexSystemWidget::slotTabCurrentChanged(int c)
|
|
|
{
|
|
|
- qDebug() << __FUNCTION__ << __LINE__ << endl;
|
|
|
+ Q_UNUSED(c)
|
|
|
}
|
|
|
|
|
|
+void IndexSystemWidget::slotSelectAllNodes() { }
|
|
|
+
|
|
|
void IndexSystemWidget::slotClearAllNodes()
|
|
|
{
|
|
|
- m_mindView->clear();
|
|
|
+ CMindView *m = (CMindView *)m_tab->currentWidget();
|
|
|
+ m->clear();
|
|
|
}
|
|
|
|
|
|
void IndexSystemWidget::slotCreateRootNode()
|
|
|
{
|
|
|
- CNodeData n = CNodeData(m_proj->id, m_type, 0);
|
|
|
+ int t = m_indexList[m_tab->currentIndex()];
|
|
|
+ CNodeData n = CNodeData(m_proj->id, t, 0);
|
|
|
n.name = m_proj->projectName;
|
|
|
addNode(n);
|
|
|
}
|
|
@@ -105,8 +119,9 @@ void IndexSystemWidget::slotAddSubNode(int pNumber)
|
|
|
if (pNumber < 0) {
|
|
|
return;
|
|
|
}
|
|
|
- CNodeData data = m_mindView->root()->data();
|
|
|
- CNodeData n = CNodeData(data.projectId, data.indexType, m_mindView->mind()->maxNumber() + 1, pNumber);
|
|
|
+ CMindView *m = (CMindView *)m_tab->currentWidget();
|
|
|
+ CNodeData data = m->root()->data();
|
|
|
+ CNodeData n = CNodeData(data.projectId, data.indexType, m->mind()->maxNumber() + 1, pNumber);
|
|
|
|
|
|
addNode(n);
|
|
|
}
|