[qet] qet/qet: [5299] simplify some code |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 5299
Author: blacksun
Date: 2018-04-05 11:37:35 +0200 (Thu, 05 Apr 2018)
Log Message:
-----------
simplify some code
Modified Paths:
--------------
trunk/sources/diagram.cpp
trunk/sources/diagram.h
trunk/sources/qetgraphicsitem/diagramtextitem.cpp
trunk/sources/qetgraphicsitem/dynamicelementtextitem.cpp
trunk/sources/qetgraphicsitem/elementtextitemgroup.cpp
trunk/sources/qetgraphicsitem/qetgraphicsitem.cpp
Modified: trunk/sources/diagram.cpp
===================================================================
--- trunk/sources/diagram.cpp 2018-04-05 08:10:06 UTC (rev 5298)
+++ trunk/sources/diagram.cpp 2018-04-05 09:37:35 UTC (rev 5299)
@@ -24,7 +24,6 @@
#include "diagramcommands.h"
#include "diagramcontent.h"
#include "diagramposition.h"
-#include "elementsmover.h"
#include "exportdialog.h"
#include "qetgraphicsitem/ghostelement.h"
#include "qetgraphicsitem/independenttextitem.h"
@@ -31,7 +30,6 @@
#include "qetgraphicsitem/diagramimageitem.h"
#include "qetgraphicsitem/qetshapeitem.h"
#include "terminal.h"
-#include "elementtextsmover.h"
#include "diagrameventinterface.h"
#include "qetapp.h"
#include "elementcollectionhandler.h"
@@ -81,10 +79,6 @@
QPen pen(Qt::NoBrush, 1.5, Qt::DashLine);
pen.setColor(Qt::black);
conductor_setter_ -> setPen(pen);
-
- //Init object for manage movement
- elements_mover_ = new ElementsMover();
- m_element_texts_mover = new ElementTextsMover();
connect(&border_and_titleblock, SIGNAL(needTitleBlockTemplate(const QString &)), this, SLOT(setTitleBlockTemplate(const QString &)));
connect(&border_and_titleblock, SIGNAL(diagramTitleChanged(const QString &)), this, SLOT(titleChanged(const QString &)));
@@ -110,10 +104,6 @@
delete qgi_manager_;
// remove of conductor setter
delete conductor_setter_;
-
- // delete of object for manage movement
- delete elements_mover_;
- delete m_element_texts_mover;
if (m_event_interface)
delete m_event_interface;
@@ -345,8 +335,8 @@
if (!movement.isNull() && !focusItem())
{
- beginMoveElements();
- continueMoveElements(movement);
+ m_elements_mover.beginMovement(this);
+ m_elements_mover.continueMovement(movement);
event->accept();
return;
}
@@ -402,7 +392,7 @@
e -> key() == Qt::Key_Up || e -> key() == Qt::Key_Down) &&
!e -> isAutoRepeat()
) {
- endMoveElements();
+ m_elements_mover.endMovement();
e -> accept();
transmit_event = false;
}
@@ -1438,59 +1428,15 @@
return (cnd_list);
}
-/**
- Initialise un deplacement d'elements, conducteurs et champs de texte sur le
- schema.
- @param driver_item Item deplace par la souris et ne necessitant donc pas
- d'etre deplace lors des appels a continueMovement.
- @see ElementsMover
-*/
-int Diagram::beginMoveElements(QGraphicsItem *driver_item) {
- return(elements_mover_ -> beginMovement(this, driver_item));
+ElementsMover &Diagram::elementsMover() {
+ return m_elements_mover;
}
-/**
- Prend en compte un mouvement composant un deplacement d'elements,
- conducteurs et champs de texte
- @param movement mouvement a ajouter au deplacement en cours
- @see ElementsMover
-*/
-void Diagram::continueMoveElements(const QPointF &movement) {
- elements_mover_ -> continueMovement(movement);
+ElementTextsMover &Diagram::elementTextsMover() {
+ return m_element_texts_mover;
}
/**
- Finalise un deplacement d'elements, conducteurs et champs de texte
- @see ElementsMover
-*/
-void Diagram::endMoveElements() {
- elements_mover_ -> endMovement();
-}
-
-/**
- Initialise un deplacement d'ElementTextItems
- @param driver_item Item deplace par la souris et ne necessitant donc pas
- d'etre deplace lors des appels a continueMovement.
- @see ElementTextsMover
-*/
-int Diagram::beginMoveElementTexts(QGraphicsItem *driver_item) {
- return(m_element_texts_mover -> beginMovement(this, driver_item));
-}
-
-void Diagram::continueMoveElementTexts(QGraphicsSceneMouseEvent *event)
-{
- m_element_texts_mover->continueMovement(event);
-}
-
-/**
- Finalise un deplacement d'ElementTextItems
- @see ElementTextsMover
-*/
-void Diagram::endMoveElementTexts() {
- m_element_texts_mover -> endMovement();
-}
-
-/**
Permet de savoir si un element est utilise sur un schema
@param location Emplacement d'un element
@return true si l'element location est utilise sur ce schema, false sinon
Modified: trunk/sources/diagram.h
===================================================================
--- trunk/sources/diagram.h 2018-04-05 08:10:06 UTC (rev 5298)
+++ trunk/sources/diagram.h 2018-04-05 09:37:35 UTC (rev 5299)
@@ -27,6 +27,8 @@
#include "numerotationcontext.h"
#include "qetproject.h"
#include "properties/xrefproperties.h"
+#include "elementsmover.h"
+#include "elementtextsmover.h"
class Conductor;
class CustomElement;
@@ -35,11 +37,9 @@
class DiagramTextItem;
class Element;
class ElementsLocation;
-class ElementsMover;
class QETProject;
class Terminal;
class DiagramImageItem;
-class ElementTextsMover;
class DiagramEventInterface;
/**
@@ -92,8 +92,8 @@
private:
QGraphicsLineItem *conductor_setter_;
- ElementsMover *elements_mover_;
- ElementTextsMover *m_element_texts_mover;
+ ElementsMover m_elements_mover;
+ ElementTextsMover m_element_texts_mover;
QGIManager *qgi_manager_;
QETProject *m_project;
@@ -190,12 +190,8 @@
QSet<Conductor *> selectedConductors() const;
DiagramContent content() const;
bool canRotateSelection() const;
- int beginMoveElements(QGraphicsItem * = nullptr);
- void continueMoveElements(const QPointF &);
- void endMoveElements();
- int beginMoveElementTexts(QGraphicsItem * = nullptr);
- void continueMoveElementTexts(QGraphicsSceneMouseEvent *event);
- void endMoveElementTexts();
+ ElementsMover &elementsMover();
+ ElementTextsMover &elementTextsMover();
bool usesElement(const ElementsLocation &);
bool usesTitleBlockTemplate(const QString &);
Modified: trunk/sources/qetgraphicsitem/diagramtextitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/diagramtextitem.cpp 2018-04-05 08:10:06 UTC (rev 5298)
+++ trunk/sources/qetgraphicsitem/diagramtextitem.cpp 2018-04-05 09:37:35 UTC (rev 5299)
@@ -286,7 +286,7 @@
//This is first move, we signal it to parent diagram
if(diagram_ && m_first_move)
- diagram_ -> beginMoveElements(this);
+ diagram_->elementsMover().beginMovement(diagram_, this);
QPointF old_pos = pos();
@@ -297,7 +297,7 @@
//Update the actual movement for other selected item
if (diagram_)
- diagram_ -> continueMoveElements(pos() - old_pos);
+ diagram_->elementsMover().continueMovement(pos() - old_pos);
}
else event -> ignore();
@@ -312,7 +312,7 @@
void DiagramTextItem::mouseReleaseEvent (QGraphicsSceneMouseEvent *event) {
//Signal to diagram movement is finish
if (diagram())
- diagram() -> endMoveElements();
+ diagram()->elementsMover().endMovement();
if (!(event -> modifiers() & Qt::ControlModifier))
QGraphicsTextItem::mouseReleaseEvent(event);
Modified: trunk/sources/qetgraphicsitem/dynamicelementtextitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/dynamicelementtextitem.cpp 2018-04-05 08:10:06 UTC (rev 5298)
+++ trunk/sources/qetgraphicsitem/dynamicelementtextitem.cpp 2018-04-05 09:37:35 UTC (rev 5299)
@@ -506,7 +506,7 @@
if((event->buttons() & Qt::LeftButton) && (flags() & ItemIsMovable))
{
if(diagram() && m_first_move)
- diagram()->beginMoveElementTexts(this);
+ diagram()->elementTextsMover().beginMovement(diagram(), this);
if(m_first_move)
{
@@ -524,7 +524,7 @@
event->modifiers() == Qt::ControlModifier ? setPos(new_pos) : setPos(Diagram::snapToGrid(new_pos));
if(diagram())
- diagram()->continueMoveElementTexts(event);
+ diagram()->elementTextsMover().continueMovement(event);
} else {
event->ignore();
}
@@ -543,7 +543,7 @@
m_parent_element->setHighlighted(false);
if(m_parent_element && m_parent_element->diagram())
- m_parent_element->diagram()->endMoveElementTexts();
+ m_parent_element.data()->diagram()->elementTextsMover().endMovement();
if(!(event->modifiers() & Qt::ControlModifier))
QGraphicsTextItem::mouseReleaseEvent(event);
Modified: trunk/sources/qetgraphicsitem/elementtextitemgroup.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/elementtextitemgroup.cpp 2018-04-05 08:10:06 UTC (rev 5298)
+++ trunk/sources/qetgraphicsitem/elementtextitemgroup.cpp 2018-04-05 09:37:35 UTC (rev 5299)
@@ -490,7 +490,7 @@
if((event->buttons() & Qt::LeftButton) && (flags() & ItemIsMovable))
{
if(diagram() && m_first_move)
- diagram()->beginMoveElementTexts(this);
+ diagram()->elementTextsMover().beginMovement(diagram(), this);
if(m_first_move)
{
@@ -508,7 +508,7 @@
event->modifiers() == Qt::ControlModifier ? setPos(new_pos) : setPos(Diagram::snapToGrid(new_pos));
if(diagram())
- diagram()->continueMoveElementTexts(event);
+ diagram()->elementTextsMover().continueMovement(event);
} else {
event->ignore();
}
@@ -525,7 +525,7 @@
{
if(diagram())
{
- diagram()->endMoveElementTexts();
+ diagram()->elementTextsMover().endMovement();
if(parentElement())
parentElement()->setHighlighted(false);
}
Modified: trunk/sources/qetgraphicsitem/qetgraphicsitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/qetgraphicsitem.cpp 2018-04-05 08:10:06 UTC (rev 5298)
+++ trunk/sources/qetgraphicsitem/qetgraphicsitem.cpp 2018-04-05 09:37:35 UTC (rev 5299)
@@ -106,7 +106,7 @@
//Item is moving
if(diagram() && first_move_) {
//It's the first movement, we signal it to parent diagram
- diagram() -> beginMoveElements(this);
+ diagram()->elementsMover().beginMovement(diagram(), this);
}
//we apply the mouse movement
@@ -122,7 +122,7 @@
if (diagram()) {
//we signal the real movement apply to diagram,
//who he apply to other selected item
- diagram() -> continueMoveElements(effective_movement);
+ diagram()->elementsMover().continueMovement(effective_movement);
}
} else e -> ignore();
@@ -135,7 +135,8 @@
* @param e
*/
void QetGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
- if (diagram()) diagram() -> endMoveElements();
+ if (diagram())
+ diagram()->elementsMover().endMovement();
if (!(e -> modifiers() & Qt::ControlModifier))
QGraphicsItem::mouseReleaseEvent(e);