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)
{
m_editingNode = true;
m_activeNode->setEditable();
m_scene->setFocusItem(m_activeNode);
setActiveNodeEditable();
}
else
{
@ -380,6 +378,9 @@ void GraphWidget::insertNode()
m_nodeList.append(node);
m_scene->addItem(new Edge(m_activeNode, node));
setActiveNode(node);
setActiveNodeEditable();
}
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));
}
void GraphWidget::setActiveNodeEditable()
{
m_editingNode = true;
m_activeNode->setEditable();
m_scene->setFocusItem(m_activeNode);
}

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

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

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

Loading…
Cancel
Save