mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 14:50:53 +01:00
Wrap code for better readability + Mod doc
This commit is contained in:
committed by
Laurent Trinques
parent
2cdfce18ec
commit
d7e1d326a2
@@ -250,7 +250,13 @@ void MoveElementsCommand::move(const QPointF &actual_movement)
|
||||
typedef DiagramContent dc;
|
||||
|
||||
//Move every movable items, except conductor
|
||||
for (QGraphicsItem *qgi : content_to_move.items(dc::Elements | dc::TextFields | dc::Images | dc::Shapes | dc::TextGroup | dc::ElementTextFields | dc::Tables))
|
||||
for (QGraphicsItem *qgi : content_to_move.items(dc::Elements
|
||||
| dc::TextFields
|
||||
| dc::Images
|
||||
| dc::Shapes
|
||||
| dc::TextGroup
|
||||
| dc::ElementTextFields
|
||||
| dc::Tables))
|
||||
{
|
||||
//If curent item have parent, and parent item is in content_to_move
|
||||
//we don't apply movement to this item, because this item will be moved by is parent.
|
||||
@@ -259,19 +265,22 @@ void MoveElementsCommand::move(const QPointF &actual_movement)
|
||||
continue;
|
||||
|
||||
if(qgi->toGraphicsObject())
|
||||
setupAnimation(qgi->toGraphicsObject(), "pos", qgi->pos(), qgi->pos() + actual_movement);
|
||||
else if(qgi->type() == QGraphicsItemGroup::Type) //ElementTextItemGroup is a QObject but not a QGraphicsObject
|
||||
setupAnimation(qgi->toGraphicsObject(), "pos",
|
||||
qgi->pos(), qgi->pos() + actual_movement);
|
||||
else if(qgi->type() == QGraphicsItemGroup::Type)
|
||||
{
|
||||
//ElementTextItemGroup is a QObject but not a QGraphicsObject
|
||||
if(ElementTextItemGroup *etig = dynamic_cast<ElementTextItemGroup *>(qgi))
|
||||
setupAnimation(etig, "pos", etig->pos(), etig->pos() + actual_movement);
|
||||
setupAnimation(etig, "pos", etig->pos(),
|
||||
etig->pos() + actual_movement);
|
||||
}
|
||||
else qgi -> setPos(qgi->pos() + actual_movement);
|
||||
}
|
||||
|
||||
// Move some conductors
|
||||
for (Conductor *conductor : content_to_move.m_conductors_to_move)
|
||||
setupAnimation(conductor, "pos", conductor->pos(), conductor->pos() + actual_movement);
|
||||
setupAnimation(conductor, "pos", conductor->pos(),
|
||||
conductor->pos() + actual_movement);
|
||||
|
||||
// Recalcul the path of other conductor
|
||||
for (Conductor *conductor : content_to_move.m_conductors_to_update)
|
||||
@@ -279,14 +288,17 @@ void MoveElementsCommand::move(const QPointF &actual_movement)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MoveElementsCommand::setupAnimation
|
||||
* Set up the animation for this undo command
|
||||
* @param target object to anim
|
||||
* @param propertyName property to animate
|
||||
* @param start value at start
|
||||
* @param end value at end
|
||||
@brief MoveElementsCommand::setupAnimation
|
||||
Set up the animation for this undo command
|
||||
@param target object to anim
|
||||
@param propertyName property to animate
|
||||
@param start value at start
|
||||
@param end value at end
|
||||
*/
|
||||
void MoveElementsCommand::setupAnimation(QObject *target, const QByteArray &propertyName, const QVariant& start, const QVariant& end) {
|
||||
void MoveElementsCommand::setupAnimation(QObject *target,
|
||||
const QByteArray &propertyName,
|
||||
const QVariant& start,
|
||||
const QVariant& end) {
|
||||
//create animation group if not yet.
|
||||
if (m_anim_group == nullptr) m_anim_group = new QParallelAnimationGroup();
|
||||
QPropertyAnimation *animation = new QPropertyAnimation(target, propertyName);
|
||||
@@ -366,11 +378,15 @@ void MoveConductorsTextsCommand::redo() {
|
||||
@param alread_moved true si le champ de texte etait deja a une position
|
||||
personnalisee par l'utilisateur, false sinon
|
||||
*/
|
||||
void MoveConductorsTextsCommand::addTextMovement(ConductorTextItem *text_item, const QPointF &old_pos, const QPointF &new_pos, bool already_moved) {
|
||||
void MoveConductorsTextsCommand::addTextMovement(ConductorTextItem *text_item,
|
||||
const QPointF &old_pos,
|
||||
const QPointF &new_pos,
|
||||
bool already_moved) {
|
||||
// si le champ de texte est deja connu de l'objet d'annulation, il sera ignore
|
||||
if (texts_to_move_.contains(text_item)) return;
|
||||
|
||||
// on memorise le champ de texte, en l'associant au mouvement effectue et a son etat avant le deplacement
|
||||
// on memorise le champ de texte,
|
||||
//en l'associant au mouvement effectue et a son etat avant le deplacement
|
||||
texts_to_move_.insert(text_item, qMakePair(new_pos - old_pos, already_moved));
|
||||
|
||||
// met a jour la description de l'objet d'annulation
|
||||
|
||||
@@ -88,7 +88,8 @@ QString itemText(const Conductor *item);
|
||||
class PasteDiagramCommand : public QUndoCommand {
|
||||
// constructors, destructor
|
||||
public:
|
||||
PasteDiagramCommand(Diagram *, const DiagramContent &, QUndoCommand * = nullptr);
|
||||
PasteDiagramCommand(Diagram *, const DiagramContent &,
|
||||
QUndoCommand * = nullptr);
|
||||
~PasteDiagramCommand() override;
|
||||
private:
|
||||
PasteDiagramCommand(const PasteDiagramCommand &);
|
||||
@@ -117,7 +118,8 @@ class PasteDiagramCommand : public QUndoCommand {
|
||||
class CutDiagramCommand : public DeleteQGraphicsItemCommand {
|
||||
// constructors, destructor
|
||||
public:
|
||||
CutDiagramCommand(Diagram *, const DiagramContent &, QUndoCommand * = nullptr);
|
||||
CutDiagramCommand(Diagram *, const DiagramContent &,
|
||||
QUndoCommand * = nullptr);
|
||||
~CutDiagramCommand() override;
|
||||
private:
|
||||
CutDiagramCommand(const CutDiagramCommand &);
|
||||
@@ -130,7 +132,8 @@ class CutDiagramCommand : public DeleteQGraphicsItemCommand {
|
||||
class MoveElementsCommand : public QUndoCommand {
|
||||
// constructors, destructor
|
||||
public:
|
||||
MoveElementsCommand(Diagram *, const DiagramContent &, const QPointF &m, QUndoCommand * = nullptr);
|
||||
MoveElementsCommand(Diagram *, const DiagramContent &,
|
||||
const QPointF &m, QUndoCommand * = nullptr);
|
||||
~MoveElementsCommand() override;
|
||||
private:
|
||||
MoveElementsCommand(const MoveElementsCommand &);
|
||||
@@ -142,7 +145,10 @@ class MoveElementsCommand : public QUndoCommand {
|
||||
virtual void move(const QPointF &);
|
||||
|
||||
private:
|
||||
void setupAnimation (QObject * target, const QByteArray &propertyName, const QVariant& start, const QVariant& end);
|
||||
void setupAnimation (QObject * target,
|
||||
const QByteArray &propertyName,
|
||||
const QVariant& start,
|
||||
const QVariant& end);
|
||||
|
||||
// attributes
|
||||
private:
|
||||
@@ -175,7 +181,8 @@ class MoveConductorsTextsCommand : public QUndoCommand {
|
||||
public:
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
virtual void addTextMovement(ConductorTextItem *, const QPointF &, const QPointF &, bool = false);
|
||||
virtual void addTextMovement(ConductorTextItem *, const QPointF &,
|
||||
const QPointF &, bool = false);
|
||||
|
||||
private:
|
||||
void regenerateTextLabel();
|
||||
@@ -191,12 +198,16 @@ class MoveConductorsTextsCommand : public QUndoCommand {
|
||||
};
|
||||
|
||||
/**
|
||||
@brief The ChangeDiagramTextCommand class
|
||||
This commad modifies a text item.
|
||||
*/
|
||||
class ChangeDiagramTextCommand : public QUndoCommand {
|
||||
// constructors, destructor
|
||||
public:
|
||||
ChangeDiagramTextCommand(DiagramTextItem *, const QString &before, const QString &after, QUndoCommand * = nullptr);
|
||||
ChangeDiagramTextCommand(DiagramTextItem *,
|
||||
const QString &before,
|
||||
const QString &after,
|
||||
QUndoCommand * = nullptr);
|
||||
~ChangeDiagramTextCommand() override;
|
||||
private:
|
||||
ChangeDiagramTextCommand(const ChangeDiagramTextCommand &);
|
||||
@@ -220,12 +231,15 @@ class ChangeDiagramTextCommand : public QUndoCommand {
|
||||
};
|
||||
|
||||
/**
|
||||
@brief The ChangeConductorCommand class
|
||||
This command changes a particular conductor.
|
||||
*/
|
||||
class ChangeConductorCommand : public QUndoCommand {
|
||||
// constructors, destructor
|
||||
public:
|
||||
ChangeConductorCommand(Conductor *, const ConductorProfile &, const ConductorProfile &, Qt::Corner, QUndoCommand * = nullptr);
|
||||
ChangeConductorCommand(Conductor *, const ConductorProfile &,
|
||||
const ConductorProfile &, Qt::Corner,
|
||||
QUndoCommand * = nullptr);
|
||||
~ChangeConductorCommand() override;
|
||||
private:
|
||||
ChangeConductorCommand(const ChangeConductorCommand &);
|
||||
@@ -256,12 +270,15 @@ class ChangeConductorCommand : public QUndoCommand {
|
||||
};
|
||||
|
||||
/**
|
||||
@brief The ResetConductorCommand class
|
||||
This command resets conductor paths.
|
||||
*/
|
||||
class ResetConductorCommand : public QUndoCommand {
|
||||
// constructors, destructor
|
||||
public:
|
||||
ResetConductorCommand(const QHash<Conductor *, ConductorProfilesGroup> &, QUndoCommand * = nullptr);
|
||||
ResetConductorCommand(const QHash<Conductor *,
|
||||
ConductorProfilesGroup> &,
|
||||
QUndoCommand * = nullptr);
|
||||
~ResetConductorCommand() override;
|
||||
private:
|
||||
ResetConductorCommand(const ResetConductorCommand &);
|
||||
@@ -281,12 +298,14 @@ class ResetConductorCommand : public QUndoCommand {
|
||||
|
||||
|
||||
/**
|
||||
@brief The ChangeBorderCommand class
|
||||
This command changes the border properties of a particular diagram.
|
||||
*/
|
||||
class ChangeBorderCommand : public QUndoCommand {
|
||||
// constructors, destructor
|
||||
public:
|
||||
ChangeBorderCommand(Diagram *, const BorderProperties &, const BorderProperties &, QUndoCommand * = nullptr);
|
||||
ChangeBorderCommand(Diagram *, const BorderProperties &,
|
||||
const BorderProperties &, QUndoCommand * = nullptr);
|
||||
~ChangeBorderCommand() override;
|
||||
private:
|
||||
ChangeBorderCommand(const ChangeBorderCommand &);
|
||||
|
||||
@@ -410,7 +410,8 @@ QLineF Terminal::HelpLine() const
|
||||
@return Le rectangle (en precision flottante) delimitant la borne et ses alentours.
|
||||
*/
|
||||
QRectF Terminal::boundingRect() const {
|
||||
if (br_ -> isNull()) {
|
||||
if (br_ -> isNull())
|
||||
{
|
||||
qreal dcx = d->m_pos.x();
|
||||
qreal dcy = d->m_pos.y();
|
||||
qreal dex = dock_elmt_.x();
|
||||
@@ -717,8 +718,12 @@ QList<Conductor *> Terminal::conductors() const {
|
||||
*/
|
||||
QDomElement Terminal::toXml(QDomDocument &doc) const {
|
||||
QDomElement qdo = doc.createElement("terminal");
|
||||
qdo.setAttribute("x", QString("%1").arg(dock_elmt_.x())); // for backward compatibility
|
||||
qdo.setAttribute("y", QString("%1").arg(dock_elmt_.y()));// for backward compatibility
|
||||
|
||||
// for backward compatibility
|
||||
qdo.setAttribute("x", QString("%1").arg(dock_elmt_.x()));
|
||||
qdo.setAttribute("y", QString("%1").arg(dock_elmt_.y()));
|
||||
// end for backward compatibility
|
||||
|
||||
qdo.setAttribute("orientation", d->m_orientation);
|
||||
qdo.setAttribute("number", number_terminal_);
|
||||
qdo.setAttribute("name", name_terminal_);
|
||||
@@ -757,7 +762,10 @@ bool Terminal::valideXml(QDomElement &terminal) {
|
||||
// parse l'orientation
|
||||
int terminal_or = terminal.attribute("orientation").toInt(&conv_ok);
|
||||
if (!conv_ok) return(false);
|
||||
if (terminal_or != Qet::North && terminal_or != Qet::South && terminal_or != Qet::East && terminal_or != Qet::West) return(false);
|
||||
if (terminal_or != Qet::North
|
||||
&& terminal_or != Qet::South
|
||||
&& terminal_or != Qet::East
|
||||
&& terminal_or != Qet::West) return(false);
|
||||
|
||||
// a ce stade, la borne est syntaxiquement correcte
|
||||
return(true);
|
||||
|
||||
@@ -44,7 +44,8 @@ class Terminal : public QGraphicsObject
|
||||
Terminal(QPointF, Qet::Orientation, Element * = nullptr);
|
||||
Terminal(qreal, qreal, Qet::Orientation, Element * = nullptr);
|
||||
Terminal(TerminalData* data, Element *e = nullptr);
|
||||
Terminal(QPointF, Qet::Orientation, QString number, QString name, bool hiddenName, Element * = nullptr);
|
||||
Terminal(QPointF, Qet::Orientation, QString number,
|
||||
QString name, bool hiddenName, Element * = nullptr);
|
||||
~Terminal() override;
|
||||
|
||||
private:
|
||||
@@ -60,7 +61,8 @@ class Terminal : public QGraphicsObject
|
||||
*/
|
||||
int type() const override { return Type; }
|
||||
|
||||
void paint (QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override;
|
||||
void paint (QPainter *,const QStyleOptionGraphicsItem *,
|
||||
QWidget *) override;
|
||||
void drawHelpLine (bool draw = true);
|
||||
QLineF HelpLine () const;
|
||||
QRectF boundingRect () const override;
|
||||
@@ -149,7 +151,8 @@ class Terminal : public QGraphicsObject
|
||||
|
||||
private:
|
||||
void init(QString number, QString name, bool hiddenName);
|
||||
void init(QPointF pf, Qet::Orientation o, QString number, QString name, bool hiddenName);
|
||||
void init(QPointF pf, Qet::Orientation o, QString number,
|
||||
QString name, bool hiddenName);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -169,12 +172,14 @@ inline QString Terminal::number() const {
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Terminal::name
|
||||
@return the name of terminal.
|
||||
*/
|
||||
inline QString Terminal::name() const {
|
||||
return(name_terminal_);
|
||||
}
|
||||
|
||||
QList<Terminal *> relatedPotentialTerminal (const Terminal *terminal, const bool all_diagram = true);
|
||||
QList<Terminal *> relatedPotentialTerminal (const Terminal *terminal,
|
||||
const bool all_diagram = true);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,14 +18,15 @@
|
||||
#include "terminalelement.h"
|
||||
|
||||
/**
|
||||
* @brief TerminalElement::TerminalElement
|
||||
* Default constructor
|
||||
* @param location location of xml definition
|
||||
* @param qgi parent QGraphicItem
|
||||
* @param s parent diagram
|
||||
* @param state int used to know if the creation of element have error
|
||||
@brief TerminalElement::TerminalElement
|
||||
Default constructor
|
||||
@param location location of xml definition
|
||||
@param qgi parent QGraphicItem
|
||||
@param s parent diagram
|
||||
@param state int used to know if the creation of element have error
|
||||
*/
|
||||
TerminalElement::TerminalElement(const ElementsLocation &location, QGraphicsItem *qgi, int *state) :
|
||||
TerminalElement::TerminalElement(const ElementsLocation &location,
|
||||
QGraphicsItem *qgi, int *state) :
|
||||
Element(location, qgi, state, Element::Terminale)
|
||||
{}
|
||||
|
||||
|
||||
@@ -22,12 +22,15 @@
|
||||
#include "element.h"
|
||||
|
||||
class QETProject;
|
||||
|
||||
/**
|
||||
@brief The TerminalElement class
|
||||
*/
|
||||
class TerminalElement : public Element
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TerminalElement(const ElementsLocation &, QGraphicsItem * = nullptr, int * = nullptr);
|
||||
TerminalElement(const ElementsLocation &,
|
||||
QGraphicsItem * = nullptr, int * = nullptr);
|
||||
~TerminalElement() override;
|
||||
void initLink(QETProject *project) override;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user