mouse double click sets selected node editable, when inserting a new node, the new node gets focus and become editable

master
Denes Matetelki 14 years ago
parent c1e011dc43
commit 74ec242dd6

@ -275,9 +275,7 @@ void GraphWidget::keyPressEvent(QKeyEvent *event)
if (m_activeNode) if (m_activeNode)
{ {
m_editingNode = true; setActiveNodeEditable();
m_activeNode->setEditable();
m_scene->setFocusItem(m_activeNode);
} }
else else
{ {
@ -380,6 +378,9 @@ void GraphWidget::insertNode()
m_nodeList.append(node); m_nodeList.append(node);
m_scene->addItem(new Edge(m_activeNode, node)); m_scene->addItem(new Edge(m_activeNode, node));
setActiveNode(node);
setActiveNodeEditable();
} }
void GraphWidget::showingAllNodeNumbers(const bool &show) void GraphWidget::showingAllNodeNumbers(const bool &show)
@ -432,3 +433,10 @@ bool GraphWidget::numberStartsWithNumber(const int &number, const int &prefix)
{ {
return (QString::number(number)).startsWith(QString::number(prefix)); return (QString::number(number)).startsWith(QString::number(prefix));
} }
void GraphWidget::setActiveNodeEditable()
{
m_editingNode = true;
m_activeNode->setEditable();
m_scene->setFocusItem(m_activeNode);
}

@ -19,6 +19,7 @@ public:
QGraphicsScene *getScene(); QGraphicsScene *getScene();
void setActiveNode(Node *node); void setActiveNode(Node *node);
void insertNode(); void insertNode();
void setActiveNodeEditable();
protected: protected:

@ -132,12 +132,11 @@ void Node::mousePressEvent(QGraphicsSceneMouseEvent *event)
QGraphicsItem::mousePressEvent(event); QGraphicsItem::mousePressEvent(event);
} }
//void Node::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) void Node::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
//{ {
// m_graph->insertNode(); Q_UNUSED(event);
m_graph->setActiveNodeEditable();
// QGraphicsItem::mouseDoubleClickEvent(event); }
//}
void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {

@ -33,7 +33,7 @@ protected:
QWidget *widget); QWidget *widget);
QVariant itemChange(GraphicsItemChange change, const QVariant &value); QVariant itemChange(GraphicsItemChange change, const QVariant &value);
void mousePressEvent(QGraphicsSceneMouseEvent *event); void mousePressEvent(QGraphicsSceneMouseEvent *event);
//void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
void linkActivated(const QString &link); void linkActivated(const QString &link);

Loading…
Cancel
Save