Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LightApp_Dialog.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 
23 // File: LightApp_Dialog.h
24 // Author: Alexander SOLOVYOV
25 //
26 #ifndef LIGHTAPP_DIALOG_H
27 #define LIGHTAPP_DIALOG_H
28 
29 #include "LightApp.h"
30 #include <QtxDialog.h>
31 
32 #include <QList>
33 #include <QMap>
34 #include <QPixmap>
35 
36 class QLineEdit;
37 class QAbstractButton;
38 class QLabel;
39 
40 class SUIT_ResourceMgr;
41 
42 #ifdef WIN32
43 #pragma warning ( disable:4251 )
44 #endif
45 
55 {
56  Q_OBJECT
57 
58 public:
60  typedef QMap<int,QStringList> SelectedObjects;
61 
62  enum ObjectWg
63  {
64  Label = 0x00000001,
65  Btn = 0x00000002,
66  Control = 0x00000004
67  };
68 
69  typedef enum
70  {
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
75  Count
76 
77  } NameIndication;
80 
81 public:
82  LightApp_Dialog( QWidget* = 0, const char* = 0, bool = false,
83  bool = false, const int = Standard, Qt::WindowFlags = 0 );
84  virtual ~LightApp_Dialog();
85 
86  virtual void show();
87 
89  bool isExclusive() const;
90 
92  void setExclusive( const bool );
93 
95  bool isAutoResumed() const;
96 
98  void setAutoResumed( const bool );
99 
101  void showObject( const int );
102 
104  void hideObject( const int );
105 
107  void setObjectShown( const int, const bool );
108 
110  bool isObjectShown( const int ) const;
111 
113  void setObjectEnabled( const int, const bool );
114 
116  bool isObjectEnabled( const int ) const;
117 
119  QWidget* objectWg( const int theId, const int theWgId ) const;
120 
122  void selectObject( const QString&, const int, const QString&, const bool = true );
123 
128  void selectObject( const QStringList&, const TypesList&, const QStringList&, const bool = true );
129 
131  QString objectText( const int ) const;
132 
134  void setObjectText( const int, const QString& );
135 
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 );
139 
141  bool hasSelection( const int ) const;
142 
144  void clearSelection( const int = -1 );
145 
147  void selectedObject( const int, QStringList& ) const;
148 
150  QString selectedObject( const int ) const;
151 
153  void objectSelection( SelectedObjects& ) const;
154 
156  void activateObject( const int );
157 
159  void deactivateAll();
160 
161 signals:
163  void selectionChanged ( int );
164 
166  void objectActivated ( int );
167 
169  void objectDeactivated( int );
170 
171  /*
172  text representation of selection is changed
173  it is emitted only if "read only" state of line edit is false
174  */
175  void objectChanged( int, const QStringList& );
176 
177 protected:
179  SUIT_ResourceMgr* resMgr() const;
180 
185  int createObject ( const QString&, QWidget*, const int = -1 );
186 
188  void setObjectPixmap ( const QPixmap& );
189 
191  void setObjectPixmap ( const QString&, const QString& );
192 
194  void renameObject ( const int, const QString& );
195 
197  void setObjectType ( const int, const int, ... );
198 
200  void setObjectType ( const int, const TypesList& );
201 
206  void addObjectType ( const int, const int, const int, ... );
207 
209  void addObjectType ( const int, const TypesList& );
210 
212  void addObjectType ( const int, const int );
213 
215  void removeObjectType( const int );
216 
218  void removeObjectType( const int, const TypesList& );
219 
221  void removeObjectType( const int, const int );
222 
224  bool hasObjectType ( const int, const int ) const;
225 
227  void objectTypes ( const int, TypesList& ) const;
228 
230  QString& typeName( const int );
231  const QString typeName( const int ) const;
232 
234  virtual QString selectionDescription( const QStringList&, const TypesList&, const NameIndication ) const;
235 
237  virtual QString countOfTypes( const TypesList& ) const;
238 
240  NameIndication nameIndication( const int ) const;
241  void setNameIndication( const int, const NameIndication );
242 
244  bool multipleSelection( const int ) const;
245 
248  void setReadOnly( const int, const bool );
249 
251  bool isReadOnly( const int ) const;
252 
253 private slots:
255  void onToggled( bool );
256 
258  void onTextChanged( const QString& );
259 
260 private:
265  void updateButtons( const int = -1 );
266 
271  void updateObject( const int, bool = true );
272 
274  void filterTypes( const int, QStringList&, TypesList&, QStringList& ) const;
275 
276 private:
277  typedef struct
278  {
282  QStringList myNames, myIds;
283  TypesList myTypes, myPossibleTypes;
285 
286  } Object;
287 
288  typedef QMap<int, Object> ObjectMap;
289 
290 private:
292 
293  QMap<int,QString> myTypeNames;
294  bool myIsExclusive, myIsBusy;
295  QPixmap myPixmap;
296 };
297 
298 #ifdef WIN32
299 #pragma warning ( default:4251 )
300 #endif
301 
302 #endif