- QString sName = activeStudy()->studyName().stripWhiteSpace();
- QString msg = sName.isEmpty() ? tr( "INF_DOC_MODIFIED" ) : tr ( "INF_DOCUMENT_MODIFIED" ).arg( sName );
- int aAnswer = SUIT_MessageBox::warn3( desktop(), tr( "TOT_DESK_FILE_CLOSE" ), msg,
- tr( "BUT_YES" ), tr( "BUT_NO" ), tr( "BUT_CANCEL" ), 1, 2, 3, 1 );
- switch ( aAnswer )
+ QString sName = activeStudy()->studyName().trimmed();
+ return closeAction( closeChoice( sName ), closePermanently );
+ }
+ }
+ return true;
+}
+
+int STD_Application::closeChoice( const QString& docName )
+{
+ int answer = SUIT_MessageBox::question( desktop(), tr( "CLOSE_STUDY" ), tr( "CLOSE_QUESTION" ).arg( docName ),
+ SUIT_MessageBox::Save | SUIT_MessageBox::Discard | SUIT_MessageBox::Cancel,
+ SUIT_MessageBox::Save );
+
+ int res = CloseCancel;
+ if ( answer == SUIT_MessageBox::Save )
+ res = CloseSave;
+ else if ( answer == SUIT_MessageBox::Discard )
+ res = CloseDiscard;
+
+ return res;
+}
+
+bool STD_Application::closeAction( const int choice, bool& closePermanently )
+{
+ bool res = true;
+ switch( choice )
+ {
+ case CloseSave:
+ if ( activeStudy()->isSaved() )
+ onSaveDoc();
+ else if ( !onSaveAsDoc() )
+ res = false;
+ break;
+ case CloseDiscard:
+ break;
+ case CloseCancel:
+ default:
+ res = false;
+ }
+
+ 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 )