From 63f69197be41ad531235f1d7331c76af31c98ad5 Mon Sep 17 00:00:00 2001 From: mkr Date: Fri, 16 Mar 2007 10:15:50 +0000 Subject: [PATCH] Add new methods to QxGraph_ActiveItem (reason : nodes' hooks don't move without nodes). Implement QxGraph_Canvas destructor. --- src/QxGraph/QxGraph_ActiveItem.h | 4 ++++ src/QxGraph/QxGraph_Canvas.cxx | 11 +++++++++++ src/QxGraph/QxGraph_CanvasView.cxx | 16 +++++++++++----- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/QxGraph/QxGraph_ActiveItem.h b/src/QxGraph/QxGraph_ActiveItem.h index 293dfb9dd..5443e189a 100644 --- a/src/QxGraph/QxGraph_ActiveItem.h +++ b/src/QxGraph/QxGraph_ActiveItem.h @@ -27,6 +27,10 @@ class QXGRAPH_EXPORT QxGraph_ActiveItem QxGraph_ActiveItem() {} ~QxGraph_ActiveItem() {} + virtual bool isMoveable() = 0; + virtual void beforeMoving() = 0; + virtual void afterMoving() = 0; + virtual void hilight() = 0; virtual void select() = 0; virtual void showPopup() = 0; diff --git a/src/QxGraph/QxGraph_Canvas.cxx b/src/QxGraph/QxGraph_Canvas.cxx index 935d0506e..a11e53f26 100644 --- a/src/QxGraph/QxGraph_Canvas.cxx +++ b/src/QxGraph/QxGraph_Canvas.cxx @@ -26,6 +26,8 @@ #include +#include + /*! Constructor */ @@ -46,6 +48,15 @@ QxGraph_Canvas::QxGraph_Canvas(SUIT_ResourceMgr* theMgr) : */ QxGraph_Canvas::~QxGraph_Canvas() { + QObjectList* aNodeList = queryList("QObject"); + QObjectListIt aIt(*aNodeList); + QObject* anObj; + while ( (anObj = aIt.current()) != 0 ) { + ++aIt; + aNodeList->removeRef(anObj); + delete anObj; + } + delete aNodeList; } /*! diff --git a/src/QxGraph/QxGraph_CanvasView.cxx b/src/QxGraph/QxGraph_CanvasView.cxx index b6a383390..6b99e370c 100644 --- a/src/QxGraph/QxGraph_CanvasView.cxx +++ b/src/QxGraph/QxGraph_CanvasView.cxx @@ -23,6 +23,7 @@ #include "QxGraph_CanvasView.h" #include "QxGraph_Canvas.h" #include "QxGraph_ViewWindow.h" +#include "QxGraph_ActiveItem.h" #include "QxGraph_Def.h" #include @@ -175,9 +176,13 @@ void QxGraph_CanvasView::contentsMousePressEvent(QMouseEvent* theEvent) QCanvasItemList aList = canvas()->collisions(myPoint); // to move items on canvas view for (QCanvasItemList::Iterator it = aList.begin(); it != aList.end(); ++it) { - myCurrentItem = *it; - myCurrentItem->setZ(2); - return; + QxGraph_ActiveItem* anActItem = dynamic_cast( *it ); + if ( anActItem && anActItem->isMoveable() ) + { // move itself only active items if it is moveable + anActItem->beforeMoving(); + myCurrentItem = *it; + return; + } } } } @@ -272,8 +277,9 @@ void QxGraph_CanvasView::contentsMouseReleaseEvent(QMouseEvent* theEvent) if (myCurrentItem) { // to move items on canvas view - myCurrentItem->setZ(0); - canvas()->update(); + QxGraph_ActiveItem* anActItem = dynamic_cast( myCurrentItem ); + if ( anActItem && anActItem->isMoveable() ) + anActItem->afterMoving(); } myCurrentItem = 0; -- 2.39.2