diff --git a/editor/editorcommands.cpp b/editor/editorcommands.cpp index 463a3517e..83a5c63c0 100644 --- a/editor/editorcommands.cpp +++ b/editor/editorcommands.cpp @@ -475,3 +475,30 @@ void ChangeZValueCommand::applySendBackward(const QList &items_ foreach(QGraphicsItem *qgi, selected_items) redo_hash.insert(qgi, z ++); foreach(QGraphicsItem *qgi, non_selected_items) redo_hash.insert(qgi, z ++); } + +/** + Constructeur + @param elmt ElementScene concernee + @param allow true pour que les connexions internes soient acceptees, false sinon + @param parent QUndoCommand parent +*/ +AllowInternalConnectionsCommand::AllowInternalConnectionsCommand(ElementScene *elmt, bool allow, QUndoCommand *parent) : + QUndoCommand(QObject::tr("modification connexions internes"), parent), + element(elmt), + ic(allow) +{ +} + +/// Destructeur +AllowInternalConnectionsCommand::~AllowInternalConnectionsCommand() { +} + +/// Annule le changement d'autorisation pour les connexions internes +void AllowInternalConnectionsCommand::undo() { + element -> setInternalConnections(!ic); +} + +/// Refait le changement d'autorisation pour les connexions internes +void AllowInternalConnectionsCommand::redo() { + element -> setInternalConnections(ic); +} diff --git a/editor/editorcommands.h b/editor/editorcommands.h index a863b9bc2..c6653f397 100644 --- a/editor/editorcommands.h +++ b/editor/editorcommands.h @@ -277,4 +277,29 @@ class ChangeZValueCommand : public QUndoCommand { /// type de traitement Option option; }; + +/** + Cette classe represente l'action d'autoriser ou non les connexions + internes pour un element. +*/ +class AllowInternalConnectionsCommand : public QUndoCommand { + // constructeurs, destructeur + public: + AllowInternalConnectionsCommand(ElementScene *, bool, QUndoCommand * = 0); + virtual ~AllowInternalConnectionsCommand(); + private: + AllowInternalConnectionsCommand(const AllowInternalConnectionsCommand &); + + // methodes + public: + virtual void undo(); + virtual void redo(); + + // attributs + private: + /// Element edite auquel il faut appliquer les modifications + ElementScene *element; + /// autorisation des connexions internes apres modification + bool ic; +}; #endif diff --git a/editor/elementscene.cpp b/editor/elementscene.cpp index a79f712c2..f9c31e28c 100644 --- a/editor/elementscene.cpp +++ b/editor/elementscene.cpp @@ -584,7 +584,7 @@ void ElementScene::slot_editOrientations() { // cree un dialogue QDialog dialog_ori; dialog_ori.setModal(true); - dialog_ori.setFixedSize(400, 230); + dialog_ori.setFixedSize(400, 260); dialog_ori.setWindowTitle(tr("\311diter les orientations")); QVBoxLayout *dialog_layout = new QVBoxLayout(&dialog_ori); @@ -599,6 +599,11 @@ void ElementScene::slot_editOrientations() { ori_widget -> setOrientationSet(ori); dialog_layout -> addWidget(ori_widget); + // ajoute une case a cocher pour les connexions internes + QCheckBox *ic_checkbox = new QCheckBox(tr("Autoriser les connexions internes")); + ic_checkbox -> setChecked(internal_connections); + dialog_layout -> addWidget(ic_checkbox); + // ajoute deux boutons au dialogue QDialogButtonBox *dialog_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); dialog_layout -> addWidget(dialog_buttons); @@ -611,6 +616,9 @@ void ElementScene::slot_editOrientations() { if (new_ori != ori) { undoStack().push(new ChangeOrientationsCommand(this, ori, new_ori)); } + if (ic_checkbox -> isChecked() != internal_connections) { + undoStack().push(new AllowInternalConnectionsCommand(this, ic_checkbox -> isChecked())); + } } } diff --git a/editor/elementscene.h b/editor/elementscene.h index 5332d06c1..aecdc444e 100644 --- a/editor/elementscene.h +++ b/editor/elementscene.h @@ -94,6 +94,8 @@ class ElementScene : public QGraphicsScene { NamesList names() const; OrientationSet orientations(); void setOrientations(const OrientationSet &); + bool internalConnections(); + void setInternalConnections(bool); virtual const QDomDocument toXml() const; virtual void fromXml(const QDomDocument &); virtual QList zItems(bool = false) const; @@ -213,4 +215,18 @@ inline void ElementScene::setOrientations(const OrientationSet &orientation_set) ori = orientation_set; } +/** + @return true si les connexions internes sont acceptees, false sinon +*/ +inline bool ElementScene::internalConnections() { + return(internal_connections); +} + +/** + @param ic true pour que les connexions internes soient acceptees, false sinon +*/ +inline void ElementScene::setInternalConnections(bool ic) { + internal_connections = ic; +} + #endif