From: nds Date: Tue, 7 Oct 2008 07:08:56 +0000 (+0000) Subject: Merging GUI_SRC module with the BR_HDF_dev_merged branch, which has been merged with... X-Git-Tag: TG_mergeto_BR_V5_DEV_finished~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=649f37d7d8929098446a31943b81584c323c5fdd;p=modules%2Fgui.git Merging GUI_SRC module with the BR_HDF_dev_merged branch, which has been merged with the BR_V5_DEV branch. --- diff --git a/src/STD/STD_Application.cxx b/src/STD/STD_Application.cxx index 35b80fc39..8af1e6246 100755 --- a/src/STD/STD_Application.cxx +++ b/src/STD/STD_Application.cxx @@ -199,11 +199,11 @@ void STD_Application::createActions() Qt::SHIFT+Qt::Key_A, desk, false, this, SLOT( onHelpAbout() ) ); - QtxDockAction* dwa = new QtxDockAction( tr( "TOT_DOCKWINDOWS" ), tr( "MEN_DOCKWINDOWS" ), desk ); + QtxDockAction* dwa = new QtxDockAction( tr( "TOT_DOCKWINDOWS" ), tr( "MEN_DESK_VIEW_DOCKWINDOWS" ), desk ); dwa->setDockType( QtxDockAction::DockWidget ); registerAction( ViewWindowsId, dwa ); - QtxDockAction* tba = new QtxDockAction( tr( "TOT_TOOLBARS" ), tr( "MEN_TOOLBARS" ), desk ); + QtxDockAction* tba = new QtxDockAction( tr( "TOT_TOOLBARS" ), tr( "MEN_DESK_VIEW_TOOLBARS" ), desk ); tba->setDockType( QtxDockAction::ToolBar ); registerAction( ViewToolBarsId, tba ); @@ -302,7 +302,7 @@ bool STD_Application::onNewDoc( const QString& name ) void STD_Application::onOpenDoc() { // It is preferrable to use OS-specific file dialog box here !!! - QString aName = getFileName( true, QString::null, getFileFilter(), QString::null, 0 ); + QString aName = getFileName( true, QString(), getFileFilter(), QString(), 0 ); if ( aName.isNull() ) return; @@ -314,76 +314,13 @@ bool STD_Application::onOpenDoc( const QString& aName ) { QApplication::setOverrideCursor( Qt::WaitCursor ); - bool res = true; - if ( !activeStudy() ) - { - // if no study - open in current desktop - res = useFile( aName ); - } - else - { - // if study exists - open in new desktop. Check: is the same file is opened? - SUIT_Session* aSession = SUIT_Session::session(); - QList aAppList = aSession->applications(); - bool isAlreadyOpen = false; - SUIT_Application* aApp = 0; - for ( QList::iterator it = aAppList.begin(); it != aAppList.end() && !isAlreadyOpen; ++it ) - { - aApp = *it; - if ( aApp->activeStudy()->studyName() == aName ) - isAlreadyOpen = true; - } - if ( !isAlreadyOpen ) - { - aApp = startApplication( 0, 0 ); - if ( aApp ) - res = aApp->useFile( aName ); - if ( !res ) - aApp->closeApplication(); - } - else - aApp->desktop()->activateWindow(); - } - + bool res = openAction( openChoice( aName ), aName ); + QApplication::restoreOverrideCursor(); return res; } -/*! \retval true, if document was loaded successful, else false.*/ -bool STD_Application::onLoadDoc( const QString& 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; - SUIT_Application* aApp = 0; - for ( QList::iterator it = aAppList.begin(); it != aAppList.end() && !isAlreadyOpen; ++it ) - { - aApp = *it; - if ( aApp->activeStudy()->studyName() == aName ) - isAlreadyOpen = true; - } - if ( !isAlreadyOpen ) - { - aApp = startApplication( 0, 0 ); - if ( aApp ) - res = aApp->useStudy( aName ); - } - else - aApp->desktop()->activateWindow(); - } - return res; -} - /*!Virtual function. Not implemented here.*/ void STD_Application::beforeCloseDoc( SUIT_Study* ) { @@ -412,7 +349,6 @@ void STD_Application::onCloseDoc( bool ask ) clearViewManagers(); setActiveStudy( 0 ); - delete study; int aNbStudies = 0; QList apps = SUIT_Session::session()->applications(); @@ -430,6 +366,9 @@ void STD_Application::onCloseDoc( bool ask ) updateCommandsStatus(); } + // IPAL19532: deleting study should be performed after calling setDesktop(0) + delete study; + afterCloseDoc(); if ( !desktop() ) @@ -489,6 +428,58 @@ bool STD_Application::closeAction( const int choice, bool& closePermanently ) return res; } +int STD_Application::openChoice( const QString& aName ) +{ + SUIT_Session* aSession = SUIT_Session::session(); + + bool isAlreadyOpen = false; + QList aAppList = aSession->applications(); + for ( QList::iterator it = aAppList.begin(); it != aAppList.end() && !isAlreadyOpen; ++it ) + isAlreadyOpen = (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName; + return isAlreadyOpen ? OpenExist : OpenNew; +} + +bool STD_Application::openAction( const int choice, const QString& aName ) +{ + bool res = true; + switch ( choice ) + { + case OpenExist: + { + SUIT_Application* aApp = 0; + SUIT_Session* aSession = SUIT_Session::session(); + QList aAppList = aSession->applications(); + for ( QList::iterator it = aAppList.begin(); it != aAppList.end() && !aApp; ++it ) + { + if ( (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName ) + aApp = *it; + } + if ( aApp ) + aApp->desktop()->activateWindow(); + else + res = false; + } + break; + case OpenNew: + if ( !activeStudy() ) + res = useFile( aName ); + else + { + SUIT_Application* aApp = startApplication( 0, 0 ); + if ( aApp ) + res = aApp->useFile( aName ); + if ( !res ) + aApp->closeApplication(); + } + break; + case OpenCancel: + default: + res = false; + } + + return res; +} + /*!Save document if all ok, else error message.*/ void STD_Application::onSaveDoc() { @@ -533,7 +524,7 @@ bool STD_Application::onSaveAsDoc() bool isOk = false; while ( !isOk ) { - QString aName = getFileName( false, study->studyName(), getFileFilter(), QString::null, 0 ); + QString aName = getFileName( false, study->studyName(), getFileFilter(), QString(), 0 ); if ( aName.isNull() ) return false; @@ -623,6 +614,8 @@ void STD_Application::updateDesktopTitle() /*!Update commands status.*/ void STD_Application::updateCommandsStatus() { + SUIT_Application::updateCommandsStatus(); + bool aHasStudy = activeStudy() != 0; bool aIsNeedToSave = false; if ( aHasStudy ) @@ -849,7 +842,7 @@ QString STD_Application::getFileName( bool open, const QString& initial, const Q SUIT_MessageBox::Yes | SUIT_MessageBox::No | SUIT_MessageBox::Cancel, SUIT_MessageBox::Yes ); if ( aAnswer == SUIT_MessageBox::Cancel ) { // cancelled - aName = QString::null; + aName = QString(); isOk = true; } else if ( aAnswer == SUIT_MessageBox::No ) // not save to this file diff --git a/src/STD/STD_Application.h b/src/STD/STD_Application.h index 3ff6d57bc..77f2ed646 100755 --- a/src/STD/STD_Application.h +++ b/src/STD/STD_Application.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 @@ -50,12 +50,10 @@ class STD_EXPORT STD_Application : public SUIT_Application public: enum { FileNewId, FileOpenId, FileCloseId, FileSaveId, FileSaveAsId, FileExitId, - ViewWindowsId, ViewToolBarsId, ViewStatusBarId, NewWindowId, + ViewWindowsId, ViewToolBarsId, ViewStatusBarId, NewWindowId, EditCutId, EditCopyId, EditPasteId, HelpAboutId, UserID }; - enum { CloseSave, CloseDiscard, CloseCancel }; - -public: + public: STD_Application(); virtual ~STD_Application(); @@ -82,8 +80,8 @@ public: void viewManagers( ViewManagerList& ) const; void viewManagers( const QString&, ViewManagerList& ) const; - virtual QString getFileFilter() const { return QString::null; } - virtual QString getFileName( bool open, const QString& initial, const QString& filters, + virtual QString getFileFilter() const { return QString(); } + virtual QString getFileName( bool open, const QString& initial, const QString& filters, const QString& caption, QWidget* parent ); QString getDirectory( const QString& initial, const QString& caption, QWidget* parent ); @@ -115,8 +113,6 @@ public slots: virtual void onOpenDoc(); virtual bool onOpenDoc( const QString& ); - virtual bool onLoadDoc( const QString& ); - virtual void onExit(); virtual void onCopy(); @@ -139,6 +135,9 @@ protected: MenuHelpId = 7 }; + enum { OpenCancel, OpenNew, OpenExist }; + enum { CloseCancel, CloseSave, CloseDiscard }; + protected: virtual void createActions(); virtual void updateDesktopTitle(); @@ -158,8 +157,11 @@ protected: virtual void setActiveViewManager( SUIT_ViewManager* ); - virtual bool closeAction( const int, bool& ); + virtual int openChoice( const QString& ); + virtual bool openAction( const int, const QString& ); + virtual int closeChoice( const QString& ); + virtual bool closeAction( const int, bool& ); private: ViewManagerList myViewMgrs; diff --git a/src/STD/STD_MDIDesktop.cxx b/src/STD/STD_MDIDesktop.cxx index db06097f2..7fc268671 100755 --- a/src/STD/STD_MDIDesktop.cxx +++ b/src/STD/STD_MDIDesktop.cxx @@ -22,23 +22,22 @@ #include #include -#include +#include #include -//#include +#include -#include -#include -#include -#include -#include +#include +#include #include -/*!Constructor.*/ +/*! + Constructor. +*/ STD_MDIDesktop::STD_MDIDesktop() : SUIT_Desktop(), -myWorkspace( 0 )//, -//myWorkspaceAction( 0 ) +myWorkspace( 0 ), +myWorkspaceAction( 0 ) { QFrame* base = new QFrame( this ); QVBoxLayout* main = new QVBoxLayout( base ); @@ -47,7 +46,7 @@ myWorkspace( 0 )//, setCentralWidget( base ); - myWorkspace = new QWorkspace( base ); + myWorkspace = new QtxWorkspace( base ); main->addWidget( myWorkspace ); connect( myWorkspace, SIGNAL( windowActivated( QWidget* ) ), @@ -56,12 +55,16 @@ myWorkspace( 0 )//, createActions(); } -/*!destructor.*/ +/*! + Destructor. +*/ STD_MDIDesktop::~STD_MDIDesktop() { } -/*!\retval SUIT_ViewWindow - return const active window.*/ +/*! + \retval SUIT_ViewWindow - return const active window. +*/ SUIT_ViewWindow* STD_MDIDesktop::activeWindow() const { SUIT_ViewWindow* wnd = 0; @@ -73,7 +76,9 @@ SUIT_ViewWindow* STD_MDIDesktop::activeWindow() const return wnd; } -/*!\retval QPtrList - return const active window list.*/ +/*! + \retval QList - return const active window list. +*/ QList STD_MDIDesktop::windows() const { QList winList; @@ -89,7 +94,9 @@ QList STD_MDIDesktop::windows() const return winList; } -/*! add the new widget into desktop.*/ +/*! + Add the new widget into desktop. +*/ void STD_MDIDesktop::addWindow( QWidget* w ) { if ( !w || !workspace() ) @@ -101,25 +108,25 @@ void STD_MDIDesktop::addWindow( QWidget* w ) /*!Call method perform for operation \a type.*/ void STD_MDIDesktop::windowOperation( const int type ) { - //myWorkspaceAction->perform( operationFlag( type ) ); + myWorkspaceAction->perform( operationFlag( type ) ); } /*!Sets window operations by \a first ... parameters.*/ void STD_MDIDesktop::setWindowOperations( const int first, ... ) { va_list ints; - va_start( ints, first ); - - QList typeList; + va_start( ints, first ); - int cur = first; - while ( cur ) - { - typeList.append( cur ); - cur = va_arg( ints, int ); + QList typeList; + + int cur = first; + while ( cur ) + { + typeList.append( cur ); + cur = va_arg( ints, int ); } - setWindowOperations( typeList ); + setWindowOperations( typeList ); } /*!Sets window operations by variable \a opList - operation list.*/ @@ -130,26 +137,31 @@ void STD_MDIDesktop::setWindowOperations( const QList& opList ) for ( QList::const_iterator it = opList.begin(); it != opList.end(); ++it ) flags = flags | operationFlag( *it ); -// myWorkspaceAction->setItems( flags ); + myWorkspaceAction->setMenuActions( flags ); } -/*!\retval QWorkspace pointer - work space.*/ -QWorkspace* STD_MDIDesktop::workspace() const +/*! + \retval QtxWorkspace pointer - work space. +*/ +QtxWorkspace* STD_MDIDesktop::workspace() const { return myWorkspace; } -/*!Emit window activated.*/ +/*! + Emit window activated. +*/ void STD_MDIDesktop::onWindowActivated( QWidget* w ) { if ( w && w->inherits( "SUIT_ViewWindow" ) ) emit windowActivated( (SUIT_ViewWindow*)w ); } -/*!Create actions: cascade, Tile, Tile Horizontal, Tile Vertical*/ +/*! + Create actions: cascade, Tile, Tile Horizontal, Tile Vertical +*/ void STD_MDIDesktop::createActions() { -/* if ( myWorkspaceAction ) return; @@ -159,50 +171,47 @@ void STD_MDIDesktop::createActions() myWorkspaceAction = new QtxWorkspaceAction( workspace(), this ); - myWorkspaceAction->setItems( QtxWorkspaceAction::Cascade | QtxWorkspaceAction::Tile | - QtxWorkspaceAction::HTile | QtxWorkspaceAction::VTile | - QtxWorkspaceAction::Windows ); + myWorkspaceAction->setMenuActions( QtxWorkspaceAction::Cascade | QtxWorkspaceAction::Tile | + QtxWorkspaceAction::HTile | QtxWorkspaceAction::VTile | + QtxWorkspaceAction::Windows ); // Cascade - myWorkspaceAction->setIconSet( QtxWorkspaceAction::Cascade, - resMgr->loadPixmap( "STD", tr( "ICON_DESK_WINDOW_CASCADE" ) ) ); - myWorkspaceAction->setMenuText( QtxWorkspaceAction::Cascade, tr( "MEN_DESK_WINDOW_CASCADE" ) ); + myWorkspaceAction->setIcon( QtxWorkspaceAction::Cascade, + resMgr->loadPixmap( "STD", tr( "ICON_DESK_WINDOW_CASCADE" ) ) ); + myWorkspaceAction->setText( QtxWorkspaceAction::Cascade, tr( "MEN_DESK_WINDOW_CASCADE" ) ); myWorkspaceAction->setStatusTip( QtxWorkspaceAction::Cascade, tr( "PRP_DESK_WINDOW_CASCADE" ) ); // Tile - myWorkspaceAction->setIconSet( QtxWorkspaceAction::Tile, - resMgr->loadPixmap( "STD", tr( "ICON_DESK_WINDOW_TILE" ) ) ); - myWorkspaceAction->setMenuText( QtxWorkspaceAction::Tile, tr( "MEN_DESK_WINDOW_TILE" ) ); + myWorkspaceAction->setIcon( QtxWorkspaceAction::Tile, + resMgr->loadPixmap( "STD", tr( "ICON_DESK_WINDOW_TILE" ) ) ); + myWorkspaceAction->setText( QtxWorkspaceAction::Tile, tr( "MEN_DESK_WINDOW_TILE" ) ); myWorkspaceAction->setStatusTip( QtxWorkspaceAction::Tile, tr( "PRP_DESK_WINDOW_TILE" ) ); // Tile Horizontal - myWorkspaceAction->setIconSet( QtxWorkspaceAction::HTile, - resMgr->loadPixmap( "STD", tr( "ICON_DESK_WINDOW_HTILE" ) ) ); - myWorkspaceAction->setMenuText( QtxWorkspaceAction::HTile, tr( "MEN_DESK_WINDOW_HTILE" ) ); + myWorkspaceAction->setIcon( QtxWorkspaceAction::HTile, + resMgr->loadPixmap( "STD", tr( "ICON_DESK_WINDOW_HTILE" ) ) ); + myWorkspaceAction->setText( QtxWorkspaceAction::HTile, tr( "MEN_DESK_WINDOW_HTILE" ) ); myWorkspaceAction->setStatusTip( QtxWorkspaceAction::HTile, tr( "PRP_DESK_WINDOW_HTILE" ) ); // Tile Vertical - myWorkspaceAction->setIconSet( QtxWorkspaceAction::VTile, - resMgr->loadPixmap( "STD", tr( "ICON_DESK_WINDOW_VTILE" ) ) ); - myWorkspaceAction->setMenuText( QtxWorkspaceAction::VTile, tr( "MEN_DESK_WINDOW_VTILE" ) ); + myWorkspaceAction->setIcon( QtxWorkspaceAction::VTile, + resMgr->loadPixmap( "STD", tr( "ICON_DESK_WINDOW_VTILE" ) ) ); + myWorkspaceAction->setText( QtxWorkspaceAction::VTile, tr( "MEN_DESK_WINDOW_VTILE" ) ); myWorkspaceAction->setStatusTip( QtxWorkspaceAction::VTile, tr( "PRP_DESK_WINDOW_VTILE" ) ); - QtxActionMenuMgr* mMgr = menuMgr(); if ( !mMgr ) return; - int winMenuId = mMgr->insert( tr( "MEN_DESK_WINDOW" ), -1, 100, MenuWindowId ); + int winMenuId = mMgr->insert( tr( "MEN_DESK_WINDOW" ), -1, 100 ); mMgr->insert( myWorkspaceAction, winMenuId, -1 ); mMgr->insert( QtxActionMenuMgr::separator(), winMenuId, -1 ); -*/ } /*!Convert STD_MDIDesktop enumerations to QtxWorkspaceAction.*/ int STD_MDIDesktop::operationFlag( const int type ) const { int res = 0; -/* switch ( type ) { case Cascade: @@ -218,6 +227,5 @@ int STD_MDIDesktop::operationFlag( const int type ) const res = QtxWorkspaceAction::VTile; break; } -*/ return res; } diff --git a/src/STD/STD_MDIDesktop.h b/src/STD/STD_MDIDesktop.h index 3d338854a..a3506a468 100755 --- a/src/STD/STD_MDIDesktop.h +++ b/src/STD/STD_MDIDesktop.h @@ -23,10 +23,8 @@ #include -class QtxAction; -class QPopupMenu; -class QWorkspace; -//class QtxWorkspaceAction; +class QtxWorkspace; +class QtxWorkspaceAction; #if defined WIN32 #pragma warning( disable: 4251 ) @@ -36,10 +34,7 @@ class STD_EXPORT STD_MDIDesktop: public SUIT_Desktop { Q_OBJECT - class Workspace; - public: - enum { MenuWindowId = 6 }; enum { Cascade, Tile, HTile, VTile }; public: @@ -54,7 +49,7 @@ public: void setWindowOperations( const int, ... ); void setWindowOperations( const QList& ); - QWorkspace* workspace() const; + QtxWorkspace* workspace() const; private slots: void onWindowActivated( QWidget* ); @@ -67,8 +62,8 @@ private: int operationFlag( const int ) const; private: - QWorkspace* myWorkspace; -// QtxWorkspaceAction* myWorkspaceAction; + QtxWorkspace* myWorkspace; + QtxWorkspaceAction* myWorkspaceAction; }; #if defined WIN32 diff --git a/src/STD/STD_SDIDesktop.cxx b/src/STD/STD_SDIDesktop.cxx index d04923414..1c9a08fd6 100755 --- a/src/STD/STD_SDIDesktop.cxx +++ b/src/STD/STD_SDIDesktop.cxx @@ -20,11 +20,8 @@ #include -#include -#include -#include - -#include +#include +#include /*!Constructor. Create instance of QVBox*/ STD_SDIDesktop::STD_SDIDesktop()