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 );
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;
{
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<SUIT_Application*> aAppList = aSession->applications();
- bool isAlreadyOpen = false;
- SUIT_Application* aApp = 0;
- for ( QList<SUIT_Application*>::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<SUIT_Application*> aAppList = aSession->applications();
- bool isAlreadyOpen = false;
- SUIT_Application* aApp = 0;
- for ( QList<SUIT_Application*>::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* )
{
clearViewManagers();
setActiveStudy( 0 );
- delete study;
int aNbStudies = 0;
QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
updateCommandsStatus();
}
+ // IPAL19532: deleting study should be performed after calling setDesktop(0)
+ delete study;
+
afterCloseDoc();
if ( !desktop() )
return res;
}
+int STD_Application::openChoice( const QString& aName )
+{
+ SUIT_Session* aSession = SUIT_Session::session();
+
+ bool isAlreadyOpen = false;
+ QList<SUIT_Application*> aAppList = aSession->applications();
+ for ( QList<SUIT_Application*>::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<SUIT_Application*> aAppList = aSession->applications();
+ for ( QList<SUIT_Application*>::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()
{
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;
/*!Update commands status.*/
void STD_Application::updateCommandsStatus()
{
+ SUIT_Application::updateCommandsStatus();
+
bool aHasStudy = activeStudy() != 0;
bool aIsNeedToSave = false;
if ( aHasStudy )
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
// 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
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();
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 );
virtual void onOpenDoc();
virtual bool onOpenDoc( const QString& );
- virtual bool onLoadDoc( const QString& );
-
virtual void onExit();
virtual void onCopy();
MenuHelpId = 7
};
+ enum { OpenCancel, OpenNew, OpenExist };
+ enum { CloseCancel, CloseSave, CloseDiscard };
+
protected:
virtual void createActions();
virtual void updateDesktopTitle();
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;
#include <SUIT_ViewWindow.h>
#include <SUIT_ResourceMgr.h>
-#include <QtxAction.h>
+#include <QtxWorkspace.h>
#include <QtxActionMenuMgr.h>
-//#include <QtxWorkspaceAction.h>
+#include <QtxWorkspaceAction.h>
-#include <QtGui/qframe.h>
-#include <QtGui/qlayout.h>
-#include <QtGui/qmenubar.h>
-#include <QtGui/qworkspace.h>
-#include <QtGui/qapplication.h>
+#include <QFrame>
+#include <QVBoxLayout>
#include <stdarg.h>
-/*!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 );
setCentralWidget( base );
- myWorkspace = new QWorkspace( base );
+ myWorkspace = new QtxWorkspace( base );
main->addWidget( myWorkspace );
connect( myWorkspace, SIGNAL( windowActivated( QWidget* ) ),
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;
return wnd;
}
-/*!\retval QPtrList<SUIT_ViewWindow> - return const active window list.*/
+/*!
+ \retval QList<SUIT_ViewWindow> - return const active window list.
+*/
QList<SUIT_ViewWindow*> STD_MDIDesktop::windows() const
{
QList<SUIT_ViewWindow*> winList;
return winList;
}
-/*! add the new widget into desktop.*/
+/*!
+ Add the new widget into desktop.
+*/
void STD_MDIDesktop::addWindow( QWidget* w )
{
if ( !w || !workspace() )
/*!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<int> typeList;
+ va_start( ints, first );
- int cur = first;
- while ( cur )
- {
- typeList.append( cur );
- cur = va_arg( ints, int );
+ QList<int> 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.*/
for ( QList<int>::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;
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:
res = QtxWorkspaceAction::VTile;
break;
}
-*/
return res;
}
#include <SUIT_Desktop.h>
-class QtxAction;
-class QPopupMenu;
-class QWorkspace;
-//class QtxWorkspaceAction;
+class QtxWorkspace;
+class QtxWorkspaceAction;
#if defined WIN32
#pragma warning( disable: 4251 )
{
Q_OBJECT
- class Workspace;
-
public:
- enum { MenuWindowId = 6 };
enum { Cascade, Tile, HTile, VTile };
public:
void setWindowOperations( const int, ... );
void setWindowOperations( const QList<int>& );
- QWorkspace* workspace() const;
+ QtxWorkspace* workspace() const;
private slots:
void onWindowActivated( QWidget* );
int operationFlag( const int ) const;
private:
- QWorkspace* myWorkspace;
-// QtxWorkspaceAction* myWorkspaceAction;
+ QtxWorkspace* myWorkspace;
+ QtxWorkspaceAction* myWorkspaceAction;
};
#if defined WIN32
#include <SUIT_ViewWindow.h>
-#include <QtGui/qframe.h>
-#include <QtGui/qlayout.h>
-#include <QtGui/qmenubar.h>
-
-#include <QtGui/qlabel.h>
+#include <QFrame>
+#include <QVBoxLayout>
/*!Constructor. Create instance of QVBox*/
STD_SDIDesktop::STD_SDIDesktop()