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