From: mzn Date: Wed, 26 Mar 2014 14:06:44 +0000 (+0000) Subject: Delete the dialog after it's closed. X-Git-Tag: BR_hydro_v1_0_1~21 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e1e5e92d93c070bcbe32b314943342aad2848144;p=modules%2Fhydro.git Delete the dialog after it's closed. --- 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; };