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 Base class for all LightApp dialogs.
41 Provides standard widget for object selection: line edit, button;
42 it is necessary to call corresponding methods on selection change.
43 Standard dialog provides filtering, selection string representation,
44 possibility to indicate necessary selection by text with list of ids.
46 class LIGHTAPP_EXPORT LightApp_Dialog : public QtxDialog
51 typedef QValueList<int> TypesList;
52 typedef QMap<int,QStringList> SelectedObjects;
63 OneName, //<! only one object can be selected and it's name is shown
64 OneNameOrCount, //<! if one object is selected, it's name is shown otherwise
65 // "<count> <type>" is shown
66 ListOfNames, //! list of all names is shown
67 Count //! In every case "<count> <type>" is shown
70 //! The enumeration describing how names of selected objects will be shown in line edit
71 //! For more details see above
74 LightApp_Dialog( QWidget* = 0, const char* = 0, bool = false,
75 bool = false, const int = Standard, WFlags = 0 );
76 virtual ~LightApp_Dialog();
80 //! Check if buttons is exclusive (as radiobuttons)
81 bool isExclusive() const;
83 //! Set exclusive state
84 void setExclusive( const bool );
86 //! Check if operation according to dialog will be resumed automatically when mouse enter the dialog
87 bool isAutoResumed() const;
89 //! Set auto resumed state
90 void setAutoResumed( const bool );
92 //! Show widgets corresponding to id
93 void showObject( const int );
95 //! Hide widgets corresponding to id
96 void hideObject( const int );
98 //! Change the shown state of widgets corresponding to id
99 void setObjectShown( const int, const bool );
101 //! Check the shown state
102 bool isObjectShown( const int ) const;
104 //! Change the enabled state of widgets corresponding to id
105 void setObjectEnabled( const int, const bool );
107 //! Check the enabled state
108 bool isObjectEnabled( const int ) const;
110 //! Get widget of object (see ObjectWg enumeration)
111 QWidget* objectWg( const int theId, const int theWgId ) const;
113 //! Pass to all active widgets name, type and id of selected object
114 void selectObject( const QString&, const int, const QString&, const bool = true );
117 Pass to all active widgets list of names, types and ids of selected objects
118 Every active widget filters list and accept only objects with possible types
120 void selectObject( const QStringList&, const TypesList&, const QStringList&, const bool = true );
122 //! Get text of object's control
123 QString objectText( const int ) const;
125 //! Set text of object's control
126 void setObjectText( const int, const QString& );
128 //! Select in certain widget avoiding check if there is active widget
129 void selectObject( const int, const QString&, const int, const QString&, const bool = true );
130 void selectObject( const int, const QStringList&, const TypesList&, const QStringList&, const bool = true );
132 //! Check if certain widget has selection
133 bool hasSelection( const int ) const;
135 //! Clear selection in widgets. If parameter is -1, then selection in all widgets will be cleared
136 void clearSelection( const int = -1 );
138 //! Get ids list of object selected in certain widget
139 void selectedObject( const int, QStringList& ) const;
141 //! Get ids list of object selected in certain widget
142 QString selectedObject( const int ) const;
144 //! Get map "widget id -> ids list"
145 void objectSelection( SelectedObjects& ) const;
147 //! Activate object selection button
148 void activateObject( const int );
150 //! Set all object selection buttons to inactive state
151 void deactivateAll();
154 //! selection in certain widget is changed
155 void selectionChanged ( int );
157 //! selection in certain widget is on
158 void objectActivated ( int );
160 //! selection in certain widget is off
161 void objectDeactivated( int );
164 text representation of selection is changed
165 it is emitted only if "read only" state of line edit is false
167 void objectChanged( int, const QStringList& );
170 //! Finds and returns resource manager
171 SUIT_ResourceMgr* resMgr() const;
173 /*! Create label, button and line edit for object selection
174 * If passed id is negative, then id will be calculated automatically (first free id)
175 * Returns the same id (if id>=0) or calculated
177 int createObject ( const QString&, QWidget*, const int = -1 );
179 //! Set pixmap as icon for all selection buttons
180 void setObjectPixmap ( const QPixmap& );
182 //! Load pixmap with section, name using resource manager and set as icon for all selection buttons
183 void setObjectPixmap ( const QString&, const QString& );
186 void renameObject ( const int, const QString& );
188 //! Set possible types for certain id. The list of arguments must be finished by negative integer
189 void setObjectType ( const int, const int, ... );
191 //! Set list as possible types for object selection
192 void setObjectType ( const int, const TypesList& );
195 Add types to list of possible types
196 The list of arguments must be finished by negative integer
198 void addObjectType ( const int, const int, const int, ... );
200 //! Add types to list of possible types
201 void addObjectType ( const int, const TypesList& );
203 //! Add type to list of possible types
204 void addObjectType ( const int, const int );
206 //! Clear list of possible types (it means, that all types are welcome)
207 void removeObjectType( const int );
209 //! Remove types in list from list of possible types
210 void removeObjectType( const int, const TypesList& );
212 //! Remove a type from list of possible types
213 void removeObjectType( const int, const int );
215 //! Check if list of possible types contains this one
216 bool hasObjectType ( const int, const int ) const;
218 //! Return list of possible types
219 void objectTypes ( const int, TypesList& ) const;
221 //!Change and get type name for indicating in selection widget
222 QString& typeName( const int );
223 const QString& typeName( const int ) const;
225 //! Create string contains selection list by list of names, list of types and current name indication state
226 virtual QString selectionDescription( const QStringList&, const TypesList&, const NameIndication ) const;
228 //! Create string by pattern "<count> <type>" for current list of types
229 virtual QString countOfTypes( const TypesList& ) const;
231 //! Get and set name indication for certain widget
232 NameIndication nameIndication( const int ) const;
233 void setNameIndication( const int, const NameIndication );
235 //! Check using name indication if multiple selection in possible
236 bool multipleSelection( const int ) const;
238 //! Set the "read only" state of object selection line edit
239 //! The "read only" will be false only if name indication is ListOfNames
240 void setReadOnly( const int, const bool );
242 //! Check the "read only" state of object selection line edit
243 bool isReadOnly( const int ) const;
246 //! emits if the object selection button changes state
247 void onToggled( bool );
249 //! text in some line edit is changed
250 void onTextChanged( const QString& );
254 If buttons are exclusive, set to "off" all buttons except one with id
255 If id=-1, then all buttons, except first with "on" state, will be set to "off"
257 void updateButtons( const int = -1 );
260 Filter types and update selection string in line edit
261 If bool is true, then signal is emitted
263 void updateObject( const int, bool = true );
265 //! Remove from list not possible types and remove from names and ids lists the corresponding items
266 void filterTypes( const int, QStringList&, TypesList&, QStringList& ) const;
274 QStringList myNames, myIds;
275 TypesList myTypes, myPossibleTypes;
280 typedef QMap<int, Object> ObjectMap;
284 QMap<int,QString> myTypeNames;
285 bool myIsExclusive, myIsBusy;