Salome HOME
bug #136 - problems with performance
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_DataObject.cxx
index 0b293cd2912df58e67fb56d336cfad6606565e3b..c35afa88d6f5bd148351adeed4d8934185efdcda 100644 (file)
 
 #include "HYDROGUI_DataObject.h"
 
-#include <HYDROData_Image.h>
-
 #include <SUIT_DataObject.h>
-
 #include <TDF_Tool.hxx>
 
 HYDROGUI_DataObject::HYDROGUI_DataObject( SUIT_DataObject* theParent, 
@@ -34,7 +31,8 @@ HYDROGUI_DataObject::HYDROGUI_DataObject( SUIT_DataObject* theParent,
 : CAM_DataObject( theParent ),
   LightApp_DataObject( theParent ),
   myData( theData ),
-  myParentEntry( theParentEntry )
+  myParentEntry( theParentEntry ),
+  myIsValid( true )
 {
 }
 
@@ -65,13 +63,42 @@ QFont HYDROGUI_DataObject::font( const int theId ) const
   QFont aFont = LightApp_DataObject::font( theId );
   if( theId == NameId )
   {
-    Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( modelObject() );
-    if( !anImage.IsNull() && anImage->MustBeUpdated() )
+    Handle(HYDROData_Entity) aDataObject = modelObject();
+    if( !aDataObject.IsNull() && aDataObject->IsMustBeUpdated() )
       aFont.setItalic( true );
   }
   return aFont;
 }
 
+QColor HYDROGUI_DataObject::color( const ColorRole theRole, const int theId ) const
+{
+  QColor aColor;
+
+  if ( !isValid() ) {
+    switch ( theRole )
+    {
+      case Text:
+      case Foreground:
+      case Highlight:
+        aColor = QColor( 255, 0, 0 ); // red
+      break;
+      case HighlightedText:
+        // text color for the highlighted item
+        aColor = QColor( 255, 255, 255 );   // white
+      break;
+
+      default:
+        break;
+    }
+  }
+
+  if ( !aColor.isValid() ) {
+    aColor = LightApp_DataObject::color( theRole, theId );
+  }
+
+  return aColor;
+}
+
 QString HYDROGUI_DataObject::dataObjectEntry( const Handle(HYDROData_Entity)& theObject,
                                               const bool theWithPrefix )
 {
@@ -87,6 +114,16 @@ QString HYDROGUI_DataObject::dataObjectEntry( const Handle(HYDROData_Entity)& th
   return aEntryStr;
 }
 
+void HYDROGUI_DataObject::setIsValid( const bool theIsValid )
+{
+  myIsValid = theIsValid;
+}
+
+bool HYDROGUI_DataObject::isValid() const
+{
+  return myIsValid;
+}
+
 HYDROGUI_NamedObject::HYDROGUI_NamedObject( SUIT_DataObject* theParent,
                                             const QString&   theName,
                                             const QString&   theParentEntry  )
@@ -109,3 +146,11 @@ QString HYDROGUI_NamedObject::name() const
 {
   return myName;
 }
+
+HYDROGUI_DropTargetObject::HYDROGUI_DropTargetObject( SUIT_DataObject* theParent,
+                                            const QString&   theName,
+                                            const QString&   theParentEntry  )
+: HYDROGUI_NamedObject( theParent, theName, theParentEntry ), CAM_DataObject( theParent )
+{
+}
+