-/*! \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();
- QPtrList<SUIT_Application> aAppList = aSession->applications();
- bool isAlreadyOpen = false;
- SUIT_Application* aApp = 0;
- for ( QPtrListIterator<SUIT_Application> it( aAppList ); it.current() && !isAlreadyOpen; ++it )
- {
- aApp = it.current();
- if ( aApp->activeStudy()->studyName() == aName )
- isAlreadyOpen = true;
- }
- if ( !isAlreadyOpen )
- {
- aApp = startApplication( 0, 0 );
- if ( aApp )
- res = aApp->useStudy( aName );
+ SUIT_Study* study = activeStudy();
+ if ( study && study->isSaved() ) {
+ // ask user for the confirmation
+ if ( SUIT_MessageBox::question( desktop(), tr( "REOPEN_STUDY" ), tr( "REOPEN_QUESTION" ),
+ SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No
+ ) == SUIT_MessageBox::No )
+ return false;
+
+ // remember study name
+ QString studyName = study->studyName();
+
+ // close study
+ beforeCloseDoc( study );
+ study->closeDocument( true );
+
+ // update views / windows / status bar / title
+ clearViewManagers();
+ setActiveStudy( 0 );
+ updateDesktopTitle();
+ updateCommandsStatus();
+
+ // delete study
+ delete study;
+ study = 0;
+
+ // post closing actions
+ afterCloseDoc();
+
+ // reload study from the file
+ res = useFile( studyName ) && activeStudy();
+
+ // if reloading is failed, close the desktop
+ if ( !res ) {
+ setDesktop( 0 );
+ closeApplication();