mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-22 01:10:53 +01:00
Minor change
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4255 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -169,14 +169,7 @@ void Diagram::drawBackground(QPainter *p, const QRectF &r) {
|
|||||||
*/
|
*/
|
||||||
void Diagram::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
void Diagram::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (m_event_interface) {
|
if (m_event_interface && m_event_interface->mouseDoubleClickEvent(event)) return;
|
||||||
if (m_event_interface -> mouseDoubleClickEvent(event)) {
|
|
||||||
if (m_event_interface->isFinish()) {
|
|
||||||
delete m_event_interface; m_event_interface = nullptr;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QGraphicsScene::mouseDoubleClickEvent(event);
|
QGraphicsScene::mouseDoubleClickEvent(event);
|
||||||
}
|
}
|
||||||
@@ -188,14 +181,7 @@ void Diagram::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
*/
|
*/
|
||||||
void Diagram::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void Diagram::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (m_event_interface) {
|
if (m_event_interface && m_event_interface->mousePressEvent(event)) return;
|
||||||
if (m_event_interface -> mousePressEvent(event)) {
|
|
||||||
if (m_event_interface->isFinish()) {
|
|
||||||
delete m_event_interface; m_event_interface = nullptr;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QGraphicsScene::mousePressEvent(event);
|
QGraphicsScene::mousePressEvent(event);
|
||||||
}
|
}
|
||||||
@@ -207,14 +193,7 @@ void Diagram::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
*/
|
*/
|
||||||
void Diagram::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
void Diagram::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (m_event_interface) {
|
if (m_event_interface && m_event_interface->mouseMoveEvent(event)) return;
|
||||||
if (m_event_interface -> mouseMoveEvent(event)) {
|
|
||||||
if (m_event_interface->isFinish()) {
|
|
||||||
delete m_event_interface; m_event_interface = nullptr;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QGraphicsScene::mouseMoveEvent(event);
|
QGraphicsScene::mouseMoveEvent(event);
|
||||||
}
|
}
|
||||||
@@ -226,14 +205,7 @@ void Diagram::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
*/
|
*/
|
||||||
void Diagram::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
void Diagram::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (m_event_interface) {
|
if (m_event_interface && m_event_interface->mouseReleaseEvent(event)) return;
|
||||||
if (m_event_interface -> mouseReleaseEvent(event)) {
|
|
||||||
if (m_event_interface->isFinish()) {
|
|
||||||
delete m_event_interface; m_event_interface = nullptr;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QGraphicsScene::mouseReleaseEvent(event);
|
QGraphicsScene::mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
@@ -245,14 +217,9 @@ void Diagram::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
*/
|
*/
|
||||||
void Diagram::wheelEvent(QGraphicsSceneWheelEvent *event)
|
void Diagram::wheelEvent(QGraphicsSceneWheelEvent *event)
|
||||||
{
|
{
|
||||||
if (m_event_interface) {
|
if (m_event_interface && m_event_interface->wheelEvent(event)) return;
|
||||||
if (m_event_interface -> wheelEvent(event)) {
|
|
||||||
if (m_event_interface->isFinish()) {
|
QGraphicsScene::wheelEvent(event);
|
||||||
delete m_event_interface; m_event_interface = nullptr;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -263,14 +230,7 @@ void Diagram::wheelEvent(QGraphicsSceneWheelEvent *event)
|
|||||||
*/
|
*/
|
||||||
void Diagram::keyPressEvent(QKeyEvent *e)
|
void Diagram::keyPressEvent(QKeyEvent *e)
|
||||||
{
|
{
|
||||||
if (m_event_interface) {
|
if (m_event_interface && m_event_interface->keyPressEvent(e)) return;
|
||||||
if (m_event_interface -> keyPressEvent(e)) {
|
|
||||||
if (m_event_interface->isFinish()) {
|
|
||||||
delete m_event_interface; m_event_interface = nullptr;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool transmit_event = true;
|
bool transmit_event = true;
|
||||||
if (!isReadOnly()) {
|
if (!isReadOnly()) {
|
||||||
@@ -301,14 +261,7 @@ void Diagram::keyPressEvent(QKeyEvent *e)
|
|||||||
*/
|
*/
|
||||||
void Diagram::keyReleaseEvent(QKeyEvent *e)
|
void Diagram::keyReleaseEvent(QKeyEvent *e)
|
||||||
{
|
{
|
||||||
if (m_event_interface) {
|
if (m_event_interface && m_event_interface->KeyReleaseEvent(e)) return;
|
||||||
if (m_event_interface -> KeyReleaseEvent(e)) {
|
|
||||||
if (m_event_interface->isFinish()) {
|
|
||||||
delete m_event_interface; m_event_interface = nullptr;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool transmit_event = true;
|
bool transmit_event = true;
|
||||||
if (!isReadOnly()) {
|
if (!isReadOnly()) {
|
||||||
@@ -334,6 +287,8 @@ void Diagram::keyReleaseEvent(QKeyEvent *e)
|
|||||||
* Diagram become the ownership of event_interface
|
* Diagram become the ownership of event_interface
|
||||||
* If there is a previous interface, they will be delete before
|
* If there is a previous interface, they will be delete before
|
||||||
* and call init() to the new interface.
|
* and call init() to the new interface.
|
||||||
|
* The derivated class of DiagramEventInterface need to emit the signal "finish" when the job is done,
|
||||||
|
* diagram use this signal to delete the interface. If the signal isn't send, the interface will never be deleted.
|
||||||
* @param event_interface
|
* @param event_interface
|
||||||
*/
|
*/
|
||||||
void Diagram::setEventInterface(DiagramEventInterface *event_interface)
|
void Diagram::setEventInterface(DiagramEventInterface *event_interface)
|
||||||
@@ -344,6 +299,7 @@ void Diagram::setEventInterface(DiagramEventInterface *event_interface)
|
|||||||
event_interface -> init();
|
event_interface -> init();
|
||||||
}
|
}
|
||||||
m_event_interface = event_interface;
|
m_event_interface = event_interface;
|
||||||
|
connect (m_event_interface, &DiagramEventInterface::finish, this, [this]() { delete this->m_event_interface; this->m_event_interface = nullptr;}, Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ bool DiagramEventAddElement::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief DiagramEventAddElement::mouseReleaseEvent
|
* @brief DiagramEventAddElement::mouseReleaseEvent
|
||||||
* Right button finish this event (isRunning = false)
|
* Right button finish this event (isRunning = false) and emit finish.
|
||||||
* Left button add an element to diagram
|
* Left button add an element to diagram
|
||||||
* @param event
|
* @param event
|
||||||
* @return always true
|
* @return always true
|
||||||
@@ -109,6 +109,7 @@ bool DiagramEventAddElement::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
delete m_element;
|
delete m_element;
|
||||||
m_element = nullptr;
|
m_element = nullptr;
|
||||||
m_running = false;
|
m_running = false;
|
||||||
|
emit finish();
|
||||||
}
|
}
|
||||||
else if (event->button() == Qt::LeftButton)
|
else if (event->button() == Qt::LeftButton)
|
||||||
{
|
{
|
||||||
@@ -121,7 +122,7 @@ bool DiagramEventAddElement::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief DiagramEventAddElement::mouseDoubleClickEvent
|
* @brief DiagramEventAddElement::mouseDoubleClickEvent
|
||||||
* If mouse left double clic, finish this event (isRunning = false)
|
* If mouse left double clic, finish this event (isRunning = false) and emit finish
|
||||||
* @param event
|
* @param event
|
||||||
* @return always true
|
* @return always true
|
||||||
*/
|
*/
|
||||||
@@ -132,6 +133,7 @@ bool DiagramEventAddElement::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *eve
|
|||||||
delete m_element;
|
delete m_element;
|
||||||
m_element = nullptr;
|
m_element = nullptr;
|
||||||
m_running = false;
|
m_running = false;
|
||||||
|
emit finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -81,9 +81,5 @@ bool DiagramEventInterface::isRunning() const {
|
|||||||
return m_running;
|
return m_running;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DiagramEventInterface::isFinish() const {
|
|
||||||
return !m_running;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DiagramEventInterface::init()
|
void DiagramEventInterface::init()
|
||||||
{}
|
{}
|
||||||
|
|||||||
@@ -29,8 +29,7 @@ class Diagram;
|
|||||||
* @brief The DiagramEventInterface class
|
* @brief The DiagramEventInterface class
|
||||||
* Each method return a bool: True if the methode do something else return false.
|
* Each method return a bool: True if the methode do something else return false.
|
||||||
* Each method of DVEventInterface return false;
|
* Each method of DVEventInterface return false;
|
||||||
* isRunning() return true if action is started but not finish. By default return false.
|
* isRunning() return true if action is running (do something). By default return false.
|
||||||
* isFinish() return true when the action is finish, or not started. By default return true.
|
|
||||||
*
|
*
|
||||||
* ##USE DiagramEventInterface##
|
* ##USE DiagramEventInterface##
|
||||||
* This class is the basic interface for manage event on a diagram.
|
* This class is the basic interface for manage event on a diagram.
|
||||||
@@ -41,8 +40,7 @@ class Diagram;
|
|||||||
* they send the event to the interface (for exemple mousePressEvent).
|
* they send the event to the interface (for exemple mousePressEvent).
|
||||||
* If the interface do something with this event, you need to return true to signal the diagram you work with this event.
|
* If the interface do something with this event, you need to return true to signal the diagram you work with this event.
|
||||||
* (if you do nothing by defaut the interface return false, so diagram do nothing)
|
* (if you do nothing by defaut the interface return false, so diagram do nothing)
|
||||||
* after that, the diagram call interface::isRunning(), if true diagram do nothing, else if false,
|
* When the interface job is done, we need to emit the signal finish(), the diagram use this signal to delete the interface.
|
||||||
* that mean interface has finish is action (interface::isFinish return true) so the diagram will delete this interface.
|
|
||||||
* Be carreful with the destructor, diagram can at any time (even if interface is still running) delete the interface,
|
* Be carreful with the destructor, diagram can at any time (even if interface is still running) delete the interface,
|
||||||
* the bool m_abort is here for that at destruction time.
|
* the bool m_abort is here for that at destruction time.
|
||||||
*
|
*
|
||||||
@@ -62,7 +60,6 @@ class DiagramEventInterface : public QObject
|
|||||||
virtual bool keyPressEvent (QKeyEvent *event);
|
virtual bool keyPressEvent (QKeyEvent *event);
|
||||||
virtual bool KeyReleaseEvent (QKeyEvent *event);
|
virtual bool KeyReleaseEvent (QKeyEvent *event);
|
||||||
virtual bool isRunning () const;
|
virtual bool isRunning () const;
|
||||||
virtual bool isFinish () const;
|
|
||||||
virtual void init();
|
virtual void init();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|||||||
Reference in New Issue
Block a user