From: vsr Date: Tue, 18 Aug 2009 04:54:56 +0000 (+0000) Subject: Issue 20099: Hide children X-Git-Tag: V5_1_3rc1~33 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6d5cdaee3efc09746c4dcd848555db8e3f78d629;p=modules%2Fgui.git Issue 20099: Hide children Use AttributeExpandable to enable/disable showing of item's children --- diff --git a/src/SalomeApp/SalomeApp_DataModel.cxx b/src/SalomeApp/SalomeApp_DataModel.cxx index 381dc68ae..1548ff23b 100644 --- a/src/SalomeApp/SalomeApp_DataModel.cxx +++ b/src/SalomeApp/SalomeApp_DataModel.cxx @@ -179,9 +179,19 @@ QList SalomeApp_DataModelSync::children( const kerPtr& obj ) const { QList ch; - _PTR(ChildIterator) it ( myStudy->NewChildIterator( obj ) ); - for( ; it->More(); it->Next() ) - ch.append( it->Value() ); + _PTR( GenericAttribute ) anAttr; + bool expandable = true; + if ( obj && obj->FindAttribute( anAttr, "AttributeExpandable" ) ) { + _PTR(AttributeExpandable) aAttrExp = anAttr; + expandable = aAttrExp->IsExpandable(); + } + + if ( expandable ) { + _PTR(ChildIterator) it ( myStudy->NewChildIterator( obj ) ); + for ( ; it->More(); it->Next() ) + ch.append( it->Value() ); + } + return ch; } diff --git a/src/SalomeApp/SalomeApp_DataObject.cxx b/src/SalomeApp/SalomeApp_DataObject.cxx index 72fd38592..a05f501fa 100644 --- a/src/SalomeApp/SalomeApp_DataObject.cxx +++ b/src/SalomeApp/SalomeApp_DataObject.cxx @@ -283,6 +283,23 @@ QString SalomeApp_DataObject::toolTip( const int /*id*/ ) const return QString( "Object \'%1\', module \'%2\', ID=%3" ).arg( name() ).arg( componentDataType() ).arg( entry() ); } +/*! + \brief Get font to be used for data object rendering in the item views + \param id column id + \return font to be used for the item rendering +*/ +QFont SalomeApp_DataObject::font( const int id ) const +{ + QFont f = LightApp_DataObject::font( id ); + if ( id == NameId ) { + if ( !expandable() && hasChildren() ) { + // set bold font to highlight the item which is non-expandable but has children + f.setBold( true ); + } + } + return f; +} + /*! \brief Get component type. \return component type @@ -341,6 +358,40 @@ _PTR(SObject) SalomeApp_DataObject::referencedObject() const return obj; } +/*! + \brief Check if object has children + \return \c true if object has at least one child sub-object and \c false otherwise +*/ +bool SalomeApp_DataObject::hasChildren() const +{ + bool ok = false; + _PTR(ChildIterator) it ( myObject->GetStudy()->NewChildIterator( myObject ) ); + for ( ; it->More() && !ok; it->Next() ) { + _PTR(SObject) obj = it->Value(); + if ( obj ) { + _PTR(SObject) refObj; + //if ( obj->ReferencedObject( refObj ) ) continue; // omit references + if ( obj->GetName() != "" ) ok = true; + } + } + return ok; +} + +/*! + \brief Check if the object is expandable (e.g. in the data tree view) + \return \c true if object is expandable and \c false otherwise +*/ +bool SalomeApp_DataObject::expandable() const +{ + bool exp = true; + _PTR(GenericAttribute) anAttr; + if ( myObject->FindAttribute( anAttr, "AttributeExpandable" ) ) { + _PTR(AttributeExpandable) aAttrExp = anAttr; + exp = aAttrExp->IsExpandable(); + } + return exp; +} + /*! \brief Check if the specified column supports custom sorting. \param id column id diff --git a/src/SalomeApp/SalomeApp_DataObject.h b/src/SalomeApp/SalomeApp_DataObject.h index 8a0462f4d..b8f4b39a1 100644 --- a/src/SalomeApp/SalomeApp_DataObject.h +++ b/src/SalomeApp/SalomeApp_DataObject.h @@ -54,11 +54,14 @@ public: virtual QPixmap icon( const int = NameId ) const; virtual QColor color( const ColorRole, const int = NameId ) const; virtual QString toolTip( const int = NameId ) const; + virtual QFont font( const int = NameId ) const; virtual _PTR(SObject) object() const; bool isReference() const; _PTR(SObject) referencedObject() const; + bool hasChildren() const; + bool expandable() const; virtual QString componentDataType() const;