1 #include "OB_ListItem.h"
3 #include "OB_ListView.h"
5 #include <SUIT_DataObject.h>
15 Descr: base template class
19 ListItemF<T>::ListItemF( T& theT, SUIT_DataObject* obj ) :
26 void ListItemF<T>::paintC( QPainter* p, QColorGroup& cg, int c, int w, int align )
28 // QColorGroup colorGrp( cg );
31 if ( myObject->color( SUIT_DataObject::Text ).isValid() )
32 cg.setColor( QColorGroup::Text, myObject->color( SUIT_DataObject::Text ) );
33 if ( myObject->color( SUIT_DataObject::Base ).isValid() )
34 cg.setColor( QColorGroup::Base, myObject->color( SUIT_DataObject::Base ) );
35 if ( myObject->color( SUIT_DataObject::Foreground ).isValid() )
36 cg.setColor( QColorGroup::Foreground, myObject->color( SUIT_DataObject::Foreground ) );
37 if ( myObject->color( SUIT_DataObject::Background ).isValid() )
38 cg.setColor( QColorGroup::Background, myObject->color( SUIT_DataObject::Background ) );
39 if ( myObject->color( SUIT_DataObject::Highlight ).isValid() )
40 cg.setColor( QColorGroup::Highlight, myObject->color( SUIT_DataObject::Highlight ) );
41 if ( myObject->color( SUIT_DataObject::HighlightedText ).isValid() )
42 cg.setColor( QColorGroup::HighlightedText, myObject->color( SUIT_DataObject::HighlightedText ) );
46 p->fillRect( 0, 0, w, myT.height(), cg.brush( QColorGroup::Base ) );
47 //int itemW = myT.width( p->fontMetrics(), myT.listView(), c );
49 //myT.paintCell( p, colorGrp, c, itemW, align );
53 void ListItemF<T>::paintFoc( QPainter* p, QColorGroup& cg, const QRect& r )
56 rect.setWidth( myT.width( p->fontMetrics(), myT.listView(), 0 ) );
57 //myT.paintFocus( p, cg, rect );
61 void ListItemF<T>::setSel( bool s )
63 QListView* lv = myT.listView();
64 if ( s && lv && lv->inherits( "OB_ListView" ) )
66 OB_ListView* objlv = (OB_ListView*)lv;
67 s = s && objlv->isOk( &myT );
70 //myT.setSelected( s );
74 void ListItemF<T>::update()
76 SUIT_DataObject* obj = dataObject();
80 myT.setText( 0, obj->name() );
82 int aIconW = obj->icon().width();
88 double aScale = 20.0 / aIconW;
89 aM.scale( aScale, aScale );
90 myT.setPixmap( 0, obj->icon().xForm( aM ) );
93 myT.setPixmap( 0, obj->icon() );
96 myT.setDragEnabled( obj->isDragable() );
97 myT.setDropEnabled( true );
102 Descr: List view item for OB_Browser.
105 OB_ListItem::OB_ListItem( SUIT_DataObject* obj, QListView* parent )
106 : ListItemF<QListViewItem>( *this, obj ),
107 QListViewItem(parent)
112 OB_ListItem::OB_ListItem( SUIT_DataObject* obj, QListViewItem* parent )
113 : ListItemF<QListViewItem>( *this, obj),
114 QListViewItem(parent)
119 OB_ListItem::OB_ListItem( SUIT_DataObject* obj, QListView* parent, QListViewItem* after )
120 : ListItemF<QListViewItem>( *this, obj),
121 QListViewItem(parent, after )
126 OB_ListItem::OB_ListItem( SUIT_DataObject* obj, QListViewItem* parent, QListViewItem* after )
127 : ListItemF<QListViewItem>( *this,obj),
128 QListViewItem(parent, after )
133 OB_ListItem::~OB_ListItem()
137 void OB_ListItem::setSelected( bool s )
140 QListViewItem::setSelected( s );
143 void OB_ListItem::paintFocus( QPainter* p, const QColorGroup& cg, const QRect& r )
145 QColorGroup col_group( cg );
146 paintFoc( p, col_group, r );
149 if ( listView() && !listView()->allColumnsShowFocus() )
150 R.setWidth( width( p->fontMetrics(), listView(), 0 ) );
152 QListViewItem::paintFocus( p, col_group, R );
155 void OB_ListItem::paintCell( QPainter* p, const QColorGroup& cg, int c, int w, int align )
157 QColorGroup col_group( cg );
158 paintC( p, col_group, c ,w, align );
161 if ( listView() && !listView()->allColumnsShowFocus() )
162 W = width( p->fontMetrics(), listView(), c );
164 QListViewItem::paintCell( p, col_group, c, W, align );
167 int OB_ListItem::RTTI()
172 int OB_ListItem::rtti() const
178 Class: OB_CheckListItem
179 Descr: Check list view item for OB_Browser.
182 OB_CheckListItem::OB_CheckListItem( SUIT_DataObject* obj, QListView* parent, Type type )
183 : ListItemF<QCheckListItem>( *this, obj),
184 QCheckListItem( parent, "", type )
189 OB_CheckListItem::OB_CheckListItem( SUIT_DataObject* obj, QListViewItem* parent, Type type )
190 : ListItemF<QCheckListItem>( *this, obj),
191 QCheckListItem( parent, "", type )
196 OB_CheckListItem::OB_CheckListItem( SUIT_DataObject* obj, QListView* parent, QListViewItem* after, Type type )
197 : ListItemF<QCheckListItem>( *this, obj),
198 #if defined(QT_VERSION) && QT_VERSION >= 0x030101
199 QCheckListItem( parent, after, "", type )
201 QCheckListItem( parent, "", type )
207 OB_CheckListItem::OB_CheckListItem( SUIT_DataObject* obj, QListViewItem* parent, QListViewItem* after, Type type )
208 : ListItemF<QCheckListItem>( *this, obj),
209 #if defined(QT_VERSION) && QT_VERSION >= 0x030101
210 QCheckListItem( parent, after, "", type )
212 QCheckListItem( parent, "", type )
218 OB_CheckListItem::~OB_CheckListItem()
222 void OB_CheckListItem::setSelected( bool s )
225 QCheckListItem::setSelected( s );
228 void OB_CheckListItem::paintFocus( QPainter* p, const QColorGroup& cg, const QRect& r )
230 QColorGroup col_group( cg );
231 paintFoc( p, col_group, r );
234 if ( listView() && !listView()->allColumnsShowFocus() )
235 R.setWidth( width( p->fontMetrics(), listView(), 0 ) );
237 QCheckListItem::paintFocus( p, col_group, R );
240 void OB_CheckListItem::paintCell( QPainter* p, const QColorGroup& cg, int c, int w, int align )
242 QColorGroup col_group( cg );
243 paintC( p, col_group, c ,w, align );
246 if ( listView() && !listView()->allColumnsShowFocus() )
247 W = width( p->fontMetrics(), listView(), c );
249 QCheckListItem::paintCell( p, col_group, c, W, align );
252 int OB_CheckListItem::RTTI()
254 return OB_ListItem::RTTI() + 1;
257 int OB_CheckListItem::rtti() const
262 void OB_CheckListItem::stateChange( bool on )
264 QCheckListItem::stateChange( on );
267 dataObject()->setOn( on );