[qet] [2714] Show corresponding diagram to undo/redo action

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 2714
Author:   blacksun
Date:     2014-01-06 19:21:58 +0100 (Mon, 06 Jan 2014)
Log Message:
-----------
Show corresponding diagram to undo/redo action

Modified Paths:
--------------
    trunk/sources/conductorautonumerotation.cpp
    trunk/sources/diagram.h
    trunk/sources/diagramcommands.cpp
    trunk/sources/diagramcommands.h
    trunk/sources/diagramview.cpp
    trunk/sources/diagramview.h
    trunk/sources/projectview.cpp

Modified: trunk/sources/conductorautonumerotation.cpp
===================================================================
--- trunk/sources/conductorautonumerotation.cpp	2014-01-06 15:58:31 UTC (rev 2713)
+++ trunk/sources/conductorautonumerotation.cpp	2014-01-06 18:21:58 UTC (rev 2714)
@@ -95,7 +95,7 @@
 		diagram_ -> undoStack().push(ccpc);
 	}
 	else {
-		QSet <Conductor *> clist = conductor_list;
+		QList <Conductor *> clist = conductor_list.toList();
 		clist << conductor_;
 		QList <ConductorProperties> old_properties, new_properties;
 		ConductorProperties cp;

Modified: trunk/sources/diagram.h
===================================================================
--- trunk/sources/diagram.h	2014-01-06 15:58:31 UTC (rev 2713)
+++ trunk/sources/diagram.h	2014-01-06 18:21:58 UTC (rev 2714)
@@ -111,6 +111,7 @@
 	void setProject(QETProject *);
 	int folioIndex() const;
 	qreal declaredQElectroTechVersion(bool = true) const;
+	void showMe() {emit showDiagram(this);}
 	
 	// methods related to read only mode
 	bool isReadOnly() const;
@@ -198,6 +199,7 @@
 	void invertSelection();
 	
 	signals:
+	void showDiagram (Diagram *);
 	void written();
 	void readOnlyChanged(bool);
 	void usedTitleBlockTemplateChanged(const QString &);

Modified: trunk/sources/diagramcommands.cpp
===================================================================
--- trunk/sources/diagramcommands.cpp	2014-01-06 15:58:31 UTC (rev 2713)
+++ trunk/sources/diagramcommands.cpp	2014-01-06 18:21:58 UTC (rev 2714)
@@ -55,11 +55,13 @@
 
 /// Annule l'ajout
 void AddElementCommand::undo() {
+	diagram->showMe();
 	diagram -> removeElement(element);
 }
 
 /// Refait l'ajout
 void AddElementCommand::redo() {
+	diagram->showMe();
 	diagram -> addElement(element);
 	element -> setPos(position);
 	element -> setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
@@ -88,11 +90,13 @@
 
 /// Annule l'ajout
 void AddTextCommand::undo() {
+	diagram->showMe();
 	diagram -> removeIndependentTextItem(textitem);
 }
 
 /// Refait l'ajout
 void AddTextCommand::redo() {
+	diagram->showMe();
 	diagram -> addIndependentTextItem(textitem);
 	textitem -> setPos(position);
 }
@@ -120,11 +124,13 @@
 
 ///Annule l'ajout
 void AddImageCommand::undo() {
+	diagram->showMe();
 	diagram -> removeItem(imageitem);
 }
 
 ///Refait l'ajout
 void AddImageCommand::redo() {
+	diagram->showMe();
 	diagram -> addDiagramImageItem(imageitem);
 	imageitem -> setPos(position - imageitem -> boundingRect().center());
 }
@@ -154,11 +160,13 @@
 
 /// Annule l'ajout
 void AddConductorCommand::undo() {
+	diagram->showMe();
 	diagram -> removeConductor(conductor);
 }
 
 /// Refait l'ajout
 void AddConductorCommand::redo() {
+	diagram->showMe();
 	diagram -> addConductor(conductor);
 }
 
@@ -195,6 +203,7 @@
 
 /// annule les suppressions
 void DeleteElementsCommand::undo() {
+	diagram->showMe();
 	// remet les elements
 	foreach(Element *e, removed_content.elements) {
 		diagram -> addElement(e);
@@ -217,6 +226,7 @@
 
 /// refait les suppressions
 void DeleteElementsCommand::redo() {
+	diagram->showMe();
 	// enleve les conducteurs
 	foreach(Conductor *c, removed_content.conductors(DiagramContent::AnyConductor)) {
 		diagram -> removeConductor(c);
@@ -274,6 +284,7 @@
 
 /// annule le coller
 void PasteDiagramCommand::undo() {
+	diagram->showMe();
 	// remove the conductors
 	foreach(Conductor *c, content.conductorsToMove) diagram -> removeConductor(c);
 	
@@ -289,6 +300,7 @@
 
 /// refait le coller
 void PasteDiagramCommand::redo() {
+	diagram->showMe();
 	if (first_redo) first_redo = false;
 	else {
 		// paste the elements
@@ -379,11 +391,13 @@
 
 /// annule le deplacement
 void MoveElementsCommand::undo() {
+	diagram->showMe();
 	move(-movement);
 }
 
 /// refait le deplacement
 void MoveElementsCommand::redo() {
+	diagram->showMe();
 	if (first_redo) first_redo = false;
 	else move(movement);
 }
@@ -481,11 +495,13 @@
 
 /// annule le deplacement
 void MoveElementsTextsCommand::undo() {
+	diagram->showMe();
 	move(-movement);
 }
 
 /// refait le deplacement
 void MoveElementsTextsCommand::redo() {
+	diagram->showMe();
 	if (first_redo) first_redo = false;
 	else move(movement);
 }
@@ -526,6 +542,7 @@
 
 /// annule le deplacement
 void MoveConductorsTextsCommand::undo() {
+	diagram->showMe();
 	foreach(ConductorTextItem *cti, texts_to_move_.keys()) {
 		QPointF movement = texts_to_move_[cti].first;
 		bool was_already_moved = texts_to_move_[cti].second;
@@ -539,6 +556,7 @@
 
 /// refait le deplacement
 void MoveConductorsTextsCommand::redo() {
+	diagram->showMe();
 	if (first_redo) {
 		first_redo = false;
 	} else {
@@ -602,7 +620,8 @@
 	text_item(dti),
 	text_before(before),
 	text_after(after),
-	first_redo(true)
+	first_redo(true),
+	diagram(dti->diagram())
 {
 }
 
@@ -612,11 +631,13 @@
 
 /// annule la modification de texte
 void ChangeDiagramTextCommand::undo() {
+	diagram->showMe();
 	text_item -> setHtml(text_before);
 }
 
 /// refait la modification de texte
 void ChangeDiagramTextCommand::redo() {
+	diagram->showMe();
 	if (first_redo) {
 		first_redo = false;
 	} else {
@@ -635,7 +656,8 @@
 	elements_to_rotate(elements),
 	texts_to_rotate(texts),
 	images_to_rotate(images),
-	applied_rotation_angle_(90.0)
+	applied_rotation_angle_(90.0),
+	diagram (elements.first()->diagram())
 {
 	setText(
 		QString(
@@ -653,6 +675,7 @@
 
 /// defait le pivotement
 void RotateElementsCommand::undo() {
+	diagram->showMe();
 	foreach(Element *e, elements_to_rotate) {
 		e -> rotateBy(-applied_rotation_angle_);
 	}
@@ -670,6 +693,7 @@
 
 /// refait le pivotement
 void RotateElementsCommand::redo() {
+	diagram->showMe();
 	foreach(Element *e, elements_to_rotate) {
 		e -> rotateBy(applied_rotation_angle_);
 	}
@@ -693,7 +717,8 @@
 RotateTextsCommand::RotateTextsCommand(const QHash<DiagramTextItem *, double> &previous_state, double applied_rotation, QUndoCommand *parent) :
 	QUndoCommand(parent),
 	texts_to_rotate(previous_state),
-	applied_rotation_angle_(applied_rotation)
+	applied_rotation_angle_(applied_rotation),
+	diagram(previous_state.key(0)->diagram())
 {
 	defineCommandName();
 }
@@ -724,6 +749,7 @@
 	Annule la rotation des textes
 */
 void RotateTextsCommand::undo() {
+	diagram->showMe();
 	foreach(DiagramTextItem *text, texts_to_rotate.keys()) {
 		if (ConductorTextItem *cti = qgraphicsitem_cast<ConductorTextItem *>(text))
 			cti -> forceRotateByUser(previous_rotate_by_user_[cti]);
@@ -735,6 +761,7 @@
 	Applique l'angle de rotation aux textes
 */
 void RotateTextsCommand::redo() {
+	diagram->showMe();
 	foreach(DiagramTextItem *text, texts_to_rotate.keys()) {
 		if (ConductorTextItem *cti = qgraphicsitem_cast<ConductorTextItem *>(text)) {
 			//we grab the previous rotation by user of each ConductorTextItem
@@ -780,7 +807,8 @@
 	old_profile(old_p),
 	new_profile(new_p),
 	path_type(path_t),
-	first_redo(true)
+	first_redo(true),
+	diagram (c->diagram())
 {
 }
 
@@ -790,12 +818,14 @@
 
 /// Annule la modification du conducteur
 void ChangeConductorCommand::undo() {
+	diagram->showMe();
 	conductor -> setProfile(old_profile, path_type);
 	conductor -> textItem() -> setPos(text_pos_before_mov_);
 }
 
 /// Refait la modification du conducteur
 void ChangeConductorCommand::redo() {
+	diagram->showMe();
 	if (first_redo) {
 		first_redo = false;
 	} else {
@@ -825,7 +855,8 @@
 	QUndoCommand *parent
 ) :
 	QUndoCommand(parent),
-	conductors_profiles(cp)
+	conductors_profiles(cp),
+	diagram(cp.keys().first()->diagram())
 {
 	setText(
 		QObject::tr(
@@ -841,6 +872,7 @@
 
 /// Annule la reinitialisation des conducteurs
 void ResetConductorCommand::undo() {
+	diagram->showMe();
 	foreach(Conductor *c, conductors_profiles.keys()) {
 		c -> setProfiles(conductors_profiles[c]);
 	}
@@ -848,6 +880,7 @@
 
 /// Refait la reinitialisation des conducteurs
 void ResetConductorCommand::redo() {
+	diagram->showMe();
 	foreach(Conductor *c, conductors_profiles.keys()) {
 		c -> setProfiles(ConductorProfilesGroup());
 	}
@@ -879,12 +912,14 @@
 
 /// Annule la modification de cartouche
 void ChangeTitleBlockCommand::undo() {
+	diagram->showMe();
 	diagram -> border_and_titleblock.importTitleBlock(old_titleblock);
 	diagram -> invalidate(diagram -> border());
 }
 
 /// Refait la modification de cartouche
 void ChangeTitleBlockCommand::redo() {
+	diagram->showMe();
 	diagram -> border_and_titleblock.importTitleBlock(new_titleblock);
 	diagram -> invalidate(diagram -> border());
 }
@@ -910,11 +945,13 @@
 
 /// Annule les changements apportes au schema
 void ChangeBorderCommand::undo() {
+	diagram->showMe();
 	diagram -> border_and_titleblock.importBorder(old_properties);
 }
 
 /// Refait les changements apportes au schema
 void ChangeBorderCommand::redo() {
+	diagram->showMe();
 	diagram -> border_and_titleblock.importBorder(new_properties);
 }
 
@@ -927,7 +964,8 @@
 	QUndoCommand(QObject::tr("modifier les propri\351t\351s d'un conducteur", "undo caption"), parent),
 	conductor(c),
 	old_settings_set(false),
-	new_settings_set(false)
+	new_settings_set(false),
+	diagram(c->diagram())
 {
 }
 
@@ -952,6 +990,7 @@
 	doivent avoir ete definis a l'aide de setNewSettings et setOldSettings
 */
 void ChangeConductorPropertiesCommand::undo() {
+	diagram->showMe();
 	if (old_settings_set && new_settings_set) {
 		conductor -> setProperties(old_properties);
 		conductor -> update();
@@ -963,6 +1002,7 @@
 	doivent avoir ete definis a l'aide de setNewSettings et setOldSettings
 */
 void ChangeConductorPropertiesCommand::redo() {
+	diagram->showMe();
 	if (old_settings_set && new_settings_set) {
 		conductor -> setProperties(new_properties);
 		conductor -> update();
@@ -974,11 +1014,12 @@
 	@param c La liste des conducteurs dont on modifie les proprietes
 	@param parent QUndoCommand parent
 */
-ChangeSeveralConductorsPropertiesCommand::ChangeSeveralConductorsPropertiesCommand(QSet<Conductor *>c, QUndoCommand *parent) :
+ChangeSeveralConductorsPropertiesCommand::ChangeSeveralConductorsPropertiesCommand(QList<Conductor *>c, QUndoCommand *parent) :
 	QUndoCommand(QObject::tr("modifier les propri\351t\351s de plusieurs conducteurs", "undo caption"), parent),
 	conductors(c),
 	old_settings_set(false),
-	new_settings_set(false)
+	new_settings_set(false),
+	diagram(c.first()->diagram())
 {
 }
 
@@ -1014,6 +1055,7 @@
 	doivent avoir ete definis a l'aide de setNewSettings et setOldSettings
 */
 void ChangeSeveralConductorsPropertiesCommand::undo() {
+	diagram->showMe();
 	if (old_settings_set && new_settings_set) {
 		int i=0;
 		foreach(Conductor *c, conductors) {
@@ -1029,6 +1071,7 @@
 	doivent avoir ete definis a l'aide de setNewSettings et setOldSettings
 */
 void ChangeSeveralConductorsPropertiesCommand::redo() {
+	diagram->showMe();
 	if (old_settings_set && new_settings_set) {
 
 		//new propertie are the same for each conductor
@@ -1062,7 +1105,8 @@
 	QUndoCommand(parent),
 	image_(image),
 	old_size (old_),
-	new_size (new_)
+	new_size (new_),
+	diagram(image->diagram())
 {}
 
 /**
@@ -1074,6 +1118,7 @@
  * @brief ImageResizerCommand::undo set the old size
  */
 void ImageResizerCommand::undo() {
+	diagram->showMe();
 	image_ -> setScale(old_size);
 }
 
@@ -1081,6 +1126,7 @@
  * @brief ImageResizerCommand::redo set the new size
  */
 void ImageResizerCommand::redo() {
+	diagram->showMe();
 	if (old_size<new_size) setText(QObject::tr("Agrandire 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);

Modified: trunk/sources/diagramcommands.h
===================================================================
--- trunk/sources/diagramcommands.h	2014-01-06 15:58:31 UTC (rev 2713)
+++ trunk/sources/diagramcommands.h	2014-01-06 18:21:58 UTC (rev 2714)
@@ -322,6 +322,7 @@
 	QString text_after;
 	/// prevent the first call to redo()
 	bool first_redo;
+	Diagram *diagram;
 };
 
 /**
@@ -352,6 +353,7 @@
 	qreal applied_rotation_angle_;
 	/// previous state of each conductor text item
 	QHash<ConductorTextItem *, bool> previous_rotate_by_user_;
+	Diagram *diagram;
 };
 
 /**
@@ -383,6 +385,7 @@
 	double applied_rotation_angle_;
 	/// previous state of each conductor text item
 	QHash<ConductorTextItem *, bool> previous_rotate_by_user_;
+	Diagram *diagram;
 };
 
 /**
@@ -418,6 +421,7 @@
 	QPointF text_pos_after_mov_;
 	/// prevent the first call to redo()
 	bool first_redo;
+	Diagram *diagram;
 };
 
 /**
@@ -440,6 +444,7 @@
 	private:
 	/// impacted conductors along with their former profiles
 	QHash<Conductor *, ConductorProfilesGroup> conductors_profiles;
+	Diagram *diagram;
 };
 
 /**
@@ -525,6 +530,7 @@
 	bool old_settings_set;
 	/// track whether post-change properties were set
 	bool new_settings_set;
+	Diagram *diagram;
 };
 
 /**
@@ -533,7 +539,7 @@
 class ChangeSeveralConductorsPropertiesCommand : public QUndoCommand {
 	// constructors, destructor
 	public:
-	ChangeSeveralConductorsPropertiesCommand(QSet<Conductor *>, QUndoCommand * = 0);
+	ChangeSeveralConductorsPropertiesCommand(QList<Conductor *>, QUndoCommand * = 0);
 	virtual ~ChangeSeveralConductorsPropertiesCommand();
 	private:
 	ChangeSeveralConductorsPropertiesCommand(const ChangeSeveralConductorsPropertiesCommand &);
@@ -549,7 +555,7 @@
 	// attributes
 	private:
 	/// modified conductor
-	QSet<Conductor *> conductors;
+	QList<Conductor *> conductors;
 	/// properties before the change
 	QList <ConductorProperties> old_properties;
 	/// properties after the change
@@ -560,6 +566,7 @@
 	bool old_settings_set;
 	/// track whether post-change properties were set
 	bool new_settings_set;
+	Diagram *diagram;
 };
 
 class ImageResizerCommand : public QUndoCommand {
@@ -577,6 +584,7 @@
 	private:
 	DiagramImageItem *image_;
 	qreal old_size, new_size;
+	Diagram *diagram;
 };
 
 #endif

Modified: trunk/sources/diagramview.cpp
===================================================================
--- trunk/sources/diagramview.cpp	2014-01-06 15:58:31 UTC (rev 2713)
+++ trunk/sources/diagramview.cpp	2014-01-06 18:21:58 UTC (rev 2714)
@@ -83,6 +83,7 @@
 	paste_here = new QAction(QET::Icons::EditPaste, tr("Coller ici", "context menu action"), this);
 	connect(paste_here, SIGNAL(triggered()), this, SLOT(pasteHere()));
 	
+	connect(scene, SIGNAL(showDiagram(Diagram*)), this, SIGNAL(showDiagram(Diagram*)));
 	connect(scene, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
 	connect(scene, SIGNAL(readOnlyChanged(bool)), this, SLOT(applyReadOnly()));
 	connect(&(scene -> border_and_titleblock), SIGNAL(borderChanged(QRectF, QRectF)), this, SLOT(adjustSceneRect()));
@@ -973,7 +974,7 @@
 
 		if (new_properties != old_properties) {
 				if (cb_apply_all -> isChecked()) {
-					QSet <Conductor *> conductorslist = edited_conductor -> relatedPotentialConductors();
+					QList <Conductor *> conductorslist = edited_conductor -> relatedPotentialConductors().toList();
 					conductorslist << edited_conductor;
 					QList <ConductorProperties> old_properties_list;
 

Modified: trunk/sources/diagramview.h
===================================================================
--- trunk/sources/diagramview.h	2014-01-06 15:58:31 UTC (rev 2713)
+++ trunk/sources/diagramview.h	2014-01-06 18:21:58 UTC (rev 2714)
@@ -131,6 +131,8 @@
 	void ImageAdded(bool);
 	/// Signal emmitted fater windows selection image have been canceled
 	void ImageAddedCanceled(bool);
+	/// Signal emmitted when diagram must be show
+	void showDiagram (Diagram *);
 	
 	public slots:
 	void selectNothing();

Modified: trunk/sources/projectview.cpp
===================================================================
--- trunk/sources/projectview.cpp	2014-01-06 15:58:31 UTC (rev 2713)
+++ trunk/sources/projectview.cpp	2014-01-06 18:21:58 UTC (rev 2714)
@@ -318,6 +318,7 @@
 	diagram -> setFrameStyle(QFrame::Plain | QFrame::NoFrame);
 	diagrams_ << diagram;
 	rebuildDiagramsMap();
+	connect(diagram, SIGNAL(showDiagram(Diagram*)), this, SLOT(showDiagram(Diagram*)));
 	connect(diagram, SIGNAL(titleChanged(DiagramView *, const QString &)), this, SLOT(updateTabTitle(DiagramView *, const QString &)));
 	connect(diagram, SIGNAL(findElementRequired(const ElementsLocation &)), this, SIGNAL(findElementRequired(const ElementsLocation &)));
 	connect(diagram, SIGNAL(editElementRequired(const ElementsLocation &)), this, SIGNAL(editElementRequired(const ElementsLocation &)));


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/