selecting destination at edge add/remove does not set the dest node the active one bugfix

master
Denes Matetelki 14 years ago
parent da74ca1a3e
commit e3b36decc3

@ -11,6 +11,11 @@ namespace Ui {
class MainWindow; class MainWindow;
} }
/** Responsibilities:
* - taking care of the menu and toolbars, file operations
* - displaying info in statusbar
* - handle content change
*/
class MainWindow : public QMainWindow class MainWindow : public QMainWindow
{ {
Q_OBJECT Q_OBJECT

@ -812,6 +812,7 @@ void GraphWidget::addEdge(Node *source, Node *destination)
if (destination == m_nodeList.first()) if (destination == m_nodeList.first())
{ {
setActiveNode(destination);
emit notification( emit notification(
tr("Root element cannot be an edge target.")); tr("Root element cannot be an edge target."));
return; return;
@ -819,6 +820,7 @@ void GraphWidget::addEdge(Node *source, Node *destination)
if (source->isConnected(destination)) if (source->isConnected(destination))
{ {
setActiveNode(destination);
emit notification( emit notification(
tr("There is already an edge between these two nodes.")); tr("There is already an edge between these two nodes."));
} }
@ -842,8 +844,9 @@ void GraphWidget::addEdge(Node *source, Node *destination)
// The Edge is secondary, because the Node already has a parent // The Edge is secondary, because the Node already has a parent
// (it is already a destination of another Edge) // (it is already a destination of another Edge)
edge->setSecondary(sec); edge->setSecondary(sec);
m_scene->addItem(edge); m_scene->addItem(edge);
setActiveNode(destination);
emit contentChanged(); emit contentChanged();
} }
} }
@ -858,11 +861,13 @@ void GraphWidget::removeEdge(Node *source, Node *destination)
if (!source->isConnected(destination)) if (!source->isConnected(destination))
{ {
setActiveNode(destination);
emit notification(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);
setActiveNode(destination);
emit contentChanged(); emit contentChanged();
} }
} }
@ -893,7 +898,8 @@ void GraphWidget::setActiveNode(Node *node)
m_activeNode->setBorder(false); m_activeNode->setBorder(false);
m_activeNode = node; m_activeNode = node;
m_activeNode->setBorder(); if (m_activeNode)
m_activeNode->setBorder();
} }
// re-draw numbers // re-draw numbers

@ -53,6 +53,7 @@ void MainWindow::statusBarMsg(const QString &msg)
void MainWindow::contentChanged(const bool& changed) void MainWindow::contentChanged(const bool& changed)
{ {
// only care about the transitions
if (m_contentChanged == false && changed == true) if (m_contentChanged == false && changed == true)
{ {
setWindowTitle(windowTitle().prepend("* ")); setWindowTitle(windowTitle().prepend("* "));
@ -276,12 +277,14 @@ void MainWindow::quit()
void MainWindow::closeEvent(QCloseEvent * event) void MainWindow::closeEvent(QCloseEvent * event)
{ {
m_contentChanged && !closeFile() ? event->ignore() : event->accept(); m_contentChanged && !closeFile() ?
event->ignore() :
event->accept();
} }
void MainWindow::keyPressEvent(QKeyEvent *event) void MainWindow::keyPressEvent(QKeyEvent *event)
{ {
// incative action does not listen to signals // inactive action does not listen to signals
if (event->modifiers() & Qt::ControlModifier) if (event->modifiers() & Qt::ControlModifier)
{ {
if (event->key() == Qt::Key_M) if (event->key() == Qt::Key_M)

Loading…
Cancel
Save