Mod doc to set style de same + Fix indentation code

This commit is contained in:
Simon De Backer
2020-07-15 18:17:39 +02:00
committed by Laurent Trinques
parent 251dfdf37a
commit 2cdfce18ec
11 changed files with 252 additions and 245 deletions

View File

@@ -43,12 +43,12 @@ QString itemText(const Conductor *item) {
} }
/** /**
* @brief PasteDiagramCommand::PasteDiagramCommand @brief PasteDiagramCommand::PasteDiagramCommand
* Constructor Constructor
* @param dia : diagram where we must to paste @param dia : diagram where we must to paste
* @param c : content to past @param c : content to past
* @param parent : parent undo command @param parent : parent undo command
*/ */
PasteDiagramCommand::PasteDiagramCommand( Diagram *dia, const DiagramContent &c, QUndoCommand *parent) : PasteDiagramCommand::PasteDiagramCommand( Diagram *dia, const DiagramContent &c, QUndoCommand *parent) :
QUndoCommand(parent), QUndoCommand(parent),
content(c), content(c),
@@ -61,17 +61,17 @@ PasteDiagramCommand::PasteDiagramCommand( Diagram *dia, const DiagramContent &c,
} }
/** /**
* @brief PasteDiagramCommand::~PasteDiagramCommand @brief PasteDiagramCommand::~PasteDiagramCommand
* Destructor Destructor
*/ */
PasteDiagramCommand::~PasteDiagramCommand() { PasteDiagramCommand::~PasteDiagramCommand() {
diagram -> qgiManager().release(content.items(filter)); diagram -> qgiManager().release(content.items(filter));
} }
/** /**
* @brief PasteDiagramCommand::undo @brief PasteDiagramCommand::undo
* Undo this command Undo this command
*/ */
void PasteDiagramCommand::undo() void PasteDiagramCommand::undo()
{ {
diagram -> showMe(); diagram -> showMe();
@@ -81,9 +81,9 @@ void PasteDiagramCommand::undo()
} }
/** /**
* @brief PasteDiagramCommand::redo @brief PasteDiagramCommand::redo
* Redo this commnand Redo this commnand
*/ */
void PasteDiagramCommand::redo() void PasteDiagramCommand::redo()
{ {
diagram -> showMe(); diagram -> showMe();
@@ -93,16 +93,16 @@ void PasteDiagramCommand::redo()
{ {
first_redo = false; first_redo = false;
//this is the first paste, we do some actions for the new element //this is the first paste, we do some actions for the new element
const QList <Element *> elmts_list = content.m_elements; const QList <Element *> elmts_list = content.m_elements;
for (Element *e : elmts_list) for (Element *e : elmts_list)
{ {
//make new uuid, because old uuid are the uuid of the copied element //make new uuid, because old uuid are the uuid of the copied element
e -> newUuid(); e -> newUuid();
if (settings.value("diagramcommands/erase-label-on-copy", true).toBool()) if (settings.value("diagramcommands/erase-label-on-copy", true).toBool())
{ {
//Reset the information about the label, the comment and location //Reset the information about the label, the comment and location
DiagramContext dc = e->elementInformations(); DiagramContext dc = e->elementInformations();
dc.addValue("formula", ""); dc.addValue("formula", "");
dc.addValue("label", ""); dc.addValue("label", "");
@@ -110,7 +110,7 @@ void PasteDiagramCommand::redo()
dc.addValue("location", ""); dc.addValue("location", "");
e->setElementInformations(dc); e->setElementInformations(dc);
//Reset the text of conductors //Reset the text of conductors
const QList <Conductor *> conductors_list = content.m_conductors_to_move; const QList <Conductor *> conductors_list = content.m_conductors_to_move;
for (Conductor *c : conductors_list) for (Conductor *c : conductors_list)
{ {
@@ -166,13 +166,13 @@ CutDiagramCommand::~CutDiagramCommand() {
} }
/** /**
* @brief MoveElementsCommand::MoveElementsCommand @brief MoveElementsCommand::MoveElementsCommand
* Constructor Constructor
* @param dia diagram @param dia diagram
* @param diagram_content diagram content (contain all items to be moved) @param diagram_content diagram content (contain all items to be moved)
* @param m movement to applied @param m movement to applied
* @param parent parent undo command @param parent parent undo command
*/ */
MoveElementsCommand::MoveElementsCommand( MoveElementsCommand::MoveElementsCommand(
Diagram *dia, Diagram *dia,
const DiagramContent &diagram_content, const DiagramContent &diagram_content,
@@ -207,16 +207,16 @@ MoveElementsCommand::MoveElementsCommand(
} }
/** /**
* @brief MoveElementsCommand::~MoveElementsCommand @brief MoveElementsCommand::~MoveElementsCommand
* Destructor Destructor
*/ */
MoveElementsCommand::~MoveElementsCommand() { MoveElementsCommand::~MoveElementsCommand() {
delete m_anim_group; delete m_anim_group;
} }
/** /**
* @brief MoveElementsCommand::undo @brief MoveElementsCommand::undo
*/ */
void MoveElementsCommand::undo() { void MoveElementsCommand::undo() {
diagram -> showMe(); diagram -> showMe();
m_anim_group->setDirection(QAnimationGroup::Forward); m_anim_group->setDirection(QAnimationGroup::Forward);
@@ -225,8 +225,8 @@ void MoveElementsCommand::undo() {
} }
/** /**
* @brief MoveElementsCommand::redo @brief MoveElementsCommand::redo
*/ */
void MoveElementsCommand::redo() { void MoveElementsCommand::redo() {
diagram -> showMe(); diagram -> showMe();
if (first_redo) { if (first_redo) {
@@ -241,10 +241,10 @@ void MoveElementsCommand::redo() {
} }
/** /**
* @brief MoveElementsCommand::move @brief MoveElementsCommand::move
* Move item and conductor to @actual_movement Move item and conductor to @actual_movement
* @param actual_movement movement to be applied @param actual_movement movement to be applied
*/ */
void MoveElementsCommand::move(const QPointF &actual_movement) void MoveElementsCommand::move(const QPointF &actual_movement)
{ {
typedef DiagramContent dc; typedef DiagramContent dc;
@@ -252,8 +252,8 @@ void MoveElementsCommand::move(const QPointF &actual_movement)
//Move every movable items, except conductor //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 //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. //we don't apply movement to this item, because this item will be moved by is parent.
if (qgi->parentItem()) if (qgi->parentItem())
if (content_to_move.items().contains(qgi->parentItem())) if (content_to_move.items().contains(qgi->parentItem()))
continue; continue;
@@ -262,17 +262,18 @@ void MoveElementsCommand::move(const QPointF &actual_movement)
setupAnimation(qgi->toGraphicsObject(), "pos", qgi->pos(), qgi->pos() + actual_movement); setupAnimation(qgi->toGraphicsObject(), "pos", qgi->pos(), qgi->pos() + actual_movement);
else if(qgi->type() == QGraphicsItemGroup::Type) //ElementTextItemGroup is a QObject but not a QGraphicsObject else if(qgi->type() == QGraphicsItemGroup::Type) //ElementTextItemGroup is a QObject but not a QGraphicsObject
{ {
//ElementTextItemGroup is a QObject but not a QGraphicsObject
if(ElementTextItemGroup *etig = dynamic_cast<ElementTextItemGroup *>(qgi)) 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); else qgi -> setPos(qgi->pos() + actual_movement);
} }
// Move some conductors // Move some conductors
for (Conductor *conductor : content_to_move.m_conductors_to_move) 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 // Recalcul the path of other conductor
for (Conductor *conductor : content_to_move.m_conductors_to_update) for (Conductor *conductor : content_to_move.m_conductors_to_update)
setupAnimation(conductor, "animPath", 1, 1); setupAnimation(conductor, "animPath", 1, 1);
} }
@@ -511,10 +512,10 @@ void ChangeConductorCommand::setConductorTextItemMove(const QPointF &pos_before,
} }
/** /**
* @brief ResetConductorCommand::ResetConductorCommand @brief ResetConductorCommand::ResetConductorCommand
* @param cp @param cp
* @param parent @param parent
*/ */
ResetConductorCommand::ResetConductorCommand( ResetConductorCommand::ResetConductorCommand(
const QHash<Conductor *, ConductorProfilesGroup> &cp, const QHash<Conductor *, ConductorProfilesGroup> &cp,
QUndoCommand *parent QUndoCommand *parent
@@ -532,14 +533,14 @@ ResetConductorCommand::ResetConductorCommand(
} }
/** /**
* @brief ResetConductorCommand::~ResetConductorCommand @brief ResetConductorCommand::~ResetConductorCommand
*/ */
ResetConductorCommand::~ResetConductorCommand() { ResetConductorCommand::~ResetConductorCommand() {
} }
/** /**
* @brief ResetConductorCommand::undo @brief ResetConductorCommand::undo
*/ */
void ResetConductorCommand::undo() { void ResetConductorCommand::undo() {
diagram -> showMe(); diagram -> showMe();
foreach(Conductor *c, conductors_profiles.keys()) { foreach(Conductor *c, conductors_profiles.keys()) {
@@ -548,8 +549,8 @@ void ResetConductorCommand::undo() {
} }
/** /**
* @brief ResetConductorCommand::redo @brief ResetConductorCommand::redo
*/ */
void ResetConductorCommand::redo() { void ResetConductorCommand::redo() {
diagram -> showMe(); diagram -> showMe();
foreach(Conductor *c, conductors_profiles.keys()) { foreach(Conductor *c, conductors_profiles.keys()) {

View File

@@ -34,10 +34,10 @@ class DiagramImageItem;
class QetGraphicsItem; class QetGraphicsItem;
/** /**
* @brief The AddItemCommand class @brief The AddItemCommand class
* This command add an item in a diagram This command add an item in a diagram
* The item to add is template, but must be QGraphicsItem or derived. The item to add is template, but must be QGraphicsItem or derived.
*/ */
template <typename QGI> template <typename QGI>
class AddItemCommand : public QUndoCommand { class AddItemCommand : public QUndoCommand {
public: public:

View File

@@ -9,11 +9,13 @@
class QGraphicsObject; class QGraphicsObject;
/*! /**
* \brief The TerminalData class @brief The TerminalData class
* Data of the terminal. Stored in extra class so it can be used by PartTerminal and Terminal without Data of the terminal.
* defining everything again. Stored in extra class so it can be used by PartTerminal
*/ and Terminal without defining everything again.
@note tis class needs to be work on
*/
class TerminalData : public PropertiesInterface class TerminalData : public PropertiesInterface
{ {
public: public:

View File

@@ -185,28 +185,28 @@ Qet::Orientation Terminal::orientation() const {
/** /**
* @brief Terminal::setNumber @brief Terminal::setNumber
* @param number @param number
*/ */
void Terminal::setNumber(QString number) { void Terminal::setNumber(QString number) {
number_terminal_ = std::move(number); number_terminal_ = std::move(number);
} }
/** /**
* @brief Terminal::setName @brief Terminal::setName
* @param name @param name
*/ */
void Terminal::setName(QString name, bool hiddenName) { void Terminal::setName(QString name, bool hiddenName) {
name_terminal_ = std::move(name); name_terminal_ = std::move(name);
name_terminal_hidden = hiddenName; name_terminal_hidden = hiddenName;
} }
/** /**
* @brief Terminal::addConductor @brief Terminal::addConductor
* Add a conductor to this terminal Add a conductor to this terminal
* @param conductor : the conductor to add. @param conductor : the conductor to add.
* @return true if the conductor was successfully added @return true if the conductor was successfully added
*/ */
bool Terminal::addConductor(Conductor *conductor) bool Terminal::addConductor(Conductor *conductor)
{ {
if (!conductor) return(false); if (!conductor) return(false);
@@ -227,10 +227,10 @@ bool Terminal::addConductor(Conductor *conductor)
} }
/** /**
* @brief Terminal::removeConductor @brief Terminal::removeConductor
* Remove a conductor from this terminal Remove a conductor from this terminal
* @param conductor : conductor to remove @param conductor : conductor to remove
*/ */
void Terminal::removeConductor(Conductor *conductor) void Terminal::removeConductor(Conductor *conductor)
{ {
int index = conductors_.indexOf(conductor); int index = conductors_.indexOf(conductor);
@@ -346,10 +346,10 @@ void Terminal::paint(QPainter *p, const QStyleOptionGraphicsItem *options, QWidg
} }
/** /**
* @brief Terminal::drawHelpLine @brief Terminal::drawHelpLine
* @param draw : true, display the help line @param draw : true, display the help line
* false, hide it. false, hide it.
*/ */
void Terminal::drawHelpLine(bool draw) void Terminal::drawHelpLine(bool draw)
{ {
if (m_draw_help_line == draw) return; if (m_draw_help_line == draw) return;
@@ -372,11 +372,11 @@ void Terminal::drawHelpLine(bool draw)
} }
/** /**
* @brief Terminal::HelpLine @brief Terminal::HelpLine
* @return a line with coordinate P1 the dock point of conductor @return a line with coordinate P1 the dock point of conductor
* and P2 the border of diagram, according to the orientation of terminal and P2 the border of diagram, according to the orientation of terminal
* The line is in scene coordinate; The line is in scene coordinate;
*/ */
QLineF Terminal::HelpLine() const QLineF Terminal::HelpLine() const
{ {
QPointF scene_dock = dockConductor(); QPointF scene_dock = dockConductor();
@@ -425,12 +425,12 @@ QRectF Terminal::boundingRect() const {
} }
/** /**
* @brief Terminal::alignedWithTerminal @brief Terminal::alignedWithTerminal
* If this terminal is aligned with an other terminal If this terminal is aligned with an other terminal
* and is orientation is opposed return the other terminal and is orientation is opposed return the other terminal
* else return nullptr else return nullptr
* @return @return
*/ */
Terminal* Terminal::alignedWithTerminal() const Terminal* Terminal::alignedWithTerminal() const
{ {
QLineF line(HelpLine()); QLineF line(HelpLine());
@@ -439,23 +439,23 @@ Terminal* Terminal::alignedWithTerminal() const
path.moveTo(line.p1()); path.moveTo(line.p1());
path.lineTo(line.p2()); path.lineTo(line.p2());
//Get all QGraphicsItem in the alignement of this terminal //Get all QGraphicsItem in the alignement of this terminal
QList <QGraphicsItem *> qgi_list = diagram() -> items(path); QList <QGraphicsItem *> qgi_list = diagram() -> items(path);
//Remove all terminals of the parent element //Remove all terminals of the parent element
foreach (Terminal *t, parent_element_ -> terminals()) foreach (Terminal *t, parent_element_ -> terminals())
qgi_list.removeAll(t); qgi_list.removeAll(t);
if (qgi_list.isEmpty()) return nullptr; if (qgi_list.isEmpty()) return nullptr;
//Get terminals only if orientation is opposed with this terminal //Get terminals only if orientation is opposed with this terminal
QList <Terminal *> available_terminals; QList <Terminal *> available_terminals;
foreach (QGraphicsItem *qgi, qgi_list) foreach (QGraphicsItem *qgi, qgi_list)
{ {
if (Terminal *tt = qgraphicsitem_cast <Terminal *> (qgi)) if (Terminal *tt = qgraphicsitem_cast <Terminal *> (qgi))
{ {
//Call QET::lineContainsPoint to be sure the line intersect //Call QET::lineContainsPoint to be sure the line intersect
//the dock point and not an other part of terminal //the dock point and not an other part of terminal
if (Qet::isOpposed(orientation(), tt -> orientation()) && if (Qet::isOpposed(orientation(), tt -> orientation()) &&
QET::lineContainsPoint(line, tt -> dockConductor())) QET::lineContainsPoint(line, tt -> dockConductor()))
{ {
@@ -467,12 +467,12 @@ Terminal* Terminal::alignedWithTerminal() const
if (available_terminals.isEmpty()) return nullptr; if (available_terminals.isEmpty()) return nullptr;
if (available_terminals.size() == 1) return (available_terminals.first()); if (available_terminals.size() == 1) return (available_terminals.first());
//Available_terminals have several terminals, we get the nearest terminal //Available_terminals have several terminals, we get the nearest terminal
line.setP2(available_terminals.first() -> dockConductor()); line.setP2(available_terminals.first() -> dockConductor());
qreal current_lenght = line.length(); qreal current_lenght = line.length();
Terminal *nearest_terminal = available_terminals.takeFirst(); Terminal *nearest_terminal = available_terminals.takeFirst();
//Search the nearest terminal to this one //Search the nearest terminal to this one
foreach (Terminal *terminal, available_terminals) foreach (Terminal *terminal, available_terminals)
{ {
line.setP2(terminal -> dockConductor()); line.setP2(terminal -> dockConductor());
@@ -517,10 +517,10 @@ void Terminal::hoverLeaveEvent(QGraphicsSceneHoverEvent *) {
@param e L'evenement souris correspondant @param e L'evenement souris correspondant
*/ */
void Terminal::mousePressEvent(QGraphicsSceneMouseEvent *e) { void Terminal::mousePressEvent(QGraphicsSceneMouseEvent *e) {
if (Diagram *diag = diagram()) { if (Diagram *diag = diagram()) {
diag -> setConductorStart(mapToScene(QPointF(d->m_pos))); diag -> setConductorStart(mapToScene(QPointF(d->m_pos)));
diag -> setConductorStop(e -> scenePos()); diag -> setConductorStop(e -> scenePos());
diag -> setConductor(true); diag -> setConductor(true);
//setCursor(Qt::CrossCursor); //setCursor(Qt::CrossCursor);
} }
} }
@@ -541,15 +541,14 @@ void Terminal::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
previous_terminal_ -> hovered_color_ = previous_terminal_ -> neutralColor; previous_terminal_ -> hovered_color_ = previous_terminal_ -> neutralColor;
previous_terminal_ -> update(); previous_terminal_ -> update();
} }
Diagram *diag = diagram();
Diagram *diag = diagram(); if (!diag) return;
if (!diag) return;
// si la scene est un Diagram, on actualise le poseur de conducteur // si la scene est un Diagram, on actualise le poseur de conducteur
diag -> setConductorStop(e -> scenePos()); diag -> setConductorStop(e -> scenePos());
// on recupere la liste des qgi sous le pointeur // on recupere la liste des qgi sous le pointeur
QList<QGraphicsItem *> qgis = diag -> items(e -> scenePos()); QList<QGraphicsItem *> qgis = diag -> items(e -> scenePos());
/* le qgi le plus haut /* le qgi le plus haut
= le poseur de conductor = le poseur de conductor
@@ -584,9 +583,9 @@ void Terminal::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
/** /**
* @brief Terminal::mouseReleaseEvent @brief Terminal::mouseReleaseEvent
* @param e @param e
*/ */
void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
{ {
previous_terminal_ = nullptr; previous_terminal_ = nullptr;
@@ -594,31 +593,31 @@ void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
if (!diagram()) return; if (!diagram()) return;
//Stop conductor preview //Stop conductor preview
diagram() -> setConductor(false); diagram() -> setConductor(false);
//Get item under cursor //Get item under cursor
QGraphicsItem *qgi = diagram() -> itemAt(e -> scenePos(), QTransform()); QGraphicsItem *qgi = diagram() -> itemAt(e -> scenePos(), QTransform());
if (!qgi) return; if (!qgi) return;
//Element must be a terminal //Element must be a terminal
Terminal *other_terminal = qgraphicsitem_cast<Terminal *>(qgi); Terminal *other_terminal = qgraphicsitem_cast<Terminal *>(qgi);
if (!other_terminal) return; if (!other_terminal) return;
other_terminal -> hovered_color_ = neutralColor; other_terminal -> hovered_color_ = neutralColor;
other_terminal -> hovered_ = false; other_terminal -> hovered_ = false;
//We stop her if we can't link this terminal with other terminal //We stop her if we can't link this terminal with other terminal
if (!canBeLinkedTo(other_terminal)) return; if (!canBeLinkedTo(other_terminal)) return;
//Create conductor //Create conductor
Conductor *new_conductor = new Conductor(this, other_terminal); Conductor *new_conductor = new Conductor(this, other_terminal);
//Get all conductors at the same potential of new conductors //Get all conductors at the same potential of new conductors
QSet <Conductor *> conductors_list = new_conductor->relatedPotentialConductors(); QSet <Conductor *> conductors_list = new_conductor->relatedPotentialConductors();
//Compare the properties of every conductors stored in conductors_list, //Compare the properties of every conductors stored in conductors_list,
//if every conductors properties is equal, we use this properties for the new conductor. //if every conductors properties is equal, we use this properties for the new conductor.
ConductorProperties others_properties; ConductorProperties others_properties;
bool use_properties = false; bool use_properties = false;
if (!conductors_list.isEmpty()) if (!conductors_list.isEmpty())
@@ -658,9 +657,9 @@ void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
} }
/** /**
* @brief Terminal::updateConductor @brief Terminal::updateConductor
* Update the path of conductor docked to this terminal Update the path of conductor docked to this terminal
*/ */
void Terminal::updateConductor() { void Terminal::updateConductor() {
foreach (Conductor *conductor, conductors_) foreach (Conductor *conductor, conductors_)
conductor->updatePath(); conductor->updatePath();
@@ -685,15 +684,15 @@ bool Terminal::isLinkedTo(Terminal *other_terminal) {
} }
/** /**
* @brief Terminal::canBeLinkedTo @brief Terminal::canBeLinkedTo
* Checking if the terminal can be linked to \p other_terminal or not Checking if the terminal can be linked to \p other_terminal or not
* Reasons for not linable: Reasons for not linable:
* - \p other_terminal is this terminal - \p other_terminal is this terminal
* - this terminal is already connected to \p other_terminal - this terminal is already connected to \p other_terminal
* @param other_terminal @param other_terminal
* @return true if this terminal can be linked to @other_terminal, @return true if this terminal can be linked to @other_terminal,
* otherwise false otherwise false
*/ */
bool Terminal::canBeLinkedTo(Terminal *other_terminal) bool Terminal::canBeLinkedTo(Terminal *other_terminal)
{ {
if (other_terminal == this || isLinkedTo(other_terminal)) if (other_terminal == this || isLinkedTo(other_terminal))
@@ -780,7 +779,7 @@ bool Terminal::fromXml(QDomElement &terminal) {
return ( return (
qFuzzyCompare(terminal.attribute("x").toDouble(), dock_elmt_.x()) && qFuzzyCompare(terminal.attribute("x").toDouble(), dock_elmt_.x()) &&
qFuzzyCompare(terminal.attribute("y").toDouble(), dock_elmt_.y()) && qFuzzyCompare(terminal.attribute("y").toDouble(), dock_elmt_.y()) &&
(terminal.attribute("orientation").toInt() == d->m_orientation) (terminal.attribute("orientation").toInt() == d->m_orientation)
); );
} }
@@ -790,7 +789,7 @@ bool Terminal::fromXml(QDomElement &terminal) {
conductors. conductors.
*/ */
QPointF Terminal::dockConductor() const { QPointF Terminal::dockConductor() const {
return(mapToScene(d->m_pos)); return(mapToScene(d->m_pos));
} }
/** /**
@@ -811,20 +810,20 @@ Element *Terminal::parentElement() const {
} }
QUuid Terminal::uuid() const { QUuid Terminal::uuid() const {
return d->m_uuid; return d->m_uuid;
} }
/** /**
* @brief Conductor::relatedPotentialTerminal @brief Conductor::relatedPotentialTerminal
* Return terminal at the same potential from the same Return terminal at the same potential from the same
* parent element of @t. parent element of @t.
* For folio report, return the terminal of linked other report. For folio report, return the terminal of linked other report.
* For Terminal element, return the other terminal of terminal element. For Terminal element, return the other terminal of terminal element.
* @param t terminal to start search @param t terminal to start search
* @param all_diagram :if true return all related terminal, @param all_diagram :if true return all related terminal,
* false return only terminal in the same diagram of @t false return only terminal in the same diagram of @t
* @return the list of terminal at the same potential @return the list of terminal at the same potential
*/ */
QList<Terminal *> relatedPotentialTerminal (const Terminal *terminal, const bool all_diagram) QList<Terminal *> relatedPotentialTerminal (const Terminal *terminal, const bool all_diagram)
{ {
// If terminal parent element is a folio report. // If terminal parent element is a folio report.

View File

@@ -29,17 +29,17 @@ class TerminalData;
@brief The Terminal class @brief The Terminal class
This class represents a terminal of an electrical element, i.e. a possible This class represents a terminal of an electrical element, i.e. a possible
plug point for conductors. plug point for conductors.
This class handles all mouse events for connecting conductors This class handles all mouse events for connecting conductors
*/ */
class Terminal : public QGraphicsObject class Terminal : public QGraphicsObject
{ {
Q_OBJECT Q_OBJECT
signals: signals:
void conductorWasAdded(Conductor *conductor); void conductorWasAdded(Conductor *conductor);
void conductorWasRemoved(Conductor *conductor); void conductorWasRemoved(Conductor *conductor);
// constructors, destructor // constructors, destructor
public: public:
Terminal(QPointF, Qet::Orientation, Element * = nullptr); Terminal(QPointF, Qet::Orientation, Element * = nullptr);
Terminal(qreal, qreal, Qet::Orientation, Element * = nullptr); Terminal(qreal, qreal, Qet::Orientation, Element * = nullptr);
@@ -50,7 +50,7 @@ class Terminal : public QGraphicsObject
private: private:
Terminal(const Terminal &); Terminal(const Terminal &);
// methods // methods
public: public:
/** /**
@brief type @brief type
@@ -65,85 +65,87 @@ class Terminal : public QGraphicsObject
QLineF HelpLine () const; QLineF HelpLine () const;
QRectF boundingRect () const override; QRectF boundingRect () const override;
// methods to manage conductors attached to the terminal // methods to manage conductors attached to the terminal
Terminal* alignedWithTerminal () const; Terminal* alignedWithTerminal () const;
bool addConductor (Conductor *conductor); bool addConductor (Conductor *conductor);
void removeConductor (Conductor *conductor); void removeConductor (Conductor *conductor);
int conductorsCount () const; int conductorsCount () const;
Diagram *diagram () const; Diagram *diagram () const;
Element *parentElement () const; Element *parentElement () const;
QUuid uuid () const; QUuid uuid () const;
QList<Conductor *> conductors() const; QList<Conductor *> conductors() const;
Qet::Orientation orientation() const; Qet::Orientation orientation() const;
QPointF dockConductor() const; QPointF dockConductor() const;
QString number() const; QString number() const;
QString name() const; QString name() const;
void setNumber(QString number); void setNumber(QString number);
void setName(QString name, bool hiddenName); void setName(QString name, bool hiddenName);
void updateConductor(); void updateConductor();
bool isLinkedTo(Terminal *); bool isLinkedTo(Terminal *);
bool canBeLinkedTo(Terminal *); bool canBeLinkedTo(Terminal *);
// methods related to XML import/export // methods related to XML import/export
static bool valideXml(QDomElement &); static bool valideXml(QDomElement &);
bool fromXml (QDomElement &); bool fromXml (QDomElement &);
QDomElement toXml (QDomDocument &) const; QDomElement toXml (QDomDocument &) const;
protected: protected:
// methods related to events management // methods related to events management
void hoverEnterEvent (QGraphicsSceneHoverEvent *) override; void hoverEnterEvent (QGraphicsSceneHoverEvent *) override;
void hoverMoveEvent (QGraphicsSceneHoverEvent *) override; void hoverMoveEvent (QGraphicsSceneHoverEvent *) override;
void hoverLeaveEvent (QGraphicsSceneHoverEvent *) override; void hoverLeaveEvent (QGraphicsSceneHoverEvent *) override;
void mousePressEvent (QGraphicsSceneMouseEvent *) override; void mousePressEvent (QGraphicsSceneMouseEvent *) override;
void mouseMoveEvent (QGraphicsSceneMouseEvent *) override; void mouseMoveEvent (QGraphicsSceneMouseEvent *) override;
void mouseReleaseEvent(QGraphicsSceneMouseEvent *) override; void mouseReleaseEvent(QGraphicsSceneMouseEvent *) override;
// attributes // attributes
public: public:
enum { Type = UserType + 1002 }; enum { Type = UserType + 1002 };
static const qreal terminalSize; static const qreal terminalSize;
static const qreal Z; static const qreal Z;
// Various static colors used for hover effects // Various static colors used for hover effects
/// default color /// default color
static QColor neutralColor; static QColor neutralColor;
/// color for legal actions /// color for legal actions
static QColor allowedColor; static QColor allowedColor;
/// color for allowed but fuzzy or not recommended actions /// color for allowed but fuzzy or not recommended actions
static QColor warningColor; static QColor warningColor;
/// color for forbidden actions /// color for forbidden actions
static QColor forbiddenColor; static QColor forbiddenColor;
private: private:
bool m_draw_help_line{false}; bool m_draw_help_line{false};
QGraphicsLineItem *m_help_line{nullptr}; QGraphicsLineItem *m_help_line{nullptr};
QGraphicsLineItem *m_help_line_a{nullptr}; QGraphicsLineItem *m_help_line_a{nullptr};
TerminalData* d; TerminalData* d;
/// Parent electrical element /// Parent electrical element
Element *parent_element_{nullptr}; Element *parent_element_{nullptr};
/// docking point for parent element /// docking point for parent element
QPointF dock_elmt_; QPointF dock_elmt_;
/// List of conductors attached to the terminal /// List of conductors attached to the terminal
QList<Conductor *> conductors_; QList<Conductor *> conductors_;
/// Pointer to a rectangle representing the terminal bounding rect; /**
/// used to calculate the bounding rect once only; Pointer to a rectangle representing the terminal bounding rect;
/// used a pointer because boundingRect() is supposed to be const. used to calculate the bounding rect once only;
QRectF *br_{nullptr}; used a pointer because boundingRect() is supposed to be const.
/// Last terminal seen through an attached conductor */
Terminal *previous_terminal_; QRectF *br_{nullptr};
/// Whether the mouse pointer is hovering the terminal /// Last terminal seen through an attached conductor
bool hovered_; Terminal *previous_terminal_;
/// Color used for the hover effect /// Whether the mouse pointer is hovering the terminal
QColor hovered_color_; bool hovered_;
/// Number of Terminal /// Color used for the hover effect
QString number_terminal_; QColor hovered_color_;
/// Name of Terminal /// Number of Terminal
QString name_terminal_; QString number_terminal_;
bool name_terminal_hidden; /// Name of Terminal
QString name_terminal_;
bool name_terminal_hidden;
private: private:
void init(QString number, QString name, bool hiddenName); void init(QString number, QString name, bool hiddenName);

View File

@@ -32,9 +32,9 @@ TerminalElement::TerminalElement(const ElementsLocation &location, QGraphicsItem
TerminalElement::~TerminalElement() {} TerminalElement::~TerminalElement() {}
/** /**
* @brief TerminalElement::initLink @brief TerminalElement::initLink
* @param project @param project
*/ */
void TerminalElement::initLink(QETProject *project) { void TerminalElement::initLink(QETProject *project) {
Element::initLink(project); Element::initLink(project);
} }

View File

@@ -28,11 +28,12 @@
#include <QPolygonF> #include <QPolygonF>
/** /**
* @brief ConductorCreator::ConductorCreator @brief ConductorCreator::ConductorCreator
* Create an electrical potential between all terminals of @terminals_list. Create an electrical potential between all terminals of @terminals_list.
* the terminals of the list must be in the same diagram. the terminals of the list must be in the same diagram.
* @param terminals_list @param d Diagram
*/ @param terminals_list QList<Terminal *>
*/
ConductorCreator::ConductorCreator(Diagram *d, QList<Terminal *> terminals_list) : ConductorCreator::ConductorCreator(Diagram *d, QList<Terminal *> terminals_list) :
m_terminals_list(terminals_list) m_terminals_list(terminals_list)
{ {
@@ -68,11 +69,11 @@ ConductorCreator::ConductorCreator(Diagram *d, QList<Terminal *> terminals_list)
} }
/** /**
* @brief ConductorCreator::create @brief ConductorCreator::create
* Create an electrical potential between the terminals of the diagram d, contained in the polygon Create an electrical potential between the terminals of the diagram d, contained in the polygon
* @param d @param d Diagram
* @param polygon : polygon in diagram coordinate @param polygon : polygon in diagram coordinate
*/ */
void ConductorCreator::create(Diagram *d, const QPolygonF &polygon) void ConductorCreator::create(Diagram *d, const QPolygonF &polygon)
{ {
QList<Terminal *> t_list; QList<Terminal *> t_list;
@@ -92,9 +93,9 @@ void ConductorCreator::create(Diagram *d, const QPolygonF &polygon)
} }
/** /**
* @brief ConductorCreator::propertieToUse @brief ConductorCreator::propertieToUse
* @return the conductor properties to use for the new conductors. @return the conductor properties to use for the new conductors.
*/ */
void ConductorCreator::setUpPropertieToUse() void ConductorCreator::setUpPropertieToUse()
{ {
QList<Conductor *> potentials = existingPotential(); QList<Conductor *> potentials = existingPotential();
@@ -130,11 +131,11 @@ void ConductorCreator::setUpPropertieToUse()
} }
/** /**
* @brief ConductorCreator::existingPotential @brief ConductorCreator::existingPotential
* Return the list of existing potential of Return the list of existing potential of
* the terminal list the terminal list
* @return @return c_list QList<Conductor *>
*/ */
QList<Conductor *> ConductorCreator::existingPotential() QList<Conductor *> ConductorCreator::existingPotential()
{ {
QList<Conductor *> c_list; QList<Conductor *> c_list;
@@ -174,9 +175,9 @@ QList<Conductor *> ConductorCreator::existingPotential()
} }
/** /**
* @brief ConductorCreator::hubTerminal @brief ConductorCreator::hubTerminal
* @return @return hub_terminal
*/ */
Terminal *ConductorCreator::hubTerminal() Terminal *ConductorCreator::hubTerminal()
{ {
Terminal *hub_terminal = m_terminals_list.first(); Terminal *hub_terminal = m_terminals_list.first();

View File

@@ -24,7 +24,7 @@
@param parent @param parent
*/ */
MacOSXOpenEvent::MacOSXOpenEvent(QObject *parent) : MacOSXOpenEvent::MacOSXOpenEvent(QObject *parent) :
QObject(parent) QObject(parent)
{} {}
/** /**
@@ -35,13 +35,13 @@ MacOSXOpenEvent::MacOSXOpenEvent(QObject *parent) :
*/ */
bool MacOSXOpenEvent::eventFilter(QObject *watched, QEvent *event) bool MacOSXOpenEvent::eventFilter(QObject *watched, QEvent *event)
{ {
if (event->type() == QEvent::FileOpen) if (event->type() == QEvent::FileOpen)
{ {
SingleApplication *app = dynamic_cast<SingleApplication *>(watched); SingleApplication *app = dynamic_cast<SingleApplication *>(watched);
QFileOpenEvent *open_event = static_cast<QFileOpenEvent*>(event); QFileOpenEvent *open_event = static_cast<QFileOpenEvent*>(event);
QString message = "launched-with-args: " + open_event->file(); QString message = "launched-with-args: " + open_event->file();
app->sendMessage(message.toUtf8()); app->sendMessage(message.toUtf8());
return true; return true;
} }
return false; return false;
} }

View File

@@ -19,13 +19,15 @@
#define MACOSXOPENEVENT_H #define MACOSXOPENEVENT_H
#include <QObject> #include <QObject>
/**
@brief The MacOSXOpenEvent class
*/
class MacOSXOpenEvent : public QObject class MacOSXOpenEvent : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit MacOSXOpenEvent(QObject *parent = nullptr); explicit MacOSXOpenEvent(QObject *parent = nullptr);
bool eventFilter(QObject *watched, QEvent *event) override; bool eventFilter(QObject *watched, QEvent *event) override;
}; };
#endif // MACOSXOPENEVENT_H #endif // MACOSXOPENEVENT_H

View File

@@ -26,7 +26,7 @@
*/ */
QString QETUtils::marginsToString(const QMargins &margins) QString QETUtils::marginsToString(const QMargins &margins)
{ {
QString str; QString str;
str += QString::number(margins.left()); str += QString::number(margins.left());
str += ";"; str += ";";
str += QString::number(margins.top()); str += QString::number(margins.top());

View File

@@ -21,12 +21,12 @@
#include <QMargins> #include <QMargins>
/** /**
* Provide some small utils function Provide some small utils function
*/ */
namespace QETUtils namespace QETUtils
{ {
QString marginsToString(const QMargins &margins); QString marginsToString(const QMargins &margins);
QMargins marginsFromString(const QString &string); QMargins marginsFromString(const QString &string);
} }
#endif // QETUTILS_H #endif // QETUTILS_H