mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 08:10:52 +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));
|
else setText(QObject::tr("R\351duire une image \340 %1 %").arg(new_size*100));
|
||||||
image_ -> setScale(new_size);
|
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);
|
||||||
|
}
|
||||||
|
|||||||
@@ -587,4 +587,19 @@ class ImageResizerCommand : public QUndoCommand {
|
|||||||
Diagram *diagram;
|
Diagram *diagram;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class LinkElementsCommand : public QUndoCommand {
|
||||||
|
public:
|
||||||
|
// constructor destructor
|
||||||
|
LinkElementsCommand (Element *elmt1, Element *elmt2, QUndoCommand *parent = 0);
|
||||||
|
virtual ~LinkElementsCommand();
|
||||||
|
//methods
|
||||||
|
virtual void undo();
|
||||||
|
virtual void redo();
|
||||||
|
|
||||||
|
private:
|
||||||
|
//attributes
|
||||||
|
Diagram*diagram_;
|
||||||
|
Element *elmt_1, *elmt_2;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ class Element : public QetGraphicsItem {
|
|||||||
bool isFree () const;
|
bool isFree () const;
|
||||||
virtual void linkToElement(Element *) {}
|
virtual void linkToElement(Element *) {}
|
||||||
virtual void unlinkAllElements() {}
|
virtual void unlinkAllElements() {}
|
||||||
|
virtual void unlinkElement(Element *elmt) {}
|
||||||
void initLink(QETProject *);
|
void initLink(QETProject *);
|
||||||
QList<Element *> linkedElements () const;
|
QList<Element *> linkedElements () const;
|
||||||
|
|
||||||
|
|||||||
@@ -77,6 +77,17 @@ void ReportElement::unlinkAllElements(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @brief ReportElement::unlinkElement
|
||||||
|
*unlink the specified element.
|
||||||
|
*for reportelement, they must be only one linked element, so we call
|
||||||
|
*unlinkAllElements for clear the connected_elements list.
|
||||||
|
* @param elmt
|
||||||
|
*/
|
||||||
|
void ReportElement::unlinkElement(Element *elmt) {
|
||||||
|
Q_UNUSED (elmt);
|
||||||
|
unlinkAllElements();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ReportElement::linkType
|
* @brief ReportElement::linkType
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ class ReportElement : public CustomElement {
|
|||||||
~ReportElement();
|
~ReportElement();
|
||||||
virtual void linkToElement(Element *);
|
virtual void linkToElement(Element *);
|
||||||
virtual void unlinkAllElements();
|
virtual void unlinkAllElements();
|
||||||
|
virtual void unlinkElement(Element *elmt);
|
||||||
virtual int linkType() const;
|
virtual int linkType() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <diagramposition.h>
|
#include <diagramposition.h>
|
||||||
#include <elementprovider.h>
|
#include <elementprovider.h>
|
||||||
#include <qetgraphicsitem/elementtextitem.h>
|
#include <qetgraphicsitem/elementtextitem.h>
|
||||||
|
#include <diagramcommands.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief FolioReportProperties::FolioReportProperties : Construcor
|
* @brief FolioReportProperties::FolioReportProperties : Construcor
|
||||||
@@ -68,5 +69,7 @@ void FolioReportProperties::BuildRadioList() {
|
|||||||
* Apply the new properties for this folio report
|
* Apply the new properties for this folio report
|
||||||
*/
|
*/
|
||||||
void FolioReportProperties::Apply() {
|
void FolioReportProperties::Apply() {
|
||||||
if (element_to_link) element_to_link->linkToElement(element_);
|
if (element_to_link) {
|
||||||
|
element_->diagram()->undoStack().push(new LinkElementsCommand(element_, element_to_link));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user