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/ or email : webmaster.salome@opencascade.com
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 #pragma warning ( disable:4251 )
43 \class LightApp_Dialog
44 Base class for all LightApp dialogs.
45 Provides standard widget for object selection: line edit, button;
46 it is necessary to call corresponding methods on selection change.
47 Standard dialog provides filtering, selection string representation,
48 possibility to indicate necessary selection by text with list of ids.
50 class LIGHTAPP_EXPORT LightApp_Dialog : public QtxDialog
55 typedef QValueList<int> TypesList;
56 typedef QMap<int,QStringList> SelectedObjects;
67 OneName, //<! only one object can be selected and it's name is shown
68 OneNameOrCount, //<! if one object is selected, it's name is shown otherwise
69 // "<count> <type>" is shown
70 ListOfNames, //! list of all names is shown
71 Count //! In every case "<count> <type>" is shown
74 //! The enumeration describing how names of selected objects will be shown in line edit
75 //! For more details see above
78 LightApp_Dialog( QWidget* = 0, const char* = 0, bool = false,
79 bool = false, const int = Standard, WFlags = 0 );
80 virtual ~LightApp_Dialog();
84 //! Check if buttons is exclusive (as radiobuttons)
85 bool isExclusive() const;
87 //! Set exclusive state
88 void setExclusive( const bool );
90 //! Check if operation according to dialog will be resumed automatically when mouse enter the dialog
91 bool isAutoResumed() const;
93 //! Set auto resumed state
94 void setAutoResumed( const bool );
96 //! Show widgets corresponding to id
97 void showObject( const int );
99 //! Hide widgets corresponding to id
100 void hideObject( const int );
102 //! Change the shown state of widgets corresponding to id
103 void setObjectShown( const int, const bool );
105 //! Check the shown state
106 bool isObjectShown( const int ) const;
108 //! Change the enabled state of widgets corresponding to id
109 void setObjectEnabled( const int, const bool );
111 //! Check the enabled state
112 bool isObjectEnabled( const int ) const;
114 //! Get widget of object (see ObjectWg enumeration)
115 QWidget* objectWg( const int theId, const int theWgId ) const;
117 //! Pass to all active widgets name, type and id of selected object
118 void selectObject( const QString&, const int, const QString&, const bool = true );
121 Pass to all active widgets list of names, types and ids of selected objects
122 Every active widget filters list and accept only objects with possible types
124 void selectObject( const QStringList&, const TypesList&, const QStringList&, const bool = true );
126 //! Get text of object's control
127 QString objectText( const int ) const;
129 //! Set text of object's control
130 void setObjectText( const int, const QString& );
132 //! Select in certain widget avoiding check if there is active widget
133 void selectObject( const int, const QString&, const int, const QString&, const bool = true );
134 void selectObject( const int, const QStringList&, const TypesList&, const QStringList&, const bool = true );
136 //! Check if certain widget has selection
137 bool hasSelection( const int ) const;
139 //! Clear selection in widgets. If parameter is -1, then selection in all widgets will be cleared
140 void clearSelection( const int = -1 );
142 //! Get ids list of object selected in certain widget
143 void selectedObject( const int, QStringList& ) const;
145 //! Get ids list of object selected in certain widget
146 QString selectedObject( const int ) const;
148 //! Get map "widget id -> ids list"
149 void objectSelection( SelectedObjects& ) const;
151 //! Activate object selection button
152 void activateObject( const int );
154 //! Set all object selection buttons to inactive state
155 void deactivateAll();
158 //! selection in certain widget is changed
159 void selectionChanged ( int );
161 //! selection in certain widget is on
162 void objectActivated ( int );
164 //! selection in certain widget is off
165 void objectDeactivated( int );
168 text representation of selection is changed
169 it is emitted only if "read only" state of line edit is false
171 void objectChanged( int, const QStringList& );
174 //! Finds and returns resource manager
175 SUIT_ResourceMgr* resMgr() const;
177 /*! Create label, button and line edit for object selection
178 * If passed id is negative, then id will be calculated automatically (first free id)
179 * Returns the same id (if id>=0) or calculated
181 int createObject ( const QString&, QWidget*, const int = -1 );
183 //! Set pixmap as icon for all selection buttons
184 void setObjectPixmap ( const QPixmap& );
186 //! Load pixmap with section, name using resource manager and set as icon for all selection buttons
187 void setObjectPixmap ( const QString&, const QString& );
190 void renameObject ( const int, const QString& );
192 //! Set possible types for certain id. The list of arguments must be finished by negative integer
193 void setObjectType ( const int, const int, ... );
195 //! Set list as possible types for object selection
196 void setObjectType ( const int, const TypesList& );
199 Add types to list of possible types
200 The list of arguments must be finished by negative integer
202 void addObjectType ( const int, const int, const int, ... );
204 //! Add types to list of possible types
205 void addObjectType ( const int, const TypesList& );
207 //! Add type to list of possible types
208 void addObjectType ( const int, const int );
210 //! Clear list of possible types (it means, that all types are welcome)
211 void removeObjectType( const int );
213 //! Remove types in list from list of possible types
214 void removeObjectType( const int, const TypesList& );
216 //! Remove a type from list of possible types
217 void removeObjectType( const int, const int );
219 //! Check if list of possible types contains this one
220 bool hasObjectType ( const int, const int ) const;
222 //! Return list of possible types
223 void objectTypes ( const int, TypesList& ) const;
225 //!Change and get type name for indicating in selection widget
226 QString& typeName( const int );
227 const QString& typeName( const int ) const;
229 //! Create string contains selection list by list of names, list of types and current name indication state
230 virtual QString selectionDescription( const QStringList&, const TypesList&, const NameIndication ) const;
232 //! Create string by pattern "<count> <type>" for current list of types
233 virtual QString countOfTypes( const TypesList& ) const;
235 //! Get and set name indication for certain widget
236 NameIndication nameIndication( const int ) const;
237 void setNameIndication( const int, const NameIndication );
239 //! Check using name indication if multiple selection in possible
240 bool multipleSelection( const int ) const;
242 //! Set the "read only" state of object selection line edit
243 //! The "read only" will be false only if name indication is ListOfNames
244 void setReadOnly( const int, const bool );
246 //! Check the "read only" state of object selection line edit
247 bool isReadOnly( const int ) const;
250 //! emits if the object selection button changes state
251 void onToggled( bool );
253 //! text in some line edit is changed
254 void onTextChanged( const QString& );
258 If buttons are exclusive, set to "off" all buttons except one with id
259 If id=-1, then all buttons, except first with "on" state, will be set to "off"
261 void updateButtons( const int = -1 );
264 Filter types and update selection string in line edit
265 If bool is true, then signal is emitted
267 void updateObject( const int, bool = true );
269 //! Remove from list not possible types and remove from names and ids lists the corresponding items
270 void filterTypes( const int, QStringList&, TypesList&, QStringList& ) const;
278 QStringList myNames, myIds;
279 TypesList myTypes, myPossibleTypes;
284 typedef QMap<int, Object> ObjectMap;
289 QMap<int,QString> myTypeNames;
290 bool myIsExclusive, myIsBusy;
295 #pragma warning ( default:4251 )