Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SUIT_DataObject.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 : SUIT_DataObject.h
24 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
25 
26 #ifndef SUIT_DATAOBJECT_H
27 #define SUIT_DATAOBJECT_H
28 
29 #include "SUIT.h"
30 
31 #include <Qtx.h>
32 
33 #include <QList>
34 #include <QObject>
35 #include <QString>
36 #include <QPixmap>
37 #include <QFont>
38 
39 class SUIT_DataObject;
41 
43 
44 #ifdef WIN32
45 #pragma warning( disable:4251 )
46 #endif
47 
49 {
50 public:
51  class Signal;
52 
54  typedef enum {
55  Text,
56  Base,
60  HighlightedText
61  } ColorRole;
62 
64  enum
65  {
67  VisibilityId
68  };
69 
71  virtual ~SUIT_DataObject();
72 
73  SUIT_DataObject* root() const;
74  SUIT_DataObject* lastChild() const;
75  SUIT_DataObject* firstChild() const;
76 
77  int childCount() const;
78  int childPos( const SUIT_DataObject* ) const;
79  void moveChildPos( SUIT_DataObject*, int );
80  SUIT_DataObject* childObject( const int ) const;
81  int level() const;
82  int position() const;
83  void setPosition(int);
84 
85  SUIT_DataObject* nextBrother() const;
86  SUIT_DataObject* prevBrother() const;
87 
88  bool autoDeleteChildren() const;
89  virtual void setAutoDeleteChildren( const bool );
90 
91  virtual void children( DataObjectList&, const bool = false ) const;
92  virtual DataObjectList children( const bool = false );
93 
94  void appendChild( SUIT_DataObject* );
95  virtual void insertChild( SUIT_DataObject*, int );
96  virtual void removeChild( SUIT_DataObject*, const bool = false );
97  bool replaceChild( SUIT_DataObject*, SUIT_DataObject*, const bool = false );
98 
99  void reparentChildren( const SUIT_DataObject* );
100 
101  virtual SUIT_DataObject* parent() const;
102  virtual void setParent( SUIT_DataObject* );
103  virtual void assignParent( SUIT_DataObject* );
104  void insertChildAtPos( SUIT_DataObject* obj, int position );
105  bool modified(){return _modified;};
106  virtual void setModified(bool modified);
107 
108  virtual QString name() const;
109  virtual QString text( const int = NameId ) const;
110  virtual QPixmap icon( const int = NameId ) const;
111  virtual QColor color( const ColorRole, const int = NameId ) const;
112  virtual QString toolTip( const int = NameId ) const;
113  virtual QString statusTip( const int = NameId ) const;
114  virtual QString whatsThis( const int = NameId ) const;
115  virtual QFont font( const int = NameId ) const;
116  virtual int alignment( const int = NameId ) const;
117 
118  virtual bool expandable() const;
119  virtual bool isVisible() const;
120  virtual bool isDraggable() const;
121  virtual bool isDropAccepted() const;
122 
123  virtual bool isEnabled() const;
124  virtual bool isSelectable() const;
125  virtual bool isCheckable( const int = NameId ) const;
126  virtual bool renameAllowed( const int = NameId ) const;
127  virtual bool setName(const QString& name);
128 
129  virtual bool isOn( const int = NameId ) const;
130  virtual void setOn( const bool, const int = NameId );
131 
132  virtual bool isOpen() const;
133  virtual void setOpen( const bool );
134 
135  virtual void update();
136  virtual bool customSorting( const int = NameId ) const;
137  virtual bool compare( const QVariant&, const QVariant&, const int = NameId ) const;
138 
139  virtual SUIT_DataObjectKey* key() const;
140  virtual int groupId() const;
141  virtual QVariant customData(Qtx::CustomDataType /*type*/);
142 
143  static Signal* signal();
144  static bool connect( const char*, QObject*, const char* );
145  static bool disconnect( const char*, QObject*, const char* );
146 
147  void deleteLater();
148 
149  void dump( const int indent = 2 ) const; // dump to cout
150 
151 private:
153  bool myOpen;
154  bool myCheck;
155  bool myAutoDel;
157  bool _modified;
158 
159  static Signal* mySignal;
160 
163 };
164 
166 {
167  Q_OBJECT
168 
169 public:
170  Signal();
171  virtual ~Signal();
172 
173 private:
174  void emitCreated( SUIT_DataObject* );
178  void emitModified( SUIT_DataObject* );
179 
180  void deleteLater( SUIT_DataObject* );
181 
182 signals:
183  void created( SUIT_DataObject* );
184  void destroyed( SUIT_DataObject* );
187  void modified( SUIT_DataObject* );
188 
189  friend class SUIT_DataObject;
190 
191 private:
193 };
194 
195 #ifdef WIN32
196 #pragma warning( default:4251 )
197 #endif
198 
199 #endif // SUIT_DATAOBJECT_H