QElectroTech  0.70
changeelementinformationcommand.cpp
Go to the documentation of this file.
1 /*
2  Copyright 2006-2019 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 */
19 #include "element.h"
20 #include <QObject>
21 
30  QUndoCommand (parent),
31  m_element (elmt),
32  m_old_info (old_info),
33  m_new_info (new_info)
34 {
35  setText(QObject::tr("Modifier les informations de l'élément : %1").arg(elmt -> name()));
36 }
37 
38 bool ChangeElementInformationCommand::mergeWith(const QUndoCommand *other)
39 {
40  if (id() != other->id()) return false;
41  ChangeElementInformationCommand const *undo = static_cast<const ChangeElementInformationCommand*>(other);
42  if (m_element != undo->m_element) return false;
43  m_new_info = undo->m_new_info;
44  return true;
45 }
46 
51  m_element -> setElementInformations(m_old_info);
52 }
53 
58  m_element -> setElementInformations(m_new_info);
59 }
bool mergeWith(const QUndoCommand *other) override
The ChangeElementInformationCommand class This class manage undo/redo to change the element informati...
QIcon tr
Definition: qeticons.cpp:204
void redo() override
ChangeElementInformationCommand::redo.
void undo() override
ChangeElementInformationCommand::undo.
ChangeElementInformationCommand(Element *elmt, DiagramContext &old_info, DiagramContext &new_info, QUndoCommand *parent=nullptr)
ChangeElementInformationCommand::ChangeElementInformationCommand Default constructor.