From e1e5e92d93c070bcbe32b314943342aad2848144 Mon Sep 17 00:00:00 2001 From: mzn Date: Wed, 26 Mar 2014 14:06:44 +0000 Subject: [PATCH] Delete the dialog after it's closed. --- src/HYDROGUI/HYDROGUI_ZLevelsOp.cxx | 38 ++++++++++++++++++++--------- src/HYDROGUI/HYDROGUI_ZLevelsOp.h | 10 +++----- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_ZLevelsOp.cxx b/src/HYDROGUI/HYDROGUI_ZLevelsOp.cxx index 87dc49ee..1b9fba2d 100644 --- a/src/HYDROGUI/HYDROGUI_ZLevelsOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ZLevelsOp.cxx @@ -42,7 +42,7 @@ */ HYDROGUI_ZLevelsOp::HYDROGUI_ZLevelsOp( HYDROGUI_Module* theModule ) : HYDROGUI_Operation( theModule ), - myZLevelsDlg( NULL ) + myDlg( NULL ) { setName( tr( "SET_Z_LEVELS" ) ); } @@ -82,15 +82,14 @@ void HYDROGUI_ZLevelsOp::startOperation() } // Show the dialog - if ( !myZLevelsDlg ) { - //TODO: delete dialog each time? - myZLevelsDlg = new HYDROGUI_ZLevelsDlg( module()->getApp()->desktop(), module() ); - connect( myZLevelsDlg, SIGNAL( applyOrder() ), this, SLOT( onApply() ) ); - connect( myZLevelsDlg, SIGNAL( rejected() ), this, SLOT( onCancel() ) ); + if ( !myDlg ) { + myDlg = new HYDROGUI_ZLevelsDlg( module()->getApp()->desktop(), module() ); + connect( myDlg, SIGNAL( applyOrder() ), this, SLOT( onApply() ) ); + connect( myDlg, SIGNAL( rejected() ), this, SLOT( onCancel() ) ); } - myZLevelsDlg->setObjects( anObject2VisibleList ); + myDlg->setObjects( anObject2VisibleList ); - myZLevelsDlg->exec(); + myDlg->exec(); } /** @@ -100,10 +99,10 @@ bool HYDROGUI_ZLevelsOp::processApply( int& theUpdateFlags, { bool aRes = false; - if ( myZLevelsDlg ) { + if ( myDlg ) { Handle(HYDROData_Document) aDoc = doc(); if( !aDoc.IsNull() ) { - HYDROGUI_ListModel::ObjectList anObjects = myZLevelsDlg->getObjects(); + HYDROGUI_ListModel::ObjectList anObjects = myDlg->getObjects(); HYDROData_SequenceOfObjects anOrderedObjects; foreach ( const Handle(HYDROData_Entity) anObject, anObjects ) { anOrderedObjects.Append( anObject ); @@ -111,7 +110,7 @@ bool HYDROGUI_ZLevelsOp::processApply( int& theUpdateFlags, aDoc->SetObjectsLayerOrder( anOrderedObjects ); - theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced; + theUpdateFlags = UF_Model | UF_OCCViewer; aRes = true; } } @@ -119,3 +118,20 @@ bool HYDROGUI_ZLevelsOp::processApply( int& theUpdateFlags, return aRes; } +/** +*/ +bool HYDROGUI_ZLevelsOp::isGranted() const +{ + return true; +} + +/** +*/ +void HYDROGUI_ZLevelsOp::processCancel() +{ + // Delete the dialog + if ( myDlg ) { + delete myDlg; + myDlg = 0; + } +} \ No newline at end of file diff --git a/src/HYDROGUI/HYDROGUI_ZLevelsOp.h b/src/HYDROGUI/HYDROGUI_ZLevelsOp.h index c83edef6..7bb84ebc 100644 --- a/src/HYDROGUI/HYDROGUI_ZLevelsOp.h +++ b/src/HYDROGUI/HYDROGUI_ZLevelsOp.h @@ -29,27 +29,25 @@ class HYDROGUI_ZLevelsDlg; + class HYDROGUI_ZLevelsOp : public HYDROGUI_Operation { Q_OBJECT public: - HYDROGUI_ZLevelsOp( HYDROGUI_Module* theModule ); virtual ~HYDROGUI_ZLevelsOp(); public: - - virtual bool isGranted() const { return true; } + virtual bool isGranted() const; protected: - virtual void startOperation(); - virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + virtual void processCancel(); private: - HYDROGUI_ZLevelsDlg* myZLevelsDlg; + HYDROGUI_ZLevelsDlg* myDlg; }; -- 2.39.2