Salome HOME
ENV: Windows porting
[modules/gui.git] / src / SalomeApp / SalomeApp_Dialog.cxx
1 // File:      SalomeApp_Dialog.cxx
2 // Author:    Alexander SOLOVYOV
3
4 #include <SalomeApp_Dialog.h>
5 #include <SUIT_Session.h>
6
7 #include <qtoolbutton.h>
8 #include <qlineedit.h>
9 #include <qlabel.h>
10
11 /*
12   Class       : SalomeApp_Dialog
13   Description : Base class for all SALOME dialogs
14 */
15
16 //=======================================================================
17 // name    : SalomeApp_Dialog
18 // Purpose : Constructor
19 //=======================================================================
20 SalomeApp_Dialog::SalomeApp_Dialog( QWidget* parent, const char* name, bool modal,
21                                     bool allowResize, const int f, WFlags wf )
22 : QtxDialog( parent, name, modal, allowResize, f, wf ),
23   myIsExclusive( true ),
24   myIsBusy( false )
25 {
26   setObjectPixmap( "SalomeApp", tr( "ICON_SELECT" ) );
27 }
28
29 //=======================================================================
30 // name    : ~SalomeApp_Dialog
31 // Purpose : Destructor
32 //=======================================================================
33 SalomeApp_Dialog::~SalomeApp_Dialog()
34 {
35 }
36
37 //=======================================================================
38 // name    : show
39 // Purpose : 
40 //=======================================================================
41 void SalomeApp_Dialog::show()
42 {
43   QtxDialog::show();
44 }
45
46 //=======================================================================
47 // name    : isExclusive
48 // Purpose :
49 //=======================================================================
50 bool SalomeApp_Dialog::isExclusive() const
51 {
52   return myIsExclusive;
53 }
54
55 //=======================================================================
56 // name    : updateButtons
57 // Purpose :
58 //=======================================================================
59 void SalomeApp_Dialog::updateButtons( const int _id )
60 {
61   if( !myIsExclusive )
62     return;
63
64   int id = _id;
65
66   ObjectMap::const_iterator anIt = myObjects.begin(),
67                             aLast = myObjects.end();
68   for( ; anIt!=aLast; anIt++ )
69   {
70     QToolButton* but = (QToolButton*)anIt.data().myBtn;
71     if( but && but->isOn() )
72     {
73       if( id==-1 )
74         id = anIt.key();
75
76       if( anIt.key()!=id )
77         but->setOn( false );
78     }
79   }
80 }
81
82 //=======================================================================
83 // name    : setExclusive
84 // Purpose :
85 //=======================================================================
86 void SalomeApp_Dialog::setExclusive( const bool ex )
87 {
88   myIsExclusive = ex;
89   updateButtons();
90 }
91
92 //=======================================================================
93 // name    : showObject
94 // Purpose :
95 //=======================================================================
96 void SalomeApp_Dialog::showObject( const int id )
97 {
98   setObjectShown( id, true );
99 }
100
101 //=======================================================================
102 // name    : hideObject
103 // Purpose :
104 //=======================================================================
105 void SalomeApp_Dialog::hideObject( const int id )
106 {
107   setObjectShown( id, false );
108 }
109
110 //=======================================================================
111 // name    : setObjectShown
112 // Purpose :
113 //=======================================================================
114 void SalomeApp_Dialog::setObjectShown( const int id, const bool shown )
115 {
116   if( myObjects.contains( id ) && isObjectShown( id )!=shown )
117   {
118     Object& obj = myObjects[ id ];
119     obj.myEdit->setShown( shown );
120     obj.myBtn->setShown( shown );
121     obj.myLabel->setShown( shown );
122     if( !shown )
123       ( ( QToolButton* )obj.myBtn )->setOn( false );
124   }
125 }
126
127 //=======================================================================
128 // name    : isObjectShown
129 // Purpose :
130 //=======================================================================
131 bool SalomeApp_Dialog::isObjectShown( const int id ) const
132 {
133   return myObjects.contains( id ) && myObjects[ id ].myEdit->isShown();
134 }
135
136 //=======================================================================
137 // name    : setObjectEnabled
138 // Purpose :
139 //=======================================================================
140 void SalomeApp_Dialog::setObjectEnabled( const int id, const bool en )
141 {
142   if( myObjects.contains( id ) && isObjectEnabled( id )!=en )
143   {
144     Object& obj = myObjects[ id ];
145     obj.myEdit->setEnabled( en );
146     obj.myBtn->setEnabled( en );
147 //    obj.myLabel->setEnabled( en );
148     if( !en )
149       ( ( QToolButton* )obj.myBtn )->setOn( false );
150   } 
151 }
152
153 //=======================================================================
154 // name    : isObjectEnabled
155 // Purpose :
156 //=======================================================================
157 bool SalomeApp_Dialog::isObjectEnabled( const int id ) const
158 {
159   return myObjects.contains( id ) && myObjects[ id ].myEdit->isEnabled();
160 }
161
162 //=======================================================================
163 // name    : selectObject
164 // Purpose :
165 //=======================================================================
166 void SalomeApp_Dialog::selectObject( const QString& name, const int type, const QString& id, const bool update )
167 {
168   QStringList names;   names.append( name );
169   TypesList types;     types.append( type );
170   QStringList ids;     ids.append( id );
171   selectObject( names, types, ids, update );
172 }
173
174 //=======================================================================
175 // name    : selectObject
176 // Purpose :
177 //=======================================================================
178 void SalomeApp_Dialog::selectObject( const QStringList& _names,
179                                      const TypesList& _types,
180                                      const QStringList& _ids,
181                                      const bool update )
182 {
183   ObjectMap::iterator anIt = myObjects.begin(),
184                       aLast = myObjects.end();
185   for( ; anIt!=aLast; anIt++ )
186     if( anIt.data().myBtn->isOn() )
187       selectObject( anIt.key(), _names, _types, _ids, update );
188 }
189
190 //=======================================================================
191 // name    : hasSelection
192 // Purpose :
193 //=======================================================================
194 bool SalomeApp_Dialog::hasSelection( const int id ) const
195 {
196   return myObjects.contains( id ) && !myObjects[ id ].myIds.isEmpty();
197 }
198
199 //=======================================================================
200 // name    : clearSelection
201 // Purpose :
202 //=======================================================================
203 void SalomeApp_Dialog::clearSelection( const int id )
204 {
205   if( id==-1 )
206   {
207     ObjectMap::const_iterator anIt = myObjects.begin(),
208                               aLast = myObjects.end();
209     for( ; anIt!=aLast; anIt++ )
210       clearSelection( anIt.key() );
211   }
212   
213   else if( myObjects.contains( id ) )
214   {
215     myObjects[ id ].myIds.clear();
216     myObjects[ id ].myTypes.clear();
217     myObjects[ id ].myNames.clear();
218     
219     myObjects[ id ].myEdit->setText( QString::null );
220     emit selectionChanged( id );
221   }
222 }
223
224 //=======================================================================
225 // name    : objectWg
226 // Purpose :
227 //=======================================================================
228 QWidget* SalomeApp_Dialog::objectWg( const int theId, const int theWgId ) const
229 {
230   QWidget* aResWg = 0;
231   if( myObjects.contains( theId ) )
232   {
233     if ( theWgId == Label )
234       aResWg = myObjects[ theId ].myLabel;
235     else if ( theWgId == Btn )
236       aResWg = myObjects[ theId ].myBtn;
237     else if ( theWgId == Control )
238       aResWg = myObjects[ theId ].myEdit;
239   }
240   return aResWg;
241 }
242
243 //=======================================================================
244 // name    : objectText
245 // Purpose :
246 //=======================================================================
247 QString SalomeApp_Dialog::objectText( const int theId ) const
248 {
249   return myObjects.contains( theId ) ? myObjects[ theId ].myEdit->text() : "";
250 }
251
252 //=======================================================================
253 // name    : setObjectText
254 // Purpose :
255 //=======================================================================
256 void SalomeApp_Dialog::setObjectText( const int theId, const QString& theText )
257 {
258   if ( myObjects.contains( theId ) )
259     myObjects[ theId ].myEdit->setText( theText );
260 }
261
262 //=======================================================================
263 // name    : selectedObject
264 // Purpose :
265 //=======================================================================
266 void SalomeApp_Dialog::selectedObject( const int id, QStringList& list ) const
267 {
268   if( myObjects.contains( id ) )
269     list = myObjects[ id ].myIds;
270 }
271
272 //=======================================================================
273 // name    : selectedObject
274 // Purpose :
275 //=======================================================================
276 QString SalomeApp_Dialog::selectedObject( const int id ) const
277 {
278   if ( myObjects.contains( id ) && myObjects[ id ].myIds.count() > 0 )
279     return myObjects[ id ].myIds.first();
280   else
281     return "";
282 }
283
284 //=======================================================================
285 // name    : objectSelection
286 // Purpose :
287 //=======================================================================
288 void SalomeApp_Dialog::objectSelection( SelectedObjects& objs ) const
289 {
290   //objs.clear();
291   ObjectMap::const_iterator anIt = myObjects.begin(),
292                             aLast = myObjects.end();
293   for( ; anIt!=aLast; anIt++ )
294   {
295     QStringList ids;
296     selectedObject( anIt.key(), ids );
297     if( !ids.isEmpty() )
298       objs.insert( anIt.key(), ids );
299   }
300 }
301
302 //=======================================================================
303 // name    : createObject
304 // Purpose :
305 //=======================================================================
306 int SalomeApp_Dialog::createObject( const QString& label, QWidget* parent, const int id )
307 {  
308   int nid = id;
309   if( nid<0 )
310     for( nid=0; myObjects.contains( nid ); nid++ );
311   
312   if( !myObjects.contains( nid ) )
313   {
314     QLabel* lab = new QLabel( label, parent );
315     myObjects[ nid ].myLabel = lab;
316     
317     QToolButton* but = new QToolButton( parent );
318     but->setIconSet( QIconSet( myPixmap ) );
319     but->setToggleButton( true );
320     but->setMaximumWidth( but->height() );
321     but->setMinimumWidth( but->height() );    
322     connect( but, SIGNAL( toggled( bool ) ), this, SLOT( onToggled( bool ) ) );
323     myObjects[ nid ].myBtn = but;
324
325     QLineEdit* ne = new QLineEdit( parent );
326     ne->setReadOnly( true );
327     ne->setMinimumWidth( 150 );
328     connect( ne, SIGNAL( textChanged( const QString& ) ), this, SLOT( onTextChanged( const QString& ) ) );
329     myObjects[ nid ].myEdit = ne;
330
331     myObjects[ nid ].myNI = OneNameOrCount;
332   }
333   return nid;
334 }
335
336 //=======================================================================
337 // name    : renameObject
338 // Purpose :
339 //=======================================================================
340 void SalomeApp_Dialog::renameObject( const int id, const QString& label )
341 {
342   if( myObjects.contains( id ) )
343     myObjects[ id ].myLabel->setText( label );
344 }
345
346 //=======================================================================
347 // name    : setObjectType
348 // Purpose :
349 //=======================================================================
350 void SalomeApp_Dialog::setObjectType( const int id, const int type1, ... )
351 {
352   TypesList types;
353   
354   const int* tt = &type1;
355   while( *tt>=0 )
356   {
357     types.append( *tt );
358     tt++;
359   }
360
361   setObjectType( id, types );
362 }
363
364 //=======================================================================
365 // name    : setObjectType
366 // Purpose :
367 //=======================================================================
368 void SalomeApp_Dialog::setObjectType( const int id, const TypesList& list )
369 {
370   if( !myObjects.contains( id ) )
371     return;
372
373   TypesList& internal = myObjects[ id ].myPossibleTypes;
374     
375   QMap<int,int> types;
376   TypesList::const_iterator anIt = list.begin(),
377                             aLast = list.end();
378   for( ; anIt!=aLast; anIt++ )
379     types.insert( *anIt, 0 );
380
381
382   internal.clear();
383   QMap<int,int>::const_iterator aMIt = types.begin(),
384                                 aMLast = types.end();
385   for( ; aMIt!=aMLast; aMIt++ )
386     internal.append( aMIt.key() );
387
388   updateObject( id );
389 }
390
391 //=======================================================================
392 // name    : addObjectType
393 // Purpose :
394 //=======================================================================
395 void SalomeApp_Dialog::addObjectType( const int id, const int type1, const int, ... )
396 {
397   TypesList types; objectTypes( id, types );
398
399   const int* tt = &type1;
400   while( *tt>=0 )
401   {
402     types.append( *tt );
403     tt++;
404   }
405
406   setObjectType( id, types );  
407 }
408
409 //=======================================================================
410 // name    : addObjectType
411 // Purpose :
412 //=======================================================================
413 void SalomeApp_Dialog::addObjectType( const int id, const TypesList& list )
414 {
415   TypesList types = list; objectTypes( id, types );
416   setObjectType( id, types );
417 }
418
419 //=======================================================================
420 // name    : addObjectType
421 // Purpose :
422 //=======================================================================
423 void SalomeApp_Dialog::addObjectType( const int id, const int type )
424 {
425   TypesList types; objectTypes( id, types );
426   types.append( type );
427   setObjectType( id, types );
428 }
429
430 //=======================================================================
431 // name    : removeObjectType
432 // Purpose :
433 //=======================================================================
434 void SalomeApp_Dialog::removeObjectType( const int id )
435 {
436   TypesList types;
437   setObjectType( id, types );
438 }
439
440 //=======================================================================
441 // name    : removeObjectType
442 // Purpose :
443 //=======================================================================
444 void SalomeApp_Dialog::removeObjectType( const int id, const TypesList& list )
445 {
446   if( !myObjects.contains( id ) )
447     return;
448
449   TypesList& internal = myObjects[ id ].myPossibleTypes;
450
451   QMap<int,int> types;
452   TypesList::const_iterator anIt = internal.begin(),
453                             aLast = internal.end();
454   for( ; anIt!=aLast; anIt++ )
455     types.insert( *anIt, 0 );
456   anIt = list.begin(); aLast = list.end();
457   for( ; anIt!=aLast; anIt++ )
458     types.remove( *anIt );
459
460
461   internal.clear();
462   QMap<int,int>::const_iterator aMIt = types.begin(),
463                                 aMLast = types.end();
464   for( ; aMIt!=aMLast; aMIt++ )
465     internal.append( aMIt.key() );
466
467   updateObject( id );
468 }
469
470 //=======================================================================
471 // name    : removeObjectType
472 // Purpose :
473 //=======================================================================
474 void SalomeApp_Dialog::removeObjectType( const int id, const int type )
475 {
476   TypesList list; list.append( type );
477   removeObjectType( id, list );
478 }
479
480 //=======================================================================
481 // name    : hasObjectType
482 // Purpose :
483 //=======================================================================
484 bool SalomeApp_Dialog::hasObjectType( const int id, const int type ) const
485 {
486   if( myObjects.contains( id ) )
487     return myObjects[ id ].myPossibleTypes.contains( type );
488   else
489     return false;
490 }
491
492 //=======================================================================
493 // name    : objectTypes
494 // Purpose :
495 //=======================================================================
496 void SalomeApp_Dialog::objectTypes( const int id, TypesList& list ) const
497 {
498   if( myObjects.contains( id ) )
499   {
500     TypesList::const_iterator anIt = myObjects[ id ].myPossibleTypes.begin(),
501                               aLast = myObjects[ id ].myPossibleTypes.end();
502     for( ; anIt!=aLast; anIt++ )
503       list.append( *anIt );
504   }  
505 }
506
507 //=======================================================================
508 // name    : onToggled
509 // Purpose :
510 //=======================================================================
511 void SalomeApp_Dialog::onToggled( bool on )
512 {
513   QButton* but = ( QButton* )sender();
514   int id = -1;
515
516   if( !but )
517     return;
518     
519   ObjectMap::const_iterator anIt = myObjects.begin(),
520                             aLast = myObjects.end();
521   for( ; anIt!=aLast && id==-1; anIt++ )
522     if( anIt.data().myBtn==but )
523       id = anIt.key();
524
525   if( id!=-1 )
526     if( on )
527     {
528       emit objectActivated( id );
529       updateButtons( id );
530     }
531     else
532       emit objectDeactivated( id );
533 }
534
535 //=======================================================================
536 // name    : updateObject
537 // Purpose :
538 //=======================================================================
539 void SalomeApp_Dialog::updateObject( const int id, bool emit_signal )
540 {
541   if( hasSelection( id ) )
542   {
543     Object& obj = myObjects[ id ];
544     filterTypes( id, obj.myNames, obj.myTypes, obj.myIds );
545     obj.myEdit->setText( selectionDescription( obj.myNames, obj.myTypes, obj.myNI ) );
546     if( emit_signal )
547       emit selectionChanged( id );
548   }
549 }
550
551 //=======================================================================
552 // name    : filterTypes
553 // Purpose :
554 //=======================================================================
555 void SalomeApp_Dialog::filterTypes( const int id, QStringList& names, TypesList& types, QStringList& ids ) const
556 {
557   if( !myObjects.contains( id ) )
558     return;
559
560   const Object& obj = myObjects[ id ];
561   if( obj.myPossibleTypes.isEmpty() )
562     return;
563
564   QStringList new_names, new_ids;
565   TypesList new_types;
566   
567   TypesList::const_iterator anIt1 = types.begin(),
568                             aLast = types.end();
569   QStringList::const_iterator anIt2 = names.begin(),
570                               anIt3 = ids.begin();
571   for( ; anIt1!=aLast; anIt1++, anIt2++, anIt3++ )
572     if( obj.myPossibleTypes.contains( *anIt1 ) )
573     {
574       if( new_types.count()==1 && !multipleSelection( id ) )
575         break;
576         
577       new_names.append( *anIt2 );
578       new_types.append( *anIt1 );
579       new_ids.append( *anIt3 );       
580     }
581   names = new_names;
582   types = new_types;
583   ids = new_ids;
584 }
585
586 //=======================================================================
587 // name    : resMgr
588 // Purpose :
589 //=======================================================================
590 SUIT_ResourceMgr* SalomeApp_Dialog::resMgr() const
591 {
592   return SUIT_Session::session()->resourceMgr();
593 }
594
595 //=======================================================================
596 // name    : setObjectPixmap
597 // Purpose :
598 //=======================================================================
599 void SalomeApp_Dialog::setObjectPixmap( const QPixmap& p )
600 {
601   myPixmap = p;
602   ObjectMap::const_iterator anIt = myObjects.begin(),
603                             aLast = myObjects.end();
604   for( ; anIt!=aLast; anIt++ )
605     ( ( QToolButton* )anIt.data().myBtn )->setIconSet( p );
606 }                        
607
608 //=======================================================================
609 // name    : setObjectPixmap
610 // Purpose :
611 //=======================================================================
612 void SalomeApp_Dialog::setObjectPixmap( const QString& section, const QString& file )
613 {
614   SUIT_ResourceMgr* mgr = resMgr();
615   if( mgr )
616     setObjectPixmap( mgr->loadPixmap( section, file ) );
617 }
618
619 //=======================================================================
620 // name    : multipleSelection
621 // Purpose :
622 //=======================================================================
623 bool SalomeApp_Dialog::multipleSelection( const int id ) const
624 {
625   return nameIndication( id )!=OneName;  
626 }
627
628 //=======================================================================
629 // name    : nameIndication
630 // Purpose :
631 //=======================================================================
632 SalomeApp_Dialog::NameIndication SalomeApp_Dialog::nameIndication( const int id ) const
633 {
634   if( myObjects.contains( id ) )
635     return myObjects[ id ].myNI;
636   else
637     return OneNameOrCount;
638 }
639
640 //=======================================================================
641 // name    : setNameIndication
642 // Purpose :
643 //=======================================================================
644 void SalomeApp_Dialog::setNameIndication( const int id, const NameIndication ni )
645 {
646   if( id==-1 )
647   {
648     ObjectMap::iterator anIt = myObjects.begin(),
649                         aNext,
650                         aLast = myObjects.end();
651     for( ; anIt!=aLast; anIt++ )
652     {
653       anIt.data().myNI = ni;
654       setReadOnly( anIt.key(), isReadOnly( anIt.key() ) );
655       aNext = anIt; aNext++;
656       updateObject( anIt.key(), aNext==aLast );
657     }
658   }
659   else if( myObjects.contains( id ) )
660   {
661     myObjects[ id ].myNI = ni;
662     setReadOnly( id, isReadOnly( id ) );
663     updateObject( id, true );
664   }
665 }
666
667 //=======================================================================
668 // name    : selectionDescription
669 // Purpose :
670 //=======================================================================
671 QString SalomeApp_Dialog::selectionDescription( const QStringList& names, const TypesList& types, const NameIndication ni ) const
672 {
673   if( names.count()!=types.count() )
674     return "SalomeApp_Dialog::selectionDescription(): Error!!!";
675     
676   if( names.isEmpty() )
677     return QString::null;
678     
679   switch( ni )
680   {
681     case OneName:
682       return names.first();
683       break;
684       
685     case OneNameOrCount:
686       if( names.count()==1 )
687         return names.first();
688       else
689         return countOfTypes( types );
690       break;
691       
692     case ListOfNames:
693       return names.join( " " );
694       break;
695       
696     case Count:
697       return countOfTypes( types );
698       break;
699   };
700   return QString::null;
701 }
702
703 //=======================================================================
704 // name    : countOfTypes
705 // Purpose :
706 //=======================================================================
707 QString SalomeApp_Dialog::countOfTypes( const TypesList& types ) const
708 {
709   QMap<int, int> typesCount;
710   QStringList typeCount;
711   
712   TypesList::const_iterator anIt = types.begin(),
713                             aLast = types.end();
714   for( ; anIt!=aLast; anIt++ )
715     if( typesCount.contains( *anIt ) )
716       typesCount[ *anIt ]++;
717     else
718       typesCount[ *anIt ] = 1;
719
720   QMap<int,int>::const_iterator aMIt = typesCount.begin(),
721                                 aMLast = typesCount.end();
722   for( ; aMIt!=aMLast; aMIt++ )
723     typeCount.append( QString( "%1 %2" ).arg( aMIt.data() ).arg( typeName( aMIt.key() ) ) );
724
725   return typeCount.join( ", " );
726 }
727
728 //=======================================================================
729 // name    : typeName
730 // Purpose :
731 //=======================================================================
732 QString& SalomeApp_Dialog::typeName( const int type )
733 {
734   return myTypeNames[ type ];
735 }
736
737 //=======================================================================
738 // name    : typeName
739 // Purpose :
740 //=======================================================================
741 const QString& SalomeApp_Dialog::typeName( const int type ) const
742 {
743   return myTypeNames[ type ];
744 }
745
746
747 //=======================================================================
748 // name    : activateObject
749 // Purpose :
750 //=======================================================================
751 void SalomeApp_Dialog::activateObject( const int theId )
752 {
753   if ( myObjects.contains( theId ) && !myObjects[ theId ].myBtn->isOn() )
754     myObjects[ theId ].myBtn->toggle();
755 }
756
757 //=======================================================================
758 // name    : deactivateAll
759 // Purpose :
760 //=======================================================================
761 void SalomeApp_Dialog::deactivateAll()
762 {
763   ObjectMap::iterator anIt = myObjects.begin(),
764                       aLast = myObjects.end();
765   for( ; anIt!=aLast; anIt++ )
766   {
767     QToolButton* btn = ( QToolButton* )anIt.data().myBtn;
768     btn->setOn( false );
769   }
770 }
771
772 //=======================================================================
773 // name    : selectObject
774 // Purpose :
775 //=======================================================================
776 void SalomeApp_Dialog::selectObject( const int id, const QString& name, const int type, const QString& selid, const bool update )
777 {
778   QStringList names;   names.append( name );
779   TypesList types;     types.append( type );
780   QStringList ids;     ids.append( selid );
781   selectObject( id, names, types, ids, update );
782 }
783
784 //=======================================================================
785 // name    : selectObject
786 // Purpose :
787 //=======================================================================
788 void SalomeApp_Dialog::selectObject( const int id, const QStringList& _names, const TypesList& _types,
789                                      const QStringList& _ids, const bool update )
790 {
791   if( !myObjects.contains( id ) )
792     return;
793     
794   QStringList names = _names, ids = _ids;
795   TypesList types = _types;
796
797   filterTypes( id, names, types, ids );
798
799   Object& obj = myObjects[ id ];
800   if( update )
801     obj.myEdit->setText( selectionDescription( names, types, obj.myNI ) );
802   obj.myTypes = types;
803   obj.myIds = ids;
804   obj.myNames = names;
805
806   emit selectionChanged( id );
807 }
808
809 //=======================================================================
810 // name    : setReadOnly
811 // Purpose :
812 //=======================================================================
813 void SalomeApp_Dialog::setReadOnly( const int id, const bool ro )
814 {
815   if( myObjects.contains( id ) )
816     myObjects[ id ].myEdit->setReadOnly( nameIndication( id )==ListOfNames || nameIndication( id )==OneName ? ro : true );
817 }
818
819 //=======================================================================
820 // name    : isReadOnly
821 // Purpose :
822 //=======================================================================
823 bool SalomeApp_Dialog::isReadOnly( const int id ) const
824 {
825   if( myObjects.contains( id ) )
826     return myObjects[ id ].myEdit->isReadOnly();
827   else
828     return true;
829 }
830   
831 //=======================================================================
832 // name    : onTextChanged
833 // Purpose :
834 //=======================================================================
835 void SalomeApp_Dialog::onTextChanged( const QString& text )
836 {
837   if( myIsBusy )
838     return;
839
840   myIsBusy = true;
841
842   if( sender() && sender()->inherits( "QLineEdit" ) )
843   {
844     QLineEdit* edit = ( QLineEdit* )sender();
845     int id = -1;
846     ObjectMap::const_iterator anIt = myObjects.begin(),
847                               aLast = myObjects.end();
848     for( ; anIt!=aLast; anIt++ )
849       if( anIt.data().myEdit == edit )
850         id = anIt.key();
851
852     if( id>=0 && !isReadOnly( id ) )
853     {
854       QStringList list = QStringList::split( " ", text );
855       emit objectChanged( id, list );
856     }
857   }
858
859   myIsBusy = false;
860 }