From: vsr Date: Tue, 10 Jul 2007 12:04:52 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: qt4_porting_delivery_220807~106 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5763c8957e8b1c49b4b754ea422a48889ea29904;p=modules%2Fgui.git *** empty log message *** --- diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 1c8061d3e..a255224ba 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -410,22 +410,6 @@ bool LightApp_Application::activateModule( const QString& modName ) return true; } -/*! - Opens other study into active Study. If Study is empty - creates it. - \param theName - name of study -*/ -bool LightApp_Application::useStudy(const QString& theName) -{ - createEmptyStudy(); - LightApp_Study* aStudy = dynamic_cast(activeStudy()); - bool res = false; - if (aStudy) - res = aStudy->loadDocument( theName ); - updateDesktopTitle(); - updateCommandsStatus(); - return res; -} - /*!Gets selection manager.*/ LightApp_SelectionMgr* LightApp_Application::selectionMgr() const { @@ -633,22 +617,20 @@ void LightApp_Application::onModuleActivation( const QString& modName ) icon = resourceMgr()->loadPixmap( "LightApp", tr( "APP_MODULE_BIG_ICO" ), false ); // default icon for any module bool cancelled = false; + while ( !modName.isEmpty() && !activeStudy() && !cancelled ){ LightApp_ModuleDlg aDlg( desktop(), modName, icon ); - int res = aDlg.exec(); + QMap opmap = activateModuleActions(); + for ( QMap::ConstIterator it = opmap.begin(); it != opmap.end(); ++it ) + aDlg.addButton( it.value(), it.key() ); - switch ( res ){ - case 1: - onNewDoc(); - break; - case 2: - onOpenDoc(); - break; - case 3: - //onLoadStudy(); - //break; - case 0: - default: + int res = aDlg.exec(); + if ( res ) { + // some operation is selected + moduleActionSelected( res ); + } + else { + // cancelled putInfo( tr("INF_CANCELLED") ); LightApp_ModuleAction* moduleAction = @@ -832,26 +814,6 @@ void LightApp_Application::onHelpAbout() delete dlg; } -/*! - SLOT: Loads document - \param aName - name of document -*/ -bool LightApp_Application::onLoadDoc( const QString& aName ) -{ - bool res = CAM_Application::onLoadDoc( aName ); - - /*jfa tmp:QAction* a = action( MRUId ); - if ( a && a->inherits( "QtxMRUAction" ) ) - { - QtxMRUAction* mru = (QtxMRUAction*)a; - if ( res ) - mru->insert( aName ); - else - mru->remove( aName ); - }*/ - return res; -} - /*! Private SLOT: Called on selection is changed Dispatchs active module that selection is changed @@ -1131,7 +1093,7 @@ void LightApp_Application::addWindow( QWidget* wid, const int flag, const int st } //myWindows[flag]->setResizeEnabled( true ); - myWindows[flag]->setFeatures( QDockWidget::DockWidgetClosable ); + myWindows[flag]->setFeatures( QDockWidget::AllDockWidgetFeatures ); myWindows[flag]->setObjectName( QString( "dock_window_%1" ).arg( flag ) ); //myWindows[flag]->setFixedExtentWidth( wid->width() ); //myWindows[flag]->setFixedExtentHeight( wid->height() ); @@ -2127,6 +2089,52 @@ void LightApp_Application::updateDesktopTitle() { desktop()->setWindowTitle( aTitle ); } +/*! + \brief Get map of the operations which can be performed + on the module activation. + + The method should return the map of the kind \c {:} + where \c is an integer identifier of the operation and + \c is a title for the button to be added to the + dialog box. After user selects the required operation by the + clicking the corresponding button in the dialog box, its identifier + is passed to the moduleActionSelected() method to process + the made choice. + + \return map of the operations + \sa moduleActionSelected() +*/ +QMap LightApp_Application::activateModuleActions() const +{ + QMap opmap; + opmap.insert( NewStudyId, tr( "ACTIVATE_MODULE_OP_NEW" ) ); + opmap.insert( OpenStudyId, tr( "ACTIVATE_MODULE_OP_OPEN" ) ); + return opmap; +} + +/*! + \brief Called when the used selectes required operation chosen + from "Activate module" dialog box. + + Performs the required operation according to the user choice. + + \param id operation identifier + \sa activateModuleActions() +*/ +void LightApp_Application::moduleActionSelected( const int id ) +{ + switch ( id ) { + case NewStudyId: + onNewDoc(); + break; + case OpenStudyId: + onOpenDoc(); + break; + default: + break; + } +} + /*! Updates windows after close document */ diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index df47d8ff6..3db912538 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -96,6 +96,11 @@ public: #endif PreferencesId, MRUId, ModulesListId, UserID }; + +protected: + enum { NewStudyId = 1, + OpenStudyId }; + public: LightApp_Application(); virtual ~LightApp_Application(); @@ -106,8 +111,6 @@ public: virtual CAM_Module* loadModule( const QString& ); virtual bool activateModule( const QString& ); - virtual bool useStudy( const QString& ); - LightApp_SelectionMgr* selectionMgr() const; LogWindow* logWindow(); @@ -172,7 +175,6 @@ public slots: virtual void onOpenDoc(); virtual void onHelpAbout(); virtual bool onOpenDoc( const QString& ); - virtual bool onLoadDoc( const QString& ); protected: virtual void createActions(); @@ -199,7 +201,10 @@ protected: virtual void preferencesChanged( const QString&, const QString& ); virtual void savePreferences(); virtual void updateDesktopTitle(); - + + virtual QMap activateModuleActions() const; + virtual void moduleActionSelected( const int ); + protected slots: virtual void onDesktopActivated(); diff --git a/src/LightApp/LightApp_ModuleDlg.cxx b/src/LightApp/LightApp_ModuleDlg.cxx index 7d8450dae..e164ebf27 100644 --- a/src/LightApp/LightApp_ModuleDlg.cxx +++ b/src/LightApp/LightApp_ModuleDlg.cxx @@ -16,22 +16,21 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File : LightApp_ModuleDlg.cxx -// Author : Michael Zorin (mzn) -// Module : LightApp +// File : LightApp_ModuleDlg.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +// #include -#include #include #include #include +#include -#ifndef WIN32 -using namespace std; -#endif - -/*!Default icon*/ +/*! + \brief Pixmap used as default icon for the module. + \internal +*/ static const char* const default_icon[] = { "48 48 17 1", ". c None", @@ -100,129 +99,161 @@ static const char* const default_icon[] = { "................................................", "................................................"}; -//============================================================================================================================== /*! - * LightApp_ModuleDlg::LightApp_ModuleDlg \n - * - * Constructor. - */ -//============================================================================================================================== -LightApp_ModuleDlg::LightApp_ModuleDlg ( QWidget * parent, const QString& component, const QPixmap icon ) - : QDialog ( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ) + \class LightApp_ModuleDlg + \brief A dialog box allowing to select study operation to be performed + on the module activating. + + The dialog box is shown when the user tries to activate any module + while there is no opened study. The dialog box proposes user to select + one of the possible operations which should be done before module activating, + for example, create new study or open study from the file. + The available operations are assigned by adding the buttons with the unique + identifier to the dialog box. When the user clicks any operation button, + the dialog box sets its identifier as the return code and closes. + + The typical usage of the dialog box: + \code + LightApp_ModuleDlg dlg( desktop() ); + dlg.addButton( "New study", NewStudyId ); + dlg.addButton( "Open study...", OpenStudyId ); + int ret = dlg.exec(); + switch( ret ) { + case NewStudyId: + // create new study + createNewStudy(); + break; + case OpenStudyId: + // open study from the file + // ... show dialog box to choose the file + QString fileName = QFileDialog::getOpenFileName( desktop(), "Open File" ); + if ( !fileName.isEmpty() ) + openStudy( fileName ); + break; + default: + // operation is cancelled + break; + } + \endcode + + \sa addButton() +*/ + +/*! + \brief Constructor. + \param parent parent widget + \param component module name + \param icon module icon +*/ +LightApp_ModuleDlg::LightApp_ModuleDlg( QWidget* parent, + const QString& component, + const QPixmap& icon ) +: QDialog ( parent ) { - setObjectName( "ActivateModuleDlg" ); setModal( true ); - QPixmap defaultIcon( ( const char** ) default_icon ); + QPixmap defaultIcon( default_icon ); setWindowTitle( tr( "CAPTION" ) ); - setSizeGripEnabled( TRUE ); - - QGridLayout* ActivateModuleDlgLayout = new QGridLayout( this ); - ActivateModuleDlgLayout->setMargin( 11 ); ActivateModuleDlgLayout->setSpacing( 6 ); - - // Module's name and icon - myComponentFrame = new QFrame( this ); - myComponentFrame->setObjectName( "myComponentFrame" ); - myComponentFrame->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ) ); - myComponentFrame->setMinimumHeight( 100 ); - myComponentFrame->setFrameStyle( QFrame::Box | QFrame::Sunken ); - QGridLayout* myComponentFrameLayout = new QGridLayout( myComponentFrame ); - myComponentFrameLayout->setMargin( 11 ); myComponentFrameLayout->setSpacing( 6 ); - - // --> icon - myComponentIcon = new QLabel( myComponentFrame ); - myComponentIcon->setObjectName( "myComponentIcon" ); - myComponentIcon->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); - myComponentIcon->setPixmap( !icon.isNull() ? icon : defaultIcon ); - myComponentIcon->setScaledContents( false ); - myComponentIcon->setAlignment( Qt::AlignCenter ); - // --> name - myComponentLab = new QLabel( component, myComponentFrame ); - myComponentLab->setObjectName( "myComponentLab" ); - QFont fnt = myComponentLab->font(); fnt.setBold( TRUE ); myComponentLab->setFont( fnt ); - myComponentLab->setAlignment( Qt::AlignCenter ); - - myComponentFrameLayout->addWidget( myComponentIcon, 0, 0 ); - myComponentFrameLayout->addWidget( myComponentLab, 0, 1 ); - - // Info - QVBoxLayout* infoLayout = new QVBoxLayout(); - infoLayout->setMargin( 0 ); infoLayout->setSpacing( 6 ); - - // --> top line - QFrame* myLine1 = new QFrame( this ); - myLine1->setObjectName( "myLine1" ); - myLine1->setFrameStyle( QFrame::HLine | QFrame::Plain ); - // --> info label - myInfoLabel = new QLabel( tr ("ActivateComponent_DESCRIPTION"), this ); - myInfoLabel->setObjectName( "myInfoLabel" ); - myInfoLabel->setAlignment( Qt::AlignCenter ); - // --> bottom line - QFrame* myLine2 = new QFrame( this ); - myLine2->setObjectName( "myLine2" ); - myLine2->setFrameStyle( QFrame::HLine | QFrame::Plain ); - - infoLayout->addStretch(); - infoLayout->addWidget( myLine1 ); - infoLayout->addWidget( myInfoLabel ); - infoLayout->addWidget( myLine2 ); - infoLayout->addStretch(); + // icon + QLabel* iconLab = new QLabel( this ); + iconLab->setFrameStyle( QFrame::Box | QFrame::Sunken ); + iconLab->setMinimumSize( 70, 70 ); + iconLab->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); + iconLab->setPixmap( !icon.isNull() ? icon : defaultIcon ); + iconLab->setScaledContents( false ); + iconLab->setAlignment( Qt::AlignCenter ); + + // info message + QLabel* infoLab = new QLabel( tr ( "DESCRIPTION" ).arg( component ), this ); + infoLab->setTextFormat( Qt::RichText ); + infoLab->setAlignment( Qt::AlignCenter ); // Buttons - QHBoxLayout* btnLayout = new QHBoxLayout(); - btnLayout->setMargin( 0 ); btnLayout->setSpacing( 6 ); - - // --> New - myNewBtn = new QPushButton( tr( "NEW" ), this ); - myNewBtn->setObjectName( "myNewBtn" ); - myNewBtn->setDefault( true ); myNewBtn->setAutoDefault( true ); - // --> Open - myOpenBtn = new QPushButton( tr( "OPEN" ), this ); - myOpenBtn->setObjectName( "myOpenBtn" ); - myOpenBtn->setAutoDefault( true ); - // --> Load - myLoadBtn = new QPushButton( tr( "LOAD" ), this ); - myLoadBtn->setObjectName( "myLoadBtn" ); - myLoadBtn->setAutoDefault( true ); - // --> Cancel - myCancelBtn = new QPushButton( tr( "CANCEL" ), this ); - myCancelBtn->setObjectName( "myCancelBtn" ); - myCancelBtn->setAutoDefault( true ); - - btnLayout->addWidget( myNewBtn ); - btnLayout->addWidget( myOpenBtn ); - btnLayout->addWidget( myLoadBtn ); - btnLayout->addStretch(); - btnLayout->addSpacing( 70 ); - btnLayout->addStretch(); - btnLayout->addWidget( myCancelBtn ); - - ActivateModuleDlgLayout->addWidget( myComponentFrame, 0, 0 ); - ActivateModuleDlgLayout->addLayout( infoLayout, 0, 1 ); - ActivateModuleDlgLayout->addLayout( btnLayout, 1, 0, 1, 2 ); + myButtonLayout = new QHBoxLayout(); + myButtonLayout->setMargin( 0 ); + myButtonLayout->setSpacing( 6 ); + + // + QPushButton* cancelBtn = new QPushButton( tr( "CANCEL" ), this ); + myButtonLayout->addSpacing( 70 ); + myButtonLayout->addStretch(); + myButtonLayout->addWidget( cancelBtn ); + + QGridLayout* layout = new QGridLayout( this ); + layout->setMargin( 11 ); + layout->setSpacing( 6 ); + + layout->addWidget( iconLab, 0, 0 ); + layout->addWidget( infoLab, 0, 1 ); + layout->addLayout( myButtonLayout, 1, 0, 1, 2 ); // signals and slots connections - connect( myNewBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) ); - connect( myOpenBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) ); - connect( myLoadBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) ); - connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); + connect( cancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); +} + +/*! + \brief Destructor. +*/ +LightApp_ModuleDlg::~LightApp_ModuleDlg() +{ +} + +/*! + \brief Add operation button to the dialog box. + + If the parameter \a id is equal to -1, then the + button identifier is generated automatically. + + \param button button text + \param id button identifier + \return button identifier +*/ +int LightApp_ModuleDlg::addButton( const QString& button, const int id ) +{ + static int lastId = 0; + int bid = id == -1 ? --lastId : id; + + QPushButton* b = findButton( bid ); + if ( b ) { + myButtons.remove( b ); + delete b; + } + + QPushButton* newButton = new QPushButton( button, this ); + + myButtons.insert( newButton, bid ); + myButtonLayout->insertWidget( myButtonLayout->count()-3, newButton ); + connect( newButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); + + return bid; } -//============================================================================================================================== /*! - * LightApp_ModuleDlg::onButtonClicked - * - * Buttons slot - */ -//============================================================================================================================== -void LightApp_ModuleDlg::onButtonClicked() + \brief Search button with the specified identifier. + \param id button identifier + \return button or 0 if \a id is invalid +*/ +QPushButton* LightApp_ModuleDlg::findButton( const int id ) const +{ + QPushButton* btn = 0; + for ( ButtonMap::ConstIterator it = myButtons.begin(); + it != myButtons.end() && !btn; ++it ) { + if ( it.value() == id ) + btn = it.key(); + } + return btn; +} + +/*! + \brief Called when any dialog button (except \c Cancel) + is clicked. + + Closes the dialog and sets its result code to the identifier + of the button clicked by the user. +*/ +void LightApp_ModuleDlg::accept() { QPushButton* btn = ( QPushButton* )sender(); - if ( btn == myNewBtn ) - done( 1 ); - if ( btn == myOpenBtn ) - done( 2 ); - if ( btn == myLoadBtn ) - done( 3 ); + done( myButtons[ btn ] ); } diff --git a/src/LightApp/LightApp_ModuleDlg.h b/src/LightApp/LightApp_ModuleDlg.h index 867ee7675..98ad3a69d 100644 --- a/src/LightApp/LightApp_ModuleDlg.h +++ b/src/LightApp/LightApp_ModuleDlg.h @@ -16,49 +16,45 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// SALOME SALOMEGUI : implementation of desktop and GUI kernel +// File : LightApp_ModuleDlg.h +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) // -// File : LightApp_ModuleDlg.h -// Author : Michael ZORIN (mzn) -// Module : SALOME #ifndef LIGHTAPP_MODULEDLG_H #define LIGHTAPP_MODULEDLG_H #include "LightApp.h" + #include #include +#include -class QFrame; -class QLabel; class QPushButton; +class QHBoxLayout; -/*! - \class LightApp_ModuleDlg - Dialog allows to choose action on module activation when there is no document. - It is possible to create new document, to open existing or to cancel module activation -*/ class LIGHTAPP_EXPORT LightApp_ModuleDlg : public QDialog { Q_OBJECT public: - LightApp_ModuleDlg ( QWidget* parent, const QString& component, const QPixmap icon = QPixmap() ) ; - ~LightApp_ModuleDlg ( ) { }; + LightApp_ModuleDlg( QWidget*, const QString&, const QPixmap& = QPixmap() ) ; + ~LightApp_ModuleDlg(); + + int addButton( const QString&, const int = -1); + +public slots: + void accept(); -private slots: - void onButtonClicked(); +private: + QPushButton* findButton( const int ) const; + +private: + typedef QMap ButtonMap; private: - QFrame* myComponentFrame; - QLabel* myComponentLab; - QLabel* myComponentIcon; - QLabel* myInfoLabel; - QPushButton* myNewBtn; - QPushButton* myOpenBtn; - QPushButton* myLoadBtn; - QPushButton* myCancelBtn; + ButtonMap myButtons; + QHBoxLayout* myButtonLayout; }; -#endif +#endif // LIGHTAPP_MODULEDLG_H diff --git a/src/LightApp/LightApp_NameDlg.cxx b/src/LightApp/LightApp_NameDlg.cxx index 31246058c..46517ae8b 100644 --- a/src/LightApp/LightApp_NameDlg.cxx +++ b/src/LightApp/LightApp_NameDlg.cxx @@ -16,9 +16,9 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File : LightApp_NameDlg.cxx -// Author : Vadim SANDLER -// $Header$ +// File : LightApp_NameDlg.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +// #include #include diff --git a/src/LightApp/LightApp_NameDlg.h b/src/LightApp/LightApp_NameDlg.h index 9f8f88bbb..59c9a27a3 100644 --- a/src/LightApp/LightApp_NameDlg.h +++ b/src/LightApp/LightApp_NameDlg.h @@ -16,12 +16,9 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// SALOME SalomeApp : implementation of desktop and GUI kernel +// File : LightApp_NameDlg.h +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) // -// File : LightApp_NameDlg.h -// Author : Vadim SANDLER -// Module : SALOME -// $Header$ #ifndef LIGHTAPP_NAMEDLG_H #define LIGHTAPP_NAMEDLG_H diff --git a/src/LightApp/resources/LightApp_msg_en.ts b/src/LightApp/resources/LightApp_msg_en.ts index 15a17e3e9..50a399391 100644 --- a/src/LightApp/resources/LightApp_msg_en.ts +++ b/src/LightApp/resources/LightApp_msg_en.ts @@ -313,6 +313,14 @@ CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITASTOT_DESK_MRU Most recently used + + ACTIVATE_MODULE_OP_NEW + &New + + + ACTIVATE_MODULE_OP_OPEN + &Open... + LightApp_Module @@ -368,20 +376,9 @@ CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS LightApp_ModuleDlg - NEW - &New - - - LOAD - &Load - - - OPEN - &Open - - - ActivateComponent_DESCRIPTION - Create, open or load study. + DESCRIPTION + You're activating module + <b>%1</b>.<br>Please, select required action by pressing the corresponding button below. CANCEL diff --git a/src/Qtx/QtxPagePrefMgr.cxx b/src/Qtx/QtxPagePrefMgr.cxx index 1863ed489..b28e75f66 100644 --- a/src/Qtx/QtxPagePrefMgr.cxx +++ b/src/Qtx/QtxPagePrefMgr.cxx @@ -1159,7 +1159,7 @@ bool QtxPagePrefFrameItem::stretch() const for ( int i = 0; l && i < l->count() && !s; i++ ) s = l->itemAt( i )->spacerItem(); - return s ? s->expandingDirections() & Qt::Vertical : false; + return s ? (bool)( s->expandingDirections() & Qt::Vertical ) : false; } /*! diff --git a/src/SalomeApp/Makefile.am b/src/SalomeApp/Makefile.am index 4299c0858..4361d18b1 100755 --- a/src/SalomeApp/Makefile.am +++ b/src/SalomeApp/Makefile.am @@ -98,11 +98,14 @@ libSalomeApp_la_CPPFLAGS=$(PYTHON_INCLUDES) $(QT_INCLUDES) $(QWT_INCLUDES) \ -I$(top_builddir)/salome_adm/unix @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ libSalomeApp_la_LDFLAGS=$(PYTHON_LIBS) $(QT_MT_LIBS) libSalomeApp_la_LIBADD= $(KERNEL_LDFLAGS) -lOpUtil -lSALOMELocalTrace -lSalomeDSClient \ - ../SUIT/libsuit.la ../STD/libstd.la ../CAM/libCAM.la \ #../ObjBrowser/libObjBrowser.la \ + ../SUIT/libsuit.la ../STD/libstd.la ../CAM/libCAM.la \ ../Prs/libSalomePrs.la ../SPlot2d/libSPlot2d.la ../GLViewer/libGLViewer.la \ ../OCCViewer/libOCCViewer.la ../VTKViewer/libVTKViewer.la ../OBJECT/libSalomeObject.la \ ../SVTK/libSVTK.la ../SOCC/libSOCC.la ../PyInterp/libPyInterp.la \ ../PyConsole/libPyConsole.la ../LogWindow/libLogWindow.la \ ../LightApp/libLightApp.la ../TOOLSGUI/libToolsGUI.la $(CAS_KERNEL) +# QT 4 PORTING TODO +#../ObjBrowser/libObjBrowser.la + EXTRA_DIST+=SalomeApp_PyInterp.h diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 11a4fbf70..3bbb36abc 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -421,18 +421,44 @@ void SalomeApp_Application::onLoadDoc() studyName.replace( QRegExp(":"), "/" ); #endif - if( LightApp_Application::onLoadDoc( studyName ) ) { + if ( onLoadDoc( studyName ) ) { updateWindows(); updateViewManagers(); updateObjectBrowser( true ); } } - /*!SLOT. Load document with \a aName.*/ bool SalomeApp_Application::onLoadDoc( const QString& aName ) { - return LightApp_Application::onLoadDoc( aName ); + bool res = true; + if ( !activeStudy() ) { + // if no study - load in current desktop + res = useStudy( aName ); + } + else { + // if study exists - load in new desktop. Check: is the same file is loaded? + SUIT_Session* aSession = SUIT_Session::session(); + QList aAppList = aSession->applications(); + bool isAlreadyOpen = false; + SalomeApp_Application* aApp = 0; + for ( QList::iterator it = aAppList.begin(); + it != aAppList.end() && !isAlreadyOpen; ++it ) { + aApp = dynamic_cast( *it ); + if ( aApp && aApp->activeStudy()->studyName() == aName ) + isAlreadyOpen = true; + } + if ( !isAlreadyOpen ) { + aApp = dynamic_cast( startApplication( 0, 0 ) ); + if ( aApp ) + res = aApp->useStudy( aName ); + } + else { + aApp->desktop()->activateWindow(); + } + } + + return res; } /*!SLOT. Copy objects to study maneger from selection maneger..*/ @@ -911,6 +937,45 @@ bool SalomeApp_Application::closeAction( const int choice, bool& closePermanentl return res; } +/*! + \brief Get map of the operations which can be performed + on the module activation. + + The method should return the map of the kind \c {:} + where \c is an integer identifier of the operation and + \c is a title for the button to be added to the + dialog box. After user selects the required operation by the + clicking the corresponding button in the dialog box, its identifier + is passed to the moduleActionSelected() method to process + the made choice. + + \return map of the operations + \sa moduleActionSelected() +*/ +QMap SalomeApp_Application::activateModuleActions() const +{ + QMap opmap = LightApp_Application::activateModuleActions(); + opmap.insert( LoadStudyId, tr( "ACTIVATE_MODULE_OP_LOAD" ) ); + return opmap; +} + +/*! + \brief Called when the used selectes required operation chosen + from "Activate module" dialog box. + + Performs the required operation according to the user choice. + + \param id operation identifier + \sa activateModuleActions() +*/ +void SalomeApp_Application::moduleActionSelected( const int id ) +{ + if ( id == LoadStudyId ) + onLoadDoc(); + else + LightApp_Application::moduleActionSelected( id ); +} + /*!Gets CORBA::ORB_var*/ CORBA::ORB_var SalomeApp_Application::orb() { @@ -1322,3 +1387,18 @@ void SalomeApp_Application::onDesktopMessage( const QString& message ) updateObjectBrowser(); } +/*! + Opens other study into active Study. If Study is empty - creates it. + \param theName - name of study +*/ +bool SalomeApp_Application::useStudy( const QString& theName ) +{ + createEmptyStudy(); + SalomeApp_Study* aStudy = dynamic_cast( activeStudy() ); + bool res = false; + if (aStudy) + res = aStudy->loadDocument( theName ); + updateDesktopTitle(); + updateCommandsStatus(); + return res; +} diff --git a/src/SalomeApp/SalomeApp_Application.h b/src/SalomeApp/SalomeApp_Application.h index 0b9c15f66..5ed7e0fb9 100644 --- a/src/SalomeApp/SalomeApp_Application.h +++ b/src/SalomeApp/SalomeApp_Application.h @@ -65,6 +65,9 @@ public: CatalogGenId, RegDisplayId, SaveGUIStateId, FileLoadId, UserID }; enum { CloseUnload = STD_Application::CloseCancel+1 }; +protected: + enum { LoadStudyId = OpenStudyId + 1 }; + public: SalomeApp_Application(); virtual ~SalomeApp_Application(); @@ -90,6 +93,8 @@ public: virtual bool isPossibleToClose( bool& ); + virtual bool useStudy( const QString& ); + public slots: virtual bool onOpenDoc( const QString& ); virtual void onLoadDoc(); @@ -118,6 +123,9 @@ protected: virtual bool closeAction( const int, bool& ); virtual int closeChoice( const QString& ); + virtual QMap activateModuleActions() const; + virtual void moduleActionSelected( const int ); + private slots: void onDeleteInvalidReferences(); void onDblClick( QListViewItem* ); diff --git a/src/SalomeApp/SalomeApp_ListView.cxx b/src/SalomeApp/SalomeApp_ListView.cxx index 6fcc0e80e..5da954734 100644 --- a/src/SalomeApp/SalomeApp_ListView.cxx +++ b/src/SalomeApp/SalomeApp_ListView.cxx @@ -16,12 +16,9 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// SALOME SalomeApp +// File : SalomeApp_ListView.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) // -// File : SalomeApp_ListView.cxx -// Author : Vadim SANDLER -// Module : SALOME -// $Header$ #include "SalomeApp_ListView.h" #include "SalomeApp_Application.h" diff --git a/src/SalomeApp/SalomeApp_ListView.h b/src/SalomeApp/SalomeApp_ListView.h index df4e3d792..d8d472248 100644 --- a/src/SalomeApp/SalomeApp_ListView.h +++ b/src/SalomeApp/SalomeApp_ListView.h @@ -16,11 +16,9 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// SALOME SalomeApp +// File : SalomeApp_ListView.h +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) // -// File : SalomeApp_ListView.h -// Author : Vadim SANDLER -// Module : SALOME #ifndef SALOMEAPP_LISTVIEW_H #define SALOMEAPP_LISTVIEW_H diff --git a/src/SalomeApp/resources/SalomeApp_msg_en.ts b/src/SalomeApp/resources/SalomeApp_msg_en.ts index 86d8d5598..9439392b0 100644 --- a/src/SalomeApp/resources/SalomeApp_msg_en.ts +++ b/src/SalomeApp/resources/SalomeApp_msg_en.ts @@ -229,6 +229,10 @@ Do you want to reload it ? TOT_DESK_MRU Most recently used + + ACTIVATE_MODULE_OP_LOAD + Load... + SalomeApp_StudyPropertiesDlg