Salome HOME
getFileName() function is defined as pure virtual public in the SUIT_Application...
authorvsr <vsr@opencascade.com>
Fri, 17 Jun 2005 05:53:26 +0000 (05:53 +0000)
committervsr <vsr@opencascade.com>
Fri, 17 Jun 2005 05:53:26 +0000 (05:53 +0000)
src/LogWindow/LogWindow.cxx
src/STD/STD_Application.cxx
src/STD/STD_Application.h
src/STD/resources/STD_msg_en.po
src/SUIT/SUIT_Application.h
src/SalomeApp/SalomeApp_Application.cxx
src/SalomeApp/SalomeApp_Application.h

index a676a7645f89273652d275fccaab1f3e89782f96..0b846b720476a4753c4e593784557c78cd7d7bd6 100755 (executable)
@@ -27,9 +27,9 @@
 #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>
@@ -214,33 +214,23 @@ void LogWindow::updateActions()
 
 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()
index 3ad2b67fa063d425cf58c4014c30869e0a01b396..89427f76aaa38ab390d143ee3d419d4f5ae5a046 100755 (executable)
@@ -225,7 +225,7 @@ void STD_Application::onNewDoc()
 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;
 
@@ -364,7 +364,7 @@ bool STD_Application::onSaveAsDoc()
   if ( !study )
     return false;
 
-  QString aName = getFileName( false );
+  QString aName = getFileName( false, study->studyName(), getFileFilter(), QString::null, 0 );
 
   if ( aName.isNull() ) 
     return false;
@@ -590,25 +590,28 @@ void STD_Application::onConnectPopupRequest( SUIT_PopupClient* client, QContextM
   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;
index bb8c25a02bd451ce95aebfee87864155327c3a58..a8d4a1fe52090644c5e9e13467b51fdff241bb6a 100755 (executable)
@@ -56,6 +56,8 @@ public:
   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();
 
@@ -99,8 +101,6 @@ protected:
 
   virtual void          setActiveViewManager( SUIT_ViewManager* );
 
-  virtual QString       getFileName( bool );
-
 private:
   ViewManagerList       myViewMgrs;
   SUIT_ViewManager*     myActiveViewMgr;
index fa0a1473ea67cbbd279e310e76c0ba004def6080..8a917960b7dbe0b79334e6a91a8833784ca8b903 100755 (executable)
@@ -303,7 +303,7 @@ msgid "STD_Application::ABOUT_INFO"
 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\"."
index 5ef047b6232f44f8cc417ea00452242f424f4475..bd2f6c776bffba3b7dc4ad6067f28302fc185e31 100755 (executable)
@@ -69,6 +69,10 @@ public:
   //! 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* );
index 6063e1fa77d2f7c799e7520a79d805eae69039c7..467b1ff5587a4e6ac763e072072eb4e1edf8589b 100644 (file)
@@ -1124,10 +1124,11 @@ void SalomeApp_Application::onProperties()
   //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 );
 }
index b6328e688c16e5c6661cfc0bf85ea6aa66125507..adb93cb4e0db2479648e38e3bfc9db972f02c2af 100644 (file)
@@ -74,6 +74,9 @@ public:
   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();
@@ -125,8 +128,6 @@ protected:
   virtual void                        beforeCloseDoc( SUIT_Study* );
   virtual void                        afterCloseDoc();
 
-  virtual QString                     getFileName( bool );
-
 private slots:
   void                                onNewWindow();
   void                                onModuleActivation( QAction* );