QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
linkelementcommand.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2024 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
23class Element;
24
31class 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
Definition element.h:43