]> SALOME platform Git repositories - modules/gui.git/blob - src/STD/STD_Application.cxx
Salome HOME
IPAL BugID9021, added a new dialog box for a list of existent studies
[modules/gui.git] / src / STD / STD_Application.cxx
1 #include "STD_Application.h"
2
3 #include "STD_MDIDesktop.h"
4
5 #include "STD_CloseDlg.h"
6
7 #include <SUIT_Tools.h>
8 #include <SUIT_Desktop.h>
9 #include <SUIT_Session.h>
10 #include <SUIT_ViewModel.h>
11 #include <SUIT_Operation.h>
12 #include <SUIT_MessageBox.h>
13 #include <SUIT_ResourceMgr.h>
14
15 #include <QtxDockAction.h>
16 #include <QtxActionMenuMgr.h>
17 #include <QtxActionToolMgr.h>
18 #include <QtxPopupMenu.h>
19
20 #include <qmenubar.h>
21 #include <qtoolbar.h>
22 #include <qpopupmenu.h>
23 #include <qstatusbar.h>
24 #include <qfiledialog.h>
25 #include <qapplication.h>
26
27 #include <iostream.h>
28
29 extern "C" STD_EXPORT SUIT_Application* createApplication()
30 {
31   return new STD_Application();
32 }
33
34 STD_Application::STD_Application()
35 : SUIT_Application(),
36 myEditEnabled( true ),
37 myActiveViewMgr( 0 )
38 {
39   STD_MDIDesktop* desk = new STD_MDIDesktop();
40
41   connect( desk, SIGNAL( closing( SUIT_Desktop*, QCloseEvent* ) ),
42            this, SLOT( onDesktopClosing( SUIT_Desktop*, QCloseEvent* ) ) );
43
44   setDesktop( desk );
45 }
46
47 STD_Application::~STD_Application()
48 {
49 }
50
51 QString STD_Application::applicationName() const
52 {
53   return QString( "StdApplication" );
54 }
55
56 void STD_Application::start()
57 {
58   createActions();
59
60   updateDesktopTitle();
61   updateCommandsStatus();
62   setEditEnabled( myEditEnabled );
63
64   SUIT_Application::start();
65 }
66
67 void STD_Application::onDesktopClosing( SUIT_Desktop*, QCloseEvent* e )
68 {
69   if ( !isPossibleToClose() )
70   {
71     e->ignore();
72     return;
73   }
74
75   SUIT_Study* study = activeStudy();
76
77   if ( study )
78     study->closeDocument();
79
80   setActiveStudy( 0 );
81   delete study;
82
83   setDesktop( 0 );
84
85   closeApplication();
86 }
87
88 void STD_Application::createActions()
89 {
90   SUIT_Desktop* desk = desktop();
91   SUIT_ResourceMgr* resMgr = resourceMgr();
92   if ( !desk || !resMgr )
93     return;
94
95   // Create actions
96
97   createAction( FileNewId, tr( "TOT_DESK_FILE_NEW" ),
98                 resMgr->loadPixmap( "STD", tr( "ICON_FILE_NEW" ) ),
99                 tr( "MEN_DESK_FILE_NEW" ), tr( "PRP_DESK_FILE_NEW" ),
100                 CTRL+Key_N, desk, false, this, SLOT( onNewDoc() ) );
101
102   createAction( FileOpenId, tr( "TOT_DESK_FILE_OPEN" ),
103                 resMgr->loadPixmap( "STD", tr( "ICON_FILE_OPEN" ) ),
104                 tr( "MEN_DESK_FILE_OPEN" ), tr( "PRP_DESK_FILE_OPEN" ),
105                 CTRL+Key_O, desk, false, this, SLOT( onOpenDoc() ) );
106
107   createAction( FileCloseId, tr( "TOT_DESK_FILE_CLOSE" ),
108                 resMgr->loadPixmap( "STD", tr( "ICON_FILE_CLOSE" ) ),
109                 tr( "MEN_DESK_FILE_CLOSE" ), tr( "PRP_DESK_FILE_CLOSE" ),
110                 CTRL+Key_W, desk, false, this, SLOT( onCloseDoc() ) );
111
112   createAction( FileExitId, tr( "TOT_DESK_FILE_EXIT" ), QIconSet(),
113                 tr( "MEN_DESK_FILE_EXIT" ), tr( "PRP_DESK_FILE_EXIT" ),
114                 CTRL+Key_Q, desk, false, this, SLOT( onExit() ) );
115
116   createAction( FileSaveId, tr( "TOT_DESK_FILE_SAVE" ),
117                 resMgr->loadPixmap( "STD", tr( "ICON_FILE_SAVE" ) ),
118                 tr( "MEN_DESK_FILE_SAVE" ), tr( "PRP_DESK_FILE_SAVE" ),
119                 CTRL+Key_S, desk, false, this, SLOT( onSaveDoc() ) );
120
121   createAction( FileSaveAsId, tr( "TOT_DESK_FILE_SAVEAS" ), QIconSet(),
122                 tr( "MEN_DESK_FILE_SAVEAS" ), tr( "PRP_DESK_FILE_SAVEAS" ),
123                 0, desk, false, this, SLOT( onSaveAsDoc() ) );
124
125   createAction( EditCopyId, tr( "TOT_DESK_EDIT_COPY" ),
126                 resMgr->loadPixmap( "STD", tr( "ICON_EDIT_COPY" ) ),
127                 tr( "MEN_DESK_EDIT_COPY" ), tr( "PRP_DESK_EDIT_COPY" ),
128                 CTRL+Key_C, desk, false, this, SLOT( onCopy() ) );
129
130   createAction( EditPasteId, tr( "TOT_DESK_EDIT_PASTE" ),
131                 resMgr->loadPixmap( "STD", tr( "ICON_EDIT_PASTE" ) ),
132                 tr( "MEN_DESK_EDIT_PASTE" ), tr( "PRP_DESK_EDIT_PASTE" ),
133                 CTRL+Key_V, desk, false, this, SLOT( onPaste() ) );
134
135   QAction* a = createAction( ViewStatusBarId, tr( "TOT_DESK_VIEW_STATUSBAR" ),
136                              QIconSet(), tr( "MEN_DESK_VIEW_STATUSBAR" ),
137                              tr( "PRP_DESK_VIEW_STATUSBAR" ), 0, desk, true );
138   a->setOn( desk->statusBar()->isVisibleTo( desk ) );
139   connect( a, SIGNAL( toggled( bool ) ), this, SLOT( onViewStatusBar( bool ) ) );
140
141   createAction( NewWindowId, tr( "TOT_DESK_NEWWINDOW" ), QIconSet(),
142                 tr( "MEN_DESK_NEWWINDOW" ), tr( "PRP_DESK_NEWWINDOW" ), 0, desk  );
143
144   createAction( HelpAboutId, tr( "TOT_DESK_HELP_ABOUT" ), QIconSet(),
145                 tr( "MEN_DESK_HELP_ABOUT" ), tr( "PRP_DESK_HELP_ABOUT" ),
146                 0, desk, false, this, SLOT( onHelpAbout() ) );
147
148   //SRN: BugID IPAL9021, add an action "Load"
149   createAction( FileLoadId, tr( "TOT_DESK_FILE_LOAD" ),
150                 resMgr->loadPixmap( "STD", tr( "ICON_FILE_OPEN" ) ),
151                 tr( "MEN_DESK_FILE_LOAD" ), tr( "PRP_DESK_FILE_LOAD" ),
152                 CTRL+Key_L, desk, false, this, SLOT( onLoadDoc() ) );      
153   //SRN: BugID IPAL9021: End 
154
155   QtxDockAction* da = new QtxDockAction( tr( "TOT_DOCK_WINDOWS" ), tr( "MEN_DOCK_WINDOWS" ), desk );
156   registerAction( ViewWindowsId, da );
157   da->setAutoPlace( false );
158
159   // Create menus
160
161   int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1, -1, 0 );
162   int editMenu = createMenu( tr( "MEN_DESK_EDIT" ), -1, -1, 10 );
163   int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1, -1, 10 );
164   int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
165
166   // Create menu items
167
168   createMenu( FileNewId, fileMenu, 0 );
169   createMenu( FileOpenId, fileMenu, 0 );
170   createMenu( FileLoadId, fileMenu, 0 );  //SRN: BugID IPAL9021, add a menu item "Load"
171   createMenu( FileCloseId, fileMenu, 0 );
172   createMenu( separator(), fileMenu, -1, 0 );
173   createMenu( FileSaveId, fileMenu, 0 );
174   createMenu( FileSaveAsId, fileMenu, 0 );
175   createMenu( separator(), fileMenu, -1, 0 );
176
177   createMenu( separator(), fileMenu );
178   createMenu( FileExitId, fileMenu );
179
180   createMenu( EditCopyId, editMenu );
181   createMenu( EditPasteId, editMenu );
182   createMenu( separator(), editMenu );
183
184   createMenu( ViewWindowsId, viewMenu );
185   createMenu( ViewStatusBarId, viewMenu );
186   createMenu( separator(), viewMenu );
187
188   createMenu( HelpAboutId, helpMenu );
189   createMenu( separator(), helpMenu );
190
191   // Create tool bars
192
193   int stdTBar = createTool( tr( "INF_DESK_TOOLBAR_STANDARD" ) );
194
195   // Create tool items
196
197   createTool( FileNewId, stdTBar );
198   createTool( FileOpenId, stdTBar );
199   createTool( FileSaveId, stdTBar );
200   createTool( FileCloseId, stdTBar );
201   createTool( separator(), stdTBar );
202   createTool( EditCopyId, stdTBar );
203   createTool( EditPasteId, stdTBar );
204 }
205
206 /*!
207   Opens new application
208 */
209 void STD_Application::onNewDoc() 
210 {
211   if ( !activeStudy() )
212   {
213     createEmptyStudy();
214     activeStudy()->createDocument();
215     updateDesktopTitle();
216     updateCommandsStatus();
217   }
218   else
219   {
220     SUIT_Application* aApp = startApplication( 0, 0 );
221     if ( aApp->inherits( "STD_Application" ) )
222       ((STD_Application*)aApp)->onNewDoc();
223     else {
224       aApp->createEmptyStudy();
225       aApp->activeStudy()->createDocument();
226     }
227   }
228 }
229
230 void STD_Application::onOpenDoc()
231 {
232   // It is preferrable to use OS-specific file dialog box here !!!
233   QString aName = getFileName( true, QString::null, getFileFilter(), QString::null, 0 );
234   if ( aName.isNull() )
235     return;
236
237   onOpenDoc( aName );
238 }
239
240 bool STD_Application::onOpenDoc( const QString& aName )
241 {
242   bool res = true;
243   if ( !activeStudy() )
244   {
245     // if no study - open in current desktop
246     res = useFile( aName );
247   }
248   else
249   {
250     // if study exists - open in new desktop. Check: is the same file is opened?
251     SUIT_Session* aSession = SUIT_Session::session();
252     QPtrList<SUIT_Application> aAppList = aSession->applications();
253     bool isAlreadyOpen = false;
254     SUIT_Application* aApp = 0;
255     for ( QPtrListIterator<SUIT_Application> it( aAppList ); it.current() && !isAlreadyOpen; ++it )
256     {
257       aApp = it.current();
258       if ( aApp->activeStudy()->studyName() == aName )
259         isAlreadyOpen = true;
260     }
261     if ( !isAlreadyOpen )
262     {
263       aApp = startApplication( 0, 0 );
264       if ( aApp )
265         res = aApp->useFile( aName );
266     }
267     else
268       aApp->desktop()->setActiveWindow();
269   }
270   return res;
271 }
272
273 void STD_Application::onLoadDoc()
274 {     
275 }
276
277 bool STD_Application::onLoadDoc( const QString& aName )
278 {
279   bool res = true;
280   if ( !activeStudy() )
281   {
282     // if no study - load in current desktop
283     res = useStudy( aName );
284   }
285   else
286   {
287     // if study exists - load in new desktop. Check: is the same file is loaded?
288     SUIT_Session* aSession = SUIT_Session::session();
289     QPtrList<SUIT_Application> aAppList = aSession->applications();
290     bool isAlreadyOpen = false;
291     SUIT_Application* aApp = 0;
292     for ( QPtrListIterator<SUIT_Application> it( aAppList ); it.current() && !isAlreadyOpen; ++it )
293     {
294       aApp = it.current();
295       if ( aApp->activeStudy()->studyName() == aName )
296         isAlreadyOpen = true;
297     }
298     if ( !isAlreadyOpen )
299     {
300       aApp = startApplication( 0, 0 );
301       if ( aApp )
302         res = aApp->useStudy( aName );
303     }
304     else
305       aApp->desktop()->setActiveWindow();
306   }
307   return res;
308 }
309
310 void STD_Application::beforeCloseDoc( SUIT_Study* )
311 {
312 }
313
314 void STD_Application::afterCloseDoc()
315 {
316 }
317
318 void STD_Application::onCloseDoc()
319 {
320   if ( !isPossibleToClose() )
321     return;
322
323   SUIT_Study* study = activeStudy();
324
325   beforeCloseDoc( study );
326
327   if ( study )
328     study->closeDocument();
329
330   clearViewManagers();
331
332   setActiveStudy( 0 );
333   delete study;
334
335   int aNbStudies = 0;
336   QPtrList<SUIT_Application> apps = SUIT_Session::session()->applications();
337   for ( unsigned i = 0; i < apps.count(); i++ )
338     aNbStudies += apps.at( i )->getNbStudies();
339
340   // STV: aNbStudies - number of currently existing studies (exclude currently closed)
341   // STV: aNbStudies should be compared with 0.
342   if ( aNbStudies )
343     setDesktop( 0 );
344   else
345   {
346     updateDesktopTitle();
347     updateCommandsStatus();
348   }
349
350   afterCloseDoc();
351
352   if ( !desktop() )
353     closeApplication();
354 }
355
356 bool STD_Application::isPossibleToClose()
357 {
358   if ( activeStudy() )
359   {
360     activeStudy()->abortAllOperations();
361     if ( activeStudy()->isModified() )
362     {
363       QString sName = activeStudy()->studyName().stripWhiteSpace();
364       QString msg = sName.isEmpty() ? tr( "INF_DOC_MODIFIED" ) : tr ( "INF_DOCUMENT_MODIFIED" ).arg( sName );
365
366       //SRN: BugID: IPAL9021: Begin
367       STD_CloseDlg dlg(desktop());
368       switch( dlg.exec() )
369       {
370       case 1:
371         if ( activeStudy()->isSaved() )
372           onSaveDoc();
373         else if ( !onSaveAsDoc() )
374           return false;
375         break;
376       case 2:
377         break;
378       case 3:
379         break;
380       case 4:
381       default:
382         return false;
383       }
384      //SRN: BugID: IPAL9021: End 
385     }
386   }
387   return true;
388 }
389
390 void STD_Application::onSaveDoc()
391 {
392   if ( !activeStudy() )
393     return;
394
395   bool isOk = false;
396   if ( activeStudy()->isSaved() )
397   {
398     isOk = activeStudy()->saveDocument();
399     if ( !isOk )
400       SUIT_MessageBox::error1( desktop(), tr( "TIT_FILE_SAVEAS" ),
401                                tr( "MSG_CANT_SAVE" ).arg( activeStudy()->studyName() ), tr( "BUT_OK" ) );
402   }
403
404   if ( isOk )
405     updateCommandsStatus();
406   else
407     onSaveAsDoc();
408 }
409
410 bool STD_Application::onSaveAsDoc()
411 {
412   SUIT_Study* study = activeStudy();
413   if ( !study )
414     return false;
415
416   QString aName = getFileName( false, study->studyName(), getFileFilter(), QString::null, 0 );
417
418   if ( aName.isNull() ) 
419     return false;
420   bool isOk = study->saveDocumentAs( aName );
421
422   updateDesktopTitle();
423   updateCommandsStatus();
424
425   return isOk;
426 }
427
428 void STD_Application::onExit()
429 {
430   SUIT_Session::session()->closeSession();
431 }
432
433 void STD_Application::onCopy()
434 {
435 }
436
437 void STD_Application::onPaste()
438 {
439 }
440
441 void STD_Application::setEditEnabled( bool theEnable )
442 {
443   myEditEnabled = theEnable;
444
445   QtxActionMenuMgr* mMgr = desktop()->menuMgr();
446   QtxActionToolMgr* tMgr = desktop()->toolMgr();
447
448   for ( int i = EditCopyId; i <= EditPasteId; i++ )
449   {
450     mMgr->setShown( i, myEditEnabled );
451     tMgr->setShown( i, myEditEnabled );
452   }
453 }
454
455 bool STD_Application::useFile(const QString& theFileName)
456 {
457   bool res = SUIT_Application::useFile(theFileName);
458   updateDesktopTitle();
459   updateCommandsStatus();
460   return res;
461 }
462
463 void STD_Application::updateDesktopTitle()
464 {
465   QString aTitle = applicationName();
466   QString aVer = applicationVersion();
467   if ( !aVer.isEmpty() )
468     aTitle += QString( " " ) + aVer;
469
470   if ( activeStudy() )
471   {
472     QString sName = SUIT_Tools::file( activeStudy()->studyName().stripWhiteSpace(), false );
473     if ( !sName.isEmpty() )
474       aTitle += QString( " - [%1]" ).arg( sName );
475   }
476
477   desktop()->setCaption( aTitle );
478 }
479
480 void STD_Application::updateCommandsStatus()
481 {
482   bool aHasStudy = activeStudy() != 0;
483   bool aIsNeedToSave = false;
484   if ( aHasStudy ) 
485     aIsNeedToSave = !activeStudy()->isSaved() || activeStudy()->isModified();
486
487   if ( action( FileSaveId ) )
488     action( FileSaveId )->setEnabled( aIsNeedToSave );
489   if ( action( FileSaveAsId ) )
490     action( FileSaveAsId )->setEnabled( aHasStudy );
491   if ( action( FileCloseId ) )
492     action( FileCloseId )->setEnabled( aHasStudy );
493   if ( action( NewWindowId ) )
494     action( NewWindowId )->setEnabled( aHasStudy );
495 }
496
497 SUIT_ViewManager* STD_Application::viewManager( const QString& vmType ) const
498 {
499   SUIT_ViewManager* vm = 0;
500   for ( QPtrListIterator<SUIT_ViewManager> it( myViewMgrs ); it.current() && !vm; ++it )
501   {
502     if ( it.current()->getType() == vmType )
503       vm = it.current();
504   }
505   return vm;
506 }
507
508 void STD_Application::viewManagers( const QString& vmType, ViewManagerList& lst ) const
509 {
510   for ( QPtrListIterator<SUIT_ViewManager> it( myViewMgrs ); it.current(); ++it )
511     if ( it.current()->getType() == vmType )
512       lst.append( it.current() );
513 }
514
515 void STD_Application::viewManagers( ViewManagerList& lst ) const
516 {
517   for ( QPtrListIterator<SUIT_ViewManager> it( myViewMgrs ); it.current(); ++it )
518     lst.append( it.current() );
519 }
520
521 ViewManagerList STD_Application::viewManagers() const
522 {
523   ViewManagerList lst;
524   viewManagers( lst );
525   return lst;
526 }
527
528 SUIT_ViewManager* STD_Application::activeViewManager() const
529 {
530   return myActiveViewMgr;
531 }
532
533 void STD_Application::addViewManager( SUIT_ViewManager* vm )
534 {
535   if ( !vm )
536     return;
537
538   if ( !containsViewManager( vm ) )
539   {
540     myViewMgrs.append( vm );
541     connect( vm, SIGNAL( activated( SUIT_ViewManager* ) ),
542              this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );
543     vm->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
544
545     emit viewManagerAdded( vm );
546   }
547 /*
548   if ( !activeViewManager() && myViewMgrs.count() == 1 )
549     setActiveViewManager( vm );
550 */
551 }
552
553 void STD_Application::removeViewManager( SUIT_ViewManager* vm )
554 {
555   if ( !vm )
556     return;
557
558   vm->closeAllViews();
559
560   emit viewManagerRemoved( vm );
561
562   vm->disconnectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
563   vm->disconnect();
564   myViewMgrs.removeRef( vm );
565
566   if ( myActiveViewMgr == vm )
567     myActiveViewMgr = 0;
568 }
569
570 void STD_Application::clearViewManagers()
571 {
572   ViewManagerList lst;
573   viewManagers( lst );
574
575   for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current(); ++it )
576     removeViewManager( it.current() );
577 }
578
579 bool STD_Application::containsViewManager( SUIT_ViewManager* vm ) const
580 {
581   return myViewMgrs.contains( vm ) > 0;
582 }
583
584 void STD_Application::onViewManagerActivated( SUIT_ViewManager* vm )
585 {
586   setActiveViewManager( vm );
587 }
588
589 void STD_Application::onViewStatusBar( bool on )
590 {
591   if ( on )
592     desktop()->statusBar()->show();
593   else
594     desktop()->statusBar()->hide();
595 }
596
597 void STD_Application::onHelpAbout()
598 {
599   SUIT_MessageBox::info1( desktop(), tr( "About" ), tr( "ABOUT_INFO" ), "&OK" );
600 }
601
602 void STD_Application::createEmptyStudy()
603 {
604   SUIT_Application::createEmptyStudy();
605
606   SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(), desktop(), new SUIT_ViewModel() );
607
608   addViewManager( vm );
609 }
610
611 void STD_Application::setActiveViewManager( SUIT_ViewManager* vm )
612 {
613   if ( !containsViewManager( vm ) )
614     return;
615
616   myActiveViewMgr = vm;
617   emit viewManagerActivated( vm );
618 }
619
620 void STD_Application::onConnectPopupRequest( SUIT_PopupClient* client, QContextMenuEvent* e )
621 {
622   QtxPopupMenu* popup = new QtxPopupMenu();
623   // fill popup by own items
624   QString title;
625   contextMenuPopup( client->popupClientType(), popup, title );
626   popup->setTitleText( title );
627
628   popup->insertSeparator();
629   // add items from popup client
630   client->contextMenuPopup( popup );
631   
632   SUIT_Tools::simplifySeparators( popup );
633
634   if ( popup->count() )
635     popup->exec( e->globalPos() );
636   delete popup;
637 }
638
639 QString STD_Application::getFileName( bool open, const QString& initial, const QString& filters, 
640                                       const QString& caption, QWidget* parent )
641 {
642   if ( !parent )
643     parent = desktop();
644   if ( open ) 
645   {
646     return QFileDialog::getOpenFileName( initial, filters, parent, 0, caption );
647   }
648   else
649   {
650     QString aName;
651     QString aUsedFilter;
652     QString anOldPath = initial;
653
654     bool isOk = false;
655     while ( !isOk )
656     {
657       // It is preferrable to use OS-specific file dialog box here !!!
658       aName = QFileDialog::getSaveFileName( anOldPath, filters, parent,
659                                             0, caption, &aUsedFilter);
660
661       if ( aName.isNull() )
662         isOk = true;
663       else
664       {
665         if ( !getFileFilter().isNull() ) // check extension and add if it is necessary
666         {
667           int aStart = aUsedFilter.find( '*' );
668           int aEnd = aUsedFilter.find( ')', aStart + 1 );
669           QString aExt = aUsedFilter.mid( aStart + 1, aEnd - aStart - 1 );
670           if ( aExt.contains( '*' ) == 0 ) // if it is not *.*
671           {
672             // Check that there is an extension at the end of the name
673             QString aNameTail = aName.right( aExt.length() );
674             if ( aNameTail != aExt )
675               aName += aExt;
676           }
677         }
678         if ( QFileInfo( aName ).exists() )
679         {
680           int aAnswer = SUIT_MessageBox::warn3( desktop(), tr( "TIT_FILE_SAVEAS" ),
681                                                 tr( "MSG_FILE_EXISTS" ).arg( aName ),
682                                                 tr( "BUT_YES" ), tr( "BUT_NO" ), tr( "BUT_CANCEL" ), 1, 2, 3, 1 );
683           if ( aAnswer == 3 ) {     // cancelled
684             aName = QString::null;
685             isOk = true;
686           }
687           else if ( aAnswer == 2 ) // not save to this file
688             anOldPath = aName;             // not to return to the same initial dir at each "while" step
689           else                     // overwrite the existing file
690             isOk = true;
691         }
692         else
693           isOk = true;
694       }
695     }
696     return aName;
697   }
698 }
699
700 QString STD_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
701 {
702   if ( !parent )
703     parent = desktop();
704   return QFileDialog::getExistingDirectory( initial, parent, 0, caption, true );
705 }