1 #include "OB_ListItem.h"
3 #include "OB_ListView.h"
5 #include <SUIT_DataObject.h>
12 Descr: base template class
15 ListItem<T>::ListItem( SUIT_DataObject* obj, QListView* parent )
23 ListItem<T>::ListItem( SUIT_DataObject* obj, QListViewItem* parent )
31 ListItem<T>::ListItem( SUIT_DataObject* obj, QListView* parent, QListViewItem* after )
39 ListItem<T>::ListItem( SUIT_DataObject* obj, QListViewItem* parent, QListViewItem* after )
47 ListItem<T>::ListItem( SUIT_DataObject* obj, QListView* parent, int type )
48 : T( parent, "", (typename T::Type)type ),
55 ListItem<T>::ListItem( SUIT_DataObject* obj, QListViewItem* parent, int type )
56 : T( parent, "", (typename T::Type)type ),
63 ListItem<T>::ListItem( SUIT_DataObject* obj, QListView* parent, QListViewItem* after, int type )
64 #if defined(QT_VERSION) && QT_VERSION >= 0x030101
65 : T( parent, after, "", (typename T::Type)type ),
67 : T( parent, "", (typename T::Type)type ),
75 ListItem<T>::ListItem( SUIT_DataObject* obj, QListViewItem* parent, QListViewItem* after, int type )
76 #if defined(QT_VERSION) && QT_VERSION >= 0x030101
77 : T( parent, after, "", (typename T::Type)type ),
79 : T( parent, "", (typename T::Type)type ),
87 void ListItem<T>::paintCell( QPainter* p, const QColorGroup& cg, int c, int w, int align )
89 QColorGroup colorGrp( cg );
92 if ( myObject->color( SUIT_DataObject::Text ).isValid() )
93 colorGrp.setColor( QColorGroup::Text, myObject->color( SUIT_DataObject::Text ) );
94 if ( myObject->color( SUIT_DataObject::Base ).isValid() )
95 colorGrp.setColor( QColorGroup::Base, myObject->color( SUIT_DataObject::Base ) );
96 if ( myObject->color( SUIT_DataObject::Foreground ).isValid() )
97 colorGrp.setColor( QColorGroup::Foreground, myObject->color( SUIT_DataObject::Foreground ) );
98 if ( myObject->color( SUIT_DataObject::Background ).isValid() )
99 colorGrp.setColor( QColorGroup::Background, myObject->color( SUIT_DataObject::Background ) );
100 if ( myObject->color( SUIT_DataObject::Highlight ).isValid() )
101 colorGrp.setColor( QColorGroup::Highlight, myObject->color( SUIT_DataObject::Highlight ) );
105 p->fillRect( 0, 0, w, this->height(), colorGrp.brush( QColorGroup::Base ) );
106 int itemW = width( p->fontMetrics(), this->listView(), c );
108 T::paintCell( p, colorGrp, c, itemW, align );
112 void ListItem<T>::paintFocus( QPainter* p, const QColorGroup& cg, const QRect& r )
115 rect.setWidth( width( p->fontMetrics(), this->listView(), 0 ) );
116 T::paintFocus( p, cg, rect );
120 void ListItem<T>::setSelected( bool s )
122 QListView* lv = T::listView();
123 if ( s && lv && lv->inherits( "OB_ListView" ) )
125 OB_ListView* objlv = (OB_ListView*)lv;
126 s = s && objlv->isOk( this );
129 QListViewItem::setSelected( s );
133 void ListItem<T>::update()
135 SUIT_DataObject* obj = dataObject();
139 setText( 0, obj->name() );
141 int aIconW = obj->icon().width();
147 double aScale = 20.0 / aIconW;
148 aM.scale( aScale, aScale );
149 setPixmap( 0, obj->icon().xForm( aM ) );
152 setPixmap( 0, obj->icon() );
155 this->setDragEnabled( obj->isDragable() );
156 this->setDropEnabled( true );
161 Descr: List view item for OB_Browser.
164 OB_ListItem::OB_ListItem( SUIT_DataObject* obj, QListView* parent )
165 : ListItem<QListViewItem>( obj, parent )
169 OB_ListItem::OB_ListItem( SUIT_DataObject* obj, QListViewItem* parent )
170 : ListItem<QListViewItem>( obj, parent )
174 OB_ListItem::OB_ListItem( SUIT_DataObject* obj, QListView* parent, QListViewItem* after )
175 : ListItem<QListViewItem>( obj, parent, after )
179 OB_ListItem::OB_ListItem( SUIT_DataObject* obj, QListViewItem* parent, QListViewItem* after )
180 : ListItem<QListViewItem>( obj, parent, after )
184 OB_ListItem::~OB_ListItem()
188 int OB_ListItem::RTTI()
193 int OB_ListItem::rtti() const
199 Class: OB_CheckListItem
200 Descr: Check list view item for OB_Browser.
203 OB_CheckListItem::OB_CheckListItem( SUIT_DataObject* obj, QListView* parent, Type type )
204 : ListItem<QCheckListItem>( obj, parent, type )
208 OB_CheckListItem::OB_CheckListItem( SUIT_DataObject* obj, QListViewItem* parent, Type type )
209 : ListItem<QCheckListItem>( obj, parent, type )
213 OB_CheckListItem::OB_CheckListItem( SUIT_DataObject* obj, QListView* parent, QListViewItem* after, Type type )
214 : ListItem<QCheckListItem>( obj, parent, after, type )
218 OB_CheckListItem::OB_CheckListItem( SUIT_DataObject* obj, QListViewItem* parent, QListViewItem* after, Type type )
219 : ListItem<QCheckListItem>( obj, parent, after, type )
223 OB_CheckListItem::~OB_CheckListItem()
227 int OB_CheckListItem::RTTI()
229 return OB_ListItem::RTTI() + 1;
232 int OB_CheckListItem::rtti() const
237 void OB_CheckListItem::stateChange( bool on )
239 QCheckListItem::stateChange( on );
242 dataObject()->setOn( on );