[qet] [3554] Minor improvment : over element, highlight every linked elements

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


Revision: 3554
Author:   blacksun
Date:     2014-12-14 19:51:49 +0100 (Sun, 14 Dec 2014)
Log Message:
-----------
Minor improvment : over element, highlight every linked elements

Modified Paths:
--------------
    trunk/sources/qetgraphicsitem/element.cpp
    trunk/sources/qetgraphicsitem/element.h
    trunk/sources/qetgraphicsitem/elementtextitem.cpp

Modified: trunk/sources/qetgraphicsitem/element.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/element.cpp	2014-12-14 17:56:01 UTC (rev 3553)
+++ trunk/sources/qetgraphicsitem/element.cpp	2014-12-14 18:51:49 UTC (rev 3554)
@@ -34,7 +34,7 @@
 	QetGraphicsItem(parent),
 	internal_connections_(false),
 	must_highlight_(false),
-	bMouseOver(false)
+	m_mouse_over(false)
 {
 	link_type_ = Simple;
 	uuid_ = QUuid::createUuid();
@@ -100,13 +100,11 @@
 #endif
 	if (must_highlight_) drawHighlight(painter, options);
 	
-	// Dessin de l'element lui-meme
+		//Draw the element himself
 	paint(painter, options);
 	
-	// Dessin du cadre de selection si necessaire
-	if (isSelected()) drawSelection(painter, options);
-
-	if ( bMouseOver )		drawSelection(painter, options);
+		//Draw the selection rectangle
+	if ( isSelected() || m_mouse_over ) drawSelection(painter, options);
 }
 
 /**
@@ -545,36 +543,34 @@
 
 
 /**
-	When mouse over element
-	change bMouseOver to true   (used in paint() function )
-	@param e QGraphicsSceneHoverEvent
+ * When mouse over element
+ * change m_mouse_over to true   (used in paint() function )
+ * Also highlight linked elements
+ * @param e QGraphicsSceneHoverEvent
 */
 void Element::hoverEnterEvent(QGraphicsSceneHoverEvent *e) {
 	Q_UNUSED(e);
 
-	bMouseOver = true;
-	QString str_ToolTip = name();
-	setToolTip( str_ToolTip );
+	foreach (Element *elmt, linkedElements())
+		elmt -> setHighlighted(true);
+
+	m_mouse_over = true;
+	setToolTip( name() );
 	update();
 }
 
 /**
-	When mouse over element leave the position
-	change bMouseOver to false(used in paint() function )
-	@param e QGraphicsSceneHoverEvent
+ * When mouse over element leave the position
+ * change m_mouse_over to false(used in paint() function )
+ * Also un-highlight linked elements
+ * @param e QGraphicsSceneHoverEvent
 */
 void Element::hoverLeaveEvent(QGraphicsSceneHoverEvent *e) {
 	Q_UNUSED(e);
-	//qDebug() << "Leave mouse over";
-	bMouseOver = false;
+
+	foreach (Element *elmt, linkedElements())
+		elmt -> setHighlighted(false);
+
+	m_mouse_over = false;
 	update();
 }
-
-/**
-	Do nothing default function .
-	@param e QGraphicsSceneHoverEvent
-*/
-void Element::hoverMoveEvent(QGraphicsSceneHoverEvent *e) {
-	Q_UNUSED(e);
-	QGraphicsItem::hoverMoveEvent(e);
-}

Modified: trunk/sources/qetgraphicsitem/element.h
===================================================================
--- trunk/sources/qetgraphicsitem/element.h	2014-12-14 17:56:01 UTC (rev 3553)
+++ trunk/sources/qetgraphicsitem/element.h	2014-12-14 18:51:49 UTC (rev 3554)
@@ -176,22 +176,21 @@
 	int orientation() const;
 	
 	protected:
-	void drawAxes(QPainter *, const QStyleOptionGraphicsItem *);
+		void drawAxes(QPainter *, const QStyleOptionGraphicsItem *);
 	
 	private:
-	bool internal_connections_;
-	bool must_highlight_;
-	void drawSelection(QPainter *, const QStyleOptionGraphicsItem *);
-	void drawHighlight(QPainter *, const QStyleOptionGraphicsItem *);
-	void updatePixmap();
+		bool internal_connections_;
+		bool must_highlight_;
+		void drawSelection(QPainter *, const QStyleOptionGraphicsItem *);
+		void drawHighlight(QPainter *, const QStyleOptionGraphicsItem *);
+		void updatePixmap();
 
 	protected:
-	virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *);
-	virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *);
-	virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *);
+		virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * );
+		virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * );
+	private:
+		bool m_mouse_over;
 
-	bool bMouseOver;
-
 };
 
 bool comparPos(const Element * elmt1, const Element * elmt2);

Modified: trunk/sources/qetgraphicsitem/elementtextitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/elementtextitem.cpp	2014-12-14 17:56:01 UTC (rev 3553)
+++ trunk/sources/qetgraphicsitem/elementtextitem.cpp	2014-12-14 18:51:49 UTC (rev 3554)
@@ -289,15 +289,12 @@
  * @brief ElementTextItem::hoverEnterEvent
  * @param event
  */
-void ElementTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
-{
-	if (tagg_ == "label" || parent_element_ -> linkType() & Element::AllReport)
-	{
-		foreach (Element *elmt, parent_element_ -> linkedElements())
-			elmt -> setHighlighted(true);
+void ElementTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) {
 
-		if (parent_element_ -> linkType() & (Element::AllReport | Element::Slave) && !parent_element_->isFree())
-		{
+	if (tagg_ == "label" || parent_element_ -> linkType() & Element::AllReport) {
+
+		if (parent_element_ -> linkType() & (Element::AllReport | Element::Slave) && !parent_element_->isFree()) {
+
 			setDefaultTextColor(Qt::blue);
 
 				//Also color the child text if parent is a slave and linked
@@ -307,23 +304,18 @@
 						qgti -> setDefaultTextColor(Qt::blue);
 		}
 	}
-	else
-	{
-		DiagramTextItem::hoverEnterEvent(event);
-	}
+
+	DiagramTextItem::hoverEnterEvent(event);
 }
 
 /**
  * @brief ElementTextItem::hoverLeaveEvent
  * @param event
  */
-void ElementTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
-{
-	if (tagg_ == "label" || parent_element_ -> linkType() & Element::AllReport)
-	{
-		foreach (Element *elmt, parent_element_ -> linkedElements())
-			elmt -> setHighlighted(false);
+void ElementTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) {
 
+	if (tagg_ == "label" || parent_element_ -> linkType() & Element::AllReport) {
+
 		if (defaultTextColor() != Qt::black)
 			setDefaultTextColor(Qt::black);
 


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