doxyfile added. Notifications to parent objects done with signals, not with callbacks. Node is created with factory method in GraphWidget.

master
Denes Matetelki 14 years ago
parent 4abf53400f
commit c9fb8b7c85

1
.gitignore vendored

@ -6,3 +6,4 @@ moc_*
qrc_* qrc_*
qtmindmap qtmindmap
*.pro.user *.pro.user
html/

@ -17,13 +17,6 @@ class GraphWidget : public QGraphicsView
public: public:
GraphWidget(MainWindow *parent = 0); GraphWidget(MainWindow *parent = 0);
// node reports back it's state change
void nodeSelected(Node *node);
void nodeMoved(QGraphicsSceneMouseEvent *event);
// notify MainWindow: a node/edge has changed
void contentChanged(const bool &changed = true);
// commands from MainWindow // commands from MainWindow
void newScene(); void newScene();
void closeScene(); void closeScene();
@ -36,7 +29,6 @@ public slots:
// commands from MainWindow's MainToolBar's actions // commands from MainWindow's MainToolBar's actions
void insertNode(); void insertNode();
void removeNode(); void removeNode();
void editNode();
void zoomIn(); void zoomIn();
void zoomOut(); void zoomOut();
void scaleUp(); void scaleUp();
@ -45,12 +37,23 @@ public slots:
void nodeTextColor(); void nodeTextColor();
void addEdge(); void addEdge();
void removeEdge(); void removeEdge();
void nodeLostFocus();
void hintMode(); void hintMode();
// bundled signals from statusIconsToolBar // bundled signals from statusIconsToolBar
void insertPicture(const QString &picture); void insertPicture(const QString &picture);
// node reports back it's state change
void nodeChanged();
void nodeSelected();
void nodeEdited();
void nodeMoved(QGraphicsSceneMouseEvent *event);
void nodeLostFocus();
signals:
void contentChanged();
void notification(const QString &msg);
protected: protected:
// key dispathcer of the whole program: long and pedant // key dispathcer of the whole program: long and pedant
@ -60,6 +63,10 @@ protected:
private: private:
Node * nodeFactory();
void selectNode(Node *node);
// zoom in/out of the view // zoom in/out of the view
void scaleView(qreal scaleFactor); void scaleView(qreal scaleFactor);

@ -20,14 +20,14 @@ public:
explicit MainWindow(QWidget *parent = 0); explicit MainWindow(QWidget *parent = 0);
~MainWindow(); ~MainWindow();
public slots:
// instead of givin access to private m_ui // instead of givin access to private m_ui
void statusBarMsg(const QString &msg); void statusBarMsg(const QString &msg);
// indicate that content has changed, modify title, save actions // indicate that content has changed, modify title, save actions
void contentChanged(const bool &changed = true); void contentChanged(const bool &changed = true);
public slots:
// filemenu actions // filemenu actions
void newFile(); void newFile();
void openFile(const QString &fileName = ""); void openFile(const QString &fileName = "");

