-// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
beforeCloseDoc( study );
study->closeDocument();
-
+ emit appClosed();
setActiveStudy( 0 );
delete study;
createAction( NewWindowId, tr( "TOT_DESK_NEWWINDOW" ), QIcon(),
tr( "MEN_DESK_NEWWINDOW" ), tr( "PRP_DESK_NEWWINDOW" ), 0, desk );
- createAction( HelpAboutId, tr( "TOT_DESK_HELP_ABOUT" ), QIcon(),
+ createAction( HelpAboutId, tr( "TOT_DESK_HELP_ABOUT" ),
+ resMgr->loadPixmap( "STD", tr( "ICON_DESK_ABOUT" ) ),
tr( "MEN_DESK_HELP_ABOUT" ), tr( "PRP_DESK_HELP_ABOUT" ),
Qt::ALT+Qt::SHIFT+Qt::Key_A, desk, false, this, SLOT( onHelpAbout() ) );
createMenu( FileNewId, fileMenu, 0 );
createMenu( FileOpenId, fileMenu, 0 );
createMenu( FileReopenId, fileMenu, 0 );
- createMenu( FileCloseId, fileMenu, 5 );
- createMenu( separator(), fileMenu, -1, 5 );
createMenu( FileSaveId, fileMenu, 5 );
createMenu( FileSaveAsId, fileMenu, 5 );
+ createMenu( FileCloseId, fileMenu, 5 );
createMenu( separator(), fileMenu, -1, 5 );
createMenu( separator(), fileMenu );
// Create tool bars
- int stdTBar = createTool( tr( "INF_DESK_TOOLBAR_STANDARD" ) );
+ int stdTBar = createTool( tr( "INF_DESK_TOOLBAR_STANDARD" ), // title (language-dependant)
+ QString( "SalomeStandard" ) ); // name (language-independant)
// Create tool items
void STD_Application::onOpenDoc()
{
// It is preferrable to use OS-specific file dialog box here !!!
- QString aName = getFileName( true, QString(), getFileFilter(), QString(), 0 );
+ QString aName = getFileName( true, QString(), getFileFilter( true ), QString(), 0 );
if ( aName.isNull() )
return;
onOpenDoc( aName );
}
-/*! \retval true, if document was opened successful, else false.*/
+/*! \retval \c true, if document was opened successful, else \c false.*/
bool STD_Application::onOpenDoc( const QString& aName )
{
+ if ( !abortAllOperations() )
+ return false;
+
QApplication::setOverrideCursor( Qt::WaitCursor );
bool res = openAction( openChoice( aName ), aName );
// update views / windows / status bar / title
clearViewManagers();
setActiveStudy( 0 );
- updateDesktopTitle();
- updateCommandsStatus();
// delete study
delete study;
// post closing actions
afterCloseDoc();
+ int aNbStudies = 0;
+ QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
+ for ( int i = 0; i < apps.count(); i++ )
+ aNbStudies += apps.at( i )->getNbStudies();
+
// reload study from the file
res = useFile( studyName ) && activeStudy();
// if reloading is failed, close the desktop
- if ( !res ) {
- setDesktop( 0 );
+ if ( aNbStudies && !res )
closeApplication();
+ else
+ {
+ updateDesktopTitle();
+ updateCommandsStatus();
}
}
return res;
if ( ask && !isPossibleToClose( closePermanently ) )
return false;
+ return closeActiveDoc( closePermanently );
+}
+
+/*!Close document.*/
+bool STD_Application::closeActiveDoc( bool permanently )
+{
SUIT_Study* study = activeStudy();
+ if ( !study ) // no active study
+ return true;
beforeCloseDoc( study );
if ( study )
- study->closeDocument( closePermanently );
+ study->closeDocument( permanently );
clearViewManagers();
}
/*!Check the application on closing.
- * \retval true if possible, else false
+ * \retval \c true if possible, else \c false
*/
bool STD_Application::isPossibleToClose( bool& closePermanently )
{
int STD_Application::closeChoice( const QString& docName )
{
- int answer = SUIT_MessageBox::question( desktop(), tr( "CLOSE_STUDY" ), tr( "CLOSE_QUESTION" ).arg( docName ),
+ int answer = SUIT_MessageBox::question( desktop(), tr( "CLOSE_STUDY" ), tr( "CLOSE_QUESTION" ),
SUIT_MessageBox::Save | SUIT_MessageBox::Discard | SUIT_MessageBox::Cancel,
SUIT_MessageBox::Save );
if ( !activeStudy() )
return;
+ if ( !abortAllOperations() )
+ return;
+
bool isOk = false;
if ( activeStudy()->isSaved() )
{
onSaveAsDoc();
}
-/*! \retval TRUE, if doument saved successful, else FALSE.*/
+/*! \retval \c true, if document saved successfully, else \c false.*/
bool STD_Application::onSaveAsDoc()
{
SUIT_Study* study = activeStudy();
if ( !study )
return false;
+ if ( !abortAllOperations() )
+ return false;
+
bool isOk = false;
while ( !isOk )
{
- QString aName = getFileName( false, study->studyName(), getFileFilter(), QString(), 0 );
+ QString aName = getFileName( false, study->studyName(), getFileFilter( false ), QString(), 0 );
if ( aName.isNull() )
return false;
}
}
-/*!\retval true, if document opened successful, else false.*/
+/*!\retval \c true, if document opened successfully, else \c false.*/
bool STD_Application::useFile(const QString& theFileName)
{
bool res = SUIT_Application::useFile( theFileName );
SUIT_ViewManager* vm = 0;
for ( QList<SUIT_ViewManager*>::const_iterator it = myViewMgrs.begin(); it != myViewMgrs.end() && !vm; ++it )
{
- if ( (*it)->getType() == vmType )
+ if ( (*it)->getType() == vmType && !(*it)->getDetached())
vm = *it;
}
return vm;
}
}
-/*!\retval TRUE, if view manager \a vm, already in view manager list (\a myViewMgrs).*/
+/*!\retval \c true, if view manager \a vm, already in view manager list (\a myViewMgrs).*/
bool STD_Application::containsViewManager( SUIT_ViewManager* vm ) const
{
return myViewMgrs.contains( vm );
setActiveViewManager( vm );
}
-/*!Sets status bar show, if \on = true, else status bar hide.*/
+/*!Shows status bar, if on is \c true, else hides status bar.*/
void STD_Application::onViewStatusBar( bool on )
{
if ( on )
delete popup;
}
+/*!\retval QString - return file extension(s).*/
+QString STD_Application::getFileFilter( bool /*open*/ ) const
+{
+ return QString();
+}
+
/*!\retval QString - return file name from dialog.*/
QString STD_Application::getFileName( bool open, const QString& initial, const QString& filters,
const QString& caption, QWidget* parent )
return myViewMgrs.indexOf(const_cast<SUIT_ViewManager*>(theManager));
}
+/*!
+ \brief Abort active operations if there are any
+ \return \c false if some operation cannot be aborted
+*/
+bool STD_Application::abortAllOperations()
+{
+ return true;
+}