QElectroTech  0.70
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
LinkElementCommand Class Reference

The LinkElementCommand class This undo class manage link between elements. In the same instance of this class, we can link and unlink elements from an edited element This undo class support the merge. More...

#include <linkelementcommand.h>

Public Member Functions

 LinkElementCommand (Element *element_, QUndoCommand *parent=nullptr)
 LinkElementCommand::LinkElementCommand Constructor. More...
 
int id () const override
 
bool mergeWith (const QUndoCommand *other) override
 LinkElementCommand::mergeWith. More...
 
void setLink (const QList< Element *> &element_list)
 LinkElementCommand::setLink Replace all linked elements of edited element by elements stored in This method do several check to know if element can be linked or not. More...
 
void setLink (Element *element_)
 LinkElementCommand::setLink This is an overloaded function. More...
 
void unlink (QList< Element *> element_list)
 LinkElementCommand::unlink Unlink all elements of element_list from the edited element. More...
 
void unlinkAll ()
 LinkElementCommand::unlinkAll Unlink all element of the edited element. More...
 
void undo () override
 LinkElementCommand::undo Undo this command. More...
 
void redo () override
 LinkElementCommand::redo Redo this command. More...
 

Static Public Member Functions

static bool isLinkable (Element *element_a, Element *element_b, bool already_linked=false)
 LinkElementCommand::isLinkable. More...
 

Private Member Functions

void setUpNewLink (const QList< Element *> &element_list, bool already_link)
 LinkElementCommand::setUpNewLink Update the content of m_link_after with the content of . Each linkable element (know via the static method isLinkable) is added to m_linked_after is used for the static method isLinkable. More...
 
void makeLink (const QList< Element *> &element_list)
 LinkElementCommand::makeLink Make the link between m_element and element_list; This method unlink elements if needed. More...
 

Private Attributes

Elementm_element
 
bool m_first_redo
 
QList< Element * > m_linked_before
 
QList< Element * > m_linked_after
 

Detailed Description

The LinkElementCommand class This undo class manage link between elements. In the same instance of this class, we can link and unlink elements from an edited element This undo class support the merge.

Definition at line 31 of file linkelementcommand.h.

Constructor & Destructor Documentation

◆ LinkElementCommand()

LinkElementCommand::LinkElementCommand ( Element element_,
QUndoCommand *  parent = nullptr 
)

LinkElementCommand::LinkElementCommand Constructor.

Parameters
element_: element where we work the link / unlink
parent: parent undo

Definition at line 31 of file linkelementcommand.cpp.

References Element::linkedElements(), m_element, m_linked_after, m_linked_before, and QET::Icons::tr.

Member Function Documentation

◆ id()

int LinkElementCommand::id ( ) const
inlineoverride

Definition at line 36 of file linkelementcommand.h.

◆ isLinkable()

bool LinkElementCommand::isLinkable ( Element element_a,
Element element_b,
bool  already_linked = false 
)
static

LinkElementCommand::isLinkable.

Parameters
element_a
element_b
already_linked
Returns
true if element_a and element_b can be linked between them. There is few condition to be linked : 1- element_a and element_b must be linkable type. (Ex : A is master and B is slave 'OK', A and B is master 'KO') 2- For element type slave and report (no matter if element is 'A' or 'B'), the element must be free (not connected to an element) 3- we can override the section 2 by set already_linked to true. In this case, if slave or report is already linked to the other element ('A' or 'B') return true, but if linked to another element (not 'A' or 'B') return false

Definition at line 66 of file linkelementcommand.cpp.

References Element::isFree(), Element::linkedElements(), Element::linkType(), Element::Master, Element::NextReport, Element::PreviousReport, Element::Simple, Element::Slave, and Element::Terminale.

Referenced by setUpNewLink().

◆ makeLink()

void LinkElementCommand::makeLink ( const QList< Element *> &  element_list)
private

LinkElementCommand::makeLink Make the link between m_element and element_list; This method unlink elements if needed.

Parameters
element_list

Definition at line 258 of file linkelementcommand.cpp.

References Element::linkedElements(), Element::linkToElement(), m_element, Element::unlinkAllElements(), and Element::unlinkElement().

Referenced by redo(), and undo().

◆ mergeWith()

bool LinkElementCommand::mergeWith ( const QUndoCommand *  other)
override

LinkElementCommand::mergeWith.

Parameters
othertry to merge this command with other
Returns
true if merge with success else false

Definition at line 45 of file linkelementcommand.cpp.

References m_element, m_linked_after, and undo().

◆ redo()

void LinkElementCommand::redo ( )
override

◆ setLink() [1/2]

void LinkElementCommand::setLink ( const QList< Element *> &  element_list)

LinkElementCommand::setLink Replace all linked elements of edited element by elements stored in This method do several check to know if element can be linked or not.

Parameters
element_list

Definition at line 132 of file linkelementcommand.cpp.

References m_linked_after, and setUpNewLink().

Referenced by LinkSingleElementWidget::associatedUndo(), MasterPropertiesWidget::associatedUndo(), and setLink().

◆ setLink() [2/2]

void LinkElementCommand::setLink ( Element element_)

LinkElementCommand::setLink This is an overloaded function.

Parameters
element_

Definition at line 143 of file linkelementcommand.cpp.

References setLink().

◆ setUpNewLink()

void LinkElementCommand::setUpNewLink ( const QList< Element *> &  element_list,
bool  already_link 
)
private

LinkElementCommand::setUpNewLink Update the content of m_link_after with the content of . Each linkable element (know via the static method isLinkable) is added to m_linked_after is used for the static method isLinkable.

Parameters
element_list
already_link

Definition at line 229 of file linkelementcommand.cpp.

References isLinkable(), Element::linkType(), m_element, m_linked_after, and Element::Master.

Referenced by setLink().

◆ undo()

void LinkElementCommand::undo ( )
override

LinkElementCommand::undo Undo this command.

Definition at line 173 of file linkelementcommand.cpp.

References QetGraphicsItem::diagram(), m_element, m_linked_before, makeLink(), and Diagram::showMe().

Referenced by mergeWith().

◆ unlink()

void LinkElementCommand::unlink ( QList< Element *>  element_list)

LinkElementCommand::unlink Unlink all elements of element_list from the edited element.

Parameters
element_list

Definition at line 155 of file linkelementcommand.cpp.

References m_linked_after.

◆ unlinkAll()

void LinkElementCommand::unlinkAll ( )

LinkElementCommand::unlinkAll Unlink all element of the edited element.

Definition at line 165 of file linkelementcommand.cpp.

References m_linked_after.

Referenced by LinkSingleElementWidget::associatedUndo(), and MasterPropertiesWidget::associatedUndo().

Member Data Documentation

◆ m_element

Element* LinkElementCommand::m_element
private

Definition at line 54 of file linkelementcommand.h.

Referenced by LinkElementCommand(), makeLink(), mergeWith(), redo(), setUpNewLink(), and undo().

◆ m_first_redo

bool LinkElementCommand::m_first_redo
private

Definition at line 55 of file linkelementcommand.h.

Referenced by redo().

◆ m_linked_after

QList<Element *> LinkElementCommand::m_linked_after
private

◆ m_linked_before

QList<Element *> LinkElementCommand::m_linked_before
private

Definition at line 56 of file linkelementcommand.h.

Referenced by LinkElementCommand(), and undo().


The documentation for this class was generated from the following files: