QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
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>

Inherits QUndoCommand.

Collaboration diagram for LinkElementCommand:
Collaboration graph

Public Member Functions

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

Static Public Member Functions

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

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 element_list. Each linkable element (know via the static method isLinkable) is added to m_linked_after already_link is used for the static method isLinkable.
 
void makeLink (const QList< Element * > &element_list)
 LinkElementCommand::makeLink Make the link between m_element and element_list; This method unlinks elements if needed.
 

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.

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
Here is the call graph for this function:

Member Function Documentation

◆ id()

int LinkElementCommand::id ( ) const
inlineoverride

◆ 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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ makeLink()

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

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

Parameters
element_list
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
Here is the call graph for this function:

◆ redo()

void LinkElementCommand::redo ( )
override

LinkElementCommand::redo Redo this command.

Here is the call graph for this function:

◆ setLink() [1/2]

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

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

Parameters
element_list
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setLink() [2/2]

void LinkElementCommand::setLink ( Element element_)

LinkElementCommand::setLink This is an overloaded function.

Parameters
element_
Here is the call graph for this function:

◆ 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 element_list. Each linkable element (know via the static method isLinkable) is added to m_linked_after already_link is used for the static method isLinkable.

Parameters
element_list
already_link
Here is the call graph for this function:
Here is the caller graph for this function:

◆ undo()

void LinkElementCommand::undo ( )
override

LinkElementCommand::undo Undo this command.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unlink()

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

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

Parameters
element_list

◆ unlinkAll()

void LinkElementCommand::unlinkAll ( )

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

Here is the caller graph for this function:

Member Data Documentation

◆ m_element

Element* LinkElementCommand::m_element
private

◆ m_first_redo

bool LinkElementCommand::m_first_redo
private

◆ m_linked_after

QList<Element *> LinkElementCommand::m_linked_after
private

◆ m_linked_before

QList<Element *> LinkElementCommand::m_linked_before
private

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