QElectroTech  0.8-dev
linkelementcommand.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2020 The QElectroTech Team
3  This file is part of QElectroTech.
4 
5  QElectroTech is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 2 of the License, or
8  (at your option) any later version.
9 
10  QElectroTech is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef LINKELEMENTCOMMAND_H
19 #define LINKELEMENTCOMMAND_H
20 
21 #include <QUndoCommand>
22 
23 class Element;
24 
31 class LinkElementCommand : public QUndoCommand
32 {
33  public:
34  LinkElementCommand(Element *element_, QUndoCommand *parent = nullptr);
35 
36  int id() const override {return 2;}
37  bool mergeWith(const QUndoCommand *other) override;
38 
39  static bool isLinkable (Element *element_a, Element *element_b, bool already_linked = false);
40 
41  void setLink (const QList<Element *>& element_list);
42  void setLink (Element *element_);
43  void unlink (QList<Element *> element_list);
44  void unlinkAll ();
45 
46  void undo() override;
47  void redo() override;
48 
49  private:
50  void setUpNewLink (const QList<Element *> &element_list, bool already_link);
51  void makeLink (const QList <Element *> &element_list);
52 
53  private:
56  QList<Element *> m_linked_before; //<Linked elements before this command, or when we call "undo"
57  QList<Element *> m_linked_after; //<Linked elements after this command, or when we recall "redo"
58 };
59 
60 #endif // LINKELEMENTCOMMAND_H
Element::Terminale
@ Terminale
Definition: element.h:57
Element::linkType
virtual kind linkType() const
Definition: element.h:159
Element::linkedElements
QList< Element * > linkedElements()
Element::linkedElements.
Definition: element.h:258
QetGraphicsItem::diagram
Diagram * diagram() const
Definition: qetgraphicsitem.cpp:40
conductor.h
Element::NextReport
@ NextReport
Definition: element.h:52
Diagram::showMe
void showMe()
Definition: diagram.h:161
Element::linkToElement
virtual void linkToElement(Element *)
Definition: element.h:154
Element::Simple
@ Simple
Definition: element.h:51
Element::Slave
@ Slave
Definition: element.h:56
QET::eachStrIsEqual
bool eachStrIsEqual(const QStringList &qsl)
QET::eachStrIsEqual.
Definition: qet.cpp:624
Element::Master
@ Master
Definition: element.h:55
potentialselectordialog.h
element.h
Element
Definition: element.h:41
Element::isFree
bool isFree() const
Definition: element.h:230
linkelementcommand.h
Element::AllReport
@ AllReport
Definition: element.h:54
conductorautonumerotation.h
Element::unlinkAllElements
virtual void unlinkAllElements()
Definition: element.h:155
Element::unlinkElement
virtual void unlinkElement(Element *)
Definition: element.h:156
PotentialSelectorDialog
The PotentialSelectorDialog class This dialog is used when user try to connect two existing potential...
Definition: potentialselectordialog.h:69
Element::conductors
QList< Conductor * > conductors() const
Element::conductors.
Definition: element.cpp:146
Conductor
Definition: conductor.h:43
QET::Icons::tr
QIcon tr
Definition: qeticons.cpp:206
Element::PreviousReport
@ PreviousReport
Definition: element.h:53
diagram.h