+
+/*!\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 )
+{
+ if ( !parent )
+ parent = desktop();
+ if ( open )
+ return QFileDialog::getOpenFileName( parent, caption, initial, filters );
+ else
+ {
+ QString aName;
+ QString aUsedFilter;
+ QString anOldPath = initial;
+
+ bool isOk = false;
+ while ( !isOk )
+ {
+ // It is preferrable to use OS-specific file dialog box here !!!
+ aName = QFileDialog::getSaveFileName( parent, caption, anOldPath, filters, &aUsedFilter );
+
+ if ( aName.isNull() )
+ isOk = true;
+ else
+ {
+ int aEnd = aUsedFilter.lastIndexOf( ')' );
+ int aStart = aUsedFilter.lastIndexOf( '(', aEnd );
+ QString wcStr = aUsedFilter.mid( aStart + 1, aEnd - aStart - 1 );
+
+ int idx = 0;
+ QStringList extList;
+ QRegExp rx( "[\b\\*]*\\.([\\w]+)" );
+ while ( ( idx = rx.indexIn( wcStr, idx ) ) != -1 )
+ {
+ extList.append( rx.cap( 1 ) );
+ idx += rx.matchedLength();
+ }
+
+ if ( !extList.isEmpty() && !extList.contains( SUIT_Tools::extension( aName ) ) )
+ aName += QString( ".%1" ).arg( extList.first() );
+
+ if ( QFileInfo( aName ).exists() )
+ {
+ int aAnswer = SUIT_MessageBox::question( desktop(), tr( "TIT_FILE_SAVEAS" ),
+ tr( "MSG_FILE_EXISTS" ).arg( aName ),
+ SUIT_MessageBox::Yes | SUIT_MessageBox::No | SUIT_MessageBox::Cancel, SUIT_MessageBox::Yes );
+ if ( aAnswer == SUIT_MessageBox::Cancel )
+ { // cancelled
+ aName = QString();
+ isOk = true;
+ }
+ else if ( aAnswer == SUIT_MessageBox::No ) // not save to this file
+ anOldPath = aName; // not to return to the same initial dir at each "while" step
+ else // overwrite the existing file
+ isOk = true;
+ }
+ else
+ isOk = true;
+ }
+ }
+ return aName;
+ }
+}
+
+/*!\retval QString - return directory name from dialog.*/
+QString STD_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
+{
+ if ( !parent )
+ parent = desktop();
+
+ return QFileDialog::getExistingDirectory( parent, caption, initial );
+}
+
+/*!
+ Changes desktop
+ \param desk - new desktop
+*/
+void STD_Application::setDesktop( SUIT_Desktop* desk )
+{
+ SUIT_Application::setDesktop( desk );
+
+ if ( desk ) {
+ connect( desk, SIGNAL( closing( SUIT_Desktop*, QCloseEvent* ) ),
+ this, SLOT( onDesktopClosing( SUIT_Desktop*, QCloseEvent* ) ), Qt::UniqueConnection );
+ }
+}
+
+/*!
+ Allow to load preferences before the desktop will be shown.
+*/
+void STD_Application::loadPreferences()
+{
+}
+
+/*!
+ Allow to save preferences before the application will be closed.
+*/
+void STD_Application::savePreferences()
+{
+}
+
+/*!
+ Custom activity after study is created
+ Updates desktop and actions
+*/
+void STD_Application::studyCreated( SUIT_Study* )
+{
+ updateDesktopTitle();
+ updateCommandsStatus();
+}
+
+/*!
+ Custom activity after study is opened
+ Updates desktop and actions
+*/
+void STD_Application::studyOpened( SUIT_Study* )
+{
+ updateDesktopTitle();
+ updateCommandsStatus();
+}
+
+/*!
+ Custom activity after study is opened
+ Updates desktop and actions
+*/
+void STD_Application::studySaved( SUIT_Study* )
+{
+ updateDesktopTitle();
+ updateCommandsStatus();
+}
+
+/*!
+ Return index of the view ma
+*/
+int STD_Application::viewManagerId( const SUIT_ViewManager* theManager) const
+{
+ 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;
+}