From d59b7be6dab2f5b97a409a18d373f4bc14435a89 Mon Sep 17 00:00:00 2001 From: stv Date: Thu, 17 Jul 2008 11:04:01 +0000 Subject: [PATCH] *** empty log message *** --- src/LightApp/LightApp_Application.cxx | 52 ++-- src/LightApp/LightApp_Preferences.cxx | 8 + src/LightApp/LightApp_Preferences.h | 2 + src/LightApp/LightApp_PreferencesDlg.cxx | 36 ++- src/Qtx/QtxActionMenuMgr.cxx | 10 +- src/Qtx/QtxActionMgr.cxx | 5 + src/Qtx/QtxMRUAction.cxx | 45 +++- src/Qtx/QtxMRUAction.h | 5 + src/Qtx/QtxPagePrefMgr.cxx | 312 +++++++++++++++++------ src/Qtx/QtxPagePrefMgr.h | 44 +++- src/Qtx/QtxPreferenceMgr.cxx | 104 ++------ src/Qtx/QtxPreferenceMgr.h | 24 +- src/Qtx/QtxWorkstack.cxx | 19 +- src/SUIT/SUIT_PreferenceMgr.cxx | 18 +- src/SalomeApp/SalomeApp_Application.cxx | 2 +- 15 files changed, 439 insertions(+), 247 deletions(-) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 9cc19a01a..943f317fb 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1499,6 +1499,8 @@ void LightApp_Application::onPreferences() if ( !prefDlg ) return; + preferences()->activateModule( activeModule() ? activeModule()->moduleName() : tr( "PREF_CATEGORY_SALOME" ) ); + if ( ( prefDlg->exec() == QDialog::Accepted || prefDlg->isSaved() ) && resourceMgr() ) { if ( desktop() ) resourceMgr()->setValue( "desktop", "geometry", desktop()->storeGeometry() ); @@ -1730,19 +1732,18 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat ); int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab ); - //pref->setItemProperty( "columns", 1, studyGroup ); + pref->setItemProperty( "columns", 2, studyGroup ); pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" ); pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" ); pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" ); int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab ); - pref->setItemProperty( "columns", 2, extgroup ); - QString platform; + QString platform; #ifdef WIN32 - platform = "winapplication"; + platform = "winapplication"; #else - platform = "application"; + platform = "application"; #endif int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", platform ); pref->setItemProperty( "mode", Qtx::PT_OpenFile, apppref ); @@ -1750,12 +1751,12 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) pref->addPreference( tr( "PREF_PARAM" ), extgroup, LightApp_Preferences::String, "ExternalBrowser", "parameters" ); int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab ); - pref->setItemProperty( "columns", 2, pythonConsoleGroup ); pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" ); int SalomeStyleGroup = pref->addPreference( tr( "PREF_GROUP_STYLE" ), genTab ); pref->addPreference( tr( "PREF_USE_SALOME_STYLE" ), SalomeStyleGroup, LightApp_Preferences::Bool, "Style", "use_salome_style" ); - if ( resourceMgr() ) resourceMgr()->booleanValue( "Style", "use_salome_style", true ); + if ( resourceMgr() ) + resourceMgr()->booleanValue( "Style", "use_salome_style", true ); int viewTab = pref->addPreference( tr( "PREF_TAB_VIEWERS" ), salomeCat ); @@ -1767,26 +1768,26 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) int supervGroup = pref->addPreference( tr( "PREF_GROUP_SUPERV" ), viewTab ); - pref->setItemProperty( "columns", 4, occGroup ); - pref->setItemProperty( "columns", 4, vtkGroup ); - pref->setItemProperty( "columns", 4, plot2dGroup ); + pref->setItemProperty( "columns", 2, occGroup ); + pref->setItemProperty( "columns", 2, vtkGroup ); + pref->setItemProperty( "columns", 2, plot2dGroup ); int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occGroup, LightApp_Preferences::DblSpin, "OCCViewer", "trihedron_size" ); - pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup, - LightApp_Preferences::Color, "OCCViewer", "background" ); - pref->setItemProperty( "min", 1.0E-06, occTS ); pref->setItemProperty( "max", 1000, occTS ); + int isoU = pref->addPreference( tr( "PREF_ISOS_U" ), occGroup, LightApp_Preferences::IntSpin, "OCCViewer", "iso_number_u" ); - int isoV = pref->addPreference( tr( "PREF_ISOS_V" ), occGroup, - LightApp_Preferences::IntSpin, "OCCViewer", "iso_number_v" ); - pref->setItemProperty( "min", 0, isoU ); pref->setItemProperty( "max", 100000, isoU ); + pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup, + LightApp_Preferences::Color, "OCCViewer", "background" ); + + int isoV = pref->addPreference( tr( "PREF_ISOS_V" ), occGroup, + LightApp_Preferences::IntSpin, "OCCViewer", "iso_number_v" ); pref->setItemProperty( "min", 0, isoV ); pref->setItemProperty( "max", 100000, isoV ); @@ -1867,7 +1868,6 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat ); int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab ); - //pref->setItemProperty( dirGroup, "columns", 1 ); pref->addPreference( tr( "" ), dirGroup, LightApp_Preferences::DirList, "FileDlg", "QuickDirList" ); @@ -1923,7 +1923,7 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) 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 )*2, themaGroup ); + pref->setItemProperty( "columns", aSModel->getGroupNbColumns( aGrpId ), themaGroup ); aPropLst = aSModel->getGroupProps( aGrpId ); for( aPropIt = aPropLst.begin(), aPropEnd = aPropLst.end(); aPropIt != aPropEnd; ++aPropIt ) { aPropId = *aPropIt; @@ -1942,7 +1942,8 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) 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 ) { + if ( aPType == LightApp_Preferences::Selector ) + { QStringList lst; QList ids; aSModel->getSelector( aPropId, lst, ids ); @@ -2032,16 +2033,17 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString if( sec=="ObjectBrowser" ) { SUIT_DataBrowser* ob = objectBrowser(); - if( !ob ) + if ( !ob ) return; - if ( param=="auto_size_first" ) { + if ( param=="auto_size_first" ) + { bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true ); - ob->setAutoSizeFirstColumn(autoSizeFirst); + ob->setAutoSizeFirstColumn( autoSizeFirst ); if ( autoSizeFirst ) ob->adjustFirstColumnWidth(); } - else if( param=="auto_size" ) { + else if ( param=="auto_size" ) { bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false ); ob->setAutoSizeColumns(autoSize); if ( autoSize ) @@ -2079,9 +2081,9 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString if( param=="use_salome_style" ) { if ( resMgr->booleanValue( "Style", "use_salome_style", true ) ) - { + { if ( !aSStyle ) - { + { aSStyle = new Style_Salome(); aSStyle->getModel()->initFromResource( resMgr ); qApp->setStyle( aSStyle ); diff --git a/src/LightApp/LightApp_Preferences.cxx b/src/LightApp/LightApp_Preferences.cxx index 8be2b36ab..38bdf7f2f 100644 --- a/src/LightApp/LightApp_Preferences.cxx +++ b/src/LightApp/LightApp_Preferences.cxx @@ -68,6 +68,14 @@ bool LightApp_Preferences::hasModule( const QString& mod ) const return res; } +void LightApp_Preferences::activateModule( const QString& mod ) const +{ + QtxPreferenceItem* item = findItem( mod, true ); + + if ( item && item->depth() < 3 ) + item->ensureVisible(); +} + /*!Do nothing.*/ void LightApp_Preferences::onHelp() { diff --git a/src/LightApp/LightApp_Preferences.h b/src/LightApp/LightApp_Preferences.h index 497cbe20e..c6c41c1e8 100644 --- a/src/LightApp/LightApp_Preferences.h +++ b/src/LightApp/LightApp_Preferences.h @@ -49,6 +49,8 @@ public: bool hasModule( const QString& ) const; + void activateModule( const QString& ) const; + protected: void changedResources( const ResourceMap& ); diff --git a/src/LightApp/LightApp_PreferencesDlg.cxx b/src/LightApp/LightApp_PreferencesDlg.cxx index 6bda54736..add5dac14 100644 --- a/src/LightApp/LightApp_PreferencesDlg.cxx +++ b/src/LightApp/LightApp_PreferencesDlg.cxx @@ -1,17 +1,17 @@ // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D -// +// // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either +// License as published by the Free Software Foundation; either // version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com @@ -40,14 +40,10 @@ myPrefs( prefs ), mySaved ( false ) setWindowTitle( tr( "CAPTION" ) ); QVBoxLayout* main = new QVBoxLayout( mainFrame() ); - main->setMargin( 5 ); + main->setMargin( 0 ); main->setSpacing( 5 ); main->addWidget( myPrefs ); - // myPrefs->setParent( vbox ); - // myPrefs->move( QPoint( 0, 0 ) ); - // myPrefs->show(); - setFocusProxy( myPrefs ); myPrefs->setFrameStyle( QFrame::Box | QFrame::Sunken ); myPrefs->show(); @@ -88,7 +84,7 @@ void LightApp_PreferencesDlg::setVisible(bool visible) myPrefs->retrieve(); myPrefs->toBackup(); } - + QtxDialog::setVisible(visible); } @@ -118,13 +114,13 @@ void LightApp_PreferencesDlg::onHelp() void LightApp_PreferencesDlg::onApply() { myPrefs->store(); - + // Fix for Bug PAL11197: Restoring the corrected values from resource manager. // (Correcting in VisuGUI.cxx and SMESHGUI.cxx in methods // ::preferencesChanged( const QString& sect, const QString& name )) myPrefs->retrieve(); // - + myPrefs->toBackup(); mySaved = true; } @@ -132,17 +128,17 @@ void LightApp_PreferencesDlg::onApply() /*! Restore default preferences*/ void LightApp_PreferencesDlg::onDefault() { - if( SUIT_MessageBox::Ok == SUIT_MessageBox::question( this, tr( "WARNING" ), tr( "DEFAULT_QUESTION" ), + if( SUIT_MessageBox::Ok == SUIT_MessageBox::question( this, tr( "WARNING" ), tr( "DEFAULT_QUESTION" ), SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel, SUIT_MessageBox::Ok ) ) { if ( myPrefs && myPrefs->resourceMgr() ) { bool prev = myPrefs->resourceMgr()->ignoreUserValues(); - myPrefs->resourceMgr()->setIgnoreUserValues( true ); + myPrefs->resourceMgr()->setIgnoreUserValues( true ); myPrefs->retrieve(); myPrefs->resourceMgr()->setIgnoreUserValues( prev ); - } + } } } @@ -157,7 +153,7 @@ void LightApp_PreferencesDlg::onImportPref() dlg.setObjectName( "" ); //dlg.setShowHiddenFiles( true ); dlg.exec(); - + QStringList files = dlg.selectedFiles(); if ( files.isEmpty() ) return; diff --git a/src/Qtx/QtxActionMenuMgr.cxx b/src/Qtx/QtxActionMenuMgr.cxx index 95d6ab7ca..94368536e 100644 --- a/src/Qtx/QtxActionMenuMgr.cxx +++ b/src/Qtx/QtxActionMenuMgr.cxx @@ -140,8 +140,9 @@ QtxActionMenuMgr::~QtxActionMenuMgr() { for ( MenuMap::Iterator itr = myMenus.begin(); itr != myMenus.end(); ++itr ) { - delete itr.value()->menu(); - delete itr.value(); + QPointer a = itr.value(); + delete a->menu(); + delete a; } delete myRoot; @@ -328,8 +329,9 @@ int QtxActionMenuMgr::insert( const QString& title, const int pId, const int gro int gid = (id == -1 || eNode ) ? generateId() : id; - QAction* ma = new QAction( title, this ); - ma->setMenu( new QMenu( 0 ) ); + QMenu* menu = new QMenu( 0 ); + QAction* ma = menu->menuAction(); + ma->setText( title ); connect( ma->menu(), SIGNAL( aboutToShow() ), this, SLOT( onAboutToShow() ) ); connect( ma->menu(), SIGNAL( aboutToHide() ), this, SLOT( onAboutToHide() ) ); diff --git a/src/Qtx/QtxActionMgr.cxx b/src/Qtx/QtxActionMgr.cxx index 053d5ab75..8d0da7fb4 100644 --- a/src/Qtx/QtxActionMgr.cxx +++ b/src/Qtx/QtxActionMgr.cxx @@ -392,6 +392,11 @@ void QtxActionMgr::triggerUpdate() if ( !isUpdatesEnabled() ) return; + // STV: debug code + updateContent(); + return; + // STV: debug code + if ( !myUpdTimer ) { myUpdTimer = new QTimer( this ); diff --git a/src/Qtx/QtxMRUAction.cxx b/src/Qtx/QtxMRUAction.cxx index 8df4dd128..d8f8d1194 100755 --- a/src/Qtx/QtxMRUAction.cxx +++ b/src/Qtx/QtxMRUAction.cxx @@ -36,14 +36,19 @@ \param parent parent object */ QtxMRUAction::QtxMRUAction( QObject* parent ) -: QtxAction( "Most Recently Used", "Most Recently Used", 0, parent ), +: QtxAction( tr( "Most Recently Used" ), tr( "Most Recently Used" ), 0, parent ), myVisCount( 5 ), myHistoryCount( -1 ), myLinkType( LinkAuto ), myInsertMode( MoveFirst ) { + myClear = new QAction( tr( "Clear" ), this ); + myClear->setVisible( false ); + setMenu( new QMenu( 0 ) ); + connect( menu(), SIGNAL( aboutToShow() ), this, SLOT( onAboutToShow() ) ); + connect( myClear, SIGNAL( triggered( bool ) ), this, SLOT( onCleared( bool ) ) ); } /*! @@ -59,8 +64,12 @@ QtxMRUAction::QtxMRUAction( const QString& text, const QString& menuText, QObjec myLinkType( LinkAuto ), myInsertMode( MoveFirst ) { + myClear = new QAction( tr( "Clear" ), this ); + myClear->setVisible( false ); + setMenu( new QMenu( 0 ) ); connect( menu(), SIGNAL( aboutToShow() ), this, SLOT( onAboutToShow() ) ); + connect( myClear, SIGNAL( triggered( bool ) ), this, SLOT( onCleared( bool ) ) ); } /*! @@ -78,8 +87,12 @@ QtxMRUAction::QtxMRUAction( const QString& text, const QIcon& icon, myLinkType( LinkAuto ), myInsertMode( MoveFirst ) { + myClear = new QAction( tr( "Clear" ), this ); + myClear->setVisible( false ); + setMenu( new QMenu( 0 ) ); connect( menu(), SIGNAL( aboutToShow() ), this, SLOT( onAboutToShow() ) ); + connect( myClear, SIGNAL( triggered( bool ) ), this, SLOT( onCleared( bool ) ) ); } /*! @@ -172,6 +185,22 @@ void QtxMRUAction::setVisibleCount( int num ) myVisCount = num; } +/*! + \brief Return visible status of the menu item which clear all MRU items. +*/ +bool QtxMRUAction::isClearPossible() const +{ + return myClear->isVisible(); +} + +/*! + \brief Set visible the menu item which clear all MRU items. +*/ +void QtxMRUAction::setClearPossible( const bool on ) +{ + myClear->setVisible( on ); +} + /*! \brief Get number of totally stored MRU items. \return number of MRU items stored in the preferences @@ -375,7 +404,7 @@ void QtxMRUAction::saveLinks( QtxResourceMgr* resMgr, const QString& section, co } int counter = 0; - for ( QStringList::const_iterator iter = lst.begin(); + for ( QStringList::const_iterator iter = lst.begin(); iter != lst.end() && ( myHistoryCount < 0 || counter < myHistoryCount ); ++iter, counter++ ) resMgr->setValue( section, itemPrefix + QString().sprintf( "%03d", counter ), *iter ); @@ -408,6 +437,11 @@ void QtxMRUAction::onActivated() emit activated( link ); } +void QtxMRUAction::onCleared( bool ) +{ + clear(); +} + /*! \brief Update MRU items popup menu. */ @@ -463,6 +497,13 @@ void QtxMRUAction::updateMenu() if ( pm->isEmpty() ) pm->addAction( tr( "" ) )->setEnabled( false ); + + if ( isClearPossible() ) + { + pm->addSeparator(); + pm->addAction( myClear ); + myClear->setEnabled( !pm->isEmpty() ); + } } /*! diff --git a/src/Qtx/QtxMRUAction.h b/src/Qtx/QtxMRUAction.h index ee1159add..f07f4fc46 100755 --- a/src/Qtx/QtxMRUAction.h +++ b/src/Qtx/QtxMRUAction.h @@ -67,6 +67,9 @@ public: int visibleCount() const; void setVisibleCount( const int ); + bool isClearPossible() const; + void setClearPossible( const bool ); + int historyCount() const; void setHistoryCount( const int ); @@ -90,12 +93,14 @@ signals: private slots: void onActivated(); void onAboutToShow(); + void onCleared( bool ); private: void updateMenu(); private: QStringList myLinks; //!< most recent used items + QAction* myClear; //!< clear item int myVisCount; //!< number of visible MRU items int myHistoryCount; //!< number of stored MRU items int myLinkType; //!< type of link names in menu diff --git a/src/Qtx/QtxPagePrefMgr.cxx b/src/Qtx/QtxPagePrefMgr.cxx index 930d11557..27701557e 100644 --- a/src/Qtx/QtxPagePrefMgr.cxx +++ b/src/Qtx/QtxPagePrefMgr.cxx @@ -1,17 +1,17 @@ // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D -// +// // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either +// License as published by the Free Software Foundation; either // version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -58,7 +59,7 @@ QtxPagePrefMgr::QtxPagePrefMgr( QtxResourceMgr* resMgr, QWidget* parent ) { myBox = new QtxGridBox( 1, Qt::Horizontal, this, 0 ); QVBoxLayout* base = new QVBoxLayout( this ); - base->setMargin( 0 ); + base->setMargin( 5 ); base->setSpacing( 0 ); base->addWidget( myBox ); } @@ -76,8 +77,6 @@ QtxPagePrefMgr::~QtxPagePrefMgr() */ QSize QtxPagePrefMgr::sizeHint() const { - initialize(); - return QFrame::sizeHint(); } @@ -87,20 +86,20 @@ QSize QtxPagePrefMgr::sizeHint() const */ QSize QtxPagePrefMgr::minimumSizeHint() const { - initialize(); - return QFrame::minimumSizeHint(); } /*! \brief Customize show/hide widget operation. - \param on if \c true the widget is being shown, otherswise + \param on if \c true the widget is being shown, otherswise it is being hidden */ void QtxPagePrefMgr::setVisible( bool on ) { - if ( on && !myInit ) - updateContents(); + if ( on ) + initialize(); + + QApplication::instance()->processEvents(); QFrame::setVisible( on ); } @@ -115,12 +114,9 @@ void QtxPagePrefMgr::updateContents() QList lst = childItems(); for ( QList::const_iterator it = lst.begin(); it != lst.end(); ++it ) { - if ( (*it)->rtti() == QtxPagePrefItem::RTTI() ) - { - QtxPagePrefItem* item = (QtxPagePrefItem*)(*it); - if ( item->widget() && item->widget()->parent() != myBox ) - item->widget()->setParent( myBox ); - } + QtxPagePrefItem* item = dynamic_cast( *it ); + if ( item && item->widget() && item->widget()->parent() != myBox ) + item->widget()->setParent( myBox ); } setWindowIcon( icon() ); @@ -195,18 +191,25 @@ void QtxPagePrefMgr::setOptionValue( const QString& name, const QVariant& val ) */ void QtxPagePrefMgr::initialize() const { - if ( myInit ) - return; + // if ( myInit ) + // return; QtxPagePrefMgr* that = (QtxPagePrefMgr*)this; - - that->updateContents(); + that->initialize( that ); + + // that->myInit = true; +} + +void QtxPagePrefMgr::initialize( QtxPreferenceItem* item ) +{ + if ( !item ) + return; - QList lst = childItems( true ); + QList lst = item->childItems( false ); for ( QList::iterator it = lst.begin(); it != lst.end(); ++it ) - (*it)->updateContents(); + initialize( *it ); - that->myInit = true; + updateContents(); } /*! @@ -215,6 +218,41 @@ void QtxPagePrefMgr::initialize() const preference items. */ +class QtxPagePrefItem::Listener : public QObject +{ +public: + Listener( QtxPagePrefItem* ); + virtual ~Listener(); + + virtual bool eventFilter( QObject*, QEvent* ); + +private: + QtxPagePrefItem* myItem; +}; + +QtxPagePrefItem::Listener::Listener( QtxPagePrefItem* item ) +: QObject( 0 ), + myItem( item ) +{ +} + +QtxPagePrefItem::Listener::~Listener() +{ +} + +bool QtxPagePrefItem::Listener::eventFilter( QObject* o, QEvent* e ) +{ + if ( !myItem || myItem->widget() != o ) + return false; + + if ( e->type() == QEvent::Show || e->type() == QEvent::ShowToParent ) + myItem->widgetShown(); + if ( e->type() == QEvent::Hide || e->type() == QEvent::HideToParent ) + myItem->widgetHided(); + + return false; +} + /*! \brief Constructor. \param title preference item title @@ -225,7 +263,8 @@ void QtxPagePrefMgr::initialize() const QtxPagePrefItem::QtxPagePrefItem( const QString& title, QtxPreferenceItem* parent, const QString& sect, const QString& param ) : QtxPreferenceItem( title, sect, param, parent ), - myWidget( 0 ) + myWidget( 0 ), + myListener( 0 ) { } @@ -235,15 +274,7 @@ QtxPagePrefItem::QtxPagePrefItem( const QString& title, QtxPreferenceItem* paren QtxPagePrefItem::~QtxPagePrefItem() { delete myWidget; -} - -/*! - \brief Get unique item type identifier. - \return item type ID -*/ -int QtxPagePrefItem::rtti() const -{ - return QtxPagePrefItem::RTTI(); + delete myListener; } /*! @@ -256,15 +287,6 @@ QWidget* QtxPagePrefItem::widget() const return myWidget; } -/*! - \brief Specify unique item class identifier. - \return item class ID -*/ -int QtxPagePrefItem::RTTI() -{ - return 1000; -} - /*! \brief Set preference item editor widget. \param wid editor widget @@ -272,7 +294,18 @@ int QtxPagePrefItem::RTTI() */ void QtxPagePrefItem::setWidget( QWidget* wid ) { + if ( myWidget && myListener ) + myWidget->removeEventFilter( myListener ); + myWidget = wid; + + if ( myWidget ) + { + if ( !myListener ) + myListener = new Listener( this ); + myWidget->installEventFilter( myListener ); + } + sendItemChanges(); } @@ -311,7 +344,7 @@ void QtxPagePrefItem::itemChanged( QtxPreferenceItem* /*item*/ ) /*! \brief Store preference item to the resource manager. - + This method should be reimplemented in the subclasses. Base implementation does nothing. @@ -323,7 +356,7 @@ void QtxPagePrefItem::store() /*! \brief Retrieve preference item from the resource manager. - + This method should be reimplemented in the subclasses. Base implementation does nothing. @@ -333,6 +366,29 @@ void QtxPagePrefItem::retrieve() { } +/*! + \brief Invoked when preference item widget is shown. +*/ +void QtxPagePrefItem::widgetShown() +{ +} + +/*! + \brief Invoked when preference item widget is hided. +*/ +void QtxPagePrefItem::widgetHided() +{ +} + +void QtxPagePrefItem::ensureVisible( QtxPreferenceItem* i ) +{ + QtxPreferenceItem::ensureVisible(); + + QtxPagePrefItem* item = dynamic_cast( i ); + if ( item && item->widget() ) + item->widget()->setVisible( true ); +} + /*! \brief Find all child items of the QtxPagePrefItem type. \param list used to return list of child items @@ -343,14 +399,15 @@ void QtxPagePrefItem::pageChildItems( QList& list, const bool QList lst = childItems( rec ); for ( QList::const_iterator it = lst.begin(); it != lst.end(); ++it ) { - if ( (*it)->rtti() == QtxPagePrefItem::RTTI() ) - list.append( (QtxPagePrefItem*)*it ); + QtxPagePrefItem* item = dynamic_cast( *it ); + if ( item ) + list.append( item ); } } /*! \brief Called when contents is changed (item is added, removed or modified). - + Triggers the item update. */ void QtxPagePrefItem::contentChanged() @@ -378,18 +435,18 @@ QtxPageNamedPrefItem::QtxPageNamedPrefItem( const QString& title, QtxPreferenceI { QWidget* main = new QWidget(); - QtxPagePrefGroupItem* aGroup = dynamic_cast(parent); - if ( !aGroup ) - { + // QtxPagePrefGroupItem* aGroup = 0;//dynamic_cast(parent); + // if ( !aGroup ) + // { QHBoxLayout* base = new QHBoxLayout( main ); base->setMargin( 0 ); base->setSpacing( 5 ); myLabel = new QLabel( title, main ); base->addWidget( myLabel ); - } - else - myLabel = new QLabel( title, aGroup->gridBox() ); + // } + // else + // myLabel = new QLabel( title, aGroup->gridBox() ); setWidget( main ); @@ -450,9 +507,41 @@ void QtxPageNamedPrefItem::setControl( QWidget* wid ) if ( myControl ) { - QtxPagePrefGroupItem* aGroup = dynamic_cast(parentItem()); - if ( !aGroup ) widget()->layout()->addWidget( myControl ); - else myControl->setParent( aGroup->gridBox() ); + // QtxPagePrefGroupItem* aGroup = 0;//dynamic_cast(parentItem()); + // if ( !aGroup ) + widget()->layout()->addWidget( myControl ); + // else myControl->setParent( aGroup->gridBox() ); + } +} + +void QtxPageNamedPrefItem::adjustLabels( QtxPagePrefItem* parent ) +{ + if ( !parent ) + return; + + QList childList = parent->childItems(); + + QList namedItems; + for ( QList::iterator it = childList.begin(); it != childList.end(); ++it ) + { + QtxPageNamedPrefItem* item = dynamic_cast( *it ); + if ( item ) + namedItems.append( item ); + } + + int sz = 0; + for ( QList::iterator it1 = namedItems.begin(); it1 != namedItems.end(); ++it1 ) + { + QtxPageNamedPrefItem* item = *it1; + if ( item->label() ) + sz = qMax( sz, item->label()->sizeHint().width() ); + } + + for ( QList::iterator it2 = namedItems.begin(); it2 != namedItems.end(); ++it2 ) + { + QtxPageNamedPrefItem* item = *it2; + if ( item->label() ) + item->label()->setMinimumWidth( sz ); } } @@ -593,6 +682,22 @@ void QtxPagePrefListItem::setOptionValue( const QString& name, const QVariant& v QtxPagePrefItem::setOptionValue( name, val ); } +void QtxPagePrefListItem::widgetShown() +{ + updateState(); +} + +void QtxPagePrefListItem::ensureVisible( QtxPreferenceItem* i ) +{ + if ( !i ) + return; + + QtxPreferenceItem::ensureVisible( i ); + + setSelected( i->id() ); + updateState(); +} + /*! \brief Called when the selection in the list box is changed. */ @@ -850,6 +955,18 @@ void QtxPagePrefToolBoxItem::updateToolBox() myToolBox->setCurrentWidget( cur ); } +void QtxPagePrefToolBoxItem::ensureVisible( QtxPreferenceItem* i ) +{ + if ( !i ) + return; + + QtxPreferenceItem::ensureVisible( i ); + + QtxPagePrefItem* item = dynamic_cast( i ); + if ( item && item->widget() ) + myToolBox->setCurrentWidget( item->widget() ); +} + /*! \class QtxPagePrefTabsItem \brief GUI implementation of the tab widget container. @@ -990,6 +1107,18 @@ void QtxPagePrefTabsItem::setOptionValue( const QString& name, const QVariant& v QtxPagePrefItem::setOptionValue( name, val ); } +void QtxPagePrefTabsItem::ensureVisible( QtxPreferenceItem* i ) +{ + if ( !i ) + return; + + QtxPreferenceItem::ensureVisible( i ); + + QtxPagePrefItem* item = dynamic_cast( i ); + if ( item && item->widget() ) + myTabs->setCurrentWidget( item->widget() ); +} + /*! \brief Update tabs. */ @@ -1079,7 +1208,10 @@ QtxPagePrefFrameItem::~QtxPagePrefFrameItem() void QtxPagePrefFrameItem::updateContents() { QtxPagePrefItem::updateContents(); + updateFrame(); + + QtxPageNamedPrefItem::adjustLabels( this ); } /*! @@ -1252,6 +1384,13 @@ void QtxPagePrefFrameItem::setOptionValue( const QString& name, const QVariant& QtxPagePrefItem::setOptionValue( name, val ); } +void QtxPagePrefFrameItem::widgetShown() +{ + QtxPagePrefItem::widgetShown(); + + QtxPageNamedPrefItem::adjustLabels( this ); +} + /*! \brief Update frame widget. */ @@ -1292,6 +1431,8 @@ QtxPagePrefGroupItem::QtxPagePrefGroupItem( const QString& title, QtxPreferenceI myGroup->setWidget( myBox ); setWidget( myGroup ); + + updateState(); } /*! @@ -1311,6 +1452,8 @@ QtxPagePrefGroupItem::QtxPagePrefGroupItem( const int cols, const QString& title myGroup->setWidget( myBox ); setWidget( myGroup ); + + updateState(); } /*! @@ -1338,10 +1481,13 @@ void QtxPagePrefGroupItem::setResource( const QString& sect, const QString& para void QtxPagePrefGroupItem::updateContents() { QtxPagePrefItem::updateContents(); + myGroup->setTitle( title() ); updateState(); updateGroup(); + + QtxPageNamedPrefItem::adjustLabels( this ); } /*! @@ -1529,6 +1675,13 @@ void QtxPagePrefGroupItem::setOptionValue( const QString& name, const QVariant& QtxPagePrefItem::setOptionValue( name, val ); } +void QtxPagePrefGroupItem::widgetShown() +{ + QtxPagePrefItem::widgetShown(); + + QtxPageNamedPrefItem::adjustLabels( this ); +} + /*! \brief Update widget state. */ @@ -1567,7 +1720,7 @@ void QtxPagePrefGroupItem::updateGroup() /*! \brief Constructor. - Creates spacer item with zero width and height and expanding + Creates spacer item with zero width and height and expanding on both directions (by height and width). \param parent parent preference item @@ -1581,7 +1734,7 @@ QtxPagePrefSpaceItem::QtxPagePrefSpaceItem( QtxPreferenceItem* parent ) /*! \brief Constructor. - Creates spacer item with zero width and height and expanding + Creates spacer item with zero width and height and expanding according to the specified orientation. \param o spacer orientation @@ -1676,7 +1829,7 @@ void QtxPagePrefSpaceItem::setStretch( Qt::Orientation o, const int sf ) sp.setVerticalStretch( sf ); sp.setVerticalPolicy( sf > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed ); } - + widget()->setSizePolicy( sp ); } @@ -1744,7 +1897,7 @@ void QtxPagePrefSpaceItem::initialize( const int w, const int h, const int hs, c QSizePolicy sp; sp.setHorizontalPolicy( hs > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed ); sp.setVerticalPolicy( vs > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed ); - + sp.setHorizontalStretch( hs ); sp.setVerticalStretch( vs ); @@ -1752,7 +1905,7 @@ void QtxPagePrefSpaceItem::initialize( const int w, const int h, const int hs, c wid->setSizePolicy( sp ); wid->setMinimumSize( w, h ); - + setWidget( wid ); } @@ -1795,7 +1948,7 @@ void QtxPagePrefCheckItem::setTitle( const QString& txt ) myCheck->setText( title() ); } - + /*! \brief Store preference item to the resource manager. \sa retrieve() @@ -1852,7 +2005,7 @@ QtxPagePrefEditItem::QtxPagePrefEditItem( const QString& title, QtxPreferenceIte \param param resource file parameter associated with the preference item */ QtxPagePrefEditItem::QtxPagePrefEditItem( const int type, const QString& title, - QtxPreferenceItem* parent, const QString& sect, + QtxPreferenceItem* parent, const QString& sect, const QString& param ) : QtxPageNamedPrefItem( title, parent, sect, param ), myType( type ) @@ -1980,7 +2133,7 @@ void QtxPagePrefEditItem::updateEditor() /*! \class QtxPagePrefSelectItem - \brief GUI implementation of the resources selector item + \brief GUI implementation of the resources selector item (string, integer or double values list). All items in the list (represented as combo box) should be specified @@ -1990,7 +2143,7 @@ void QtxPagePrefEditItem::updateEditor() /*! \brief Constructor. - + Creates preference item with combo box widget which is not editable (direct value entering is disabled). @@ -2012,7 +2165,7 @@ QtxPagePrefSelectItem::QtxPagePrefSelectItem( const QString& title, QtxPreferenc /*! \brief Constructor. - + Creates preference item with combo box widget which is editable according to the specified input type (integer, double or string values). @@ -2319,7 +2472,7 @@ QtxPagePrefSpinItem::QtxPagePrefSpinItem( const QString& title, QtxPreferenceIte \param param resource file parameter associated with the preference item */ QtxPagePrefSpinItem::QtxPagePrefSpinItem( const int type, const QString& title, - QtxPreferenceItem* parent, const QString& sect, + QtxPreferenceItem* parent, const QString& sect, const QString& param ) : QtxPageNamedPrefItem( title, parent, sect, param ), myType( type ) @@ -2434,7 +2587,7 @@ QString QtxPagePrefSpinItem::suffix() const } /*! - \brief Get spin box preference item special value text (which is shown + \brief Get spin box preference item special value text (which is shown when the spin box reaches minimum value). \return spin box special value text \sa setSpecialValueText() @@ -2532,7 +2685,7 @@ void QtxPagePrefSpinItem::setSuffix( const QString& txt ) } /*! - \brief Set spin box preference item special value text (which is shown + \brief Set spin box preference item special value text (which is shown when the spin box reaches minimum value). \param txt new spin box special value text \sa specialValueText() @@ -2689,7 +2842,7 @@ void QtxPagePrefSpinItem::updateSpinBox() \param sect resource file section associated with the preference item \param param resource file parameter associated with the preference item */ -QtxPagePrefTextItem::QtxPagePrefTextItem( QtxPreferenceItem* parent, const QString& sect, +QtxPagePrefTextItem::QtxPagePrefTextItem( QtxPreferenceItem* parent, const QString& sect, const QString& param ) : QtxPageNamedPrefItem( QString(), parent, sect, param ) { @@ -2757,9 +2910,10 @@ QtxPagePrefColorItem::QtxPagePrefColorItem( const QString& title, QtxPreferenceI const QString& sect, const QString& param ) : QtxPageNamedPrefItem( title, parent, sect, param ) { - QtxPagePrefGroupItem* aGroup = dynamic_cast( parent ); + // QtxPagePrefGroupItem* aGroup 0; //= dynamic_cast( parent ); - setControl( myColor = new QtxColorButton( aGroup ? aGroup->gridBox() : 0 ) ); + // setControl( myColor = new QtxColorButton( aGroup ? aGroup->gridBox() : 0 ) ); + setControl( myColor = new QtxColorButton( 0 ) ); myColor->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); } @@ -2802,7 +2956,7 @@ void QtxPagePrefColorItem::retrieve() \param param resource file parameter associated with the preference item */ QtxPagePrefFontItem::QtxPagePrefFontItem( const int feat, const QString& title, - QtxPreferenceItem* parent, const QString& sect, + QtxPreferenceItem* parent, const QString& sect, const QString& param ) : QtxPageNamedPrefItem( title, parent, sect, param ) { diff --git a/src/Qtx/QtxPagePrefMgr.h b/src/Qtx/QtxPagePrefMgr.h index 0f2770d75..11ca33aa3 100644 --- a/src/Qtx/QtxPagePrefMgr.h +++ b/src/Qtx/QtxPagePrefMgr.h @@ -1,17 +1,17 @@ // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D -// +// // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either +// License as published by the Free Software Foundation; either // version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com @@ -79,6 +79,7 @@ protected: private: void initialize() const; + void initialize( QtxPreferenceItem* ); private: QtxGridBox* myBox; @@ -87,17 +88,15 @@ private: class QTX_EXPORT QtxPagePrefItem : public QtxPreferenceItem { + class Listener; + public: QtxPagePrefItem( const QString&, QtxPreferenceItem* = 0, const QString& = QString(), const QString& = QString() ); virtual ~QtxPagePrefItem(); - virtual int rtti() const; - QWidget* widget() const; - static int RTTI(); - protected: void setWidget( QWidget* ); @@ -110,11 +109,17 @@ protected: virtual void store(); virtual void retrieve(); + virtual void widgetShown(); + virtual void widgetHided(); + + virtual void ensureVisible( QtxPreferenceItem* ); + private: virtual void contentChanged(); private: QPointer myWidget; + Listener* myListener; }; class QTX_EXPORT QtxPageNamedPrefItem : public QtxPagePrefItem @@ -126,6 +131,8 @@ public: virtual void setTitle( const QString& ); + static void adjustLabels( QtxPagePrefItem* ); + protected: QLabel* label() const; QWidget* control() const; @@ -160,6 +167,9 @@ private slots: protected: virtual QVariant optionValue( const QString& ) const; virtual void setOptionValue( const QString&, const QVariant& ); + virtual void ensureVisible( QtxPreferenceItem* ); + + virtual void widgetShown(); private: void updateInfo(); @@ -189,6 +199,9 @@ public: virtual void updateContents(); +protected: + virtual void ensureVisible( QtxPreferenceItem* ); + private: void updateToolBox(); @@ -217,6 +230,7 @@ public: protected: virtual QVariant optionValue( const QString& ) const; virtual void setOptionValue( const QString&, const QVariant& ); + virtual void ensureVisible( QtxPreferenceItem* ); private: void updateTabs(); @@ -253,6 +267,8 @@ protected: virtual QVariant optionValue( const QString& ) const; virtual void setOptionValue( const QString&, const QVariant& ); + virtual void widgetShown(); + private: void updateFrame(); @@ -297,6 +313,8 @@ protected: virtual QVariant optionValue( const QString& ) const; virtual void setOptionValue( const QString&, const QVariant& ); + virtual void widgetShown(); + private: void updateState(); void updateGroup(); @@ -533,7 +551,7 @@ public: protected: virtual QVariant optionValue( const QString& ) const; virtual void setOptionValue( const QString&, const QVariant& ); - + private: QtxPathEdit* myPath; }; diff --git a/src/Qtx/QtxPreferenceMgr.cxx b/src/Qtx/QtxPreferenceMgr.cxx index 1b12db5e6..26ebbf2a3 100644 --- a/src/Qtx/QtxPreferenceMgr.cxx +++ b/src/Qtx/QtxPreferenceMgr.cxx @@ -1,17 +1,17 @@ // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D -// +// // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either +// License as published by the Free Software Foundation; either // version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com @@ -121,7 +121,7 @@ void QtxPreferenceItem::Updater::customEvent( QEvent* /*e*/ ) \class QtxPreferenceItem \brief Base class for implementing of all the preference items. - To implement any specific preference item, cubclass from the + To implement any specific preference item, cubclass from the QtxPreferenceItem and redefine store() and retrieve() methods. */ @@ -554,6 +554,11 @@ QtxPreferenceItem* QtxPreferenceItem::findItem( const QString& title, const int return item; } +void QtxPreferenceItem::ensureVisible() +{ + if ( parentItem() ) + parentItem()->ensureVisible( this ); +} /*! \brief Get integer resources value corresponding to the item. @@ -705,7 +710,7 @@ void QtxPreferenceItem::setFont( const QFont& val ) /*! \brief Callback function which is called when the child preference item is added. - + This function can be reimplemented in the subclasses to customize child item addition operation. Base implementation does nothing. @@ -719,7 +724,7 @@ void QtxPreferenceItem::itemAdded( QtxPreferenceItem* /*item*/ ) /*! \brief Callback function which is called when the child preference item is removed. - + This function can be reimplemented in the subclasses to customize child item removal operation. Base implementation does nothing. @@ -733,15 +738,20 @@ void QtxPreferenceItem::itemRemoved( QtxPreferenceItem* /*item*/ ) /*! \brief Callback function which is called when the child preference item is modified. - + This function can be reimplemented in the subclasses to customize child item modifying operation. Base implementation does nothing. \param item child item being modified \sa itemAdded(), itemRemoved() */ -void QtxPreferenceItem::itemChanged( QtxPreferenceItem* /*item*/ ) +void QtxPreferenceItem::itemChanged( QtxPreferenceItem* ) +{ +} + +void QtxPreferenceItem::ensureVisible( QtxPreferenceItem* ) { + ensureVisible(); } /*! @@ -757,7 +767,7 @@ void QtxPreferenceItem::triggerUpdate() This function can be reimplemented in the subclasses. Base implementation does nothing. - + \param name option name \return property value or null QVariant if option is not set \sa setOptionValue() @@ -775,7 +785,7 @@ QVariant QtxPreferenceItem::optionValue( const QString& name ) const This function can be reimplemented in the subclasses. Base implementation does nothing. - + \param name option name \param val new property value \sa optionValue() @@ -848,39 +858,6 @@ QtxPreferenceMgr* QtxPreferenceMgr::preferenceMgr() const return (QtxPreferenceMgr*)this; } -/* - \brief Add new preference item. - \param label label of widget to edit preference item - \param pId parent preference item id - \param type preference item type - \param section resource file section associated to the preference item - \param param resource file parameter associated to the preference item -*/ -/* -int QtxPreferenceMgr::addItem( const QString& label, const int pId, const int type, - const QString& section, const QString& param ) -{ - Item* i = createItem( label, type, pId ); - if ( !i ) - return -1; - - if ( !myItems.contains( i->id() ) ) - { - myItems.insert( i->id(), i ); - - i->setTitle( label ); - i->setResource( section, param ); - - if ( !i->parentItem() && !myChildren.contains( i ) ) - myChildren.append( i ); - - itemAdded( i ); - } - - return i->id(); -} -*/ - /*! \brief Get preference item option value. \param id preference item ID @@ -976,40 +953,13 @@ void QtxPreferenceMgr::fromBackup() /*! \brief Update preferences manager. - + Base implementation does nothing. */ void QtxPreferenceMgr::update() { } -/* - \brief Create preference item. - \param label preference item title - \param type preference item type - \param pId parent preference item ID - \return new item -*/ -/* -QtxPreferenceItem* QtxPreferenceMgr::createItem( const QString& label, const int type, const int pId ) -{ - Item* i = 0; - if ( pId < 0 ) - i = createItem( label, type ); - else - { - Item* pItem = item( pId ); - if ( pItem ) - { - i = pItem->createItem( label, type ); - pItem->insertChild( i ); - } - } - - return i; -} -*/ - /*! \brief Get all resources items values. \param map used as container filled with the resources values (:) @@ -1124,7 +1074,7 @@ void QtxPreferenceMgr::differentValues( const ResourceMap& map1, const ResourceM This method is called from store() and fromBackup() methods. Base implementation does nothing. - + \sa store(), fromBackup() */ void QtxPreferenceMgr::changedResources( const ResourceMap& ) diff --git a/src/Qtx/QtxPreferenceMgr.h b/src/Qtx/QtxPreferenceMgr.h index 7022351f9..1b99d84ad 100644 --- a/src/Qtx/QtxPreferenceMgr.h +++ b/src/Qtx/QtxPreferenceMgr.h @@ -1,17 +1,17 @@ // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D -// +// // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either +// License as published by the Free Software Foundation; either // version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com @@ -89,6 +89,8 @@ public: virtual QtxResourceMgr* resourceMgr() const; virtual QtxPreferenceMgr* preferenceMgr() const; + void ensureVisible(); + static int RTTI(); protected: @@ -103,13 +105,15 @@ protected: void setDouble( const double ); void setBoolean( const bool ); void setColor( const QColor& ); - void setFont( const QFont& ); + void setFont( const QFont& ); void setString( const QString& ); virtual void itemAdded( QtxPreferenceItem* ); virtual void itemRemoved( QtxPreferenceItem* ); virtual void itemChanged( QtxPreferenceItem* ); + virtual void ensureVisible( QtxPreferenceItem* ); + void sendItemChanges(); virtual void triggerUpdate(); @@ -163,7 +167,7 @@ protected: void setResourceValues( QMap& ) const; void setResourceValues( ResourceMap& ) const; - + void differentValues( const QMap&, const QMap&, QMap&, const bool fromFirst = false ) const; void differentValues( const ResourceMap&, const ResourceMap&, diff --git a/src/Qtx/QtxWorkstack.cxx b/src/Qtx/QtxWorkstack.cxx index 6349b92ac..47ddd7e78 100644 --- a/src/Qtx/QtxWorkstack.cxx +++ b/src/Qtx/QtxWorkstack.cxx @@ -23,22 +23,20 @@ #include "QtxAction.h" -#include #include -#include -#include #include +#include #include +#include #include +#include +#include #include #include +#include #include #include #include -#include -#include - -#define DARK_COLOR_LIGHT 250 /*! \class QtxWorkstackArea::WidgetEvent @@ -1495,6 +1493,13 @@ QtxWorkstack::QtxWorkstack( QWidget* parent ) connect( myActionsMap[Close], SIGNAL( triggered( bool ) ), this, SLOT( onCloseWindow() ) ); connect( myActionsMap[Rename], SIGNAL( triggered( bool ) ), this, SLOT( onRename() ) ); + // Action shortcut will work when action added in any widget. + for ( QMap::iterator it = myActionsMap.begin(); it != myActionsMap.end(); ++it ) + { + addAction( it.value() ); + it.value()->setShortcutContext( Qt::ApplicationShortcut ); + } + QVBoxLayout* base = new QVBoxLayout( this ); base->setMargin( 0 ); diff --git a/src/SUIT/SUIT_PreferenceMgr.cxx b/src/SUIT/SUIT_PreferenceMgr.cxx index 0424de3ca..191eef251 100644 --- a/src/SUIT/SUIT_PreferenceMgr.cxx +++ b/src/SUIT/SUIT_PreferenceMgr.cxx @@ -1,17 +1,17 @@ // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D -// +// // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either +// License as published by the Free Software Foundation; either // version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com @@ -76,7 +76,7 @@ int SUIT_PreferenceMgr::addItem( const QString& title, const int pId, QtxPreferenceItem* item = parent->findItem( title, true ); - if ( item ) + if ( item && item->depth() < 4 ) return item->id(); if ( pId == -1 ) diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 71bcbed49..b74ed59fb 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -827,7 +827,7 @@ void SalomeApp_Application::createPreferences( LightApp_Preferences* pref ) pref->addPreference( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i-1 ).toLatin1() ), defCols, LightApp_Preferences::Bool, "ObjectBrowser", QString().sprintf( "visibility_column_%d", i-1 ) ); } - pref->setItemProperty( "columns", 1, defCols ); + pref->setItemProperty( "orientation", Qt::Vertical, defCols ); // adding preference to LightApp_Application handled preferences.. a bit of hacking with resources.. int genTab = pref->addPreference( LightApp_Application::tr( "PREF_TAB_GENERAL" ), salomeCat ); -- 2.39.2