1 // Copyright (C) 2007-2014 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, or (at your option) any later version.
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
23 // File: LightApp_Dialog.h
24 // Author: Alexander SOLOVYOV
26 #ifndef LIGHTAPP_DIALOG_H
27 #define LIGHTAPP_DIALOG_H
30 #include <QtxDialog.h>
37 class QAbstractButton;
40 class SUIT_ResourceMgr;
43 #pragma warning ( disable:4251 )
47 \class LightApp_Dialog
48 Base class for all LightApp dialogs.
49 Provides standard widget for object selection: line edit, button;
50 it is necessary to call corresponding methods on selection change.
51 Standard dialog provides filtering, selection string representation,
52 possibility to indicate necessary selection by text with list of ids.
54 class LIGHTAPP_EXPORT LightApp_Dialog : public QtxDialog
59 typedef QList<int> TypesList;
60 typedef QMap<int,QStringList> SelectedObjects;
71 OneName, //<! only one object can be selected and it's name is shown
72 OneNameOrCount, //<! if one object is selected, it's name is shown otherwise
73 // "<count> <type>" is shown
74 ListOfNames, //! list of all names is shown
75 Count //! In every case "<count> <type>" is shown
78 //! The enumeration describing how names of selected objects will be shown in line edit
79 //! For more details see above
82 LightApp_Dialog( QWidget* = 0, const char* = 0, bool = false,
83 bool = false, const int = Standard, Qt::WindowFlags = 0 );
84 virtual ~LightApp_Dialog();
88 //! Check if buttons is exclusive (as radiobuttons)
89 bool isExclusive() const;
91 //! Set exclusive state
92 void setExclusive( const bool );
94 //! Check if operation according to dialog will be resumed automatically when mouse enter the dialog
95 bool isAutoResumed() const;
97 //! Set auto resumed state
98 void setAutoResumed( const bool );
100 //! Show widgets corresponding to id
101 void showObject( const int );
103 //! Hide widgets corresponding to id
104 void hideObject( const int );
106 //! Change the shown state of widgets corresponding to id
107 void setObjectShown( const int, const bool );
109 //! Check the shown state
110 bool isObjectShown( const int ) const;
112 //! Change the enabled state of widgets corresponding to id
113 void setObjectEnabled( const int, const bool );
115 //! Check the enabled state
116 bool isObjectEnabled( const int ) const;
118 //! Get widget of object (see ObjectWg enumeration)
119 QWidget* objectWg( const int theId, const int theWgId ) const;
121 //! Pass to all active widgets name, type and id of selected object
122 void selectObject( const QString&, const int, const QString&, const bool = true );
125 Pass to all active widgets list of names, types and ids of selected objects
126 Every active widget filters list and accept only objects with possible types
128 void selectObject( const QStringList&, const TypesList&, const QStringList&, const bool = true );
130 //! Get text of object's control
131 QString objectText( const int ) const;
133 //! Set text of object's control
134 void setObjectText( const int, const QString& );
136 //! Select in certain widget avoiding check if there is active widget
137 void selectObject( const int, const QString&, const int, const QString&, const bool = true );
138 void selectObject( const int, const QStringList&, const TypesList&, const QStringList&, const bool = true );
140 //! Check if certain widget has selection
141 bool hasSelection( const int ) const;
143 //! Clear selection in widgets. If parameter is -1, then selection in all widgets will be cleared
144 void clearSelection( const int = -1 );
146 //! Get ids list of object selected in certain widget
147 void selectedObject( const int, QStringList& ) const;
149 //! Get ids list of object selected in certain widget
150 QString selectedObject( const int ) const;
152 //! Get map "widget id -> ids list"
153 void objectSelection( SelectedObjects& ) const;
155 //! Activate object selection button
156 void activateObject( const int );
158 //! Set all object selection buttons to inactive state
159 void deactivateAll();
162 //! selection in certain widget is changed
163 void selectionChanged ( int );
165 //! selection in certain widget is on
166 void objectActivated ( int );
168 //! selection in certain widget is off
169 void objectDeactivated( int );
172 text representation of selection is changed
173 it is emitted only if "read only" state of line edit is false
175 void objectChanged( int, const QStringList& );
178 //! Finds and returns resource manager
179 SUIT_ResourceMgr* resMgr() const;
181 /*! Create label, button and line edit for object selection
182 * If passed id is negative, then id will be calculated automatically (first free id)
183 * Returns the same id (if id>=0) or calculated
185 int createObject ( const QString&, QWidget*, const int = -1 );
187 //! Set pixmap as icon for all selection buttons
188 void setObjectPixmap ( const QPixmap& );
190 //! Load pixmap with section, name using resource manager and set as icon for all selection buttons
191 void setObjectPixmap ( const QString&, const QString& );
194 void renameObject ( const int, const QString& );
196 //! Set possible types for certain id. The list of arguments must be finished by negative integer
197 void setObjectType ( const int, const int, ... );
199 //! Set list as possible types for object selection
200 void setObjectType ( const int, const TypesList& );
203 Add types to list of possible types
204 The list of arguments must be finished by negative integer
206 void addObjectType ( const int, const int, const int, ... );
208 //! Add types to list of possible types
209 void addObjectType ( const int, const TypesList& );
211 //! Add type to list of possible types
212 void addObjectType ( const int, const int );
214 //! Clear list of possible types (it means, that all types are welcome)
215 void removeObjectType( const int );
217 //! Remove types in list from list of possible types
218 void removeObjectType( const int, const TypesList& );
220 //! Remove a type from list of possible types
221 void removeObjectType( const int, const int );
223 //! Check if list of possible types contains this one
224 bool hasObjectType ( const int, const int ) const;
226 //! Return list of possible types
227 void objectTypes ( const int, TypesList& ) const;
229 //!Change and get type name for indicating in selection widget
230 QString& typeName( const int );
231 const QString typeName( const int ) const;
233 //! Create string contains selection list by list of names, list of types and current name indication state
234 virtual QString selectionDescription( const QStringList&, const TypesList&, const NameIndication ) const;
236 //! Create string by pattern "<count> <type>" for current list of types
237 virtual QString countOfTypes( const TypesList& ) const;
239 //! Get and set name indication for certain widget
240 NameIndication nameIndication( const int ) const;
241 void setNameIndication( const int, const NameIndication );
243 //! Check using name indication if multiple selection in possible
244 bool multipleSelection( const int ) const;
246 //! Set the "read only" state of object selection line edit
247 //! The "read only" will be false only if name indication is ListOfNames
248 void setReadOnly( const int, const bool );
250 //! Check the "read only" state of object selection line edit
251 bool isReadOnly( const int ) const;
254 //! emits if the object selection button changes state
255 void onToggled( bool );
257 //! text in some line edit is changed
258 void onTextChanged( const QString& );
262 If buttons are exclusive, set to "off" all buttons except one with id
263 If id=-1, then all buttons, except first with "on" state, will be set to "off"
265 void updateButtons( const int = -1 );
268 Filter types and update selection string in line edit
269 If bool is true, then signal is emitted
271 void updateObject( const int, bool = true );
273 //! Remove from list not possible types and remove from names and ids lists the corresponding items
274 void filterTypes( const int, QStringList&, TypesList&, QStringList& ) const;
280 QAbstractButton* myBtn;
282 QStringList myNames, myIds;
283 TypesList myTypes, myPossibleTypes;
288 typedef QMap<int, Object> ObjectMap;
293 QMap<int,QString> myTypeNames;
294 bool myIsExclusive, myIsBusy;
299 #pragma warning ( default:4251 )