#include <qpopupmenu.h>
#include <qtextbrowser.h>
#include <qapplication.h>
+#include <qdatetime.h>
#include <SUIT_Tools.h>
-#include <SUIT_FileDlg.h>
#include <SUIT_Session.h>
#include <SUIT_MessageBox.h>
#include <SUIT_ResourceMgr.h>
void LogWindow::onSaveToFile()
{
- QString aUsedFilter;
- QString aName = QFileDialog::getSaveFileName( QString::null, QString( "*.log" ), this,
- 0, QString::null, &aUsedFilter );
- if ( aName.isNull() )
+ SUIT_Application* app = SUIT_Session::session()->activeApplication();
+ if ( !app )
return;
- int aStart = aUsedFilter.find('*');
- int aEnd = aUsedFilter.find(')', aStart + 1);
- QString aExt = aUsedFilter.mid(aStart + 1, aEnd - aStart - 1);
- if ( aExt.contains('*') == 0 )
- {
- if ( aName.contains( aExt, false ) == 0 )
- aName += aExt;
- }
-
+ // call application-specific "Save file" dialog box
+ QString aName = app->getFileName( false, QString::null, QString( "*.log" ), QString::null, 0 );
+ if ( aName.isNull() )
+ return;
- if ( !aName.isNull() )
- {
- QApplication::setOverrideCursor( Qt::waitCursor );
+ QApplication::setOverrideCursor( Qt::waitCursor );
- bool bOk = saveLog( aName );
+ bool bOk = saveLog( aName );
- QApplication::restoreOverrideCursor();
+ QApplication::restoreOverrideCursor();
- if ( !bOk )
- SUIT_MessageBox::error1( this, tr( "Error" ), tr( "Can't save file" ), tr( "OK" ) );
- }
+ if ( !bOk )
+ SUIT_MessageBox::error1( this, tr( "Error" ), tr( "Can't save file" ), tr( "OK" ) );
}
void LogWindow::onSelectAll()
void STD_Application::onOpenDoc()
{
// It is preferrable to use OS-specific file dialog box here !!!
- QString aName = getFileName( true );
+ QString aName = getFileName( true, QString::null, getFileFilter(), QString::null, 0 );
if ( aName.isNull() )
return;
if ( !study )
return false;
- QString aName = getFileName( false );
+ QString aName = getFileName( false, study->studyName(), getFileFilter(), QString::null, 0 );
if ( aName.isNull() )
return false;
delete popup;
}
-QString STD_Application::getFileName( bool open )
+QString STD_Application::getFileName( bool open, const QString& initial, const QString& filters,
+ const QString& caption, QWidget* parent )
{
+ if ( !parent )
+ parent = desktop();
+ QStringList fls = QStringList::split( ";", filters, false );
if ( open )
{
- return QFileDialog::getOpenFileName( QString::null, getFileFilter(), desktop() );
+ return QFileDialog::getOpenFileName( initial, fls.join( ";;" ), parent, 0, caption );
}
else
{
- SUIT_Study* study = activeStudy();
QString aName;
QString aUsedFilter;
- QString anOldPath = study->studyName();
+ QString anOldPath = initial;
bool isOk = false;
while ( !isOk )
{
// It is preferrable to use OS-specific file dialog box here !!!
- aName = QFileDialog::getSaveFileName( anOldPath, getFileFilter(), desktop(),
- 0, QString::null, &aUsedFilter);
+ aName = QFileDialog::getSaveFileName( anOldPath, fls.join( ";;" ), parent,
+ 0, caption, &aUsedFilter);
if ( aName.isNull() )
isOk = true;
void viewManagers( const QString&, ViewManagerList& ) const;
virtual QString getFileFilter() const { return QString::null; }
+ QString getFileName( bool open, const QString& initial, const QString& filters,
+ const QString& caption, QWidget* parent );
virtual void start();
virtual void setActiveViewManager( SUIT_ViewManager* );
- virtual QString getFileName( bool );
-
private:
ViewManagerList myViewMgrs;
SUIT_ViewManager* myActiveViewMgr;
msgstr "SUIT Std application"
msgid "MSG_FILE_EXISTS"
-msgstr "File \"%1\" already exists.\nDo you want to continue?"
+msgstr "File \"%1\" already exists.\nDo you want to overwrite it?"
msgid "MSG_CANT_SAVE"
msgstr "Can't save file \"%1\"."
//! Puts the message to the status bar
void putInfo ( const QString&, const int = 0 );
+ //! Invokes application-specific "Open/Save" file dialog and returns the selected file name.
+ virtual QString getFileName( bool open, const QString& initial, const QString& filters,
+ const QString& caption, QWidget* parent ) = 0;
+
signals:
void applicationClosed( SUIT_Application* );
void activated( SUIT_Application* );
//study->updateCaptions();
}
-QString SalomeApp_Application::getFileName( bool open )
+QString SalomeApp_Application::getFileName( bool open, const QString& initial, const QString& filters,
+ const QString& caption, QWidget* parent )
{
- QStringList filtersList;
- filtersList.append( getFileFilter() );
- QString initial = open ? QString( "" ) : ( activeStudy() ? activeStudy()->studyName() : QString( "" ) );
- return SUIT_FileDlg::getFileName( desktop(), initial, filtersList, QString::null, open, true );
+ if ( !parent )
+ parent = desktop();
+ QStringList fls = QStringList::split( ";", filters, false );
+ return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
}
QtxResourceEdit* resourceEdit() const;
virtual QString getFileFilter() const;
+ QString getFileName( bool open, const QString& initial, const QString& filters,
+ const QString& caption, QWidget* parent );
+
SUIT_ViewManager* getViewManager( const QString&, const bool );
void updateActions();
virtual void beforeCloseDoc( SUIT_Study* );
virtual void afterCloseDoc();
- virtual QString getFileName( bool );
-
private slots:
void onNewWindow();
void onModuleActivation( QAction* );