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 : SUIT_DataObject.h
23 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
25 #ifndef SUIT_DATAOBJECT_H
26 #define SUIT_DATAOBJECT_H
36 class SUIT_DataObject;
37 class SUIT_DataObjectKey;
39 typedef QList<SUIT_DataObject*> DataObjectList;
42 #pragma warning( disable:4251 )
45 class SUIT_EXPORT SUIT_DataObject
52 Text, //!< editor foreground (text) color
53 Base, //!< editor background color
54 Foreground, //!< foreground (text) color
55 Background, //!< background color
56 Highlight, //!< highlight background color
57 HighlightedText //!< highlighted foreground (text) color
63 NameId //!< name column
66 SUIT_DataObject( SUIT_DataObject* = 0 );
67 virtual ~SUIT_DataObject();
69 SUIT_DataObject* root() const;
70 SUIT_DataObject* lastChild() const;
71 SUIT_DataObject* firstChild() const;
73 int childCount() const;
74 int childPos( const SUIT_DataObject* ) const;
75 SUIT_DataObject* childObject( const int ) const;
79 SUIT_DataObject* nextBrother() const;
80 SUIT_DataObject* prevBrother() const;
82 bool autoDeleteChildren() const;
83 virtual void setAutoDeleteChildren( const bool );
85 virtual void children( DataObjectList&, const bool = false ) const;
86 virtual DataObjectList children( const bool = false );
88 void appendChild( SUIT_DataObject* );
89 virtual void insertChild( SUIT_DataObject*, int );
90 virtual void removeChild( SUIT_DataObject*, const bool = false );
91 bool replaceChild( SUIT_DataObject*, SUIT_DataObject*, const bool = false );
93 void reparentChildren( const SUIT_DataObject* );
95 virtual SUIT_DataObject* parent() const;
96 virtual void setParent( SUIT_DataObject* );
98 virtual QString name() const;
99 virtual QString text( const int = NameId ) const;
100 virtual QPixmap icon( const int = NameId ) const;
101 virtual QColor color( const ColorRole, const int = NameId ) const;
102 virtual QString toolTip( const int = NameId ) const;
103 virtual QString statusTip( const int = NameId ) const;
104 virtual QString whatsThis( const int = NameId ) const;
105 virtual QFont font( const int = NameId ) const;
106 virtual int alignment( const int = NameId ) const;
108 virtual bool isDragable() const;
109 virtual bool isDropAccepted( SUIT_DataObject* obj );
111 virtual bool isEnabled() const;
112 virtual bool isSelectable() const;
113 virtual bool isCheckable( const int = NameId ) const;
115 virtual bool isOn( const int = NameId ) const;
116 virtual void setOn( const bool, const int = NameId );
118 virtual bool isOpen() const;
119 virtual void setOpen( const bool );
121 virtual void update();
122 virtual bool customSorting( const int = NameId ) const;
123 virtual bool compare( const QVariant&, const QVariant&, const int = NameId ) const;
125 virtual SUIT_DataObjectKey* key() const;
126 virtual int groupId() const;
128 static Signal* signal();
129 static bool connect( const char*, QObject*, const char* );
130 static bool disconnect( const char*, QObject*, const char* );
134 void dump( const int indent = 2 ) const; // dump to cout
137 SUIT_DataObject* myParent;
141 DataObjectList myChildren;
143 static Signal* mySignal;
145 friend class SUIT_DataObject::Signal;
146 friend class SUIT_DataObjectIterator;
149 class SUIT_EXPORT SUIT_DataObject::Signal : public QObject
158 void emitCreated( SUIT_DataObject* );
159 void emitDestroyed( SUIT_DataObject* );
160 void emitInserted( SUIT_DataObject*, SUIT_DataObject* );
161 void emitRemoved( SUIT_DataObject*, SUIT_DataObject* );
163 void deleteLater( SUIT_DataObject* );
166 void created( SUIT_DataObject* );
167 void destroyed( SUIT_DataObject* );
168 void inserted( SUIT_DataObject*, SUIT_DataObject* );
169 void removed( SUIT_DataObject*, SUIT_DataObject* );
171 friend class SUIT_DataObject;
174 DataObjectList myDelLaterObjects;
178 #pragma warning( default:4251 )
181 #endif // SUIT_DATAOBJECT_H