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