1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/
19 #ifndef SUIT_DATAOBJECT_H
20 #define SUIT_DATAOBJECT_H
29 class SUIT_DataObject;
30 class SUIT_DataObjectKey;
32 typedef QPtrList<SUIT_DataObject> DataObjectList;
33 typedef QPtrListIterator<SUIT_DataObject> DataObjectListIterator;
36 #pragma warning( disable:4251 )
40 \class SUIT_DataObject
41 Data Object represents uniform data tree structure recommended to use in SUIT-based applications
42 Many of standard classes (DataModel,ObjectBrowser) deal with SUIT_DataObjects
44 class SUIT_EXPORT SUIT_DataObject
49 typedef enum { None, RadioButton, CheckBox } CheckType;
50 typedef enum { Text, Base, Foreground, Background, Highlight, HighlightedText } ColorRole;
52 SUIT_DataObject( SUIT_DataObject* = 0 );
53 virtual ~SUIT_DataObject();
55 SUIT_DataObject* root() const;
56 SUIT_DataObject* lastChild() const;
57 SUIT_DataObject* firstChild() const;
59 int childCount() const;
60 int childPos( const SUIT_DataObject* ) const;
61 SUIT_DataObject* childObject( const int ) const;
64 SUIT_DataObject* nextBrother() const;
65 SUIT_DataObject* prevBrother() const;
67 bool autoDeleteChildren() const;
68 virtual void setAutoDeleteChildren( const bool );
70 virtual void children( DataObjectList&, const bool = false ) const;
71 virtual DataObjectList children( const bool = false );
73 void appendChild( SUIT_DataObject* );
74 virtual void removeChild( SUIT_DataObject* );
75 virtual void insertChild( SUIT_DataObject*, int thePosition );
76 bool replaceChild( SUIT_DataObject*, SUIT_DataObject*, const bool = false );
78 void reparentChildren( const SUIT_DataObject* );
80 virtual QString text( const int ) const;
81 virtual QColor color( const ColorRole ) const;
83 virtual QString name() const;
84 virtual QPixmap icon() const;
85 virtual QString toolTip() const;
87 virtual SUIT_DataObject* parent() const;
88 virtual void setParent( SUIT_DataObject* );
90 virtual bool isDragable() const;
91 virtual bool isDropAccepted( SUIT_DataObject* obj );
93 virtual CheckType checkType() const;
95 virtual bool isOn() const;
96 virtual void setOn( const bool );
98 virtual bool isOpen() const;
99 virtual void setOpen( const bool );
101 virtual SUIT_DataObjectKey* key() const;
103 bool connect( QObject*, const char* );
104 bool disconnect( QObject*, const char* );
108 void dump( const int indent = 2 ) const; // dump to cout
114 SUIT_DataObject* myParent;
115 DataObjectList myChildren;
117 friend class SUIT_DataObject::Signal;
118 friend class SUIT_DataObjectIterator;
122 \class SUIT_DataObject::Signal
123 Auxiliary class providing functionality to use signals of data object state change
124 SUIT_DataObject cannot have signals, because it isn't QObject, but
125 methods connect/disconnect of SUIT_DataObject with help of this it is possible
126 to emulate Qt signal processing
128 class SUIT_DataObject::Signal : public QObject
133 Signal( SUIT_DataObject* );
137 void setOwner( SUIT_DataObject* o );
140 void destroyed( SUIT_DataObject* );
143 SUIT_DataObject* myOwner;
147 #pragma warning( default:4251 )