1 // Copyright (C) 2007-2015 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 : SUIT_DataObject.h
24 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
26 #ifndef SUIT_DATAOBJECT_H
27 #define SUIT_DATAOBJECT_H
39 class SUIT_DataObject;
40 class SUIT_DataObjectKey;
42 typedef QList<SUIT_DataObject*> DataObjectList;
45 #pragma warning( disable:4251 )
48 class SUIT_EXPORT SUIT_DataObject
55 Text, //!< editor foreground (text) color
56 Base, //!< editor background color
57 Foreground, //!< foreground (text) color
58 Background, //!< background color
59 Highlight, //!< highlight background color
60 HighlightedText //!< highlighted foreground (text) color
66 NameId, //!< name column
67 VisibilityId //!< visibility state column
70 SUIT_DataObject( SUIT_DataObject* = 0 );
71 virtual ~SUIT_DataObject();
73 SUIT_DataObject* root() const;
74 SUIT_DataObject* lastChild() const;
75 SUIT_DataObject* firstChild() const;
77 int childCount() const;
78 int childPos( const SUIT_DataObject* ) const;
79 void moveChildPos( SUIT_DataObject*, int );
80 SUIT_DataObject* childObject( const int ) const;
83 void setPosition(int);
85 SUIT_DataObject* nextBrother() const;
86 SUIT_DataObject* prevBrother() const;
88 bool autoDeleteChildren() const;
89 virtual void setAutoDeleteChildren( const bool );
91 virtual void children( DataObjectList&, const bool = false ) const;
92 virtual DataObjectList children( const bool = false );
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 );
99 void reparentChildren( const SUIT_DataObject* );
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);
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;
118 virtual bool expandable() const;
119 virtual bool isVisible() const;
120 virtual bool isDraggable() const;
121 virtual bool isDropAccepted() const;
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);
129 virtual bool isOn( const int = NameId ) const;
130 virtual void setOn( const bool, const int = NameId );
132 virtual bool isOpen() const;
133 virtual void setOpen( const bool );
135 virtual void update();
136 virtual bool customSorting( const int = NameId ) const;
137 virtual bool compare( const QVariant&, const QVariant&, const int = NameId ) const;
139 virtual SUIT_DataObjectKey* key() const;
140 virtual int groupId() const;
141 virtual QVariant customData(Qtx::CustomDataType /*type*/);
143 static Signal* signal();
144 static bool connect( const char*, QObject*, const char* );
145 static bool disconnect( const char*, QObject*, const char* );
149 void dump( const int indent = 2 ) const; // dump to cout
152 SUIT_DataObject* myParent;
156 DataObjectList myChildren;
159 static Signal* mySignal;
161 friend class SUIT_DataObject::Signal;
162 friend class SUIT_DataObjectIterator;
165 class SUIT_EXPORT SUIT_DataObject::Signal : public QObject
174 void emitCreated( SUIT_DataObject* );
175 void emitDestroyed( SUIT_DataObject* );
176 void emitInserted( SUIT_DataObject*, SUIT_DataObject* );
177 void emitRemoved( SUIT_DataObject*, SUIT_DataObject* );
178 void emitModified( SUIT_DataObject* );
180 void deleteLater( SUIT_DataObject* );
183 void created( SUIT_DataObject* );
184 void destroyed( SUIT_DataObject* );
185 void inserted( SUIT_DataObject*, SUIT_DataObject* );
186 void removed( SUIT_DataObject*, SUIT_DataObject* );
187 void modified( SUIT_DataObject* );
189 friend class SUIT_DataObject;
192 DataObjectList myDelLaterObjects;
196 #pragma warning( default:4251 )
199 #endif // SUIT_DATAOBJECT_H