Salome HOME
projects
/
modules
/
gui.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Enable back CAF package.
[modules/gui.git]
/
src
/
STD
/
STD_Application.cxx
diff --git
a/src/STD/STD_Application.cxx
b/src/STD/STD_Application.cxx
index 8ed218f1d59ed1d805b7ee0e8771af1e9c47cb7f..d252e149199e4b51c1f7d1fcbe4bab3f99aed980 100755
(executable)
--- a/
src/STD/STD_Application.cxx
+++ b/
src/STD/STD_Application.cxx
@@
-1,4
+1,4
@@
-// Copyright (C) 2007-201
4
CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-201
6
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
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@
-111,7
+111,7
@@
void STD_Application::closeApplication()
beforeCloseDoc( study );
study->closeDocument();
beforeCloseDoc( study );
study->closeDocument();
-
+ emit appClosed();
setActiveStudy( 0 );
delete study;
setActiveStudy( 0 );
delete study;
@@
-229,10
+229,9
@@
void STD_Application::createActions()
createMenu( FileNewId, fileMenu, 0 );
createMenu( FileOpenId, fileMenu, 0 );
createMenu( FileReopenId, fileMenu, 0 );
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( FileSaveId, fileMenu, 5 );
createMenu( FileSaveAsId, fileMenu, 5 );
+ createMenu( FileCloseId, fileMenu, 5 );
createMenu( separator(), fileMenu, -1, 5 );
createMenu( separator(), fileMenu );
createMenu( separator(), fileMenu, -1, 5 );
createMenu( separator(), fileMenu );
@@
-253,7
+252,8
@@
void STD_Application::createActions()
// Create tool bars
// 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
// Create tool items
@@
-314,16
+314,19
@@
bool STD_Application::onNewDoc( const QString& name )
void STD_Application::onOpenDoc()
{
// It is preferrable to use OS-specific file dialog box here !!!
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 );
}
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 )
{
bool STD_Application::onOpenDoc( const QString& aName )
{
+ if ( !abortAllOperations() )
+ return false;
+
QApplication::setOverrideCursor( Qt::WaitCursor );
bool res = openAction( openChoice( aName ), aName );
QApplication::setOverrideCursor( Qt::WaitCursor );
bool res = openAction( openChoice( aName ), aName );
@@
-356,8
+359,6
@@
bool STD_Application::onReopenDoc()
// update views / windows / status bar / title
clearViewManagers();
setActiveStudy( 0 );
// update views / windows / status bar / title
clearViewManagers();
setActiveStudy( 0 );
- updateDesktopTitle();
- updateCommandsStatus();
// delete study
delete study;
// delete study
delete study;
@@
-366,13
+367,21
@@
bool STD_Application::onReopenDoc()
// post closing actions
afterCloseDoc();
// 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
// reload study from the file
res = useFile( studyName ) && activeStudy();
// if reloading is failed, close the desktop
- if ( !res ) {
- setDesktop( 0 );
+ if ( aNbStudies && !res )
closeApplication();
closeApplication();
+ else
+ {
+ updateDesktopTitle();
+ updateCommandsStatus();
}
}
return res;
}
}
return res;
@@
-390,18
+399,32
@@
void STD_Application::afterCloseDoc()
/*!Close document, if it's possible.*/
void STD_Application::onCloseDoc( bool ask )
/*!Close document, if it's possible.*/
void STD_Application::onCloseDoc( bool ask )
+{
+ closeDoc( ask );
+}
+
+/*!Close document, if it's possible.*/
+bool STD_Application::closeDoc( bool ask )
{
bool closePermanently = true;
if ( ask && !isPossibleToClose( closePermanently ) )
{
bool closePermanently = true;
if ( ask && !isPossibleToClose( closePermanently ) )
- return;
+ return
false
;
+ return closeActiveDoc( closePermanently );
+}
+
+/*!Close document.*/
+bool STD_Application::closeActiveDoc( bool permanently )
+{
SUIT_Study* study = activeStudy();
SUIT_Study* study = activeStudy();
+ if ( !study ) // no active study
+ return true;
beforeCloseDoc( study );
if ( study )
beforeCloseDoc( study );
if ( study )
- study->closeDocument(
closeP
ermanently );
+ study->closeDocument(
p
ermanently );
clearViewManagers();
clearViewManagers();
@@
-430,10
+453,11
@@
void STD_Application::onCloseDoc( bool ask )
if ( !desktop() )
closeApplication();
if ( !desktop() )
closeApplication();
+ return true;
}
/*!Check the application on closing.
}
/*!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 )
{
*/
bool STD_Application::isPossibleToClose( bool& closePermanently )
{
@@
-451,7
+475,7
@@
bool STD_Application::isPossibleToClose( bool& closePermanently )
int STD_Application::closeChoice( const QString& docName )
{
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 );
SUIT_MessageBox::Save | SUIT_MessageBox::Discard | SUIT_MessageBox::Cancel,
SUIT_MessageBox::Save );
@@
-543,6
+567,9
@@
void STD_Application::onSaveDoc()
if ( !activeStudy() )
return;
if ( !activeStudy() )
return;
+ if ( !abortAllOperations() )
+ return;
+
bool isOk = false;
if ( activeStudy()->isSaved() )
{
bool isOk = false;
if ( activeStudy()->isSaved() )
{
@@
-571,17
+598,20
@@
void STD_Application::onSaveDoc()
onSaveAsDoc();
}
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;
bool STD_Application::onSaveAsDoc()
{
SUIT_Study* study = activeStudy();
if ( !study )
return false;
+ if ( !abortAllOperations() )
+ return false;
+
bool isOk = false;
while ( !isOk )
{
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;
if ( aName.isNull() )
return false;
@@
-639,7
+669,7
@@
void STD_Application::setEditEnabled( bool theEnable )
}
}
}
}
-/*!\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 );
bool STD_Application::useFile(const QString& theFileName)
{
bool res = SUIT_Application::useFile( theFileName );
@@
-789,7
+819,7
@@
void STD_Application::clearViewManagers()
}
}
}
}
-/*!\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 );
bool STD_Application::containsViewManager( SUIT_ViewManager* vm ) const
{
return myViewMgrs.contains( vm );
@@
-801,7
+831,7
@@
void STD_Application::onViewManagerActivated( SUIT_ViewManager* vm )
setActiveViewManager( vm );
}
setActiveViewManager( vm );
}
-/*!S
ets status bar show, if \on = true, else status bar hide
.*/
+/*!S
hows status bar, if on is \c true, else hides status bar
.*/
void STD_Application::onViewStatusBar( bool on )
{
if ( on )
void STD_Application::onViewStatusBar( bool on )
{
if ( on )
@@
-854,6
+884,12
@@
void STD_Application::onConnectPopupRequest( SUIT_PopupClient* client, QContextM
delete popup;
}
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 )
/*!\retval QString - return file name from dialog.*/
QString STD_Application::getFileName( bool open, const QString& initial, const QString& filters,
const QString& caption, QWidget* parent )
@@
-992,3
+1028,11
@@
int STD_Application::viewManagerId( const SUIT_ViewManager* theManager) const
return myViewMgrs.indexOf(const_cast<SUIT_ViewManager*>(theManager));
}
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;
+}