From b9be82e1ac00a5945f2d55d30b5f71adcf2001cd Mon Sep 17 00:00:00 2001 From: mzn Date: Fri, 23 May 2008 11:08:20 +0000 Subject: [PATCH] Fix for bug IPAL19326. --- src/LightApp/LightApp_Application.cxx | 30 +++++++++++++---------- src/LightApp/resources/LightApp_msg_en.ts | 4 +++ src/SUIT/SUIT_DataBrowser.cxx | 29 ++++++++++++++++++++++ src/SUIT/SUIT_DataBrowser.h | 3 +++ src/SalomeApp/SalomeApp_Application.cxx | 2 ++ 5 files changed, 55 insertions(+), 13 deletions(-) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index bb7eb2311..a730a0515 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1875,6 +1875,8 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) "ObjectBrowser", "auto_size_first" ); pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool, "ObjectBrowser", "auto_size" ); + pref->addPreference( tr( "PREF_RESIZE_ON_EXPAND_ITEM" ), objSetGroup, LightApp_Preferences::Bool, + "ObjectBrowser", "resize_on_expand_item" ); // theme values Style_Model* aSModel = 0; @@ -2014,26 +2016,28 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString if( sec=="ObjectBrowser" ) { - if( param=="auto_size" || param=="auto_size_first" ) - { - SUIT_DataBrowser* ob = objectBrowser(); - if( !ob ) - return; + SUIT_DataBrowser* ob = objectBrowser(); + if( !ob ) + return; - bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false ), - autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true ); - + if ( param=="auto_size_first" ) { + bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true ); ob->setAutoSizeFirstColumn(autoSizeFirst); - ob->setAutoSizeColumns(autoSize); - if ( autoSizeFirst ) ob->adjustFirstColumnWidth(); + } + else if( param=="auto_size" ) { + bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false ); + ob->setAutoSizeColumns(autoSize); if ( autoSize ) ob->adjustColumnsWidth(); } - else if ( param == "auto_hide_search_tool" ) - { - objectBrowser()->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) ); + else if ( param=="resize_on_expand_item" ) { + bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false ); + ob->setResizeOnExpandItem(resizeOnExpandItem); + } + else if ( param == "auto_hide_search_tool" ) { + ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) ); } } diff --git a/src/LightApp/resources/LightApp_msg_en.ts b/src/LightApp/resources/LightApp_msg_en.ts index e9df1e199..ad21157a8 100644 --- a/src/LightApp/resources/LightApp_msg_en.ts +++ b/src/LightApp/resources/LightApp_msg_en.ts @@ -189,6 +189,10 @@ CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITASPREF_AUTO_SIZE_FIRST Auto size for first column + + PREF_RESIZE_ON_EXPAND_ITEM + Resize columns after expanding an item + PREF_GROUP_SUPERV Graph Supervisor diff --git a/src/SUIT/SUIT_DataBrowser.cxx b/src/SUIT/SUIT_DataBrowser.cxx index 4828d6e97..1f9e4d042 100644 --- a/src/SUIT/SUIT_DataBrowser.cxx +++ b/src/SUIT/SUIT_DataBrowser.cxx @@ -282,6 +282,19 @@ void SUIT_DataBrowser::contextMenuEvent( QContextMenuEvent* e ) contextMenuRequest( e ); } +/*! + \brief Set 'resize on expand item' flag value. + + If this flag is set to \c true (by default is false), after + expanding an item columns will be resized to its contents. + + \param on 'resize on expand item' flag value +*/ +void SUIT_DataBrowser::setResizeOnExpandItem( const bool on ) +{ + myResizeOnExpandItem = on; +} + /*! \brief Initialize object browser. \param root root data object @@ -297,10 +310,13 @@ void SUIT_DataBrowser::init( SUIT_DataObject* root ) model(), SLOT( setSortingEnabled( bool ) ) ); connect( treeView(), SIGNAL( doubleClicked( const QModelIndex& ) ), this, SLOT( onDblClicked( const QModelIndex& ) ) ); + connect( treeView(), SIGNAL( expanded( const QModelIndex& ) ), + this, SLOT( onExpanded( const QModelIndex& ) ) ); myShortcut = new QShortcut( Qt::Key_F5, this, SIGNAL( requestUpdate() ), SIGNAL( requestUpdate() ) ); myAutoSizeFirstColumn = true; myAutoSizeColumns = false; + myResizeOnExpandItem = false; } /*! @@ -347,3 +363,16 @@ void SUIT_DataBrowser::onDblClicked( const QModelIndex& index ) if ( obj ) emit( doubleClicked( obj ) ); } } + +/*! + \brief Called when item specified by index is expanded. + \internal +*/ +void SUIT_DataBrowser::onExpanded( const QModelIndex& index ) +{ + if (myResizeOnExpandItem) { + adjustFirstColumnWidth(); + adjustColumnsWidth(); + } +} + diff --git a/src/SUIT/SUIT_DataBrowser.h b/src/SUIT/SUIT_DataBrowser.h index b1bc41f43..9ab076bb3 100644 --- a/src/SUIT/SUIT_DataBrowser.h +++ b/src/SUIT/SUIT_DataBrowser.h @@ -62,6 +62,7 @@ public: void setAutoSizeFirstColumn( const bool on ); void setAutoSizeColumns( const bool on ); + void setResizeOnExpandItem( const bool on ); protected: virtual void contextMenuEvent( QContextMenuEvent* ); @@ -76,12 +77,14 @@ signals: private slots: void onModelUpdated(); void onDblClicked( const QModelIndex& ); + void onExpanded( const QModelIndex& ); private: QShortcut* myShortcut; bool myAutoSizeFirstColumn; bool myAutoSizeColumns; + bool myResizeOnExpandItem; }; #endif // SUIT_BROWSER_H diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index c724c08e5..c085ab018 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -757,9 +757,11 @@ QWidget* SalomeApp_Application::createWindow( const int flag ) bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false ); bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true ); + bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", true ); ob->setAutoSizeFirstColumn(autoSizeFirst); ob->setAutoSizeColumns(autoSize); + ob->setResizeOnExpandItem(resizeOnExpandItem); // temporary commented /* -- 2.39.2