|
@@ -4,6 +4,13 @@
|
|
|
#include "CLineItem.h"
|
|
|
#include "CTextItem.h"
|
|
|
|
|
|
+#include "CMind.h"
|
|
|
+
|
|
|
+#include <QMenu>
|
|
|
+#include <QContextMenuEvent>
|
|
|
+
|
|
|
+#include <QDebug>
|
|
|
+
|
|
|
CMindView::CMindView(QWidget *parent) : QGraphicsView(new QGraphicsScene(), parent)
|
|
|
{
|
|
|
setRenderHints(QPainter::Antialiasing); // 抗锯齿
|
|
@@ -28,6 +35,41 @@ void CMindView::setALignment(CMindView::Alignment align)
|
|
|
m_align = align;
|
|
|
}
|
|
|
|
|
|
+void CMindView::contextMenuEvent(QContextMenuEvent *event)
|
|
|
+{
|
|
|
+ QMenu *menu = new QMenu();
|
|
|
+
|
|
|
+ QAction *selectAction = menu->addAction("全选");
|
|
|
+ connect(selectAction, &QAction::triggered, this, &CMindView::slotSelectAllNodes);
|
|
|
+
|
|
|
+ QAction *clearAction = menu->addAction("清空");
|
|
|
+ connect(clearAction, &QAction::triggered, this, &CMindView::slotClearAllNodes);
|
|
|
+
|
|
|
+ if (m_mind != nullptr && m_mind->nodeList().count() <= 0) {
|
|
|
+ QAction *root = menu->addAction("创建根节点");
|
|
|
+ connect(root, &QAction::triggered, this, &CMindView::slotCreateRootNode);
|
|
|
+ }
|
|
|
+
|
|
|
+ menu->exec(event->globalPos());
|
|
|
+
|
|
|
+ QGraphicsView::contextMenuEvent(event);
|
|
|
+}
|
|
|
+
|
|
|
+void CMindView::slotCreateRootNode()
|
|
|
+{
|
|
|
+ qDebug() << __FUNCTION__ << __LINE__ << endl;
|
|
|
+}
|
|
|
+
|
|
|
+void CMindView::slotClearAllNodes()
|
|
|
+{
|
|
|
+ qDebug() << __FUNCTION__ << __LINE__ << endl;
|
|
|
+}
|
|
|
+
|
|
|
+void CMindView::slotSelectAllNodes()
|
|
|
+{
|
|
|
+ qDebug() << __FUNCTION__ << __LINE__ << endl;
|
|
|
+}
|
|
|
+
|
|
|
void CMindView::testItems()
|
|
|
{
|
|
|
CRectItem *r = new CRectItem(QRectF(0, 0, 100, 100));
|