Les modifications de conducteur sont desormais annulables

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@140 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
xavierqet
2007-09-27 17:42:02 +00:00
parent 27e8ced638
commit 2c184a46da
6 changed files with 129 additions and 12 deletions

View File

@@ -244,16 +244,10 @@ MoveElementsCommand::MoveElementsCommand(
movement(m)
{
setText(QObject::tr("d\351placer ") + QET::ElementsAndConducersSentence(elements_to_move.count(), conducers_to_move.count()));
foreach(QGraphicsItem *qgi, elements_to_move) diagram -> qgiManager().manage(qgi);
foreach(QGraphicsItem *qgi, conducers_to_move) diagram -> qgiManager().manage(qgi);
foreach(QGraphicsItem *qgi, conducers_to_update) diagram -> qgiManager().manage(qgi);
}
/// Destructeur
MoveElementsCommand::~MoveElementsCommand() {
foreach(QGraphicsItem *qgi, elements_to_move) diagram -> qgiManager().release(qgi);
foreach(QGraphicsItem *qgi, conducers_to_move) diagram -> qgiManager().release(qgi);
foreach(QGraphicsItem *qgi, conducers_to_update) diagram -> qgiManager().release(qgi);
}
/// annule le deplacement
@@ -357,3 +351,39 @@ void RotateElementsCommand::redo() {
e -> update();
}
}
/**
Constructeur
@param c Conducteur modifie
@param old_p ancien profil du conducteur
@param new_p nouveau profil du conducteur
@param parent QUndoCommand parent
*/
ChangeConducerCommand::ChangeConducerCommand(
Conducer *c,
const ConducerProfile &old_p,
const ConducerProfile &new_p,
QUndoCommand *parent
) :
QUndoCommand(QObject::tr("modifier un conducteur"), parent),
conducer(c),
old_profile(old_p),
new_profile(new_p),
first_redo(true)
{
}
/// Destructeur
ChangeConducerCommand::~ChangeConducerCommand() {
}
/// Annule la modification du conducteur
void ChangeConducerCommand::undo() {
conducer -> setProfile(old_profile);
}
/// Refait la modification du conducteur
void ChangeConducerCommand::redo() {
if (first_redo) first_redo = false;
else conducer -> setProfile(new_profile);
}