1 // File: LightApp_Dialog.h
2 // Author: Alexander SOLOVYOV
4 #ifndef LIGHTAPP_DIALOG_H
5 #define LIGHTAPP_DIALOG_H
10 #include <qvaluelist.h>
18 class SUIT_ResourceMgr;
21 Class : LightApp_Dialog
22 Description : Base class for all LightApp dialogs
24 class LIGHTAPP_EXPORT LightApp_Dialog : public QtxDialog
29 typedef QValueList<int> TypesList;
30 typedef QMap<int,QStringList> SelectedObjects;
41 OneName, //<! only one object can be selected and it's name is shown
42 OneNameOrCount, //<! if one object is selected, it's name is shown otherwise
43 // "<count> <type>" is shown
44 ListOfNames, //! list of all names is shown
45 Count //! In every case "<count> <type>" is shown
48 //! The enumeration describing how names of selected objects will be shown in line edit
49 //! For more details see above
52 LightApp_Dialog( QWidget* = 0, const char* = 0, bool = false,
53 bool = false, const int = Standard, WFlags = 0 );
54 virtual ~LightApp_Dialog();
58 //! Check if buttons is exclusive (as radiobuttons)
59 bool isExclusive() const;
61 //! Set exclusive state
62 void setExclusive( const bool );
64 //! Check if operation according to dialog will be resumed automatically when mouse enter the dialog
65 bool isAutoResumed() const;
67 //! Set auto resumed state
68 void setAutoResumed( const bool );
70 //! Show widgets corresponding to id
71 void showObject( const int );
73 //! Hide widgets corresponding to id
74 void hideObject( const int );
76 //! Change the shown state of widgets corresponding to id
77 void setObjectShown( const int, const bool );
79 //! Check the shown state
80 bool isObjectShown( const int ) const;
82 //! Change the enabled state of widgets corresponding to id
83 void setObjectEnabled( const int, const bool );
85 //! Check the enabled state
86 bool isObjectEnabled( const int ) const;
88 //! Get widget of object (see ObjectWg enumeration)
89 QWidget* objectWg( const int theId, const int theWgId ) const;
91 //! Pass to all active widgets name, type and id of selected object
92 void selectObject( const QString&, const int, const QString&, const bool = true );
95 Pass to all active widgets list of names, types and ids of selected objects
96 Every active widget filters list and accept only objects with possible types
98 void selectObject( const QStringList&, const TypesList&, const QStringList&, const bool = true );
100 //! Get text of object's control
101 QString objectText( const int ) const;
103 //! Set text of object's control
104 void setObjectText( const int, const QString& );
106 //! Select in certain widget avoiding check if there is active widget
107 void selectObject( const int, const QString&, const int, const QString&, const bool = true );
108 void selectObject( const int, const QStringList&, const TypesList&, const QStringList&, const bool = true );
110 //! Check if certain widget has selection
111 bool hasSelection( const int ) const;
113 //! Clear selection in widgets. If parameter is -1, then selection in all widgets will be cleared
114 void clearSelection( const int = -1 );
116 //! Get ids list of object selected in certain widget
117 void selectedObject( const int, QStringList& ) const;
119 //! Get ids list of object selected in certain widget
120 QString selectedObject( const int ) const;
122 //! Get map "widget id -> ids list"
123 void objectSelection( SelectedObjects& ) const;
125 //! Activate object selection button
126 void activateObject( const int );
128 //! Set all object selection buttons to inactive state
129 void deactivateAll();
132 //! selection in certain widget is changed
133 void selectionChanged ( int );
135 //! selection in certain widget is on
136 void objectActivated ( int );
138 //! selection in certain widget is off
139 void objectDeactivated( int );
142 text representation of selection is changed
143 it is emitted only if "read only" state of line edit is false
145 void objectChanged( int, const QStringList& );
148 //! Finds and returns resource manager
149 SUIT_ResourceMgr* resMgr() const;
151 /*! Create label, button and line edit for object selection
152 * If passed id is negative, then id will be calculated automatically (first free id)
153 * Returns the same id (if id>=0) or calculated
155 int createObject ( const QString&, QWidget*, const int = -1 );
157 //! Set pixmap as icon for all selection buttons
158 void setObjectPixmap ( const QPixmap& );
160 //! Load pixmap with section, name using resource manager and set as icon for all selection buttons
161 void setObjectPixmap ( const QString&, const QString& );
164 void renameObject ( const int, const QString& );
166 //! Set possible types for certain id. The list of arguments must be finished by negative integer
167 void setObjectType ( const int, const int, ... );
169 //! Set list as possible types for object selection
170 void setObjectType ( const int, const TypesList& );
173 Add types to list of possible types
174 The list of arguments must be finished by negative integer
176 void addObjectType ( const int, const int, const int, ... );
178 //! Add types to list of possible types
179 void addObjectType ( const int, const TypesList& );
181 //! Add type to list of possible types
182 void addObjectType ( const int, const int );
184 //! Clear list of possible types (it means, that all types are welcome)
185 void removeObjectType( const int );
187 //! Remove types in list from list of possible types
188 void removeObjectType( const int, const TypesList& );
190 //! Remove a type from list of possible types
191 void removeObjectType( const int, const int );
193 //! Check if list of possible types contains this one
194 bool hasObjectType ( const int, const int ) const;
196 //! Return list of possible types
197 void objectTypes ( const int, TypesList& ) const;
199 //!Change and get type name for indicating in selection widget
200 QString& typeName( const int );
201 const QString& typeName( const int ) const;
203 //! Create string contains selection list by list of names, list of types and current name indication state
204 virtual QString selectionDescription( const QStringList&, const TypesList&, const NameIndication ) const;
206 //! Create string by pattern "<count> <type>" for current list of types
207 virtual QString countOfTypes( const TypesList& ) const;
209 //! Get and set name indication for certain widget
210 NameIndication nameIndication( const int ) const;
211 void setNameIndication( const int, const NameIndication );
213 //! Check using name indication if multiple selection in possible
214 bool multipleSelection( const int ) const;
216 //! Set the "read only" state of object selection line edit
217 //! The "read only" will be false only if name indication is ListOfNames
218 void setReadOnly( const int, const bool );
220 //! Check the "read only" state of object selection line edit
221 bool isReadOnly( const int ) const;
224 //! emits if the object selection button changes state
225 void onToggled( bool );
227 //! text in some line edit is changed
228 void onTextChanged( const QString& );
232 If buttons are exclusive, set to "off" all buttons except one with id
233 If id=-1, then all buttons, except first with "on" state, will be set to "off"
235 void updateButtons( const int = -1 );
238 Filter types and update selection string in line edit
239 If bool is true, then signal is emitted
241 void updateObject( const int, bool = true );
243 //! Remove from list not possible types and remove from names and ids lists the corresponding items
244 void filterTypes( const int, QStringList&, TypesList&, QStringList& ) const;
252 QStringList myNames, myIds;
253 TypesList myTypes, myPossibleTypes;
258 typedef QMap<int, Object> ObjectMap;
262 QMap<int,QString> myTypeNames;
263 bool myIsExclusive, myIsBusy;