/* Copyright 2006-2025 The QElectroTech Team This file is part of QElectroTech. QElectroTech is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. QElectroTech is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with QElectroTech. If not, see . */ #ifndef LINKELEMENTCOMMAND_H #define LINKELEMENTCOMMAND_H #include class Element; /** @brief 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. */ class LinkElementCommand : public QUndoCommand { public: LinkElementCommand(Element *element_, QUndoCommand *parent = nullptr); int id() const override {return 2;} bool mergeWith(const QUndoCommand *other) override; static bool isLinkable (Element *element_a, Element *element_b, bool already_linked = false); void setLink (const QList& element_list); void setLink (Element *element_); void unlink (QList element_list); void unlinkAll (); void undo() override; void redo() override; private: void setUpNewLink (const QList &element_list, bool already_link); void makeLink (const QList &element_list); private: Element *m_element; bool m_first_redo; QList m_linked_before; // m_linked_after; //