Salome HOME
Update from BR_V5_DEV 13Feb2009
[modules/gui.git] / src / SUIT / SUIT_DataObject.h
index 01f0ffa599545604e7aa0cc7c9cfa8bbdc40fffc..8e06fad064460a5b95932f3567e427e9f0cda3cb 100755 (executable)
@@ -1,53 +1,67 @@
-// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-// 
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either 
-// version 2.1 of the License.
-// 
-// This library is distributed in the hope that it will be useful 
-// but WITHOUT ANY WARRANTY; without even the implied warranty of 
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-// Lesser General Public License for more details.
+//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-// You should have received a copy of the GNU Lesser General Public  
-// License along with this library; if not, write to the Free Software 
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File   : SUIT_DataObject.h
+// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
 //
 #ifndef SUIT_DATAOBJECT_H
 #define SUIT_DATAOBJECT_H
 
-#include <qobject.h>
-#include <qstring.h>
-#include <qpixmap.h>
-#include <qptrlist.h>
-
 #include "SUIT.h"
 
+#include <QList>
+#include <QObject>
+#include <QString>
+#include <QPixmap>
+#include <QFont>
+
 class SUIT_DataObject;
 class SUIT_DataObjectKey;
 
-typedef QPtrList<SUIT_DataObject>         DataObjectList;
-typedef QPtrListIterator<SUIT_DataObject> DataObjectListIterator;
+typedef QList<SUIT_DataObject*> DataObjectList;
 
 #ifdef WIN32
 #pragma warning( disable:4251 )
 #endif
 
-/*!
-  \class SUIT_DataObject
-  Data Object represents uniform data tree structure recommended to use in SUIT-based applications
-  Many of standard classes (DataModel,ObjectBrowser) deal with SUIT_DataObjects
-*/
 class SUIT_EXPORT SUIT_DataObject  
 {
 public:
   class Signal;
 
-  typedef enum { None, RadioButton, CheckBox } CheckType;
-  typedef enum { Text, Base, Foreground, Background, Highlight, HighlightedText } ColorRole;
+  //! Color role
+  typedef enum { 
+    Text,              //!< editor foreground (text) color
+    Base,              //!< editor background color
+    Foreground,        //!< foreground (text) color
+    Background,        //!< background color
+    Highlight,         //!< highlight background color
+    HighlightedText    //!< highlighted foreground (text) color
+  } ColorRole;
+
+  //! Column id
+  enum
+  { 
+    NameId            //!< name column
+  };
 
   SUIT_DataObject( SUIT_DataObject* = 0 );
   virtual ~SUIT_DataObject();
@@ -60,6 +74,7 @@ public:
   int                         childPos( const SUIT_DataObject* ) const;
   SUIT_DataObject*            childObject( const int ) const;
   int                         level() const;
+  int                         position() const;
 
   SUIT_DataObject*            nextBrother() const;
   SUIT_DataObject*            prevBrother() const;
@@ -71,80 +86,96 @@ public:
   virtual DataObjectList      children( const bool = false );
   
   void                        appendChild( SUIT_DataObject* );
-  virtual void                removeChild( SUIT_DataObject* );
-  virtual void                insertChild( SUIT_DataObject*, int thePosition );
+  virtual void                insertChild( SUIT_DataObject*, int );
+  virtual void                removeChild( SUIT_DataObject*, const bool = false );
   bool                        replaceChild( SUIT_DataObject*, SUIT_DataObject*, const bool = false );
 
   void                        reparentChildren( const SUIT_DataObject* );
 
-  virtual QString             text( const int ) const;
-  virtual QColor              color( const ColorRole ) const;
-
-  virtual QString             name() const;
-  virtual QPixmap             icon() const;
-  virtual QString             toolTip() const;
-
   virtual SUIT_DataObject*    parent() const;
   virtual void                setParent( SUIT_DataObject* );
 
+  virtual QString             name() const;
+  virtual QString             text( const int = NameId ) const;
+  virtual QPixmap             icon( const int = NameId ) const;
+  virtual QColor              color( const ColorRole, const int = NameId ) const;
+  virtual QString             toolTip( const int = NameId ) const;
+  virtual QString             statusTip( const int = NameId ) const;
+  virtual QString             whatsThis( const int = NameId ) const;
+  virtual QFont               font( const int = NameId ) const;
+  virtual int                 alignment( const int = NameId ) const;
+
   virtual bool                isDragable() const;
   virtual bool                isDropAccepted( SUIT_DataObject* obj );
 
-  virtual CheckType           checkType() const;
+  virtual bool                isEnabled() const;
+  virtual bool                isSelectable() const;
+  virtual bool                isCheckable( const int = NameId ) const;
 
-  virtual bool                isOn() const;
-  virtual void                setOn( const bool );
+  virtual bool                isOn( const int = NameId ) const;
+  virtual void                setOn( const bool, const int = NameId );
 
   virtual bool                isOpen() const;
   virtual void                setOpen( const bool );
 
+  virtual void                update();
+  virtual bool                customSorting( const int = NameId ) const;
+  virtual bool                compare( const QVariant&, const QVariant&, const int = NameId ) const;
+
   virtual SUIT_DataObjectKey* key() const;
+  virtual int groupId() const;
 
-  bool                        connect( QObject*, const char* );
-  bool                        disconnect( QObject*, const char* );
+  static Signal*              signal();
+  static bool                 connect( const char*, QObject*, const char* );
+  static bool                 disconnect( const char*, QObject*, const char* );
 
   void                        deleteLater();
-  
+
   void                        dump( const int indent = 2 ) const; // dump to cout
 
 private:
+  SUIT_DataObject*            myParent;
   bool                        myOpen;
   bool                        myCheck;
-  Signal*                     mySignal;
-  SUIT_DataObject*            myParent;
+  bool                        myAutoDel;
   DataObjectList              myChildren;
 
+  static Signal*              mySignal;
+
   friend class SUIT_DataObject::Signal;
   friend class SUIT_DataObjectIterator;
 };
 
-/*!
-  \class SUIT_DataObject::Signal
-  Auxiliary class providing functionality to use signals of data object state change
-  SUIT_DataObject cannot have signals, because it isn't QObject, but
-  methods connect/disconnect of SUIT_DataObject with help of this it is possible
-  to emulate Qt signal processing
-*/
-class SUIT_DataObject::Signal : public QObject
+class SUIT_EXPORT SUIT_DataObject::Signal : public QObject
 {
   Q_OBJECT
 
 public:
-  Signal( SUIT_DataObject* );
+  Signal();
   virtual ~Signal();
 
-  void                        emitSignal();
-  void                        setOwner( SUIT_DataObject* o );
+private:
+  void emitCreated( SUIT_DataObject* );
+  void emitDestroyed( SUIT_DataObject* );
+  void emitInserted( SUIT_DataObject*, SUIT_DataObject* );
+  void emitRemoved( SUIT_DataObject*, SUIT_DataObject* );
+
+  void deleteLater( SUIT_DataObject* );
 
 signals:
-  void                        destroyed( SUIT_DataObject* );
+  void created( SUIT_DataObject* );
+  void destroyed( SUIT_DataObject* );
+  void inserted( SUIT_DataObject*, SUIT_DataObject* );
+  void removed( SUIT_DataObject*, SUIT_DataObject* );
+
+  friend class SUIT_DataObject;
 
 private:
-  SUIT_DataObject*            myOwner;
+  DataObjectList myDelLaterObjects;
 };
 
 #ifdef WIN32
 #pragma warning( default:4251 )
 #endif
 
-#endif
+#endif  // SUIT_DATAOBJECT_H