1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
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.
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.
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
17 // See http://www.salome-platform.org/
19 // File: LightApp_Dialog.h
20 // Author: Alexander SOLOVYOV
22 #ifndef LIGHTAPP_DIALOG_H
23 #define LIGHTAPP_DIALOG_H
26 #include <QtxDialog.h>
28 #include <qvaluelist.h>
36 class SUIT_ResourceMgr;
39 Class : LightApp_Dialog
40 Description : Base class for all LightApp dialogs
42 class LIGHTAPP_EXPORT LightApp_Dialog : public QtxDialog
47 typedef QValueList<int> TypesList;
48 typedef QMap<int,QStringList> SelectedObjects;
59 OneName, //<! only one object can be selected and it's name is shown
60 OneNameOrCount, //<! if one object is selected, it's name is shown otherwise
61 // "<count> <type>" is shown
62 ListOfNames, //! list of all names is shown
63 Count //! In every case "<count> <type>" is shown
66 //! The enumeration describing how names of selected objects will be shown in line edit
67 //! For more details see above
70 LightApp_Dialog( QWidget* = 0, const char* = 0, bool = false,
71 bool = false, const int = Standard, WFlags = 0 );
72 virtual ~LightApp_Dialog();
76 //! Check if buttons is exclusive (as radiobuttons)
77 bool isExclusive() const;
79 //! Set exclusive state
80 void setExclusive( const bool );
82 //! Check if operation according to dialog will be resumed automatically when mouse enter the dialog
83 bool isAutoResumed() const;
85 //! Set auto resumed state
86 void setAutoResumed( const bool );
88 //! Show widgets corresponding to id
89 void showObject( const int );
91 //! Hide widgets corresponding to id
92 void hideObject( const int );
94 //! Change the shown state of widgets corresponding to id
95 void setObjectShown( const int, const bool );
97 //! Check the shown state
98 bool isObjectShown( const int ) const;
100 //! Change the enabled state of widgets corresponding to id
101 void setObjectEnabled( const int, const bool );
103 //! Check the enabled state
104 bool isObjectEnabled( const int ) const;
106 //! Get widget of object (see ObjectWg enumeration)
107 QWidget* objectWg( const int theId, const int theWgId ) const;
109 //! Pass to all active widgets name, type and id of selected object
110 void selectObject( const QString&, const int, const QString&, const bool = true );
113 Pass to all active widgets list of names, types and ids of selected objects
114 Every active widget filters list and accept only objects with possible types
116 void selectObject( const QStringList&, const TypesList&, const QStringList&, const bool = true );
118 //! Get text of object's control
119 QString objectText( const int ) const;
121 //! Set text of object's control
122 void setObjectText( const int, const QString& );
124 //! Select in certain widget avoiding check if there is active widget
125 void selectObject( const int, const QString&, const int, const QString&, const bool = true );
126 void selectObject( const int, const QStringList&, const TypesList&, const QStringList&, const bool = true );
128 //! Check if certain widget has selection
129 bool hasSelection( const int ) const;
131 //! Clear selection in widgets. If parameter is -1, then selection in all widgets will be cleared
132 void clearSelection( const int = -1 );
134 //! Get ids list of object selected in certain widget
135 void selectedObject( const int, QStringList& ) const;
137 //! Get ids list of object selected in certain widget
138 QString selectedObject( const int ) const;
140 //! Get map "widget id -> ids list"
141 void objectSelection( SelectedObjects& ) const;
143 //! Activate object selection button
144 void activateObject( const int );
146 //! Set all object selection buttons to inactive state
147 void deactivateAll();
150 //! selection in certain widget is changed
151 void selectionChanged ( int );
153 //! selection in certain widget is on
154 void objectActivated ( int );
156 //! selection in certain widget is off
157 void objectDeactivated( int );
160 text representation of selection is changed
161 it is emitted only if "read only" state of line edit is false
163 void objectChanged( int, const QStringList& );
166 //! Finds and returns resource manager
167 SUIT_ResourceMgr* resMgr() const;
169 /*! Create label, button and line edit for object selection
170 * If passed id is negative, then id will be calculated automatically (first free id)
171 * Returns the same id (if id>=0) or calculated
173 int createObject ( const QString&, QWidget*, const int = -1 );
175 //! Set pixmap as icon for all selection buttons
176 void setObjectPixmap ( const QPixmap& );
178 //! Load pixmap with section, name using resource manager and set as icon for all selection buttons
179 void setObjectPixmap ( const QString&, const QString& );
182 void renameObject ( const int, const QString& );
184 //! Set possible types for certain id. The list of arguments must be finished by negative integer
185 void setObjectType ( const int, const int, ... );
187 //! Set list as possible types for object selection
188 void setObjectType ( const int, const TypesList& );
191 Add types to list of possible types
192 The list of arguments must be finished by negative integer
194 void addObjectType ( const int, const int, const int, ... );
196 //! Add types to list of possible types
197 void addObjectType ( const int, const TypesList& );
199 //! Add type to list of possible types
200 void addObjectType ( const int, const int );
202 //! Clear list of possible types (it means, that all types are welcome)
203 void removeObjectType( const int );
205 //! Remove types in list from list of possible types
206 void removeObjectType( const int, const TypesList& );
208 //! Remove a type from list of possible types
209 void removeObjectType( const int, const int );
211 //! Check if list of possible types contains this one
212 bool hasObjectType ( const int, const int ) const;
214 //! Return list of possible types
215 void objectTypes ( const int, TypesList& ) const;
217 //!Change and get type name for indicating in selection widget
218 QString& typeName( const int );
219 const QString& typeName( const int ) const;
221 //! Create string contains selection list by list of names, list of types and current name indication state
222 virtual QString selectionDescription( const QStringList&, const TypesList&, const NameIndication ) const;
224 //! Create string by pattern "<count> <type>" for current list of types
225 virtual QString countOfTypes( const TypesList& ) const;
227 //! Get and set name indication for certain widget
228 NameIndication nameIndication( const int ) const;
229 void setNameIndication( const int, const NameIndication );
231 //! Check using name indication if multiple selection in possible
232 bool multipleSelection( const int ) const;
234 //! Set the "read only" state of object selection line edit
235 //! The "read only" will be false only if name indication is ListOfNames
236 void setReadOnly( const int, const bool );
238 //! Check the "read only" state of object selection line edit
239 bool isReadOnly( const int ) const;
242 //! emits if the object selection button changes state
243 void onToggled( bool );
245 //! text in some line edit is changed
246 void onTextChanged( const QString& );
250 If buttons are exclusive, set to "off" all buttons except one with id
251 If id=-1, then all buttons, except first with "on" state, will be set to "off"
253 void updateButtons( const int = -1 );
256 Filter types and update selection string in line edit
257 If bool is true, then signal is emitted
259 void updateObject( const int, bool = true );
261 //! Remove from list not possible types and remove from names and ids lists the corresponding items
262 void filterTypes( const int, QStringList&, TypesList&, QStringList& ) const;
270 QStringList myNames, myIds;
271 TypesList myTypes, myPossibleTypes;
276 typedef QMap<int, Object> ObjectMap;
280 QMap<int,QString> myTypeNames;
281 bool myIsExclusive, myIsBusy;