QElectroTech
0.70
sources
undocommand
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
*/
18
#include "
changeelementinformationcommand.h
"
19
#include "
element.h
"
20
#include <QObject>
21
29
ChangeElementInformationCommand::ChangeElementInformationCommand
(
Element
*elmt,
DiagramContext
&old_info,
DiagramContext
&new_info, QUndoCommand *parent) :
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
50
void
ChangeElementInformationCommand::undo
() {
51
m_element
-> setElementInformations(
m_old_info
);
52
}
53
57
void
ChangeElementInformationCommand::redo
() {
58
m_element
-> setElementInformations(
m_new_info
);
59
}
ChangeElementInformationCommand::m_old_info
DiagramContext m_old_info
Definition:
changeelementinformationcommand.h:42
element.h
ChangeElementInformationCommand::mergeWith
bool mergeWith(const QUndoCommand *other) override
Definition:
changeelementinformationcommand.cpp:38
DiagramContext
Definition:
diagramcontext.h:53
ChangeElementInformationCommand
The ChangeElementInformationCommand class This class manage undo/redo to change the element informati...
Definition:
changeelementinformationcommand.h:30
QET::Icons::tr
QIcon tr
Definition:
qeticons.cpp:204
Element
Definition:
element.h:40
ChangeElementInformationCommand::redo
void redo() override
ChangeElementInformationCommand::redo.
Definition:
changeelementinformationcommand.cpp:57
ChangeElementInformationCommand::m_element
Element * m_element
Definition:
changeelementinformationcommand.h:41
ChangeElementInformationCommand::m_new_info
DiagramContext m_new_info
Definition:
changeelementinformationcommand.h:42
ChangeElementInformationCommand::undo
void undo() override
ChangeElementInformationCommand::undo.
Definition:
changeelementinformationcommand.cpp:50
ChangeElementInformationCommand::ChangeElementInformationCommand
ChangeElementInformationCommand(Element *elmt, DiagramContext &old_info, DiagramContext &new_info, QUndoCommand *parent=nullptr)
ChangeElementInformationCommand::ChangeElementInformationCommand Default constructor.
Definition:
changeelementinformationcommand.cpp:29
changeelementinformationcommand.h
Generated by
1.8.15