From 1389b2f49d3ffa490de013937cd1f60eafeb734d Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 9 Aug 2007 12:47:42 +0000 Subject: [PATCH] Correction of preferences layouting. --- src/LightApp/LightApp_Application.cxx | 73 +++++++++++++++------------ src/Style/Style_Model.cxx | 43 +++++++++++----- src/Style/Style_Model.h | 26 ++++++---- 3 files changed, 87 insertions(+), 55 deletions(-) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 98f5c142a..3153501b2 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1915,6 +1915,7 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) pref->addPreference( tr( "" ), dirGroup, LightApp_Preferences::DirList, "FileDlg", "QuickDirList" ); + pref->setItemProperty( "columns", 2, supervGroup ); pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), supervGroup, LightApp_Preferences::Color, "SUPERVGraph", "Background" ); pref->addPreference( tr( "PREF_SUPERV_TITLE_COLOR" ), supervGroup, @@ -1924,6 +1925,7 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat ); int objSetGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SETTINGS" ), obTab ); + pref->setItemProperty( "columns", 2, objSetGroup ); pref->addPreference( tr( "PREF_AUTO_SIZE_FIRST" ), objSetGroup, LightApp_Preferences::Bool, "ObjectBrowser", "auto_size_first" ); pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool, @@ -1945,39 +1947,46 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) QtxResourceMgr* aResMgr = pref->resourceMgr(); aSModel->initFromResource( aResMgr ); - QList aGrpLst = aSModel->getGroups(); - QList::iterator anIt = aGrpLst.begin(), anEnd = aGrpLst.end(); - QList aPropLst; - QList::iterator aPropIt, aPropEnd; + QList aTabLst = aSModel->getTabs(); + QList::iterator aTabIt = aTabLst.begin(), aTabEnd = aTabLst.end(); + QList aGrpLst, aPropLst; + QList::iterator anIt, anEnd, aPropIt, aPropEnd; int aGrpId, aPropId, aPrefId; - for( ; anIt != anEnd; ++anIt ) { - aGrpId = *anIt; - int themaGroup = pref->addPreference( aSModel->getGroupTitle( aGrpId ), themaTab ); - pref->setItemProperty( "columns", aSModel->getGroupNbColumns( aGrpId ), themaGroup ); - aPropLst = aSModel->getGroupProps( aGrpId ); - for( aPropIt = aPropLst.begin(), aPropEnd = aPropLst.end(); aPropIt != aPropEnd; ++aPropIt ) { - aPropId = *aPropIt; - Style_Model::PropType aType = aSModel->getPropType( aPropId ); - LightApp_Preferences::PrefItemType aPType = LightApp_Preferences::Auto; - switch( aType ) { - case Style_Model::Bool: aPType = LightApp_Preferences::Bool; break; - case Style_Model::Color: aPType = LightApp_Preferences::Color; break; - case Style_Model::String: aPType = LightApp_Preferences::String; break; - case Style_Model::IntSpin: aPType = LightApp_Preferences::IntSpin; break; - case Style_Model::DblSpin: aPType = LightApp_Preferences::DblSpin; break; - case Style_Model::Selector: aPType = LightApp_Preferences::Selector; break; - case Style_Model::Font: aPType = LightApp_Preferences::Font; break; - default: break; - } - aPrefId = pref->addPreference( aSModel->getPropTitle( aPropId ), themaGroup, - aPType, aSection, aSModel->getPropName( aPropId ) ); - aSModel->getValueTo( aResMgr, aPropId, true );//set default values into resource - if ( aPType == LightApp_Preferences::Selector ) { - QStringList lst; - QList ids; - aSModel->getSelector( aPropId, lst, ids ); - pref->setItemProperty( "strings", lst, aPrefId ); - pref->setItemProperty( "indexes", ids, aPrefId ); + int themaSubTab = pref->addPreference( "ThemeTabs", themaTab, + SUIT_PreferenceMgr::Tab ); + for ( ; aTabIt != aTabEnd; ++aTabIt ) { + QList aGrpLst = aSModel->getGroups( *aTabIt ); + int themaSubSubTab = pref->addPreference( aSModel->getTabTitle( *aTabIt ), themaSubTab, + SUIT_PreferenceMgr::Frame ); + for( anIt = aGrpLst.begin(), anEnd = aGrpLst.end(); anIt != anEnd; ++anIt ) { + aGrpId = *anIt; + int themaGroup = pref->addPreference( aSModel->getGroupTitle( aGrpId ), themaSubSubTab, SUIT_PreferenceMgr::GroupBox ); + pref->setItemProperty( "columns", aSModel->getGroupNbColumns( aGrpId ), themaGroup ); + aPropLst = aSModel->getGroupProps( aGrpId ); + for( aPropIt = aPropLst.begin(), aPropEnd = aPropLst.end(); aPropIt != aPropEnd; ++aPropIt ) { + aPropId = *aPropIt; + Style_Model::PropType aType = aSModel->getPropType( aPropId ); + LightApp_Preferences::PrefItemType aPType = LightApp_Preferences::Auto; + switch( aType ) { + case Style_Model::Bool: aPType = LightApp_Preferences::Bool; break; + case Style_Model::Color: aPType = LightApp_Preferences::Color; break; + case Style_Model::String: aPType = LightApp_Preferences::String; break; + case Style_Model::IntSpin: aPType = LightApp_Preferences::IntSpin; break; + case Style_Model::DblSpin: aPType = LightApp_Preferences::DblSpin; break; + case Style_Model::Selector: aPType = LightApp_Preferences::Selector; break; + case Style_Model::Font: aPType = LightApp_Preferences::Font; break; + default: break; + } + aPrefId = pref->addPreference( aSModel->getPropTitle( aPropId ), themaGroup, + aPType, aSection, aSModel->getPropName( aPropId ) ); + aSModel->getValueTo( aResMgr, aPropId, true );//set default values into resource + if ( aPType == LightApp_Preferences::Selector ) { + QStringList lst; + QList ids; + aSModel->getSelector( aPropId, lst, ids ); + pref->setItemProperty( "strings", lst, aPrefId ); + pref->setItemProperty( "indexes", ids, aPrefId ); + } } } } diff --git a/src/Style/Style_Model.cxx b/src/Style/Style_Model.cxx index 86764f5b2..894cb344e 100644 --- a/src/Style/Style_Model.cxx +++ b/src/Style/Style_Model.cxx @@ -79,7 +79,7 @@ Style_Model::Style_Model() fillValue( lines_clr, "lines-color", "Color", grp_lines, Color ); // grp_font group - fillValue( font_value, "app-font", "App Font", grp_font, Font ); + fillValue( font_value, "app-font", "Font", grp_font, Font ); // grp_values group fillValue( all_antialized, "all-antialized", "All borders antialized", grp_value, Bool ); fillValue( auto_raising_wdg, "is-raising-widget", "Auto raising widget", grp_value, Bool ); @@ -88,15 +88,18 @@ Style_Model::Style_Model() fillValue( slider_rad, "slider-rad", "Rounding of slider", grp_value, DblSpin ); fillValue( hor_handle_delta, "hor-hadle-delta", "Hor spacinig of handle ", grp_value, DblSpin ); fillValue( ver_handle_delta, "ver-handle-delta", "Ver spacing of handle", grp_value, DblSpin ); - fillValue( split_handle_len, "split-handle-len", "Lenght of splitter handle", grp_value, DblSpin ); + fillValue( split_handle_len, "split-handle-len", "Length of splitter handle", grp_value, DblSpin ); fillValue( dock_wdg_sep_extent, "dock-widget-sep-extent", "DockWidget separator extent", grp_value, DblSpin ); - fillGroup( grp_style, "Predefined style", 2 ); - fillGroup( grp_color, "Colors", 3 ); - fillGroup( grp_col_values, "ColorValues", 2 ); - fillGroup( grp_lines, "Lines", 3 ); - fillGroup( grp_font, "Application font", 1 ); - fillGroup( grp_value, "Values", 2 ); + fillGroup( grp_style, tab_value, "Predefined style", 2 ); + fillGroup( grp_color, tab_color, "Colors", 3 ); + fillGroup( grp_col_values, tab_color, "ColorValues", 2 ); + fillGroup( grp_lines, tab_value, "Lines", 3 ); + fillGroup( grp_font, tab_value, "Font", 1 ); + fillGroup( grp_value, tab_value, "Values", 2 ); + + myTabs[tab_color] = QString( "Colors" ); + myTabs[tab_value] = QString( "Values" ); } Style_Model::~Style_Model() @@ -188,6 +191,7 @@ void Style_Model::initFromResource( QtxResourceMgr* theResMgr ) for ( ; anIt != anEnd; ++anIt ) setValueFrom( theResMgr, anIt.key() ); + //setValue( is_defined_style, QVariant( false ) ); if ( getBoolValue( is_defined_style ) ) setPredefinedStyle( getIntValue( defined_style ) ); } @@ -481,9 +485,24 @@ QFont Style_Model::getFontValue( int theId, const bool theIsDef ) const return aFont; } -QList Style_Model::getGroups() const +QList Style_Model::getTabs() const { - return myGroups.keys(); + return myTabs.keys(); +} + +QString Style_Model::getTabTitle( int theId ) const +{ + return myTabs.contains( theId ) ? myTabs[theId] : ""; +} + +QList Style_Model::getGroups( int theId ) const +{ + QList groups; + GroupMap::const_iterator anIt = myGroups.begin(), anEnd = myGroups.end(); + for ( ; anIt != anEnd; ++anIt ) + if ( anIt.value().myTabType == theId ) + groups.append( anIt.key() ); + return groups; } QString Style_Model::getGroupTitle( int theId ) const @@ -504,7 +523,6 @@ QList Style_Model::getGroupProps( int theId ) const if ( anIt.value().myGroupId == theId ) values.append( anIt.key() ); return values; - } QString Style_Model::getPropTitle( int theId ) const @@ -561,9 +579,10 @@ void Style_Model::fillValue( Properties theId, const QString& theName, myValues[theId] = aValue; } -void Style_Model::fillGroup( Groups theId, const QString& theTitle, int theNbCols ) +void Style_Model::fillGroup( Groups theId, Tabs theTab, const QString& theTitle, int theNbCols ) { GroupValue aValue; + aValue.myTabType = theTab; aValue.myTitle = theTitle; aValue.myNbColumns = theNbCols; diff --git a/src/Style/Style_Model.h b/src/Style/Style_Model.h index 4428c08c0..11b15063d 100644 --- a/src/Style/Style_Model.h +++ b/src/Style/Style_Model.h @@ -43,8 +43,9 @@ public: static QString sectionName(); + typedef enum { tab_color, tab_value } Tabs; typedef enum { grp_style, grp_color, grp_col_values, grp_lines, grp_font, grp_value } Groups; - + typedef enum { None, Bool, Color, String, IntSpin, DblSpin, Selector, Font } PropType; typedef enum { // grp_style is_defined_style, defined_style, // grp colors @@ -68,8 +69,6 @@ public: hor_handle_delta, ver_handle_delta, split_handle_len, dock_wdg_sep_extent } Properties; - typedef enum { None, Bool, Color, String, IntSpin, DblSpin, Selector, Font } PropType; - void reset(); void setDefaults( QApplication* ); void initFromResource( QtxResourceMgr* ); @@ -87,7 +86,9 @@ public: QString getStringValue( int, const bool = false ) const; QFont getFontValue( int, const bool = false ) const; - QList getGroups() const; + QList getTabs() const; + QString getTabTitle( int ) const; + QList getGroups( int ) const; QString getGroupTitle( int ) const; int getGroupNbColumns( int ) const; QList getGroupProps( int ) const; @@ -102,7 +103,7 @@ private: void fillValue( Properties, const QString&, const QString&, Groups, PropType = Color ); - void fillGroup( Groups, const QString&, int ); + void fillGroup( Groups, Tabs, const QString&, int ); private: typedef struct { @@ -115,17 +116,20 @@ private: } StyleValue; typedef struct { + Tabs myTabType; QString myTitle; int myNbColumns; } GroupValue; typedef QMap ValuesMap; - typedef QMap StringMap; - ValuesMap myValues; - StringMap myGroups; - - QStringList myPStyles; - QStringList myLines; + typedef QMap GroupMap; + typedef QMap StringMap; + ValuesMap myValues; + GroupMap myGroups; + StringMap myTabs; + + QStringList myPStyles; + QStringList myLines; }; #endif // STYLE_MODEL_H -- 2.39.2