QElectroTech  0.8-dev
deleteqgraphicsitemcommand.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 DELETEQGRAPHICSITEMCOMMAND_H
19 #define DELETEQGRAPHICSITEMCOMMAND_H
20 
21 #include <QUndoCommand>
22 #include "diagramcontent.h"
23 
24 class Diagram;
26 class Terminal;
28 class QGraphicsScene;
29 
30 class DeleteQGraphicsItemCommand : public QUndoCommand
31 {
32  public:
33  DeleteQGraphicsItemCommand(Diagram *diagram, const DiagramContent &content, QUndoCommand * parent = nullptr);
34  ~DeleteQGraphicsItemCommand() override;
35 
36  private:
38 
40  Terminal *terminalInSamePotential(Terminal *terminal, Conductor *conductor_to_exclude);
41 
42  public:
43  void undo() override;
44  void redo() override;
45 
46  // attributes
47  private:
50  QHash <Element *, QList<Element *> > m_link_hash;
51  QHash <DynamicElementTextItem *, Element *> m_elmt_text_hash;
52  QHash <DynamicElementTextItem *, ElementTextItemGroup *> m_grp_texts_hash;
53  QList <QPair<Terminal *, Terminal *>> m_connected_terminals;
54  QHash <QetGraphicsTableItem *, QPointer<QGraphicsScene>> m_table_scene_hash;
55  bool m_remove_linked_table = false;
56 };
57 
58 #endif // DELETEQGRAPHICSITEMCOMMAND_H
DeleteQGraphicsItemCommand::undo
void undo() override
DeleteQGraphicsItemCommand::undo Undo this command.
Definition: deleteqgraphicsitemcommand.cpp:244
Terminal::conductors
QList< Conductor * > conductors() const
Terminal::conductors.
Definition: terminal.cpp:715
DeleteQGraphicsItemCommand::DeleteQGraphicsItemCommand
DeleteQGraphicsItemCommand(const DeleteQGraphicsItemCommand &)
DiagramContent::AnyConductor
@ AnyConductor
Definition: diagramcontent.h:61
Element::addTextToGroup
bool addTextToGroup(DynamicElementTextItem *text, ElementTextItemGroup *group)
Element::addTextToGroup Add the text text to the group group; If group isn't owned by this element re...
Definition: element.cpp:1432
DynamicElementTextItem
The DynamicElementTextItem class This class provide a simple text field of element who can be added o...
Definition: dynamicelementtextitem.h:39
diagramcommands.h
Conductor::setProperties
void setProperties(const ConductorProperties &property)
Conductor::setProperties Set property as current property of conductor.
Definition: conductor.cpp:1538
Element::linkedElements
QList< Element * > linkedElements()
Element::linkedElements.
Definition: element.h:258
QetGraphicsTableItem
The QetGraphicsTableItem class This item display a table destined to represent the content of a QAbst...
Definition: qetgraphicstableitem.h:43
conductor.h
DeleteQGraphicsItemCommand::m_connected_terminals
QList< QPair< Terminal *, Terminal * > > m_connected_terminals
Keep the parent group of each deleted element text item.
Definition: deleteqgraphicsitemcommand.h:53
ElementTextItemGroup::parentElement
Element * parentElement() const
ElementTextItemGroup::parentElement.
Definition: elementtextitemgroup.cpp:357
conductortextitem.h
DeleteQGraphicsItemCommand
Definition: deleteqgraphicsitemcommand.h:31
Diagram::showMe
void showMe()
Definition: diagram.h:161
elementtextitemgroup.h
Diagram::addItem
virtual void addItem(QGraphicsItem *item)
Diagram::addItem Réimplemented from QGraphicsScene::addItem(QGraphicsItem *item) Do some specific ope...
Definition: diagram.cpp:1550
Conductor::diagram
Diagram * diagram() const
Definition: conductor.cpp:559
DiagramContent
Definition: diagramcontent.h:46
DiagramContent::m_elements
QList< Element * > m_elements
Definition: diagramcontent.h:69
Terminal::parentElement
Element * parentElement() const
Terminal::parentElement.
Definition: terminal.cpp:822
DeleteQGraphicsItemCommand::DeleteQGraphicsItemCommand
DeleteQGraphicsItemCommand(Diagram *diagram, const DiagramContent &content, QUndoCommand *parent=nullptr)
DeleteQGraphicsItemCommand::DeleteQGraphicsItemCommand.
Definition: deleteqgraphicsitemcommand.cpp:37
addelementtextcommand.h
DiagramContent::conductors
QList< Conductor * > conductors(int=AnyConductor) const
DiagramContent::conductors.
Definition: diagramcontent.cpp:167
DiagramContent::sentence
QString sentence(int=All) const
DiagramContent::sentence.
Definition: diagramcontent.cpp:438
DeleteQGraphicsItemCommand::m_grp_texts_hash
QHash< DynamicElementTextItem *, ElementTextItemGroup * > m_grp_texts_hash
Keep the parent element of each deleted dynamic element text item.
Definition: deleteqgraphicsitemcommand.h:52
DeleteQGraphicsItemCommand::redo
void redo() override
DeleteQGraphicsItemCommand::redo Redo the delete command.
Definition: deleteqgraphicsitemcommand.cpp:282
Diagram
The Diagram class This class represents an electric diagram. It manages its various child elements,...
Definition: diagram.h:56
Element::removeTextFromGroup
bool removeTextFromGroup(DynamicElementTextItem *text, ElementTextItemGroup *group)
Element::removeTextFromGroup Remove the text text from the group group, en reparent text to this elem...
Definition: element.cpp:1455
DeleteQGraphicsItemCommand::m_table_scene_hash
QHash< QetGraphicsTableItem *, QPointer< QGraphicsScene > > m_table_scene_hash
Definition: deleteqgraphicsitemcommand.h:54
DeleteQGraphicsItemCommand::m_diagram
Diagram * m_diagram
Definition: deleteqgraphicsitemcommand.h:49
DeleteQGraphicsItemCommand::setPotentialsOfRemovedElements
void setPotentialsOfRemovedElements()
DeleteQGraphicsItemCommand::setPotentialsOfRemovedElements This function creates new conductors (if n...
Definition: deleteqgraphicsitemcommand.cpp:121
QET::Icons::Conductor
QIcon Conductor
Definition: qeticons.cpp:35
Diagram::removeItem
virtual void removeItem(QGraphicsItem *item)
Diagram::removeItem Reimplemented from QGraphicsScene::removeItem(QGraphicsItem *item) Do some specif...
Definition: diagram.cpp:1581
DeleteQGraphicsItemCommand::m_elmt_text_hash
QHash< DynamicElementTextItem *, Element * > m_elmt_text_hash
keep linked element for each removed element linked to other element.
Definition: deleteqgraphicsitemcommand.h:51
DiagramContent::m_texts_groups
QSet< ElementTextItemGroup * > m_texts_groups
Definition: diagramcontent.h:78
Element::removeDynamicTextItem
void removeDynamicTextItem(DynamicElementTextItem *deti)
Element::removeDynamicTextItem Remove deti, no matter if is a child of this element or a child of a g...
Definition: element.cpp:1287
AddItemCommand
The AddItemCommand class This command add an item in a diagram The item to add is template,...
Definition: diagramcommands.h:42
QGIManager::release
void release(QGraphicsItem *)
Definition: qgimanager.cpp:60
element.h
DeleteQGraphicsItemCommand::~DeleteQGraphicsItemCommand
~DeleteQGraphicsItemCommand() override
Definition: deleteqgraphicsitemcommand.cpp:112
Element::addDynamicTextItem
void addDynamicTextItem(DynamicElementTextItem *deti=nullptr)
Element::addDynamiqueTextItem Add deti as a dynamic text item of this element, deti is reparented to ...
Definition: element.cpp:1264
DiagramContent::m_tables
QVector< QetGraphicsTableItem * > m_tables
Definition: diagramcontent.h:80
RemoveTextsGroupCommand
The RemoveTextsGroupCommand class Manage the removinf of a texts group.
Definition: addelementtextcommand.h:85
Element
Definition: element.h:41
Element::terminals
QList< Terminal * > terminals() const
Element::terminals.
Definition: element.cpp:136
DynamicElementTextItem::parentElement
Element * parentElement() const
DynamicElementTextItem::ParentElement.
Definition: dynamicelementtextitem.cpp:227
diagramcontent.h
Diagram::qgiManager
QGIManager & qgiManager()
Diagram::qgiManager.
Definition: diagram.h:405
DiagramContent::All
@ All
Definition: diagramcontent.h:65
DiagramContent::m_element_texts
QSet< DynamicElementTextItem * > m_element_texts
Definition: diagramcontent.h:77
qetgraphicstableitem.h
ElementTextItemGroup
The ElementTextItemGroup class This class represent a group of element text Texts in the group can be...
Definition: elementtextitemgroup.h:36
DeleteQGraphicsItemCommand::m_removed_contents
DiagramContent m_removed_contents
Definition: deleteqgraphicsitemcommand.h:48
ConductorProperties
The ConductorProperties class This class represents the functional properties of a particular conduct...
Definition: conductorproperties.h:68
DeleteQGraphicsItemCommand::m_link_hash
QHash< Element *, QList< Element * > > m_link_hash
Definition: deleteqgraphicsitemcommand.h:50
qetdiagrameditor.h
DiagramContent::items
QList< QGraphicsItem * > items(int=All) const
DiagramContent::items.
Definition: diagramcontent.cpp:374
DynamicElementTextItem::parentGroup
ElementTextItemGroup * parentGroup() const
DynamicElementTextItem::parentGroup.
Definition: dynamicelementtextitem.cpp:236
dynamicelementtextitem.h
DeleteQGraphicsItemCommand::m_remove_linked_table
bool m_remove_linked_table
Definition: deleteqgraphicsitemcommand.h:55
QGIManager::manage
void manage(QGraphicsItem *)
Definition: qgimanager.cpp:48
DeleteQGraphicsItemCommand::terminalInSamePotential
Terminal * terminalInSamePotential(Terminal *terminal, Conductor *conductor_to_exclude)
DeleteQGraphicsItemCommand::terminalInSamePotential Return a terminal at the same potential of termin...
Definition: deleteqgraphicsitemcommand.cpp:214
Conductor
Definition: conductor.h:43
terminal.h
Terminal
The Terminal class This class represents a terminal of an electrical element, i.e....
Definition: terminal.h:35
DiagramContent::Elements
@ Elements
Definition: diagramcontent.h:54
deleteqgraphicsitemcommand.h
QET::Icons::tr
QIcon tr
Definition: qeticons.cpp:206
diagram.h