@ -12,6 +12,8 @@ class GraphWidget;
class Node : public QGraphicsTextItem class Node : public QGraphicsTextItem
{ {
Q_OBJECT
public: public:
Node(GraphWidget *graphWidget = 0); Node(GraphWidget *graphWidget = 0);
@ -54,6 +56,17 @@ public:
// returns with the biggest angle between the edges // returns with the biggest angle between the edges
double calculateBiggestAngle() const; double calculateBiggestAngle() const;
static const QPointF newNodeCenter;
static const QPointF newNodeBottomRigth;
signals:
void nodeChanged();
void nodeSelected();
void nodeEdited();
void nodeMoved(QGraphicsSceneMouseEvent *event);
void nodeLostFocus();
protected: protected:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,

File diff suppressed because it is too large Load Diff

@ -40,26 +40,10 @@ GraphWidget::GraphWidget(MainWindow *parent)
} }
void GraphWidget::nodeSelected(Node *node) void GraphWidget::nodeSelected()
{ {
// leave hint mode // if node == 0 then nodeSelected invoked after a signal from a Node
showingAllNodeNumbers(false); selectNode(dynamic_cast<Node*>(QObject::sender()));
m_showingNodeNumbers = false;
if (m_edgeAdding)
{
addEdge(m_activeNode, node);
m_edgeAdding = false;
}
else if (m_edgeDeleting)
{
removeEdge(m_activeNode, node);
m_edgeDeleting = false;
}
else
{
setActiveNode(node);
}
} }
void GraphWidget::nodeMoved(QGraphicsSceneMouseEvent *event) void GraphWidget::nodeMoved(QGraphicsSceneMouseEvent *event)
@ -80,9 +64,9 @@ void GraphWidget::nodeMoved(QGraphicsSceneMouseEvent *event)
node->setPos(node->pos() + event->scenePos() - event->lastScenePos()); node->setPos(node->pos() + event->scenePos() - event->lastScenePos());
} }
void GraphWidget::contentChanged(const bool &changed) void GraphWidget::nodeChanged()
{ {
m_parent->contentChanged(changed); emit contentChanged();
} }
void GraphWidget::newScene() void GraphWidget::newScene()
@ -105,13 +89,13 @@ bool GraphWidget::readContentFromXmlFile(const QString &fileName)
QFile file(fileName); QFile file(fileName);
if (!file.open(QIODevice::ReadOnly)) if (!file.open(QIODevice::ReadOnly))
{ {
m_parent->statusBarMsg(tr("Couldn't read file.")); emit notification(tr("Couldn't read file."));
return false; return false;
} }
if (!doc.setContent(&file)) if (!doc.setContent(&file))
{ {
m_parent->statusBarMsg(tr("Couldn't parse XML file.")); emit notification(tr("Couldn't parse XML file."));
file.close(); file.close();
return false; return false;
} }
@ -126,9 +110,8 @@ bool GraphWidget::readContentFromXmlFile(const QString &fileName)
QDomElement e = nodes.item(i).toElement(); QDomElement e = nodes.item(i).toElement();
if(!e.isNull()) if(!e.isNull())
{ {
Node *node = new Node(this); Node *node = nodeFactory();
node->setHtml(e.attribute("htmlContent")); node->setHtml(e.attribute("htmlContent"));
m_scene->addItem(node);
node->setPos(e.attribute("x").toFloat(), node->setPos(e.attribute("x").toFloat(),
e.attribute("y").toFloat()); e.attribute("y").toFloat());
node->setScale(e.attribute("scale").toFloat(),sceneRect()); node->setScale(e.attribute("scale").toFloat(),sceneRect());
@ -138,8 +121,6 @@ bool GraphWidget::readContentFromXmlFile(const QString &fileName)
node->setTextColor(QColor(e.attribute("text_red").toFloat(), node->setTextColor(QColor(e.attribute("text_red").toFloat(),
e.attribute("text_green").toFloat(), e.attribute("text_green").toFloat(),
e.attribute("text_blue").toFloat())); e.attribute("text_blue").toFloat()));
m_nodeList.append(node);
} }
} }
@ -227,7 +208,7 @@ void GraphWidget::writeContentToXmlFile(const QString &fileName)
QFile file(fileName); QFile file(fileName);
if (!file.open(QIODevice::WriteOnly)) if (!file.open(QIODevice::WriteOnly))
{ {
m_parent->statusBarMsg(tr("Couldn't open file to write.")); emit notification(tr("Couldn't open file to write."));
return; return;
} }
QTextStream ts( &file ); QTextStream ts( &file );
@ -235,7 +216,7 @@ void GraphWidget::writeContentToXmlFile(const QString &fileName)
file.close(); file.close();
// show a statusBar message to the user // show a statusBar message to the user
m_parent->statusBarMsg(tr("Saved.")); emit notification(tr("Saved."));
} }
void GraphWidget::writeContentToPngFile(const QString &fileName) void GraphWidget::writeContentToPngFile(const QString &fileName)
@ -257,7 +238,7 @@ void GraphWidget::writeContentToPngFile(const QString &fileName)
img.save(fileName); img.save(fileName);
// show a statusBar message to the user // show a statusBar message to the user
m_parent->statusBarMsg(tr("MindMap exported as ") + fileName); emit notification(tr("MindMap exported as ") + fileName);
} }
void GraphWidget::insertNode() void GraphWidget::insertNode()
@ -266,7 +247,7 @@ void GraphWidget::insertNode()
if (!m_activeNode) if (!m_activeNode)
{ {
m_parent->statusBarMsg(tr("No active node.")); emit notification(tr("No active node."));
return; return;
} }
@ -278,36 +259,32 @@ void GraphWidget::insertNode()
QPointF pos(length * cos(angle), length * sin(angle)); QPointF pos(length * cos(angle), length * sin(angle));
// add a new node which inherits the color and textColor
Node *node = new Node(this);
node->setColor(m_activeNode->color());
node->setTextColor(m_activeNode->textColor());
node->setHtml(QString(""));
m_scene->addItem(node);
QPointF newPos(m_activeNode->sceneBoundingRect().center() + QPointF newPos(m_activeNode->sceneBoundingRect().center() +
pos - pos - Node::newNodeCenter);
node->boundingRect().center());
QRectF rect (scene()->sceneRect().topLeft(), QRectF rect (scene()->sceneRect().topLeft(),
scene()->sceneRect().bottomRight() - scene()->sceneRect().bottomRight()
node->boundingRect().bottomRight()); - Node::newNodeBottomRigth);
if (!rect.contains(newPos)) if (!rect.contains(newPos))
{ {
delete node; emit notification(tr("New node would be placed outside of the scene"));
m_parent->statusBarMsg(tr("New node would be placed outside of the scene"));
return; return;
} }
// add a new node which inherits the color and textColor
Node *node = nodeFactory();
node->setColor(m_activeNode->color());
node->setTextColor(m_activeNode->textColor());
node->setHtml(QString(""));
node->setPos(newPos); node->setPos(newPos);
m_nodeList.append(node);
addEdge(m_activeNode, node); addEdge(m_activeNode, node);
// set it the active Node and editable, so the user can edit it at once // set it the active Node and editable, so the user can edit it at once
setActiveNode(node); setActiveNode(node);
editNode(); nodeEdited();
contentChanged(); emit contentChanged();
// it we are in hint mode, the numbers shall be re-calculated // it we are in hint mode, the numbers shall be re-calculated
if (m_showingNodeNumbers) if (m_showingNodeNumbers)
@ -318,13 +295,13 @@ void GraphWidget::removeNode()
{ {
if (!m_activeNode) if (!m_activeNode)
{ {
m_parent->statusBarMsg(tr("No active node.")); emit notification(tr("No active node."));
return; return;
} }
if (m_activeNode == m_nodeList.first()) if (m_activeNode == m_nodeList.first())
{ {
m_parent->statusBarMsg(tr("Base node cannot be deleted.")); emit notification(tr("Base node cannot be deleted."));
return; return;
} }
@ -350,18 +327,18 @@ void GraphWidget::removeNode()
} }
m_activeNode = 0; m_activeNode = 0;
contentChanged(); emit contentChanged();
// it we are in hint mode, the numbers shall be re-calculated // it we are in hint mode, the numbers shall be re-calculated
if (m_showingNodeNumbers) if (m_showingNodeNumbers)
showNodeNumbers(); showNodeNumbers();
} }
void GraphWidget::editNode() void GraphWidget::nodeEdited()
{ {
if (!m_activeNode) if (!m_activeNode)
{ {
m_parent->statusBarMsg(tr("No active node.")); emit notification(tr("No active node."));
return; return;
} }
@ -384,7 +361,7 @@ void GraphWidget::scaleUp()
{ {
if (!m_activeNode) if (!m_activeNode)
{ {
m_parent->statusBarMsg(tr("No active node.")); emit notification(tr("No active node."));
return; return;
} }
@ -405,7 +382,7 @@ void GraphWidget::scaleDown()
{ {
if (!m_activeNode) if (!m_activeNode)
{ {
m_parent->statusBarMsg(tr("No active node.")); emit notification(tr("No active node."));
return; return;
} }
@ -426,7 +403,7 @@ void GraphWidget::nodeColor()
{ {
if (!m_activeNode) if (!m_activeNode)
{ {
m_parent->statusBarMsg(tr("No active node.")); emit notification(tr("No active node."));
return; return;
} }
@ -462,7 +439,7 @@ void GraphWidget::nodeTextColor()
{ {
if (!m_activeNode) if (!m_activeNode)
{ {
m_parent->statusBarMsg(tr("No active node.")); emit notification(tr("No active node."));
return; return;
} }
@ -492,13 +469,13 @@ void GraphWidget::nodeTextColor()
void GraphWidget::addEdge() void GraphWidget::addEdge()
{ {
m_parent->statusBarMsg(tr("Add edge: select destination node.")); emit notification(tr("Add edge: select destination node."));
m_edgeAdding = true; m_edgeAdding = true;
} }
void GraphWidget::removeEdge() void GraphWidget::removeEdge()
{ {
m_parent->statusBarMsg(tr("Delete edge: select other end-node.")); emit notification(tr("Delete edge: select other end-node."));
m_edgeDeleting = true; m_edgeDeleting = true;
} }
@ -518,14 +495,14 @@ void GraphWidget::nodeLostFocus()
if (m_edgeAdding) if (m_edgeAdding)
{ {
m_edgeAdding = false; m_edgeAdding = false;
m_parent->statusBarMsg(tr("Edge adding cancelled.")); emit notification(tr("Edge adding cancelled."));
return; return;
} }
if (m_edgeDeleting) if (m_edgeDeleting)
{ {
m_edgeDeleting = false; m_edgeDeleting = false;
m_parent->statusBarMsg(tr("Edge deleting cancelled.")); emit notification(tr("Edge deleting cancelled."));
return; return;
} }
@ -558,7 +535,7 @@ void GraphWidget::insertPicture(const QString &picture)
{ {
if (!m_activeNode) if (!m_activeNode)
{ {
m_parent->statusBarMsg(tr("No active node.")); emit notification(tr("No active node."));
return; return;
} }
@ -595,7 +572,7 @@ void GraphWidget::keyPressEvent(QKeyEvent *event)
if (!m_activeNode) if (!m_activeNode)
{ {
m_parent->statusBarMsg(tr("No active node.")); emit notification(tr("No active node."));
return; return;
} }
@ -612,7 +589,7 @@ void GraphWidget::keyPressEvent(QKeyEvent *event)
else if (event->key() == Qt::Key_Left) node->moveBy(-20, 0); else if (event->key() == Qt::Key_Left) node->moveBy(-20, 0);
else if (event->key() == Qt::Key_Right) node->moveBy(20, 0); else if (event->key() == Qt::Key_Right) node->moveBy(20, 0);
contentChanged(); emit contentChanged();
} }
} }
else // Move just the active Node. else // Move just the active Node.
@ -626,7 +603,7 @@ void GraphWidget::keyPressEvent(QKeyEvent *event)
else if (event->key() == Qt::Key_Right) else if (event->key() == Qt::Key_Right)
m_activeNode->moveBy(20, 0); m_activeNode->moveBy(20, 0);
contentChanged(); emit contentChanged();
} }
} }
else // Move scene. else // Move scene.
@ -695,13 +672,13 @@ void GraphWidget::keyPressEvent(QKeyEvent *event)
case Qt::Key_Enter: case Qt::Key_Enter:
if (m_hintNode && m_showingNodeNumbers) if (m_hintNode && m_showingNodeNumbers)
nodeSelected(m_hintNode); selectNode(m_hintNode);
break; break;
case Qt::Key_F2: case Qt::Key_F2:
editNode(); nodeEdited();
break; break;
case Qt::Key_Delete: case Qt::Key_Delete:
@ -754,6 +731,45 @@ void GraphWidget::drawBackground(QPainter *painter, const QRectF &rect)
painter->drawRect(m_scene->sceneRect()); painter->drawRect(m_scene->sceneRect());
} }
Node * GraphWidget::nodeFactory()
{
Node *node = new Node(this);
connect(node, SIGNAL(nodeChanged()), this, SLOT(nodeChanged()));
connect(node, SIGNAL(nodeSelected()), this, SLOT(nodeSelected()));
connect(node, SIGNAL(nodeEdited()), this, SLOT(nodeEdited()));
connect(node, SIGNAL(nodeMoved(QGraphicsSceneMouseEvent*)),
this, SLOT(nodeMoved(QGraphicsSceneMouseEvent*)));
connect(node, SIGNAL(nodeLostFocus()), this, SLOT(nodeLostFocus()));
m_scene->addItem(node);
m_nodeList.append(node);
return node;
}
void GraphWidget::selectNode(Node *node)
{
// leave hint mode
showingAllNodeNumbers(false);
m_showingNodeNumbers = false;
if (m_edgeAdding)
{
addEdge(m_activeNode, node);
m_edgeAdding = false;
}
else if (m_edgeDeleting)
{
removeEdge(m_activeNode, node);
m_edgeDeleting = false;
}
else
{
setActiveNode(node);
}
}
void GraphWidget::scaleView(qreal scaleFactor) void GraphWidget::scaleView(qreal scaleFactor)
{ {
qreal factor = transform().scale(scaleFactor, scaleFactor). qreal factor = transform().scale(scaleFactor, scaleFactor).
@ -786,20 +802,20 @@ void GraphWidget::addEdge(Node *source, Node *destination)
{ {
if (!m_activeNode) if (!m_activeNode)
{ {
m_parent->statusBarMsg(tr("No active node.")); emit notification(tr("No active node."));
return; return;
} }
if (destination == m_nodeList.first()) if (destination == m_nodeList.first())
{ {
m_parent->statusBarMsg( emit notification(
tr("Root element cannot be an edge target.")); tr("Root element cannot be an edge target."));
return; return;
} }
if (source->isConnected(destination)) if (source->isConnected(destination))
{ {
m_parent->statusBarMsg( emit notification(
tr("There is already an edge between these two nodes.")); tr("There is already an edge between these two nodes."));
} }
else else
@ -808,7 +824,7 @@ void GraphWidget::addEdge(Node *source, Node *destination)
bool sec(false); bool sec(false);
if (!destination->edgesToThis().empty()) if (!destination->edgesToThis().empty())
{ {
m_parent->statusBarMsg( emit notification(
tr("The graph is acyclic, edge added as secondary edge.")); tr("The graph is acyclic, edge added as secondary edge."));
sec = true; sec = true;
} }
@ -821,7 +837,7 @@ void GraphWidget::addEdge(Node *source, Node *destination)
edge->setSecondary(sec); edge->setSecondary(sec);
m_scene->addItem(edge); m_scene->addItem(edge);
contentChanged(); emit contentChanged();
} }
} }
@ -829,29 +845,26 @@ void GraphWidget::removeEdge(Node *source, Node *destination)
{ {
if (!m_activeNode) if (!m_activeNode)
{ {
m_parent->statusBarMsg(tr("No active node.")); emit notification(tr("No active node."));
return; return;
} }
if (!source->isConnected(destination)) if (!source->isConnected(destination))
{ {
m_parent->statusBarMsg(tr("There no edge between these two nodes.")); emit notification(tr("There no edge between these two nodes."));
} }
else else
{ {
source->deleteEdge(destination); source->deleteEdge(destination);
contentChanged(); emit contentChanged();
} }
} }
void GraphWidget::addFirstNode() void GraphWidget::addFirstNode()
{ {
Node *node = new Node(this); Node *node = nodeFactory();
node->setHtml( node->setHtml(
QString("<img src=:/qtmindmap.svg width=50 height=50></img>")); QString("<img src=:/qtmindmap.svg width=50 height=50></img>"));
m_scene->addItem(node);
m_nodeList.append(node);
m_activeNode = m_nodeList.first(); m_activeNode = m_nodeList.first();
m_activeNode->setBorder(); m_activeNode->setBorder();
@ -931,7 +944,7 @@ void GraphWidget::showingNodeNumbersBeginWithNumber(const int &prefix,
} }
if (hit==1) if (hit==1)
{ {
nodeSelected(m_hintNode); selectNode(m_hintNode);
} }
else if (hit == 0) else if (hit == 0)
{ {

@ -22,12 +22,17 @@ MainWindow::MainWindow(QWidget *parent) :
connect(m_ui->actionAbout_QtMindMap, SIGNAL(activated()), connect(m_ui->actionAbout_QtMindMap, SIGNAL(activated()),
this, SLOT(about())); this, SLOT(about()));
// graphwidget is hided by def, new/open file will show it // graphwidget is hided by def, new/open file will show it
m_graphicsView = new GraphWidget(this); m_graphicsView = new GraphWidget(this);
setCentralWidget(m_graphicsView); setCentralWidget(m_graphicsView);
m_graphicsView->hide(); m_graphicsView->hide();
connect(m_graphicsView, SIGNAL(contentChanged()),
this, SLOT(contentChanged()));
connect(m_graphicsView, SIGNAL(notification(QString)),
this, SLOT(statusBarMsg(QString)));
// setup toolbars, don't show them // setup toolbars, don't show them
setUpMainToolbar(); setUpMainToolbar();
m_ui->mainToolBar->hide(); m_ui->mainToolBar->hide();
@ -309,7 +314,7 @@ void MainWindow::setUpMainToolbar()
m_editNode = new QAction(tr("Edit node (F2, dubclick)"), this); m_editNode = new QAction(tr("Edit node (F2, dubclick)"), this);
connect(m_editNode, SIGNAL(activated()), m_graphicsView, connect(m_editNode, SIGNAL(activated()), m_graphicsView,
SLOT(editNode())); SLOT(nodeEdited()));
m_scaleUpNode = new QAction(tr("ScaleUp Node (Ctrl +)"), this); m_scaleUpNode = new QAction(tr("ScaleUp Node (Ctrl +)"), this);
connect(m_scaleUpNode, SIGNAL(activated()), m_graphicsView, connect(m_scaleUpNode, SIGNAL(activated()), m_graphicsView,

@ -6,6 +6,9 @@
#include <QGraphicsSceneMouseEvent> #include <QGraphicsSceneMouseEvent>
#include <QTextDocument> #include <QTextDocument>
const QPointF Node::newNodeCenter = QPointF(4, 11.5);
const QPointF Node::newNodeBottomRigth = QPointF(8, 23);
const double Node::m_pi = 3.14159265358979323846264338327950288419717; const double Node::m_pi = 3.14159265358979323846264338327950288419717;
const double Node::m_oneAndHalfPi = Node::m_pi * 1.5; const double Node::m_oneAndHalfPi = Node::m_pi * 1.5;
const double Node::m_twoPi = Node::m_pi * 2.0; const double Node::m_twoPi = Node::m_pi * 2.0;
@ -233,14 +236,14 @@ void Node::insertPicture(const QString &picture)
c.insertHtml(QString("<img src=").append(picture). c.insertHtml(QString("<img src=").append(picture).
append(" width=15 height=15></img>")); append(" width=15 height=15></img>"));
m_graph->contentChanged();
foreach (EdgeElement element, m_edgeList) element.edge->adjust(); foreach (EdgeElement element, m_edgeList) element.edge->adjust();
emit nodeChanged();
} }
QPointF Node::intersection(const QLineF &line, const bool &reverse) const QPointF Node::intersection(const QLineF &line, const bool &reverse) const
{ {
/// @note What a shame, the following does not work, /// @note What a pity, the following does not work,
/// doing it with brute (unaccurate) force /// doing it with brute (unaccurate) force
// QPainterPath nodeShape(shape()); // QPainterPath nodeShape(shape());
@ -358,8 +361,9 @@ void Node::keyPressEvent(QKeyEvent *event)
// not cursor movement: editing // not cursor movement: editing
QGraphicsTextItem::keyPressEvent(event); QGraphicsTextItem::keyPressEvent(event);
m_graph->contentChanged();
foreach (EdgeElement element, m_edgeList) element.edge->adjust(); foreach (EdgeElement element, m_edgeList) element.edge->adjust();
emit nodeChanged();
} }
///@note leaving editing mode is done with esc, handled by graphwidget ///@note leaving editing mode is done with esc, handled by graphwidget
@ -432,8 +436,8 @@ QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value)
case ItemPositionHasChanged: case ItemPositionHasChanged:
// Notify parent, adjust edges that a move has happended. // Notify parent, adjust edges that a move has happended.
m_graph->contentChanged();
foreach (EdgeElement element, m_edgeList) element.edge->adjust(); foreach (EdgeElement element, m_edgeList) element.edge->adjust();
emit nodeChanged();
break; break;
default: default:
@ -445,7 +449,7 @@ QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value)
void Node::mousePressEvent(QGraphicsSceneMouseEvent *event) void Node::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
m_graph->nodeSelected(this); emit nodeSelected();
QGraphicsItem::mousePressEvent(event); QGraphicsItem::mousePressEvent(event);
} }
@ -453,7 +457,8 @@ void Node::mousePressEvent(QGraphicsSceneMouseEvent *event)
void Node::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) void Node::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
m_graph->editNode();
emit nodeEdited();
} }
void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
@ -464,7 +469,7 @@ void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
// notify parent so subtree can be moved too if necessary // notify parent so subtree can be moved too if necessary
void Node::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void Node::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
m_graph->nodeMoved(event); emit nodeMoved(event);
} }
QPainterPath Node::shape () const QPainterPath Node::shape () const
@ -479,7 +484,8 @@ void Node::focusOutEvent(QFocusEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
setEditable(false); setEditable(false);
m_graph->nodeLostFocus();
emit nodeLostFocus();
} }
// there is no such thing as modulo operator for double :P // there is no such thing as modulo operator for double :P

Loading…
Cancel
Save