Commit 92556a61 authored by Florent D'Halluin's avatar Florent D'Halluin
Browse files

[yavgui] Do not add a state when a transition is highlighted.

* yavgui/src/g_painter.hxx: Add necessary connections.
* yavgui/src/g_scene.cc,
* yavgui/src/g_scene.hh: Ignore right click when any item is selected.
* yavgui/src/g_vcsn_handler.hxx: Unselect a state upon destruction.
parent 696af6a6
2009-08-04 d-halluin <d-halluin@lrde.epita.fr>
[yavgui] Do not add a state when a transition is highlighted.
* yavgui/src/g_painter.hxx: Add necessary connections.
* yavgui/src/g_scene.cc,
* yavgui/src/g_scene.hh: Ignore right click when any item is selected.
* yavgui/src/g_vcsn_handler.hxx: Unselect a state upon destruction.
2009-08-04 d-halluin <d-halluin@lrde.epita.fr>
 
[yavgui] Update state property dialog.
......
......@@ -48,7 +48,6 @@ namespace gui
AUTOMATON_TYPES(Automaton)
std::vector<GState*> states;
std::map<hstate_t, GState*> state_map;
int i = 0;
for_all_states (istate, automaton)
{
QString initial_entry;
......@@ -70,7 +69,7 @@ namespace gui
color.setGreen (color.green () - 30);
color.setRed (color.red () - 30);
}
GState *state = new GState (i++, color,
GState *state = new GState (*istate, color,
initial_entry,
final_entry);
states.push_back(state);
......@@ -96,6 +95,7 @@ namespace gui
GTransition *transition =
new GTransition (*from, *to, label.str ().c_str (), index);
(*scene_)->addItem (transition);
(*scene_)->connectTransition(transition);
}
(*view_)->fitInView ((*scene_)->itemsBoundingRect (),
......
......@@ -30,14 +30,14 @@ namespace gui
namespace display
{
GScene::GScene ()
: state_selected_(false)
: item_selected_(false)
{
}
void
GScene::mousePressEvent(QGraphicsSceneMouseEvent* event)
{
if (state_selected_ == false && event->button() == Qt::RightButton)
if (!item_selected_ && event->button() == Qt::RightButton)
{
emit addState(event->scenePos ());
}
......@@ -50,28 +50,36 @@ namespace gui
connect(state, SIGNAL(delState()),
this, SLOT(delState()));
connect(state, SIGNAL(selected()),
this, SLOT(stateSelected()));
this, SLOT(itemSelected()));
connect(state, SIGNAL(deselected()),
this, SLOT(stateDeselected()));
this, SLOT(itemDeselected()));
}
void
GScene::connectTransition(GTransition* transition)
{
connect(transition, SIGNAL(selected()),
this, SLOT(itemSelected()));
connect(transition, SIGNAL(deselected()),
this, SLOT(itemDeselected()));
}
void
GScene::delState()
{
state_selected_ = false;
emit delState(dynamic_cast<GState*>(sender()));
}
void
GScene::stateSelected()
GScene::itemSelected()
{
state_selected_ = true;
item_selected_ = true;
}
void
GScene::stateDeselected()
GScene::itemDeselected()
{
state_selected_ = false;
item_selected_ = false;
}
} // ! namespace display
......
......@@ -29,6 +29,7 @@
# include "common.hh"
# include "g_state.hh"
# include "g_transition.hh"
namespace gui
{
......@@ -42,6 +43,7 @@ namespace gui
GScene();
void connectState(GState* state);
void connectTransition(GTransition* transition);
void mousePressEvent(QGraphicsSceneMouseEvent* event);
public slots:
......@@ -49,8 +51,8 @@ namespace gui
void delState();
// Used to ignore right click events.
void stateSelected();
void stateDeselected();
void itemSelected();
void itemDeselected();
signals:
// Automaton structure modification requests.
......@@ -59,7 +61,7 @@ namespace gui
void addState(QPointF pos);
private:
bool state_selected_;
bool item_selected_;
};
} // ! namespace display
......
......@@ -60,6 +60,7 @@ namespace gui
automaton.del_state(state->index());
delete (state); // removes it from the scene properly.
(*(info.scene))->itemDeselected();
state = 0;
}
} // ! namespace display
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment