chengxr 1 year ago
parent
commit
72ee856dd7

+ 6 - 0
QFD/CCanvas/CMindView.cpp

@@ -65,6 +65,7 @@ void CMindView::addNode(CNodeData n)
 {
     m_mind->addNode(n);
     CNodeItem *item = new CNodeItem(n);
+    connect(item, &CNodeItem::sigEditNode, this, &CMindView::slotEditNode);
     connect(item, &CNodeItem::sigAddSubItem, this, &CMindView::slotAddSubNode);
     connect(item, &CNodeItem::sigRemoveItem, this, &CMindView::slotRemoveNode);
     connect(item, &CNodeItem::sigTextChanged, this, &CMindView::slotTextChanged);
@@ -224,6 +225,11 @@ void CMindView::testData()
     }
 }
 
+void CMindView::slotEditNode(CNodeData n)
+{
+    emit sigEditNode(n);
+}
+
 void CMindView::slotAddSubNode(int pNumber)
 {
     emit sigAddSubNode(pNumber);

+ 5 - 0
QFD/CCanvas/CMindView.h

@@ -45,6 +45,9 @@ public:
     void testData();
 
 public slots:
+
+    void slotEditNode(CNodeData n);
+
     void slotAddSubNode(int pNumber);  // 指定父节点, 创建子节点
 
     void slotRemoveNode(int number);  // 移除节点
@@ -54,6 +57,8 @@ public slots:
     void slotWillBeginEditing();
 
 signals:
+    void sigEditNode(CNodeData n);
+
     void sigAddSubNode(int pNumber);
 
     void sigNodeChanged(CNodeData n);

+ 6 - 0
QFD/CCanvas/CNodeItem.cpp

@@ -133,6 +133,7 @@ void CNodeItem::setMinHeight(qreal h)
 
 void CNodeItem::connectSignalsAndSlots()
 {
+    connect(m_rectItem->editAction(), &QAction::triggered, this, &CNodeItem::slotEditNode);
     connect(m_rectItem->selectAction(), &QAction::triggered, this, &CNodeItem::slotSelect);
     connect(m_rectItem->subNodeAction(), &QAction::triggered, this, &CNodeItem::slotSubNode);
     connect(m_rectItem->removeAction(), &QAction::triggered, this, &CNodeItem::slotRemove);
@@ -316,6 +317,11 @@ CNodeItem *CNodeItem::editingNode()
     return node;
 }
 
+void CNodeItem::slotEditNode()
+{
+    emit sigEditNode(data());
+}
+
 void CNodeItem::slotSelect()
 {
     m_rectItem->setHighlighted(!m_rectItem->highlighted());

+ 2 - 0
QFD/CCanvas/CNodeItem.h

@@ -93,12 +93,14 @@ public:
     CNodeItem *editingNode();
 
 signals:
+    void sigEditNode(CNodeData n);
     void sigAddSubItem(int pNumber);
     void sigRemoveItem(int number);
     void sigTextChanged();
     void sigWillBeginEditing();
 
 public slots:
+    void slotEditNode();
     void slotSelect();
     void slotSubNode();
     void slotRemove();

+ 1 - 1
QFD/CCanvas/CPathItem.h

@@ -24,7 +24,7 @@ public:
     void setHighlightFillColor(QColor c);
 
     bool highlighted() const;
-    void setHighlighted(bool h);
+    virtual void setHighlighted(bool h);
 
     virtual void updatePath() = 0;
 

+ 11 - 1
QFD/CCanvas/CRectItem.cpp

@@ -19,7 +19,9 @@ CRectItem::CRectItem(const QRectF &rect, QGraphicsItem *parent) : CPathItem(pare
     m_subNode = new QAction("添加子节点");
     m_select  = new QAction("选中");
     m_remove  = new QAction("删除");
+    m_edit    = new QAction("编辑节点");
 
+    m_menu->addAction(m_edit);
     m_menu->addAction(m_subNode);
     m_menu->addAction(m_select);
     m_menu->addAction(m_remove);
@@ -71,7 +73,10 @@ void CRectItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
     m_menu->exec(event->screenPos() + QPoint(-40, -20));
 }
 
-void CRectItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { }
+void CRectItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+    Q_UNUSED(event)
+}
 
 QAction *CRectItem::selectAction() const
 {
@@ -88,6 +93,11 @@ QAction *CRectItem::removeAction() const
     return m_remove;
 }
 
+QAction *CRectItem::editAction() const
+{
+    return m_edit;
+}
+
 void CRectItem::slotSelect()
 {
     qDebug() << __FUNCTION__ << __LINE__ << endl;

+ 2 - 0
QFD/CCanvas/CRectItem.h

@@ -36,6 +36,7 @@ public:
     QAction *selectAction() const;
     QAction *subNodeAction() const;
     QAction *removeAction() const;
+    QAction *editAction() const;
 
 private slots:
     void slotSelect();
@@ -49,6 +50,7 @@ private:
     QAction *m_select  = nullptr;
     QAction *m_subNode = nullptr;
     QAction *m_remove  = nullptr;
+    QAction *m_edit    = nullptr;
 };
 
 #endif  // CRECTITEM_H

+ 0 - 1
QFD/CCanvas/CTextItem.cpp

@@ -75,7 +75,6 @@ void CTextItem::setAllowEdit(bool a)
 
 QSizeF CTextItem::textSize(const QString t, qreal width)
 {
-    qDebug() << __FUNCTION__ << __LINE__ << endl;
     static CTextItem *i = nullptr;
     if (i == nullptr) {
         i = new CTextItem(nullptr);

+ 2 - 0
QFD/QFD.pro

@@ -93,6 +93,7 @@ SOURCES += \
     widgets/DataCollectionWidget.cpp \
     widgets/DataProcessingWidget.cpp \
     widgets/DataTableWidget.cpp \
+    widgets/EditNodeWidget.cpp \
     widgets/EvalSchemeWidget.cpp \
     widgets/EvalSchemeWidget2.cpp \
     widgets/EvalWidget.cpp \
@@ -140,6 +141,7 @@ HEADERS += \
     widgets/DataCollectionWidget.h \
     widgets/DataProcessingWidget.h \
     widgets/DataTableWidget.h \
+    widgets/EditNodeWidget.h \
     widgets/EvalSchemeWidget.h \
     widgets/EvalSchemeWidget2.h \
     widgets/EvalWidget.h \

+ 4 - 0
QFD/widgets/DataTableWidget.h

@@ -13,6 +13,10 @@ class QTabWidget;
 class QVBoxLayout;
 class QHBoxLayout;
 
+/**
+ * @brief The DataTableWidget class
+ * 数据表, 整体上是包含多个 QTableView 的 QTabWidget
+ */
 class DataTableWidget : public QWidget
 {
     Q_OBJECT

+ 3 - 0
QFD/widgets/EditNodeWidget.cpp

@@ -0,0 +1,3 @@
+#include "EditNodeWidget.h"
+
+EditNodeWidget::EditNodeWidget(CNodeData n, QWidget *parent) { }

+ 22 - 0
QFD/widgets/EditNodeWidget.h

@@ -0,0 +1,22 @@
+#ifndef EDITNODEWIDGET_H
+#define EDITNODEWIDGET_H
+
+#include <QDialog>
+
+#include <CNode.h>
+
+class EditNodeWidget : public QDialog
+{
+    Q_OBJECT
+public:
+    EditNodeWidget(CNodeData n, QWidget *parent = nullptr);
+
+    CNodeData node() const;
+
+    void setNode(CNodeData n);
+
+private:
+    CNodeData m_node;
+};
+
+#endif  // EDITNODEWIDGET_H

+ 6 - 0
QFD/widgets/IndexSystemWidget.cpp

@@ -66,6 +66,7 @@ void IndexSystemWidget::setupTabWidget()
             m->setNodeList(list);
         }
 
+        connect(m, &CMindView::sigEditNode, this, &IndexSystemWidget::slotEditNode);
         connect(m, &CMindView::sigAddSubNode, this, &IndexSystemWidget::slotAddSubNode);
         connect(m->mind(), &CMind::sigRemoveNode, this, &IndexSystemWidget::slotRemoveNode);
         connect(m, &CMindView::sigNodeChanged, this, &IndexSystemWidget::slotUpdateNode);
@@ -114,6 +115,11 @@ void IndexSystemWidget::slotCreateRootNode()
     addNode(n);
 }
 
+void IndexSystemWidget::slotEditNode(CNodeData n)
+{
+    qDebug() << __FUNCTION__ << __LINE__ << n.name << endl;
+}
+
 void IndexSystemWidget::slotAddSubNode(int pNumber)
 {
     if (pNumber < 0) {

+ 2 - 0
QFD/widgets/IndexSystemWidget.h

@@ -41,6 +41,8 @@ public slots:
 
     void slotCreateRootNode();
 
+    void slotEditNode(CNodeData n);
+
     void slotAddSubNode(int pNumber);
 
     void slotUpdateNode(CNodeData node);