1 // File: SalomeApp_Dialog.h
2 // Author: Alexander SOLOVYOV
4 #ifndef SALOMEAPP_DIALOG_H
5 #define SALOMEAPP_DIALOG_H
9 #include <qvaluelist.h>
17 class SUIT_ResourceMgr;
20 Class : SalomeApp_Dialog
21 Description : Base class for all SALOME dialogs
23 class SalomeApp_Dialog : public QtxDialog
28 typedef QValueList<int> TypesList;
29 typedef QMap<int,QStringList> SelectedObjects;
40 OneName, //<! only one object can be selected and it's name is shown
41 OneNameOrCount, //<! if one object is selected, it's name is shown otherwise
42 // "<count> <type>" is shown
43 ListOfNames, //! list of all names is shown
44 Count //! In every case "<count> <type>" is shown
47 //! The enumeration describing how names of selected objects will be shown in line edit
48 //! For more details see above
51 SalomeApp_Dialog( QWidget* = 0, const char* = 0, bool = false,
52 bool = false, const int = Standard, WFlags = 0 );
53 virtual ~SalomeApp_Dialog();
57 //! Check if buttons is exclusive (as radiobuttons)
58 bool isExclusive() const;
60 //! Set exclusive state
61 void setExclusive( const bool );
63 //! Check if operation according to dialog will be resumed automatically when mouse enter the dialog
64 bool isAutoResumed() const;
66 //! Set auto resumed state
67 void setAutoResumed( const bool );
69 //! Show widgets corresponding to id
70 void showObject( const int );
72 //! Hide widgets corresponding to id
73 void hideObject( const int );
75 //! Change the shown state of widgets corresponding to id
76 void setObjectShown( const int, const bool );
78 //! Check the shown state
79 bool isObjectShown( const int ) const;
81 //! Change the enabled state of widgets corresponding to id
82 void setObjectEnabled( const int, const bool );
84 //! Check the enabled state
85 bool isObjectEnabled( const int ) const;
87 //! Get widget of object (see ObjectWg enumeration)
88 QWidget* objectWg( const int theId, const int theWgId ) const;
90 //! Pass to all active widgets name, type and id of selected object
91 void selectObject( const QString&, const int, const QString&, const bool = true );
94 Pass to all active widgets list of names, types and ids of selected objects
95 Every active widget filters list and accept only objects with possible types
97 void selectObject( const QStringList&, const TypesList&, const QStringList&, const bool = true );
99 //! Get text of object's control
100 QString objectText( const int ) const;
102 //! Set text of object's control
103 void setObjectText( const int, const QString& );
105 //! Select in certain widget avoiding check if there is active widget
106 void selectObject( const int, const QString&, const int, const QString&, const bool = true );
107 void selectObject( const int, const QStringList&, const TypesList&, const QStringList&, const bool = true );
109 //! Check if certain widget has selection
110 bool hasSelection( const int ) const;
112 //! Clear selection in widgets. If parameter is -1, then selection in all widgets will be cleared
113 void clearSelection( const int = -1 );
115 //! Get ids list of object selected in certain widget
116 void selectedObject( const int, QStringList& ) const;
118 //! Get ids list of object selected in certain widget
119 QString selectedObject( const int ) const;
121 //! Get map "widget id -> ids list"
122 void objectSelection( SelectedObjects& ) const;
124 //! Activate object selection button
125 void activateObject( const int );
127 //! Set all object selection buttons to inactive state
128 void deactivateAll();
131 //! selection in certain widget is changed
132 void selectionChanged ( int );
134 //! selection in certain widget is on
135 void objectActivated ( int );
137 //! selection in certain widget is off
138 void objectDeactivated( int );
141 text representation of selection is changed
142 it is emitted only if "read only" state of line edit is false
144 void objectChanged( int, const QStringList& );
147 //! Finds and returns resource manager
148 SUIT_ResourceMgr* resMgr() const;
150 /*! Create label, button and line edit for object selection
151 * If passed id is negative, then id will be calculated automatically (first free id)
152 * Returns the same id (if id>=0) or calculated
154 int createObject ( const QString&, QWidget*, const int = -1 );
156 //! Set pixmap as icon for all selection buttons
157 void setObjectPixmap ( const QPixmap& );
159 //! Load pixmap with section, name using resource manager and set as icon for all selection buttons
160 void setObjectPixmap ( const QString&, const QString& );
163 void renameObject ( const int, const QString& );
165 //! Set possible types for certain id. The list of arguments must be finished by negative integer
166 void setObjectType ( const int, const int, ... );
168 //! Set list as possible types for object selection
169 void setObjectType ( const int, const TypesList& );
172 Add types to list of possible types
173 The list of arguments must be finished by negative integer
175 void addObjectType ( const int, const int, const int, ... );
177 //! Add types to list of possible types
178 void addObjectType ( const int, const TypesList& );
180 //! Add type to list of possible types
181 void addObjectType ( const int, const int );
183 //! Clear list of possible types (it means, that all types are welcome)
184 void removeObjectType( const int );
186 //! Remove types in list from list of possible types
187 void removeObjectType( const int, const TypesList& );
189 //! Remove a type from list of possible types
190 void removeObjectType( const int, const int );
192 //! Check if list of possible types contains this one
193 bool hasObjectType ( const int, const int ) const;
195 //! Return list of possible types
196 void objectTypes ( const int, TypesList& ) const;
198 //!Change and get type name for indicating in selection widget
199 QString& typeName( const int );
200 const QString& typeName( const int ) const;
202 //! Create string contains selection list by list of names, list of types and current name indication state
203 virtual QString selectionDescription( const QStringList&, const TypesList&, const NameIndication ) const;
205 //! Create string by pattern "<count> <type>" for current list of types
206 virtual QString countOfTypes( const TypesList& ) const;
208 //! Get and set name indication for certain widget
209 NameIndication nameIndication( const int ) const;
210 void setNameIndication( const int, const NameIndication );
212 //! Check using name indication if multiple selection in possible
213 bool multipleSelection( const int ) const;
215 //! Set the "read only" state of object selection line edit
216 //! The "read only" will be false only if name indication is ListOfNames
217 void setReadOnly( const int, const bool );
219 //! Check the "read only" state of object selection line edit
220 bool isReadOnly( const int ) const;
223 //! emits if the object selection button changes state
224 void onToggled( bool );
226 //! text in some line edit is changed
227 void onTextChanged( const QString& );
231 If buttons are exclusive, set to "off" all buttons except one with id
232 If id=-1, then all buttons, except first with "on" state, will be set to "off"
234 void updateButtons( const int = -1 );
237 Filter types and update selection string in line edit
238 If bool is true, then signal is emitted
240 void updateObject( const int, bool = true );
242 //! Remove from list not possible types and remove from names and ids lists the corresponding items
243 void filterTypes( const int, QStringList&, TypesList&, QStringList& ) const;
251 QStringList myNames, myIds;
252 TypesList myTypes, myPossibleTypes;
257 typedef QMap<int, Object> ObjectMap;
261 QMap<int,QString> myTypeNames;
262 bool myIsExclusive, myIsBusy;