From b4f7c6ac3963435757e053e20d3f1fdb877409b6 Mon Sep 17 00:00:00 2001 From: abd Date: Fri, 3 Nov 2006 15:18:53 +0000 Subject: [PATCH] Fix 13730 Saving of togle button state --- src/LightApp/LightApp_Dialog.cxx | 33 ++++++++++++++++++++++++++++++++ src/LightApp/LightApp_Dialog.h | 17 +++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) 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; -- 2.39.2