From e17ca00c9822f7bd3dbbfb39d66e8c332dde51ac Mon Sep 17 00:00:00 2001 From: stv Date: Fri, 28 Nov 2008 10:16:11 +0000 Subject: [PATCH] Bug fixes for IPAL20000, IPAL20289. --- src/CAM/CAM_Module.cxx | 107 +++++++++++----------- src/LightApp/LightApp_Application.cxx | 63 ++++++++----- src/LightApp/LightApp_Application.h | 3 + src/LightApp/resources/LightApp_msg_en.ts | 4 +- src/Qtx/QtxDockWidget.cxx | 4 + src/Qtx/QtxMultiAction.cxx | 2 +- src/Qtx/QtxPagePrefMgr.cxx | 65 +++++++++++++ src/Qtx/QtxPagePrefMgr.h | 20 ++++ src/Qtx/QtxPreferenceMgr.cxx | 38 +++++++- src/Qtx/QtxPreferenceMgr.h | 3 +- src/SUIT/SUIT_Application.cxx | 39 ++++---- 11 files changed, 249 insertions(+), 99 deletions(-) diff --git a/src/CAM/CAM_Module.cxx b/src/CAM/CAM_Module.cxx index 13f20b8ec..651d4499c 100755 --- a/src/CAM/CAM_Module.cxx +++ b/src/CAM/CAM_Module.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 @@ -30,10 +30,10 @@ #include #include -/*! +/*! \class CAM_Module \brief Base implementation of the module in the CAM application architecture. - + Provides support of menu/toolbars management. */ @@ -51,7 +51,7 @@ CAM_Module::CAM_Module() /*! \brief Constructor. - + Creates module with the specified \a name. \param name module name @@ -66,7 +66,7 @@ CAM_Module::CAM_Module( const QString& name ) /*! \brief Destructor. - + Destroy data model. */ CAM_Module::~CAM_Module() @@ -78,7 +78,7 @@ CAM_Module::~CAM_Module() /*! \brief Initialize module. - This method is usually called when the module is created (for example, + This method is usually called when the module is created (for example, on the module library loading). Successor classes can use this method to create menu/toolbar actions and perform other module initialization. @@ -152,9 +152,9 @@ QString CAM_Module::moduleName() const /*! \brief Get data model. - + Creates data model, if it is not yet created. - + \return data model pointer \sa createDataModel() */ @@ -194,7 +194,7 @@ bool CAM_Module::isSelectionCompatible() for example, to show own menus, toolbars, etc. Default implementation always returns \c true. - + \return \c true if module is activated successfully. \sa initialize(), deactivateModule() */ @@ -211,7 +211,7 @@ bool CAM_Module::activateModule( SUIT_Study* /*study*/ ) for example, to hide own menus, toolbars, etc. Default implementation always returns \c true. - + \return \c true if module is deactivated successfully. \sa initialize(), activateModule() */ @@ -224,13 +224,13 @@ bool CAM_Module::deactivateModule( SUIT_Study* ) \brief Called when study is closed. Removes data model from the \a study. - + \param study study being closed */ void CAM_Module::studyClosed( SUIT_Study* study ) { CAM_Study* camDoc = dynamic_cast( study ); - if ( !camDoc ) + if ( !camDoc ) return; CAM_DataModel* dm = dataModel(); @@ -244,7 +244,7 @@ void CAM_Module::studyClosed( SUIT_Study* study ) \brief Called when study is changed (obsolete). Default implementation does nothing. - + \param oldStudy old study \param newStudy new study */ @@ -263,7 +263,7 @@ bool CAM_Module::isActiveModule() const /*! \brief Put the text message into the status bar of the application main window. - + If \a msec > 0, the message will be shown \a msec milliseconds. If \a msec < 0, the message will be constantly displayed until module is active. @@ -311,7 +311,7 @@ void CAM_Module::onApplicationClosed( SUIT_Application* theApp ) \return created data model object or 0 if it could not be created */ CAM_DataModel* CAM_Module::createDataModel() -{ +{ return new CAM_DataModel( this ); } @@ -335,7 +335,7 @@ void CAM_Module::setModuleName( const QString& name ) myName = name; } -/*! +/*! \brief Get menu manager. \return menu manager pointer */ @@ -347,7 +347,7 @@ QtxActionMenuMgr* CAM_Module::menuMgr() const return mgr; } -/*! +/*! \brief Get toolbar manager. \return toolbar manager pointer */ @@ -359,11 +359,11 @@ QtxActionToolMgr* CAM_Module::toolMgr() const return mgr; } -/*! +/*! \brief Create toolbar with speicifed \a name. If the toolbar has been already created, its ID is just returned. - + \param name toolbar name \return toolbar ID or -1 if toolbar could not be created */ @@ -379,7 +379,7 @@ int CAM_Module::createTool( const QString& name ) \brief Add toolbar item. Insert action \a to the toolbar manager and register it with specified \a id. - Resulting action ID may differ from the requested one. This can happen if + Resulting action ID may differ from the requested one. This can happen if requested ID is already in use. If action has been already added previously, its ID is just returned. @@ -387,7 +387,7 @@ int CAM_Module::createTool( const QString& name ) If \a id < 0, the action ID is generated automatically. If \a idx < 0, the action is added to the end of the toolbar. - + \param a action \param tBar toolbar ID \param id requested action ID @@ -408,7 +408,7 @@ int CAM_Module::createTool( QAction* a, const int tBar, const int id, const int \brief Add toolbar item. Insert action \a to the toolbar manager and register it with specified \a id. - Resulting action ID may differ from the requested one. This can happen if + Resulting action ID may differ from the requested one. This can happen if requested ID is already in use. If action has been already added previously, its ID is just returned. @@ -416,7 +416,7 @@ int CAM_Module::createTool( QAction* a, const int tBar, const int id, const int If \a id < 0, the action ID is generated automatically. If \a idx < 0, the action is added to the end of the toolbar. - + \param a action \param tBar toolbar name \param id requested action ID @@ -439,13 +439,13 @@ int CAM_Module::createTool( QAction* a, const QString& tBar, const int id, const Insert action with \a id identifier to the toolbar manager. It is assumed that action has been already registered. - Resulting action ID may differ from the requested one. This can happen if + Resulting action ID may differ from the requested one. This can happen if requested ID is already in use. If action has been already added previously, its ID is just returned. If \a idx < 0, the action is added to the end of the toolbar. - + \param id action ID \param tBar toolbar ID \param idx action index (desired position in the toolbar) @@ -466,13 +466,13 @@ int CAM_Module::createTool( const int id, const int tBar, const int idx ) Insert action with \a id identifier to the toolbar manager. It is assumed that action has been already registered. - Resulting action ID may differ from the requested one. This can happen if + Resulting action ID may differ from the requested one. This can happen if requested ID is already in use. If action has been already added previously, its ID is just returned. If \a idx < 0, the action is added to the end of the toolbar. - + \param id action ID \param tBar toolbar name \param idx action index (desired position in the toolbar) @@ -491,18 +491,18 @@ int CAM_Module::createTool( const int id, const QString& tBar, const int idx ) \brief Create menu or submenu. Create main menu or popup submenu and register it with specified \a id. - Resulting action ID may differ from the requested one. This can happen if + Resulting action ID may differ from the requested one. This can happen if requested ID is already in use. If \a id < 0, the menu ID is generated automatically. If menu has been already created previously, its ID is just returned. The \a menu parameter represents the menu name - it could be a sequence - of strings, separated by '|' symbol. For example, "File|Edit" means + of strings, separated by '|' symbol. For example, "File|Edit" means File->Edit submenu. If menu doesn't exist, it is created automatically. Parameter \a idx defines the index of the menu item in the menu group which - is defined by the \a group. If \a idx < 0, the menu/submenu is added to the + is defined by the \a group. If \a idx < 0, the menu/submenu is added to the end of the menu group. \param subMenu subMenu name @@ -525,18 +525,18 @@ int CAM_Module::createMenu( const QString& subMenu, const int menu, \brief Create menu or submenu. Create main menu or popup submenu and register it with specified \a id. - Resulting action ID may differ from the requested one. This can happen if + Resulting action ID may differ from the requested one. This can happen if requested ID is already in use. If \a id < 0, the menu ID is generated automatically. If menu has been already created previously, its ID is just returned. The \a menu parameter represents the menu name - it could be a sequence - of strings, separated by '|' symbol. For example, "File|Edit" means + of strings, separated by '|' symbol. For example, "File|Edit" means File->Edit submenu. If menu doesn't exist, it is created automatically. Parameter \a idx defines the index of the menu item in the menu group which - is defined by the \a group. If \a idx < 0, the menu/submenu is added to the + is defined by the \a group. If \a idx < 0, the menu/submenu is added to the end of the menu group. \param subMenu subMenu name @@ -559,7 +559,7 @@ int CAM_Module::createMenu( const QString& subMenu, const QString& menu, \brief Add menu item. Insert action \a to the menu manager and register it with specified \a id. - Resulting action ID may differ from the requested one. This can happen if + Resulting action ID may differ from the requested one. This can happen if requested ID is already in use. If \a id < 0, the action ID is generated automatically. @@ -567,7 +567,7 @@ int CAM_Module::createMenu( const QString& subMenu, const QString& menu, If action has been already added previously, its ID is just returned. Parameter \a idx defines the index of the menu item in the menu group which - is defined by the \a group. If \a idx < 0, the action is added to the + is defined by the \a group. If \a idx < 0, the action is added to the end of the menu group. \param a action @@ -591,7 +591,7 @@ int CAM_Module::createMenu( QAction* a, const int menu, const int id, const int \brief Add menu item. Insert action \a to the menu manager and register it with specified \a id. - Resulting action ID may differ from the requested one. This can happen if + Resulting action ID may differ from the requested one. This can happen if requested ID is already in use. If \a id < 0, the action ID is generated automatically. @@ -599,11 +599,11 @@ int CAM_Module::createMenu( QAction* a, const int menu, const int id, const int If action has been already added previously, its ID is just returned. The \a menu parameter represents the menu name - it could be a sequence - of strings, separated by '|' symbol. For example, "File|Edit" means + of strings, separated by '|' symbol. For example, "File|Edit" means File->Edit submenu. If menu doesn't exist, it is created automatically. Parameter \a idx defines the index of the menu item in the menu group which - is defined by the \a group. If \a idx < 0, the action is added to the + is defined by the \a group. If \a idx < 0, the action is added to the end of the menu group. \param a action @@ -629,13 +629,13 @@ int CAM_Module::createMenu( QAction* a, const QString& menu, const int id, const Insert action with \a id identifier to the menu manager. It is assumed that action has been already registered. - Resulting action ID may differ from the requested one. This can happen if + Resulting action ID may differ from the requested one. This can happen if requested ID is already in use. If action has been already added previously, its ID is just returned. Parameter \a idx defines the index of the menu item in the menu group which - is defined by the \a group. If \a idx < 0, the action is added to the + is defined by the \a group. If \a idx < 0, the action is added to the end of the menu group. \param id action ID @@ -659,17 +659,17 @@ int CAM_Module::createMenu( const int id, const int menu, const int group, const Insert action with \a id identifier to the menu manager. It is assumed that action has been already registered. - Resulting action ID may differ from the requested one. This can happen if + Resulting action ID may differ from the requested one. This can happen if requested ID is already in use. If action has been already added previously, its ID is just returned. The \a menu parameter represents the menu name - it could be a sequence - of strings, separated by '|' symbol. For example, "File|Edit" means + of strings, separated by '|' symbol. For example, "File|Edit" means File->Edit submenu. If menu doesn't exist, it is created automatically. Parameter \a idx defines the index of the menu item in the menu group which - is defined by the \a group. If \a idx < 0, the action is added to the + is defined by the \a group. If \a idx < 0, the action is added to the end of the menu group. \param id action ID @@ -813,7 +813,7 @@ int CAM_Module::actionId( const QAction* a ) const /*! \brief Create new instance of QtxAction and register action with specified \a id. - Resulting action ID may differ from the requested one. This can happen if + Resulting action ID may differ from the requested one. This can happen if requested ID is already in use. If \a id < 0, the action ID is generated automatically. @@ -875,6 +875,9 @@ int CAM_Module::registerAction( const int id, QAction* a ) if ( toolMgr() ) toolMgr()->registerAction( a ); + if ( application() && application()->desktop() ) + application()->desktop()->addAction( a ); + return ident; } @@ -918,7 +921,7 @@ bool CAM_Module::unregisterAction( QAction* a ) /*! \brief Create separator action. - + Separator action can be used in menus or toolbars. \return new separator action diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 80d7fc139..62e5a7584 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -569,7 +569,7 @@ void LightApp_Application::createActions() moduleAction->insertModule( *it, icon ); } - + connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ), this, SLOT( onModuleActivation( const QString& ) ) ); registerAction( ModulesListId, moduleAction ); } @@ -1292,7 +1292,7 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType viewMgr = new QxScene_ViewManager( activeStudy(), desktop() ); QxScene_Viewer* vm = new QxScene_Viewer(); viewMgr->setViewModel( vm ); - QxScene_ViewWindow* wnd = dynamic_cast( viewMgr->getActiveView() ); + //QxScene_ViewWindow* wnd = dynamic_cast( viewMgr->getActiveView() ); } //#ifndef DISABLE_SUPERVGRAPHVIEWER // if( vmType == SUPERVGraph_Viewer::Type() ) @@ -1311,11 +1311,10 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType { viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() ); OCCViewer_Viewer* vm; - bool staticTrihedron = resMgr->booleanValue( "OCCViewer", "static_trihedron", true ); #ifndef DISABLE_SALOMEOBJECT vm = new SOCC_Viewer(); #else - vm = new OCCViewer_Viewer( true, staticTrihedron ); + vm = new OCCViewer_Viewer( true, resMgr->booleanValue( "OCCViewer", "static_trihedron", true ) ); #endif vm->setBackgroundColor( resMgr->colorValue( "OCCViewer", "background", vm->backgroundColor() ) ); vm->setTrihedronSize( resMgr->doubleValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ) ); @@ -1700,21 +1699,30 @@ LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const that->myPrefs = _prefs_; + SUIT_ResourceMgr* resMgr = resourceMgr(); + QList appList = SUIT_Session::session()->applications(); - QListIterator appIt ( appList ); - while ( appIt.hasNext() ) + for ( QList::iterator appIt = appList.begin(); appIt != appList.end(); ++appIt ) { - SUIT_Application* anItem = appIt.next(); - if ( !anItem->inherits( "LightApp_Application" ) ) + LightApp_Application* app = ::qobject_cast( *appIt ); + if ( !app ) continue; - LightApp_Application* app = (LightApp_Application*)anItem; - QStringList modNameList; app->modules( modNameList, false ); - for ( QStringList::const_iterator it = modNameList.begin(); - it != modNameList.end(); ++it ) - _prefs_->addPreference( *it ); + + QMap iconMap; + app->moduleIconNames( iconMap ); + + for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it ) + { + if ( !app->isLibExists( *it ) ) + continue; + + int modId = _prefs_->addPreference( *it ); + if ( iconMap.contains( *it ) ) + _prefs_->setItemIcon( modId, Qtx::scaleIcon( resMgr->loadPixmap( moduleName( *it ), iconMap[*it], false ), 20 ) ); + } ModuleList modList; app->modules( modList ); @@ -1732,9 +1740,7 @@ LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const _prefs_->addPreference( mod->moduleName() ); if( toCreate ) mod->createPreferences(); - QtxPreferenceItem* item = _prefs_->findItem( mod->moduleName(), true ); - if ( item && item->isEmpty() ) - delete item; + that->emptyPreferences( mod->moduleName() ); } } } @@ -1761,12 +1767,24 @@ void LightApp_Application::moduleAdded( CAM_Module* mod ) { myPrefs->addPreference( mod->moduleName() ); lightMod->createPreferences(); - QtxPreferenceItem* item = myPrefs->findItem( mod->moduleName(), true ); - if ( item && item->isEmpty() ) - delete item; + emptyPreferences( mod->moduleName() ); } } +void LightApp_Application::emptyPreferences( const QString& modName ) +{ + QtxPreferenceItem* item = myPrefs->findItem( modName, true ); + if ( !item || !item->isEmpty() ) + return; + + QtxPagePrefFrameItem* frm = new QtxPagePrefFrameItem( item->title(), item->parentItem() ); + frm->setIcon( item->icon() ); + frm->setStretch( false ); + item->parentItem()->insertItem( frm, item ); + new QtxPagePrefLabelItem( Qt::AlignCenter, tr( "PREFERENCES_NOT_SUPPORTED" ).arg( modName ), frm ); + delete item; +} + /*! Create preferences */ @@ -1779,6 +1797,7 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) QList anIndicesList; int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) ); + pref->setItemIcon( salomeCat, Qtx::scaleIcon( resourceMgr()->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false ), 20 ) ); int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat ); int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab ); @@ -1814,9 +1833,9 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) int supervGroup = pref->addPreference( tr( "PREF_GROUP_SUPERV" ), viewTab ); - pref->setItemProperty( "columns", 4, occGroup ); + pref->setItemProperty( "columns", 2, occGroup ); pref->setItemProperty( "columns", 1, vtkGroup ); - pref->setItemProperty( "columns", 4, plot2dGroup ); + pref->setItemProperty( "columns", 2, plot2dGroup ); // OCC Viewer int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occGroup, @@ -2180,7 +2199,7 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString #endif #ifndef DISABLE_VTKVIEWER - if ( sec == QString( "VTKViewer" ) && (param == QString( "spacemouse_func1_btn" ) || + if ( sec == QString( "VTKViewer" ) && (param == QString( "spacemouse_func1_btn" ) || param == QString( "spacemouse_func2_btn" ) || param == QString( "spacemouse_func5_btn" ) ) ) { diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index 0ae88f775..103cfaddd 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -246,6 +246,9 @@ protected: void showPreferences( const QString& = QString() ); +private: + void emptyPreferences( const QString& ); + protected: typedef QPointer WinPtr; typedef QMap WinMap; diff --git a/src/LightApp/resources/LightApp_msg_en.ts b/src/LightApp/resources/LightApp_msg_en.ts index 0c8e44c89..6a0e6dff6 100644 --- a/src/LightApp/resources/LightApp_msg_en.ts +++ b/src/LightApp/resources/LightApp_msg_en.ts @@ -591,8 +591,8 @@ File does not exist Full - - + PREFERENCES_NOT_SUPPORTED + Preferences for module "%1" not supported diff --git a/src/Qtx/QtxDockWidget.cxx b/src/Qtx/QtxDockWidget.cxx index fde9657d5..a2efaca39 100644 --- a/src/Qtx/QtxDockWidget.cxx +++ b/src/Qtx/QtxDockWidget.cxx @@ -374,6 +374,10 @@ QSize QtxDockWidget::sizeHint() const { QSize sz = QDockWidget::sizeHint(); + printf( "----------------> QtxDockWidget::sizeHint()\n" ); + + return QSize( 500, 100 ); + return sz; } diff --git a/src/Qtx/QtxMultiAction.cxx b/src/Qtx/QtxMultiAction.cxx index 88e2b764b..a70bf021c 100644 --- a/src/Qtx/QtxMultiAction.cxx +++ b/src/Qtx/QtxMultiAction.cxx @@ -328,7 +328,7 @@ QWidget* QtxMultiAction::createWidget( QWidget* parent ) if ( !tb ) return 0; - QToolButton* w = new Button( tb ); + QToolButton* w = new QToolButton( tb ); w->setMenu( new Menu( w ) ); w->setMouseTracking( true ); w->setFocusPolicy( Qt::NoFocus ); diff --git a/src/Qtx/QtxPagePrefMgr.cxx b/src/Qtx/QtxPagePrefMgr.cxx index 30a08cea6..5ace6c4d7 100644 --- a/src/Qtx/QtxPagePrefMgr.cxx +++ b/src/Qtx/QtxPagePrefMgr.cxx @@ -1720,6 +1720,71 @@ void QtxPagePrefGroupItem::updateGroup() } } +/*! + \class QtxPagePrefLabelItem + \brief Label item which can be used in the preferences editor dialog box. +*/ + +/*! + \brief Constructor. + + Creates label item with specified title. + + \param text label text + \param parent parent preference item +*/ +QtxPagePrefLabelItem::QtxPagePrefLabelItem( const QString& text, QtxPreferenceItem* parent ) +: QtxPagePrefItem( text, parent ) +{ + setWidget( myLabel = new QLabel( text ) ); +} + +QtxPagePrefLabelItem::QtxPagePrefLabelItem( Qt::Alignment align, const QString& text, QtxPreferenceItem* parent ) +: QtxPagePrefItem( text, parent ) +{ + setWidget( myLabel = new QLabel( text ) ); + myLabel->setAlignment( align ); +} + +QtxPagePrefLabelItem::~QtxPagePrefLabelItem() +{ +} + +void QtxPagePrefLabelItem::setTitle( const QString& text ) +{ + QtxPagePrefItem::setTitle( text ); + + if ( myLabel ) + myLabel->setText( text ); +} + +Qt::Alignment QtxPagePrefLabelItem::alignment() const +{ + return myLabel->alignment(); +} + +void QtxPagePrefLabelItem::setAlignment( Qt::Alignment align ) +{ + myLabel->setAlignment( align ); +} + +QVariant QtxPagePrefLabelItem::optionValue( const QString& name ) const +{ + QVariant val; + if ( name == "alignment" ) + val = (int)alignment(); + return val; +} + +void QtxPagePrefLabelItem::setOptionValue( const QString& name, const QVariant& val ) +{ + if ( name == "alignment" ) + { + if ( val.canConvert( QVariant::Int ) ) + setAlignment( (Qt::Alignment)val.toInt() ); + } +} + /*! \class QtxPagePrefSpaceItem \brief Simple spacer item which can be used in the preferences diff --git a/src/Qtx/QtxPagePrefMgr.h b/src/Qtx/QtxPagePrefMgr.h index 40d0dd992..2169bfe42 100644 --- a/src/Qtx/QtxPagePrefMgr.h +++ b/src/Qtx/QtxPagePrefMgr.h @@ -326,6 +326,26 @@ private: QtxGroupBox* myGroup; }; +class QTX_EXPORT QtxPagePrefLabelItem : public QtxPagePrefItem +{ +public: + QtxPagePrefLabelItem( const QString&, QtxPreferenceItem* = 0 ); + QtxPagePrefLabelItem( Qt::Alignment, const QString&, QtxPreferenceItem* = 0 ); + virtual ~QtxPagePrefLabelItem(); + + virtual void setTitle( const QString& ); + + Qt::Alignment alignment() const; + void setAlignment( Qt::Alignment ); + +protected: + virtual QVariant optionValue( const QString& ) const; + virtual void setOptionValue( const QString&, const QVariant& ); + +private: + QPointer myLabel; +}; + class QTX_EXPORT QtxPagePrefSpaceItem : public QtxPagePrefItem { public: diff --git a/src/Qtx/QtxPreferenceMgr.cxx b/src/Qtx/QtxPreferenceMgr.cxx index e3212ca7e..736c9a7e8 100644 --- a/src/Qtx/QtxPreferenceMgr.cxx +++ b/src/Qtx/QtxPreferenceMgr.cxx @@ -245,16 +245,41 @@ QtxPreferenceItem* QtxPreferenceItem::parentItem() const \param item item to be added \sa removeItem() */ -void QtxPreferenceItem::insertItem( QtxPreferenceItem* item ) +void QtxPreferenceItem::appendItem( QtxPreferenceItem* item ) { - if ( !item || myChildren.contains( item ) ) + insertItem( item, 0 ); +} + +/*! + \brief Insert child preference item before specified item. + If the before item is 0 then new item is appended. + + Removes (if necessary) the item from the previous parent. + + \param item item to be added + \param before item before which is inserted new \aitem + \sa removeItem() +*/ +void QtxPreferenceItem::insertItem( QtxPreferenceItem* item, QtxPreferenceItem* before ) +{ + if ( !item ) + return; + + if ( myChildren.contains( item ) && item == before ) return; + if ( myChildren.contains( item ) ) + myChildren.removeAll( item ); + + int idx = myChildren.indexOf( before ); + if ( idx < 0 ) + idx = myChildren.count(); + if ( item->parentItem() && item->parentItem() != this ) item->parentItem()->removeItem( item ); item->myParent = this; - myChildren.append( item ); + myChildren.insert( idx, item ); itemAdded( item ); } @@ -781,6 +806,8 @@ QVariant QtxPreferenceItem::optionValue( const QString& name ) const QVariant val; if ( name == "eval" || name == "evaluation" || name == "subst" || name == "substitution" ) val = isEvaluateValues(); + else if ( name == "title" ) + val = title(); return val; } @@ -801,6 +828,11 @@ void QtxPreferenceItem::setOptionValue( const QString& name, const QVariant& val if ( val.canConvert( QVariant::Bool ) ) setEvaluateValues( val.toBool() ); } + else if ( name == "title" ) + { + if ( val.canConvert( QVariant::String ) ) + setTitle( val.toString() ); + } } /*! diff --git a/src/Qtx/QtxPreferenceMgr.h b/src/Qtx/QtxPreferenceMgr.h index 244d6b360..de6bb409d 100644 --- a/src/Qtx/QtxPreferenceMgr.h +++ b/src/Qtx/QtxPreferenceMgr.h @@ -57,8 +57,9 @@ public: int count() const; virtual bool isEmpty() const; - void insertItem( QtxPreferenceItem* ); + void appendItem( QtxPreferenceItem* ); void removeItem( QtxPreferenceItem* ); + void insertItem( QtxPreferenceItem*, QtxPreferenceItem* = 0 ); QIcon icon() const; QString title() const; diff --git a/src/SUIT/SUIT_Application.cxx b/src/SUIT/SUIT_Application.cxx index ead59e4c4..7a9db1407 100755 --- a/src/SUIT/SUIT_Application.cxx +++ b/src/SUIT/SUIT_Application.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 @@ -61,7 +61,7 @@ SUIT_Application::SUIT_Application() /*! Destructor */ -SUIT_Application::~SUIT_Application() +SUIT_Application::~SUIT_Application() { SUIT_Study* s = myStudy; setActiveStudy( 0 ); @@ -79,7 +79,7 @@ SUIT_Desktop* SUIT_Application::desktop() } /*! - \return FALSE if application can not be closed (because of non saved data for example). + \return FALSE if application can not be closed (because of non saved data for example). This method called by SUIT_Session whin closing of application was requested. */ bool SUIT_Application::isPossibleToClose( bool& ) @@ -151,7 +151,7 @@ void SUIT_Application::createEmptyStudy() } /*! - \return number of Studies. + \return number of Studies. Must be redefined in Applications which support several studies for one Application instance. */ int SUIT_Application::getNbStudies() const @@ -173,7 +173,7 @@ SUIT_ResourceMgr* SUIT_Application::resourceMgr() const #define DEFAULT_MESSAGE_DELAY 3000 /*! - Puts the message to the status bar + Puts the message to the status bar \param msg - text of message \param msec - time in milliseconds, after that the status label will be cleared */ @@ -283,12 +283,12 @@ void SUIT_Application::setActiveStudy( SUIT_Study* study ) return; if ( myStudy ) - disconnect( myStudy, SIGNAL( studyModified( SUIT_Study* ) ), + disconnect( myStudy, SIGNAL( studyModified( SUIT_Study* ) ), this, SLOT( updateCommandsStatus() ) ); if ( study ) - connect( study, SIGNAL( studyModified( SUIT_Study* ) ), + connect( study, SIGNAL( studyModified( SUIT_Study* ) ), this, SLOT( updateCommandsStatus() ) ); - + myStudy = study; } @@ -490,7 +490,7 @@ void SUIT_Application::setMenuShown( QAction* a, const bool on ) { if ( !a || !desktop() ) return; - + QtxActionMenuMgr* mMgr = desktop()->menuMgr(); if ( mMgr ) mMgr->setShown( mMgr->actionId( a ), on ); @@ -515,7 +515,7 @@ void SUIT_Application::setToolShown( QAction* a, const bool on ) { if ( !a || !desktop() ) return; - + QtxActionToolMgr* tMgr = desktop()->toolMgr(); if ( tMgr ) tMgr->setShown( tMgr->actionId( a ), on ); @@ -633,7 +633,7 @@ int SUIT_Application::registerAction( const int id, QAction* a ) static int generatedId = -1; ident = id == -1 ? --generatedId : id; - if ( action( ident ) ) + if ( action( ident ) ) qWarning( "Action registration id is already in use: %d", ident ); myActionMap.insert( ident, a ); @@ -644,6 +644,9 @@ int SUIT_Application::registerAction( const int id, QAction* a ) if ( desktop() && desktop()->toolMgr() ) desktop()->toolMgr()->registerAction( a ); + if ( desktop() ) + desktop()->addAction( a ); + return ident; } -- 2.39.2