[qet] [3916] Minor code change

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


Revision: 3916
Author:   blacksun
Date:     2015-04-18 13:02:10 +0200 (Sat, 18 Apr 2015)
Log Message:
-----------
Minor code change

Modified Paths:
--------------
    trunk/sources/editor/elementscene.cpp
    trunk/sources/editor/elementscene.h
    trunk/sources/editor/elementview.cpp
    trunk/sources/editor/elementview.h
    trunk/sources/editor/esevent/eseventinterface.cpp

Modified: trunk/sources/editor/elementscene.cpp
===================================================================
--- trunk/sources/editor/elementscene.cpp	2015-04-18 10:30:05 UTC (rev 3915)
+++ trunk/sources/editor/elementscene.cpp	2015-04-18 11:02:10 UTC (rev 3916)
@@ -174,6 +174,17 @@
 }
 
 /**
+ * @brief ElementScene::contextMenuEvent
+ * Display the context menu event, only if behavior are Normal
+ * @param event
+ */
+void ElementScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
+{
+	if (behavior == ElementScene::Normal)
+		element_editor -> contextMenu(event->screenPos());
+}
+
+/**
 	Dessine l'arriere-plan de l'editeur, cad l'indicateur de hotspot.
 	@param p Le QPainter a utiliser pour dessiner
 	@param rect Le rectangle de la zone a dessiner
@@ -212,6 +223,16 @@
 }
 
 /**
+ * @brief ElementScene::setBehavior
+ * Modifie the current behavior of this scene
+ * @param b
+ */
+void ElementScene::setBehavior(ElementScene::Behavior b)
+{
+	behavior = b;
+}
+
+/**
 	@return la taille horizontale de la grille
 */
 int ElementScene::xGrid() const {
@@ -460,11 +481,6 @@
 	last_copied_ = clipboard_content;
 }
 
-void ElementScene::contextMenu(QContextMenuEvent *event) {
-	if (behavior == ElementScene::Normal)
-		element_editor -> contextMenu(event);
-}
-
 QETElementEditor* ElementScene::editor() const {
 	return element_editor;
 }

Modified: trunk/sources/editor/elementscene.h
===================================================================
--- trunk/sources/editor/elementscene.h	2015-04-18 10:30:05 UTC (rev 3915)
+++ trunk/sources/editor/elementscene.h	2015-04-18 11:02:10 UTC (rev 3916)
@@ -41,7 +41,7 @@
 	
 	// enum
 	public:
-	enum Behavior { Normal, PasteArea };
+	enum Behavior { Normal, PasteArea, AddPart };
 	enum ItemOption {
 		SortByZValue = 1,
 		IncludeTerminals = 2,
@@ -105,6 +105,7 @@
 	// methods
 	public:
 		void setEventInterface (ESEventInterface *event_interface);
+		void setBehavior (ElementScene::Behavior);
 		QPointF snapToGrid(QPointF point);
 	void setNames(const NamesList &);
 	NamesList names() const;
@@ -131,7 +132,6 @@
 	bool wasCopiedFromThisElement(const QString &);
 	void cut();
 	void copy();
-	void contextMenu (QContextMenuEvent *event);
 	QETElementEditor* editor() const;
 	
 	protected:
@@ -140,8 +140,9 @@
 		virtual void mouseReleaseEvent     (QGraphicsSceneMouseEvent *);
 		virtual void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event);
 		virtual void keyPressEvent         (QKeyEvent *event);
+		virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
 
-	virtual void drawForeground(QPainter *, const QRectF &);
+		virtual void drawForeground(QPainter *, const QRectF &);
 	
 	private:
 	QRectF elementContentBoundingRect(const ElementContent &) const;

Modified: trunk/sources/editor/elementview.cpp
===================================================================
--- trunk/sources/editor/elementview.cpp	2015-04-18 10:30:05 UTC (rev 3915)
+++ trunk/sources/editor/elementview.cpp	2015-04-18 11:02:10 UTC (rev 3916)
@@ -67,10 +67,6 @@
 	return(QRectF(scene_left_top, scene_right_bottom));
 }
 
-void ElementView::contextMenuEvent(QContextMenuEvent *event) {
-	scene_ -> contextMenu(event);
-}
-
 /**
 	Definit l'ElementScene visualisee par cette ElementView
 	@param s l'ElementScene visualisee par cette ElementView

Modified: trunk/sources/editor/elementview.h
===================================================================
--- trunk/sources/editor/elementview.h	2015-04-18 10:30:05 UTC (rev 3915)
+++ trunk/sources/editor/elementview.h	2015-04-18 11:02:10 UTC (rev 3916)
@@ -41,7 +41,6 @@
 	ElementScene *scene() const;
 	void setScene(ElementScene *);
 	QRectF viewedSceneRect() const;
-	void contextMenuEvent(QContextMenuEvent *event);
 	
 	protected:
 	void mousePressEvent(QMouseEvent *);

Modified: trunk/sources/editor/esevent/eseventinterface.cpp
===================================================================
--- trunk/sources/editor/esevent/eseventinterface.cpp	2015-04-18 10:30:05 UTC (rev 3915)
+++ trunk/sources/editor/esevent/eseventinterface.cpp	2015-04-18 11:02:10 UTC (rev 3916)
@@ -31,20 +31,26 @@
 	init();
 }
 
-void ESEventInterface::init() {
-	foreach (QGraphicsView *qgv, m_scene->views())
-		qgv->setContextMenuPolicy(Qt::NoContextMenu);
-
+/**
+ * @brief ESEventInterface::init
+ * Init this event interface
+ */
+void ESEventInterface::init()
+{
+	m_scene->setBehavior(ElementScene::Behavior::AddPart);
 	m_editor->slot_setNoDragToView();
 }
 
-ESEventInterface::~ESEventInterface() {
+/**
+ * @brief ESEventInterface::~ESEventInterface
+ * Destructor
+ */
+ESEventInterface::~ESEventInterface()
+{
 	delete m_help_horiz;
 	delete m_help_verti;
 
-	foreach (QGraphicsView *qgv, m_scene->views())
-		qgv->setContextMenuPolicy(Qt::DefaultContextMenu);
-
+	m_scene->setBehavior(ElementScene::Behavior::Normal);
 	m_editor->slot_setRubberBandToView();
 }
 


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