From 26c42324c345edd513f45434137aac7a48acfa08 Mon Sep 17 00:00:00 2001 From: stv Date: Mon, 6 Jun 2005 11:30:04 +0000 Subject: [PATCH] Columns in object browser --- src/ObjBrowser/OB_Browser.cxx | 219 +++++++++++++------- src/ObjBrowser/OB_Browser.h | 26 ++- src/ObjBrowser/OB_ListItem.cxx | 2 + src/Qtx/QtxListView.cxx | 3 + src/SUIT/SUIT_DataObject.h | 9 +- src/SalomeApp/SalomeApp_Application.cxx | 7 +- src/SalomeApp/SalomeApp_DataObject.cxx | 177 +++++++++++++++- src/SalomeApp/SalomeApp_DataObject.h | 14 ++ src/SalomeApp/resources/SalomeApp_msg_en.po | 19 +- 9 files changed, 377 insertions(+), 99 deletions(-) diff --git a/src/ObjBrowser/OB_Browser.cxx b/src/ObjBrowser/OB_Browser.cxx index cfac73697..fe451d4b1 100755 --- a/src/ObjBrowser/OB_Browser.cxx +++ b/src/ObjBrowser/OB_Browser.cxx @@ -44,7 +44,7 @@ void OB_Browser::ToolTip::maybeTip( const QPoint& pos ) if ( !parentWidget() || !myBrowser || !myBrowser->isShowToolTips() ) return; - QListView* lv = myBrowser->getListView(); + QListView* lv = myBrowser->listView(); QListViewItem* item = lv->itemAt( pos ); SUIT_DataObject* obj = myBrowser->dataObject( item ); @@ -76,8 +76,8 @@ myAutoUpdate( false ), myAutoDelObjs( false ), myRootDecorated( true ) { - myView = new OB_ListView( this ); - myView->addColumn( "Data" ); + myView = new OB_ListView( QtxListView::HeaderAuto, this ); + myView->setAppropriate( myView->addColumn( "Data" ), false ); myView->setSorting( -1 ); myView->setRootIsDecorated( true ); myView->setSelectionMode( QListView::Extended ); @@ -187,10 +187,10 @@ void OB_Browser::setRootObject( SUIT_DataObject* theRoot ) if ( myRoot ) updateView( myRoot ); - else if ( getListView() ) + else if ( listView() ) { myItems.clear(); - getListView()->clear(); + listView()->clear(); } restoreState( selObjs, openObjs, curObj, selKeys, openKeys, curKey ); @@ -204,9 +204,9 @@ void OB_Browser::setRootObject( SUIT_DataObject* theRoot ) int OB_Browser::numberOfSelected() const { int count = 0; - if ( getListView() ) + if ( listView() ) { - for ( QListViewItemIterator it( getListView() ); it.current(); ++it ) + for ( QListViewItemIterator it( listView() ); it.current(); ++it ) if ( it.current()->isSelected() ) count++; } @@ -224,16 +224,16 @@ void OB_Browser::getSelected( DataObjectList& theObjList ) const { theObjList.clear(); - if ( !getListView() ) + if ( !listView() ) return; - for ( QListViewItemIterator it( getListView() ); it.current(); ++it ) + for ( QListViewItemIterator it( listView() ); it.current(); ++it ) { if ( it.current()->isSelected() ) { SUIT_DataObject* obj = dataObject( it.current() ); if ( obj ) - theObjList.append( obj ); + theObjList.append( obj ); } } } @@ -247,7 +247,7 @@ void OB_Browser::setSelected( const SUIT_DataObject* theObject, const bool appen void OB_Browser::setSelected( const DataObjectList& theObjLst, const bool append ) { - QListView* lv = getListView(); + QListView* lv = listView(); if ( !lv ) return; @@ -307,22 +307,22 @@ void OB_Browser::setSelected( const DataObjectList& theObjLst, const bool append bool OB_Browser::isOpen( SUIT_DataObject* theObject ) const { bool res = false; - if ( getListView() ) - res = getListView()->isOpen( listViewItem( theObject ) ); + if ( listView() ) + res = listView()->isOpen( listViewItem( theObject ) ); return res; } void OB_Browser::setOpen( SUIT_DataObject* theObject, const bool theOpen ) { - if ( getListView() ) - getListView()->setOpen( listViewItem( theObject ), theOpen ); + if ( listView() ) + listView()->setOpen( listViewItem( theObject ), theOpen ); } SUIT_DataObject* OB_Browser::dataObjectAt( const QPoint& pos ) const { SUIT_DataObject* obj = 0; - QListView* lv = getListView(); + QListView* lv = listView(); if ( lv ) obj = dataObject( lv->itemAt( pos ) ); @@ -339,63 +339,115 @@ void OB_Browser::setFilter( OB_Filter* f ) myView->setFilter( f ); } -int OB_Browser::addColumn( const QString & label, int width, int index ) +int OB_Browser::addColumn( const QString& label, const int id, const int width ) { - int id = -1; - if ( !myView ) - return id; - if ( index != -1 && myColumnIds.contains( index ) ) - return id; // can not reuse index - - int trueId = index; - id = myView->addColumn( label, width ); - if ( trueId == -1 ) - trueId = id; - myColumnIds.insert( trueId, id ); - updateText(); - - return trueId; + return addColumn( QIconSet(), label, id, width ); } -int OB_Browser::addColumn( const QIconSet & iconset, const QString & label, int width, int index ) +int OB_Browser::addColumn( const QIconSet& icon, const QString& label, const int id, const int width ) { - int id = -1; - if ( !myView ) - return id; - if ( index != -1 && myColumnIds.contains( index ) ) - return id; // can not reuse index + QListView* lv = listView(); + if ( !lv ) + return -1; + + int theId = id; + if ( theId < 0 ) + { + while ( myColumnIds.contains( theId ) ) + theId++; + } + + if ( myColumnIds.contains( theId ) ) + return -1; // can not reuse id - int trueId = index; - id = myView->addColumn( iconset, label, width ); - if ( trueId == -1 ) - trueId = id; - myColumnIds.insert( trueId, id ); + int sec = -1; + if ( icon.isNull() ) + sec = lv->addColumn( label, width ); + else + sec = lv->addColumn( icon, label, width ); + + if ( sec == -1 ) + return -1; + + myColumnIds.insert( theId, sec ); updateText(); - return trueId; + return theId; } -void OB_Browser::removeColumn( int index ) +void OB_Browser::removeColumn( const int id ) { - if ( !myView || !myColumnIds.contains( index ) ) + QListView* lv = listView(); + if ( !lv || !myColumnIds.contains( id ) ) return; - int id = myColumnIds[ index ]; - myView->removeColumn( id ); + int sec = myColumnIds[id]; + lv->removeColumn( sec ); // update map of column indeces - myColumnIds.remove( index ); + myColumnIds.remove( id ); for ( QMap::iterator it = myColumnIds.begin(); it != myColumnIds.end(); ++it ) { - if ( it.key() > index ) + if ( it.key() > id ) it.data()--; } updateText(); } +void OB_Browser::setNameTitle( const QString& label ) +{ + setNameTitle( QIconSet(), label ); +} + +void OB_Browser::setNameTitle( const QIconSet& icon, const QString& label ) +{ + QListView* lv = listView(); + if ( !lv ) + return; + + if ( icon.isNull() ) + lv->setColumnText( 0, label ); + else + lv->setColumnText( 0, icon, label ); +} + +void OB_Browser::setColumnTitle( const int id, const QString& label ) +{ + setColumnTitle( id, QIconSet(), label ); +} + +void OB_Browser::setColumnTitle( const int id, const QIconSet& icon, const QString& label ) +{ + QListView* lv = listView(); + if ( !lv || !myColumnIds.contains( id ) ) + return; + + if ( icon.isNull() ) + lv->setColumnText( myColumnIds[id], label ); + else + lv->setColumnText( myColumnIds[id], icon, label ); +} + +bool OB_Browser::isColumnVisible( const int id ) const +{ + myColumnIds.contains( id ) && myView->isShown( myColumnIds[id] ); +} + +void OB_Browser::setColumnShown( const int id, const bool on ) +{ + if ( !myColumnIds.contains( id ) ) + return; + + myView->setShown( myColumnIds[id], on ); +} + void OB_Browser::updateTree( SUIT_DataObject* o ) { - SUIT_DataObject* obj = o ? o : getRootObject(); + updateTree( o ? o : getRootObject(), false ); +} + +void OB_Browser::updateTree( SUIT_DataObject* obj, const bool notify ) +{ if ( !obj ) return; @@ -407,6 +459,9 @@ void OB_Browser::updateTree( SUIT_DataObject* o ) SUIT_DataObject* curObj = storeState( selObjs, openObjs, selKeys, openKeys, curKey ); + if ( notify ) + emit aboutRefresh(); + createConnections( obj ); updateView( obj ); @@ -457,7 +512,7 @@ void OB_Browser::replaceTree( SUIT_DataObject* src, SUIT_DataObject* trg ) void OB_Browser::updateView( const SUIT_DataObject* theStartObj ) { - QListView* lv = getListView(); + QListView* lv = listView(); if ( !lv ) return; @@ -513,7 +568,7 @@ void OB_Browser::updateView( const SUIT_DataObject* theStartObj ) } QListViewItem* OB_Browser::createTree( const SUIT_DataObject* obj, - QListViewItem* parent, QListViewItem* after ) + QListViewItem* parent, QListViewItem* after ) { if ( !obj ) return 0; @@ -531,7 +586,7 @@ QListViewItem* OB_Browser::createTree( const SUIT_DataObject* obj, QListViewItem* OB_Browser::createItem( const SUIT_DataObject* o, QListViewItem* parent, QListViewItem* after ) { - QListView* lv = getListView(); + QListView* lv = listView(); if ( !lv || !o ) return 0; @@ -585,17 +640,19 @@ QListViewItem* OB_Browser::createItem( const SUIT_DataObject* o, myItems.insert( obj, item ); + updateText( item ); + return item; } void OB_Browser::adjustWidth() { - if ( !getListView() ) + if ( !listView() ) return; - getListView()->setColumnWidth( 0, 0 ); - if ( getListView()->firstChild() ) - adjustWidth( getListView()->firstChild() ); + listView()->setColumnWidth( 0, 0 ); + if ( listView()->firstChild() ) + adjustWidth( listView()->firstChild() ); } void OB_Browser::adjustWidth( QListViewItem* item ) @@ -631,7 +688,7 @@ QListViewItem* OB_Browser::listViewItem( const SUIT_DataObject* obj ) const return item; } -QListView* OB_Browser::getListView() const +QListView* OB_Browser::listView() const { return myView; } @@ -670,7 +727,7 @@ SUIT_DataObject* OB_Browser::storeState( DataObjectMap& selObjs, DataObjectMap& DataObjectKeyMap& selKeys, DataObjectKeyMap& openKeys, DataObjectKey& curKey ) const { - QListView* lv = getListView(); + QListView* lv = listView(); if ( !lv ) return 0; @@ -699,7 +756,7 @@ void OB_Browser::restoreState( const DataObjectMap& selObjs, const DataObjectMap const SUIT_DataObject* curObj, const DataObjectKeyMap& selKeys, const DataObjectKeyMap& openKeys, const DataObjectKey& curKey ) { - QListView* lv = getListView(); + QListView* lv = listView(); if ( !lv ) return; @@ -774,7 +831,7 @@ void OB_Browser::onExpand() void OB_Browser::onRefresh() { - updateTree(); + updateTree( 0, true ); } void OB_Browser::onDestroyed( SUIT_DataObject* obj ) @@ -802,24 +859,32 @@ void OB_Browser::onDropped( QPtrList items, QListViewItem* item, void OB_Browser::updateText() { - if ( !myView ) + if ( myColumnIds.isEmpty() ) return; - - if ( myColumnIds.size() ) + + QListView* lv = listView(); + if ( !lv ) + return; + + for ( QListViewItemIterator it( lv ); it.current(); ++it ) { - QListViewItemIterator it( myView ); - for ( ; it.current() != 0; ++it ) - { - QListViewItem* item = it.current(); - SUIT_DataObject* obj = dataObject( item ); - if ( !item || !obj ) - continue; - QMap::iterator it = myColumnIds.begin(); - for( ; it != myColumnIds.end(); ++it ) - item->setText( it.data(), obj->text( it.key() ) ); - } + SUIT_DataObject* obj = dataObject( it.current() ); + if ( !obj ) + continue; + + for( QMap::iterator itr = myColumnIds.begin(); itr != myColumnIds.end(); ++itr ) + it.current()->setText( itr.data(), obj->text( itr.key() ) ); } - updateView(); +} + +void OB_Browser::updateText( QListViewItem* item ) +{ + SUIT_DataObject* obj = dataObject( item ); + if ( !obj ) + return; + + for( QMap::iterator it = myColumnIds.begin(); it != myColumnIds.end(); ++it ) + item->setText( it.data(), obj->text( it.key() ) ); } bool OB_Browser::eventFilter(QObject* watched, QEvent* e) @@ -909,7 +974,7 @@ void OB_Browser::removeObject( SUIT_DataObject* obj, const bool autoUpd ) void OB_Browser::autoOpenBranches() { int level = autoOpenLevel(); - QListView* lv = getListView(); + QListView* lv = listView(); if ( !lv || level < 1 ) return; diff --git a/src/ObjBrowser/OB_Browser.h b/src/ObjBrowser/OB_Browser.h index e1ea16ad3..2534a0d96 100755 --- a/src/ObjBrowser/OB_Browser.h +++ b/src/ObjBrowser/OB_Browser.h @@ -27,8 +27,8 @@ class OB_EXPORT OB_Browser : public QFrame, public SUIT_PopupClient class ToolTip; public: - OB_Browser( QWidget* = 0, SUIT_DataObject* theRoot = 0 ); - virtual ~OB_Browser(); + OB_Browser( QWidget* = 0, SUIT_DataObject* theRoot = 0 ); + virtual ~OB_Browser(); virtual QString popupClientType() const { return QString( "ObjectBrowser" ); } @@ -71,17 +71,26 @@ public: int autoOpenLevel() const; void setAutoOpenLevel( const int ); - virtual int addColumn( const QString & label, int width = -1, int index = -1 ); - virtual int addColumn( const QIconSet & iconset, const QString & label, int width = -1, int index = -1 ); - virtual void removeColumn( int index ); + virtual int addColumn( const QString&, const int id = -1, const int width = -1 ); + virtual int addColumn( const QIconSet&, const QString&, const int id = -1, const int width = -1 ); + virtual void removeColumn( const int id ); + + void setNameTitle( const QString& ); + virtual void setNameTitle( const QIconSet&, const QString& ); + void setColumnTitle( const int id, const QString& ); + virtual void setColumnTitle( const int id, const QIconSet&, const QString& ); + + bool isColumnVisible( const int ) const; + virtual void setColumnShown( const int, const bool ); virtual bool eventFilter(QObject* watched, QEvent* e); - QListView* getListView() const; - + QListView* listView() const; + virtual void contextMenuPopup( QPopupMenu* ); signals: + void aboutRefresh(); void selectionChanged(); void dropped( DataObjectList, SUIT_DataObject*, int ); @@ -118,6 +127,9 @@ private: void createConnections( SUIT_DataObject* ); void removeObject( SUIT_DataObject*, const bool = true ); + void updateText( QListViewItem* ); + void updateTree( SUIT_DataObject*, const bool ); + DataObjectKey objectKey( QListViewItem* ) const; DataObjectKey objectKey( SUIT_DataObject* ) const; diff --git a/src/ObjBrowser/OB_ListItem.cxx b/src/ObjBrowser/OB_ListItem.cxx index 663040ebb..570d3a9e1 100755 --- a/src/ObjBrowser/OB_ListItem.cxx +++ b/src/ObjBrowser/OB_ListItem.cxx @@ -99,6 +99,8 @@ void ListItem::paintCell( QPainter* p, const QColorGroup& cg, int c, int w, i colorGrp.setColor( QColorGroup::Background, myObject->color( SUIT_DataObject::Background ) ); if ( myObject->color( SUIT_DataObject::Highlight ).isValid() ) colorGrp.setColor( QColorGroup::Highlight, myObject->color( SUIT_DataObject::Highlight ) ); + if ( myObject->color( SUIT_DataObject::HighlightedText ).isValid() ) + colorGrp.setColor( QColorGroup::HighlightedText, myObject->color( SUIT_DataObject::HighlightedText ) ); } diff --git a/src/Qtx/QtxListView.cxx b/src/Qtx/QtxListView.cxx index 2ae608b74..e009ea3b2 100755 --- a/src/Qtx/QtxListView.cxx +++ b/src/Qtx/QtxListView.cxx @@ -186,6 +186,9 @@ void QtxListView::setShown( int ind, bool sh ) void QtxListView::setColumnWidth( int c, int w ) { + if ( myColumns.contains( c ) ) + myColumns[c].width = w; + QListView::setColumnWidth( c, !myColumns.contains( c ) ? w : 0 ); } diff --git a/src/SUIT/SUIT_DataObject.h b/src/SUIT/SUIT_DataObject.h index e9a960fd0..f303d0dea 100755 --- a/src/SUIT/SUIT_DataObject.h +++ b/src/SUIT/SUIT_DataObject.h @@ -24,7 +24,7 @@ public: class Signal; typedef enum { None, RadioButton, CheckBox } CheckType; - typedef enum { Text, Base, Foreground, Background, Highlight } ColorRole; + typedef enum { Text, Base, Foreground, Background, Highlight, HighlightedText } ColorRole; SUIT_DataObject( SUIT_DataObject* = 0 ); virtual ~SUIT_DataObject(); @@ -53,12 +53,11 @@ public: void reparentChildren( const SUIT_DataObject* ); - QString text() const { return text( 0 ); } - QColor color() const { return color( Foreground ); } - virtual QString name() const; - virtual QPixmap icon() const; 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; diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index e95d3b11f..f33c25e2e 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -10,6 +10,7 @@ #include "SalomeApp_Study.h" #include "SalomeApp_Module.h" #include "SalomeApp_OBFilter.h" +#include "SalomeApp_DataObject.h" #include "SalomeApp_EventFilter.h" #include "SalomeApp_WidgetContainer.h" @@ -769,6 +770,10 @@ QWidget* SalomeApp_Application::createWindow( const int flag ) ob->resize( OBJECT_BROWSER_WIDTH, ob->height() ); ob->setFilter( new SalomeApp_OBFilter( selectionMgr() ) ); + ob->setNameTitle( tr( "OBJ_BROWSER_NAME" ) ); + for ( int i = SalomeApp_DataObject::CT_Value; i <= SalomeApp_DataObject::CT_RefEntry; i++ ) + ob->addColumn( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), i ); + // Create OBSelector new SalomeApp_OBSelector( ob, mySelMgr ); @@ -792,7 +797,7 @@ QWidget* SalomeApp_Application::createWindow( const int flag ) logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) ); } - + return wid; } diff --git a/src/SalomeApp/SalomeApp_DataObject.cxx b/src/SalomeApp/SalomeApp_DataObject.cxx index 2822ed556..0a1bbe819 100644 --- a/src/SalomeApp/SalomeApp_DataObject.cxx +++ b/src/SalomeApp/SalomeApp_DataObject.cxx @@ -1,13 +1,20 @@ #include "SalomeApp_DataObject.h" -#include "SalomeApp_RootObject.h" + #include "SalomeApp_Study.h" +#include "SalomeApp_RootObject.h" -#include #include #include +#include #include +#include +#include +#include +#include +#include + /*! Class: SalomeApp_DataObject::Key Level: Internal @@ -83,10 +90,15 @@ SUIT_DataObjectKey* SalomeApp_DataObject::key() const QString SalomeApp_DataObject::name() const { + QString str; + if ( myObject ) - return myObject->GetName().c_str(); - return QString::null; - //return QString( "%1 [%2]" ).arg( myName ).arg( myEntry ); // for debug + str = myObject->GetName().c_str(); + + if ( isReference() ) + str = QString( "* " ) + str; + + return str; } QPixmap SalomeApp_DataObject::icon() const @@ -109,14 +121,65 @@ QPixmap SalomeApp_DataObject::icon() const QColor SalomeApp_DataObject::color() const { _PTR(GenericAttribute) anAttr; - if ( myObject && myObject->FindAttribute( anAttr, "AttributeTextColor" ) ){ - _PTR(AttributeTextColor) aColAttr ( anAttr ); + if ( myObject && myObject->FindAttribute( anAttr, "AttributeTextColor" ) ) + { + _PTR(AttributeTextColor) aColAttr( anAttr ); QColor color( (int)aColAttr->TextColor().R, (int)aColAttr->TextColor().G, (int)aColAttr->TextColor().B ); return color; } return QColor(); } +QString SalomeApp_DataObject::text( const int id ) const +{ + QString txt; + switch ( id ) + { + case CT_Value: + if ( componentObject() != this ) + txt = value( referencedObject() ); + break; + case CT_Entry: + txt = entry( referencedObject() ); + break; + case CT_IOR: + txt = ior( referencedObject() ); + break; + case CT_RefEntry: + if ( isReference() ) + txt = entry( object() ); + break; + } + return txt; +} + +QColor SalomeApp_DataObject::color( const ColorRole cr ) const +{ + QColor clr; + switch ( cr ) + { + case Foreground: + { + _PTR(GenericAttribute) anAttr; + if ( myObject && myObject->FindAttribute( anAttr, "AttributeTextColor" ) ) + { + _PTR(AttributeTextColor) aColAttr( anAttr ); + clr = QColor( (int)aColAttr->TextColor().R, (int)aColAttr->TextColor().G, (int)aColAttr->TextColor().B ); + } + } + break; + case Highlight: + if ( isReference() ) + clr = QColor( 255, 0, 0 ); + break; + case HighlightedText: + if ( isReference() ) + clr = QColor( 255, 255, 255 ); + break; + } + return clr; +} + QString SalomeApp_DataObject::toolTip() const { //return object()->Name(); @@ -144,7 +207,7 @@ QString SalomeApp_DataObject::componentDataType() const const SalomeApp_DataObject* compObj = dynamic_cast( componentObject() ); if ( compObj && compObj->object() ) { - _PTR(SComponent) aComp ( compObj->object() ); + _PTR(SComponent) aComp( compObj->object() ); if ( aComp ) return aComp->ComponentDataType().c_str(); } @@ -157,6 +220,104 @@ _PTR(SObject) SalomeApp_DataObject::object() const return myObject; } +bool SalomeApp_DataObject::isReference() const +{ + bool isRef = false; + if ( myObject ) + { + _PTR(SObject) refObj; + isRef = myObject->ReferencedObject( refObj ); + } + return isRef; +} + +_PTR(SObject) SalomeApp_DataObject::referencedObject() const +{ + _PTR(SObject) refObj; + _PTR(SObject) obj = myObject; + while ( obj && obj->ReferencedObject( refObj ) ) + obj = refObj; + + return obj; +} + +QString SalomeApp_DataObject::ior( const _PTR(SObject)& obj ) const +{ + QString txt; + if ( obj ) + { + _PTR(GenericAttribute) attr; + if ( obj->FindAttribute( attr, "AttributeIOR" ) ) + { + _PTR(AttributeIOR) iorAttr = attr; + if ( iorAttr ) + { + std::string str = iorAttr->Value(); + txt = QString( str.c_str() ); + } + } + } + return txt; +} + +QString SalomeApp_DataObject::entry( const _PTR(SObject)& obj ) const +{ + QString txt; + if ( obj ) + { + std::string str = obj->GetID(); + txt = QString( str.c_str() ); + } + return txt; +} + +QString SalomeApp_DataObject::value( const _PTR(SObject)& obj ) const +{ + if ( !obj ) + return QString::null; + + QString val; + _PTR(GenericAttribute) attr; + + if ( obj->FindAttribute( attr, "AttributeInteger" ) ) + { + _PTR(AttributeInteger) intAttr = attr; + if ( intAttr ) + val = QString::number( intAttr->Value() ); + } + else if ( obj->FindAttribute( attr, "AttributeReal" ) ) + { + _PTR(AttributeReal) realAttr = attr; + if ( realAttr ) + val = QString::number( realAttr->Value() ); + } + else if ( obj->FindAttribute( attr, "AttributeTableOfInteger" ) ) + { + _PTR(AttributeTableOfInteger) tableAttr = attr; + std::string title = tableAttr->GetTitle(); + val = QString( title.c_str() ); + if ( !val.isEmpty() ) + val += QString( " " ); + val += QString( "[%1,%2]" ).arg( tableAttr->GetNbRows() ).arg( tableAttr->GetNbColumns() ); + } + else if ( obj->FindAttribute( attr, "AttributeTableOfReal" ) ) + { + _PTR(AttributeTableOfReal) tableAttr = attr; + std::string title = tableAttr->GetTitle(); + val = QString( title.c_str() ); + if ( !val.isEmpty() ) + val += QString( " " ); + val += QString( "[%1,%2]" ).arg( tableAttr->GetNbRows() ).arg( tableAttr->GetNbColumns() ); + } + else if ( obj->FindAttribute( attr, "AttributeComment") ) + { + _PTR(AttributeComment) comm = attr; + std::string str = comm->Value(); + val = QString( str.c_str() ); + } + + return val; +} /*! Class: SalomeApp_ModuleObject diff --git a/src/SalomeApp/SalomeApp_DataObject.h b/src/SalomeApp/SalomeApp_DataObject.h index 39f4a0960..26ffdfeb4 100644 --- a/src/SalomeApp/SalomeApp_DataObject.h +++ b/src/SalomeApp/SalomeApp_DataObject.h @@ -14,6 +14,9 @@ class SALOMEAPP_EXPORT SalomeApp_DataObject : public virtual CAM_DataObject { class Key; +public: + enum { CT_Value, CT_Entry, CT_IOR, CT_RefEntry }; + public: SalomeApp_DataObject( SUIT_DataObject* = 0 ); SalomeApp_DataObject( const _PTR(SObject)&, SUIT_DataObject* = 0 ); @@ -24,14 +27,25 @@ public: virtual QColor color() const; virtual QString toolTip() const; + virtual QString text( const int ) const; + virtual QColor color( const ColorRole ) const; + virtual SUIT_DataObjectKey* key() const; virtual QString entry() const; virtual _PTR(SObject) object() const; // location of corresponding SALOMEDS::SObject + bool isReference() const; + _PTR(SObject) referencedObject() const; + SUIT_DataObject* componentObject() const; QString componentDataType() const; // GEOM, SMESH, VISU, etc. +private: + QString ior( const _PTR(SObject)& ) const; + QString entry( const _PTR(SObject)& ) const; + QString value( const _PTR(SObject)& ) const; + private: _PTR(SObject) myObject; }; diff --git a/src/SalomeApp/resources/SalomeApp_msg_en.po b/src/SalomeApp/resources/SalomeApp_msg_en.po index 804fa093e..780d08f3c 100644 --- a/src/SalomeApp/resources/SalomeApp_msg_en.po +++ b/src/SalomeApp/resources/SalomeApp_msg_en.po @@ -99,6 +99,23 @@ msgstr "Module activation cancelled" //======================================================================================= +msgid "SalomeApp_Application::OBJ_BROWSER_NAME" +msgstr "Object" + +msgid "SalomeApp_Application::OBJ_BROWSER_COLUMN_0" +msgstr "Value" + +msgid "SalomeApp_Application::OBJ_BROWSER_COLUMN_1" +msgstr "Entry" + +msgid "SalomeApp_Application::OBJ_BROWSER_COLUMN_2" +msgstr "IOR" + +msgid "SalomeApp_Application::OBJ_BROWSER_COLUMN_3" +msgstr "Reference entry" + +//======================================================================================= + msgid "SalomeApp_ModuleDlg::CAPTION" msgstr "Activate module" @@ -117,4 +134,4 @@ msgstr "&Cancel" msgid "SalomeApp_ModuleDlg::ActivateComponent_DESCRIPTION" msgstr "Create, open or load study." -//======================================================================================= \ No newline at end of file +//======================================================================================= -- 2.30.2