From: abd Date: Fri, 3 Nov 2006 15:18:53 +0000 (+0000) Subject: Fix 13730 X-Git-Tag: For_HDF~51 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b4f7c6ac3963435757e053e20d3f1fdb877409b6;p=modules%2Fgui.git Fix 13730 Saving of togle button state --- diff --git a/src/LightApp/LightApp_Dialog.cxx b/src/LightApp/LightApp_Dialog.cxx index 27219f5f1..14d674a10 100644 --- a/src/LightApp/LightApp_Dialog.cxx +++ b/src/LightApp/LightApp_Dialog.cxx @@ -807,6 +807,39 @@ void LightApp_Dialog::deactivateAll() } } + +//! Return toggle buttons on/off state +LightApp_SimpleGuiStateMap LightApp_Dialog::getActiveState() const { + + LightApp_SimpleGuiStateMap state; + ObjectMap::const_iterator anIt = myObjects.begin(), + aLast = myObjects.end(); + for( ; anIt!=aLast; anIt++ ) + { + QToolButton* btn = ( QToolButton* )anIt.data().myBtn; + const bool isOn = btn->isOn(); + const int id = anIt.key(); + state[id] = isOn; + } + + return state; +} + +/*! Restores the state of toggle buttons - +to activate the buttons, deactivated by deactivateAll() +*/ +void LightApp_Dialog::restoreState(const LightApp_SimpleGuiStateMap& stateMap) { + LightApp_SimpleGuiStateMap::const_iterator it = stateMap.begin(), + aLast = stateMap.end(); + for (; it != aLast; it++) { + int btnId = it.key(); + bool btnOn = (bool) it.data(); + if (btnOn) activateObject(btnId); + } +} + + + /*! Passes to widget name, type and id of selected object \param id - identificator of object selection widget diff --git a/src/LightApp/LightApp_Dialog.h b/src/LightApp/LightApp_Dialog.h index 970e6b860..22cfa7188 100644 --- a/src/LightApp/LightApp_Dialog.h +++ b/src/LightApp/LightApp_Dialog.h @@ -39,6 +39,10 @@ class SUIT_ResourceMgr; #pragma warning ( disable:4251 ) #endif + + + typedef QMap LightApp_SimpleGuiStateMap; + /*! \class LightApp_Dialog Base class for all LightApp dialogs. @@ -54,7 +58,8 @@ class LIGHTAPP_EXPORT LightApp_Dialog : public QtxDialog public: typedef QValueList TypesList; typedef QMap SelectedObjects; - + + enum ObjectWg { Label = 0x00000001, @@ -153,6 +158,15 @@ public: //! Set all object selection buttons to inactive state void deactivateAll(); + + + + //! Return toggle buttons on/off state + LightApp_SimpleGuiStateMap getActiveState() const; + + //! Restores the state of toggle buttons - + // to activate the buttons, deactivated by deactivateAll() + void restoreState(const LightApp_SimpleGuiStateMap&); signals: //! selection in certain widget is changed @@ -285,6 +299,7 @@ private: private: ObjectMap myObjects; + QMap myTypeNames; bool myIsExclusive, myIsBusy; QPixmap myPixmap;