element editor : improve add line

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3454 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2014-11-05 10:09:12 +00:00
parent 1177512f23
commit c81b4fb07c
3 changed files with 26 additions and 14 deletions

View File

@@ -68,6 +68,7 @@ ElementScene::~ElementScene() {
*/
void ElementScene::slot_move() {
behavior = Normal;
if (m_event_interface) delete m_event_interface; m_event_interface = nullptr;
}
/**
@@ -75,6 +76,7 @@ void ElementScene::slot_move() {
*/
void ElementScene::slot_addRectangle() {
behavior = Rectangle;
if (m_event_interface) delete m_event_interface; m_event_interface = nullptr;
}
/**
@@ -82,6 +84,7 @@ void ElementScene::slot_addRectangle() {
*/
void ElementScene::slot_addCircle() {
behavior = Circle;
if (m_event_interface) delete m_event_interface; m_event_interface = nullptr;
}
/**
@@ -89,6 +92,7 @@ void ElementScene::slot_addCircle() {
*/
void ElementScene::slot_addEllipse() {
behavior = Ellipse;
if (m_event_interface) delete m_event_interface; m_event_interface = nullptr;
}
/**
@@ -96,6 +100,7 @@ void ElementScene::slot_addEllipse() {
*/
void ElementScene::slot_addPolygon() {
behavior = Polygon;
if (m_event_interface) delete m_event_interface; m_event_interface = nullptr;
}
@@ -104,6 +109,7 @@ void ElementScene::slot_addPolygon() {
*/
void ElementScene::slot_addText() {
behavior = Text;
if (m_event_interface) delete m_event_interface; m_event_interface = nullptr;
}
/**
@@ -111,6 +117,7 @@ void ElementScene::slot_addText() {
*/
void ElementScene::slot_addTerminal() {
behavior = Terminal;
if (m_event_interface) delete m_event_interface; m_event_interface = nullptr;
}
/**
@@ -118,6 +125,7 @@ void ElementScene::slot_addTerminal() {
*/
void ElementScene::slot_addArc() {
behavior = Arc;
if (m_event_interface) delete m_event_interface; m_event_interface = nullptr;
}
/**
@@ -125,6 +133,7 @@ void ElementScene::slot_addArc() {
*/
void ElementScene::slot_addTextField() {
behavior = TextField;
if (m_event_interface) delete m_event_interface; m_event_interface = nullptr;
}
/**

View File

@@ -72,18 +72,6 @@ bool ESEventAddLine::mousePressEvent(QGraphicsSceneMouseEvent *event) {
return true;
}
//Remove the current line if exist
//or finish if no line
if (event -> button() == Qt::RightButton) {
if (m_line) {
delete m_line; m_line = nullptr;
}
else {
m_running = false;
}
return true;
}
return false;
}
@@ -101,3 +89,17 @@ bool ESEventAddLine::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
m_line -> setLine(QLineF(m_line->line().p1(), pos));
return true;
}
/**
* @brief ESEventAddLine::mouseReleaseEvent
* @param event
* @return
*/
bool ESEventAddLine::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
if (event -> button() == Qt::RightButton) {
if (m_line) {delete m_line; m_line = nullptr;}
else {m_running = false;}
return true;
}
return false;
}

View File

@@ -30,8 +30,9 @@ class ESEventAddLine : public ESEventInterface
ESEventAddLine(ElementScene *scene);
virtual ~ESEventAddLine();
virtual bool mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual bool mouseMoveEvent (QGraphicsSceneMouseEvent *event);
virtual bool mousePressEvent (QGraphicsSceneMouseEvent *event);
virtual bool mouseMoveEvent (QGraphicsSceneMouseEvent *event);
virtual bool mouseReleaseEvent (QGraphicsSceneMouseEvent *event);
private:
PartLine *m_line;