1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File: LightApp_Dialog.h
23 // Author: Alexander SOLOVYOV
25 #ifndef LIGHTAPP_DIALOG_H
26 #define LIGHTAPP_DIALOG_H
29 #include <QtxDialog.h>
36 class QAbstractButton;
39 class SUIT_ResourceMgr;
42 #pragma warning ( disable:4251 )
46 \class LightApp_Dialog
47 Base class for all LightApp dialogs.
48 Provides standard widget for object selection: line edit, button;
49 it is necessary to call corresponding methods on selection change.
50 Standard dialog provides filtering, selection string representation,
51 possibility to indicate necessary selection by text with list of ids.
53 class LIGHTAPP_EXPORT LightApp_Dialog : public QtxDialog
58 typedef QList<int> TypesList;
59 typedef QMap<int,QStringList> SelectedObjects;
70 OneName, //<! only one object can be selected and it's name is shown
71 OneNameOrCount, //<! if one object is selected, it's name is shown otherwise
72 // "<count> <type>" is shown
73 ListOfNames, //! list of all names is shown
74 Count //! In every case "<count> <type>" is shown
77 //! The enumeration describing how names of selected objects will be shown in line edit
78 //! For more details see above
81 LightApp_Dialog( QWidget* = 0, const char* = 0, bool = false,
82 bool = false, const int = Standard, Qt::WindowFlags = 0 );
83 virtual ~LightApp_Dialog();
87 //! Check if buttons is exclusive (as radiobuttons)
88 bool isExclusive() const;
90 //! Set exclusive state
91 void setExclusive( const bool );
93 //! Check if operation according to dialog will be resumed automatically when mouse enter the dialog
94 bool isAutoResumed() const;
96 //! Set auto resumed state
97 void setAutoResumed( const bool );
99 //! Show widgets corresponding to id
100 void showObject( const int );
102 //! Hide widgets corresponding to id
103 void hideObject( const int );
105 //! Change the shown state of widgets corresponding to id
106 void setObjectShown( const int, const bool );
108 //! Check the shown state
109 bool isObjectShown( const int ) const;
111 //! Change the enabled state of widgets corresponding to id
112 void setObjectEnabled( const int, const bool );
114 //! Check the enabled state
115 bool isObjectEnabled( const int ) const;
117 //! Get widget of object (see ObjectWg enumeration)
118 QWidget* objectWg( const int theId, const int theWgId ) const;
120 //! Pass to all active widgets name, type and id of selected object
121 void selectObject( const QString&, const int, const QString&, const bool = true );
124 Pass to all active widgets list of names, types and ids of selected objects
125 Every active widget filters list and accept only objects with possible types
127 void selectObject( const QStringList&, const TypesList&, const QStringList&, const bool = true );
129 //! Get text of object's control
130 QString objectText( const int ) const;
132 //! Set text of object's control
133 void setObjectText( const int, const QString& );
135 //! Select in certain widget avoiding check if there is active widget
136 void selectObject( const int, const QString&, const int, const QString&, const bool = true );
137 void selectObject( const int, const QStringList&, const TypesList&, const QStringList&, const bool = true );
139 //! Check if certain widget has selection
140 bool hasSelection( const int ) const;
142 //! Clear selection in widgets. If parameter is -1, then selection in all widgets will be cleared
143 void clearSelection( const int = -1 );
145 //! Get ids list of object selected in certain widget
146 void selectedObject( const int, QStringList& ) const;
148 //! Get ids list of object selected in certain widget
149 QString selectedObject( const int ) const;
151 //! Get map "widget id -> ids list"
152 void objectSelection( SelectedObjects& ) const;
154 //! Activate object selection button
155 void activateObject( const int );
157 //! Set all object selection buttons to inactive state
158 void deactivateAll();
161 //! selection in certain widget is changed
162 void selectionChanged ( int );
164 //! selection in certain widget is on
165 void objectActivated ( int );
167 //! selection in certain widget is off
168 void objectDeactivated( int );
171 text representation of selection is changed
172 it is emitted only if "read only" state of line edit is false
174 void objectChanged( int, const QStringList& );
177 //! Finds and returns resource manager
178 SUIT_ResourceMgr* resMgr() const;
180 /*! Create label, button and line edit for object selection
181 * If passed id is negative, then id will be calculated automatically (first free id)
182 * Returns the same id (if id>=0) or calculated
184 int createObject ( const QString&, QWidget*, const int = -1 );
186 //! Set pixmap as icon for all selection buttons
187 void setObjectPixmap ( const QPixmap& );
189 //! Load pixmap with section, name using resource manager and set as icon for all selection buttons
190 void setObjectPixmap ( const QString&, const QString& );
193 void renameObject ( const int, const QString& );
195 //! Set possible types for certain id. The list of arguments must be finished by negative integer
196 void setObjectType ( const int, const int, ... );
198 //! Set list as possible types for object selection
199 void setObjectType ( const int, const TypesList& );
202 Add types to list of possible types
203 The list of arguments must be finished by negative integer
205 void addObjectType ( const int, const int, const int, ... );
207 //! Add types to list of possible types
208 void addObjectType ( const int, const TypesList& );
210 //! Add type to list of possible types
211 void addObjectType ( const int, const int );
213 //! Clear list of possible types (it means, that all types are welcome)
214 void removeObjectType( const int );
216 //! Remove types in list from list of possible types
217 void removeObjectType( const int, const TypesList& );
219 //! Remove a type from list of possible types
220 void removeObjectType( const int, const int );
222 //! Check if list of possible types contains this one
223 bool hasObjectType ( const int, const int ) const;
225 //! Return list of possible types
226 void objectTypes ( const int, TypesList& ) const;
228 //!Change and get type name for indicating in selection widget
229 QString& typeName( const int );
230 const QString typeName( const int ) const;
232 //! Create string contains selection list by list of names, list of types and current name indication state
233 virtual QString selectionDescription( const QStringList&, const TypesList&, const NameIndication ) const;
235 //! Create string by pattern "<count> <type>" for current list of types
236 virtual QString countOfTypes( const TypesList& ) const;
238 //! Get and set name indication for certain widget
239 NameIndication nameIndication( const int ) const;
240 void setNameIndication( const int, const NameIndication );
242 //! Check using name indication if multiple selection in possible
243 bool multipleSelection( const int ) const;
245 //! Set the "read only" state of object selection line edit
246 //! The "read only" will be false only if name indication is ListOfNames
247 void setReadOnly( const int, const bool );
249 //! Check the "read only" state of object selection line edit
250 bool isReadOnly( const int ) const;
253 //! emits if the object selection button changes state
254 void onToggled( bool );
256 //! text in some line edit is changed
257 void onTextChanged( const QString& );
261 If buttons are exclusive, set to "off" all buttons except one with id
262 If id=-1, then all buttons, except first with "on" state, will be set to "off"
264 void updateButtons( const int = -1 );
267 Filter types and update selection string in line edit
268 If bool is true, then signal is emitted
270 void updateObject( const int, bool = true );
272 //! Remove from list not possible types and remove from names and ids lists the corresponding items
273 void filterTypes( const int, QStringList&, TypesList&, QStringList& ) const;
279 QAbstractButton* myBtn;
281 QStringList myNames, myIds;
282 TypesList myTypes, myPossibleTypes;
287 typedef QMap<int, Object> ObjectMap;
292 QMap<int,QString> myTypeNames;
293 bool myIsExclusive, myIsBusy;
298 #pragma warning ( default:4251 )