From: stv Date: Tue, 31 May 2005 05:15:33 +0000 (+0000) Subject: no message X-Git-Tag: T3_0_0_a1~76 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=81d25a47b06dc8195fd850bfc4d0d9b98f2d48e3;p=modules%2Fgui.git no message --- diff --git a/src/ObjBrowser/OB_ListItem.cxx b/src/ObjBrowser/OB_ListItem.cxx index 0b352d631..81fa6b747 100755 --- a/src/ObjBrowser/OB_ListItem.cxx +++ b/src/ObjBrowser/OB_ListItem.cxx @@ -1,5 +1,7 @@ #include "OB_ListItem.h" +#include "OB_ListView.h" + #include #include @@ -114,6 +116,18 @@ void ListItem::paintFocus( QPainter* p, const QColorGroup& cg, const QRect& r T::paintFocus( p, cg, rect ); } +template +void ListItem::setSelected( bool s ) +{ + if ( s && listView() && listView()->inherits( "OB_ListView" ) ) + { + OB_ListView* oblv = (OB_ListView*)listView(); + s = s && oblv->isOk( this ); + } + + QListViewItem::setSelected( s ); +} + template void ListItem::update() { diff --git a/src/ObjBrowser/OB_ListItem.h b/src/ObjBrowser/OB_ListItem.h index 5d057dc6a..f53145c66 100755 --- a/src/ObjBrowser/OB_ListItem.h +++ b/src/ObjBrowser/OB_ListItem.h @@ -11,7 +11,8 @@ class SUIT_DataObject; base template class for ListViewItems and CheckListItems */ -template class ListItem : public T { +template class ListItem : public T +{ public: ListItem( SUIT_DataObject*, QListView* ); ListItem( SUIT_DataObject*, QListViewItem* ); @@ -23,15 +24,13 @@ public: ListItem( SUIT_DataObject*, QListView*, QListViewItem*, int ); ListItem( SUIT_DataObject*, QListViewItem*, QListViewItem*, int ); - virtual void paintCell( QPainter* p, const QColorGroup& cg, int c, int w, int align ); - - virtual void paintFocus( QPainter* p, const QColorGroup& cg, const QRect& r ); - - inline SUIT_DataObject* dataObject() const - { return myObject; } + virtual void setSelected( bool s ); + inline SUIT_DataObject* dataObject() const { return myObject; } + virtual void paintFocus( QPainter* p, const QColorGroup& cg, const QRect& r ); + virtual void paintCell( QPainter* p, const QColorGroup& cg, int c, int w, int align ); private: - void update(); + void update(); private: SUIT_DataObject* myObject; diff --git a/src/ObjBrowser/OB_ListView.cxx b/src/ObjBrowser/OB_ListView.cxx index fb9ba2341..866161e4a 100755 --- a/src/ObjBrowser/OB_ListView.cxx +++ b/src/ObjBrowser/OB_ListView.cxx @@ -38,17 +38,13 @@ void OB_ListView::setFilter( OB_Filter* f ) myFilter = f; } -void OB_ListView::setSelected( QListViewItem* item, bool sel ) +bool OB_ListView::isOk( QListViewItem* item ) const { - bool on = sel; - if ( filter() ) - { - SUIT_DataObject* obj = dataObject( item ); - if ( obj ) - on = on && filter()->isOk( obj ); - } - - QListView::setSelected( item, on ); + bool ok = true; + SUIT_DataObject* obj = dataObject( item ); + if ( obj && filter() ) + ok = filter()->isOk( obj ); + return ok; } int OB_ListView::addColumn( const QString& label, int width ) diff --git a/src/ObjBrowser/OB_ListView.h b/src/ObjBrowser/OB_ListView.h index 391c0948e..6fca182eb 100755 --- a/src/ObjBrowser/OB_ListView.h +++ b/src/ObjBrowser/OB_ListView.h @@ -28,11 +28,11 @@ public: OB_Filter* filter() const; void setFilter( OB_Filter* ); - virtual void setSelected( QListViewItem*, bool ); - virtual int addColumn( const QString& label, int width = -1 ); virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 ); + bool isOk( QListViewItem* ) const; + signals: void dropped( QPtrList, QListViewItem*, int );