From 066d92f9778710baaa06f87c978b6eb87b4ca2a7 Mon Sep 17 00:00:00 2001 From: ouv Date: Thu, 12 May 2011 11:32:17 +0000 Subject: [PATCH] DIAGRAM issue 0000331: Feedback 3. Copy/Paste of operators: images are not enough separated. --- src/GraphicsView/GraphicsView_ViewPort.cxx | 18 ++++++++++++------ src/GraphicsView/GraphicsView_ViewPort.h | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/GraphicsView/GraphicsView_ViewPort.cxx b/src/GraphicsView/GraphicsView_ViewPort.cxx index 82d36c8c5..f7d995c38 100644 --- a/src/GraphicsView/GraphicsView_ViewPort.cxx +++ b/src/GraphicsView/GraphicsView_ViewPort.cxx @@ -255,13 +255,18 @@ void GraphicsView_ViewPort::removeItem( QGraphicsItem* theItem ) // Function : getObjects // Purpose : //================================================================ -GraphicsView_ObjectList GraphicsView_ViewPort::getObjects() const +GraphicsView_ObjectList GraphicsView_ViewPort::getObjects( bool theIsSortSelected ) const { GraphicsView_ObjectList aList; QListIterator anIter( items() ); while( anIter.hasNext() ) if( GraphicsView_Object* anObject = dynamic_cast( anIter.next() ) ) - aList.append( anObject ); + { + if( theIsSortSelected && anObject->isSelected() ) + aList.prepend( anObject ); // put the selected objects to a head of the list + else + aList.append( anObject ); + } return aList; } @@ -774,10 +779,11 @@ void GraphicsView_ViewPort::highlight( double theX, double theY ) GraphicsView_Object* aPreviousHighlightedObject = myHighlightedObject; GraphicsView_Object* aHighlightedObject = 0; - QListIterator anIter( items() ); + GraphicsView_ObjectList aList = getObjects( true ); + GraphicsView_ObjectListIterator anIter( aList ); while( anIter.hasNext() ) { - if( GraphicsView_Object* anObject = dynamic_cast( anIter.next() ) ) + if( GraphicsView_Object* anObject = anIter.next() ) { if( anObject->isVisible() && anObject->isSelectable() ) { @@ -799,9 +805,9 @@ void GraphicsView_ViewPort::highlight( double theX, double theY ) if( !anIsOnObject ) { - anIter = items(); + anIter = aList; while( anIter.hasNext() ) - if( GraphicsView_Object* anObject = dynamic_cast( anIter.next() ) ) + if( GraphicsView_Object* anObject = anIter.next() ) anObject->unhighlight(); myHighlightedObject = 0; diff --git a/src/GraphicsView/GraphicsView_ViewPort.h b/src/GraphicsView/GraphicsView_ViewPort.h index aac2af85f..0cb8921b4 100644 --- a/src/GraphicsView/GraphicsView_ViewPort.h +++ b/src/GraphicsView/GraphicsView_ViewPort.h @@ -71,7 +71,7 @@ public: void addItem( QGraphicsItem* theItem ); void removeItem( QGraphicsItem* theItem ); - GraphicsView_ObjectList getObjects() const; + GraphicsView_ObjectList getObjects( bool theIsSortSelected = false ) const; QRectF objectsBoundingRect( bool theOnlyVisible = false ) const; -- 2.39.2