mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
add undo command for linkable element
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2716 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -1131,3 +1131,47 @@ void ImageResizerCommand::redo() {
|
||||
else setText(QObject::tr("R\351duire une image \340 %1 %").arg(new_size*100));
|
||||
image_ -> setScale(new_size);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief LinkElementsCommand::LinkElementsCommand
|
||||
*Constructor
|
||||
* @param elmt1 element to Link
|
||||
* @param elmt2 element to link
|
||||
* @param parent parent undo command
|
||||
*/
|
||||
LinkElementsCommand::LinkElementsCommand(Element *elmt1, Element *elmt2, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
diagram_(elmt1->diagram()),
|
||||
elmt_1(elmt1),
|
||||
elmt_2(elmt2)
|
||||
{
|
||||
if (elmt1->linkType() & Element::AllReport &&
|
||||
elmt2->linkType() & Element::AllReport)
|
||||
setText(QObject::tr("Lier deux reports de folio",
|
||||
"title for undo LinkElementsCommand if two elements are folio report"));
|
||||
else setText(QObject::tr("Lier deux éléments"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief LinkElementsCommand::~LinkElementsCommand
|
||||
*destructor
|
||||
*/
|
||||
LinkElementsCommand::~LinkElementsCommand(){}
|
||||
|
||||
/**
|
||||
* @brief LinkElementsCommand::undo
|
||||
*Undo command
|
||||
*/
|
||||
void LinkElementsCommand::undo() {
|
||||
diagram_->showMe();
|
||||
elmt_1->unlinkElement(elmt_2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief LinkElementsCommand::redo
|
||||
*redo command
|
||||
*/
|
||||
void LinkElementsCommand::redo() {
|
||||
diagram_->showMe();
|
||||
elmt_1->linkToElement(elmt_2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user