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 if ( s && listView() && listView()->inherits( "OB_ListView" ) )
124 OB_ListView* oblv = (OB_ListView*)listView();
125 s = s && oblv->isOk( this );
128 QListViewItem::setSelected( s );
132 void ListItem<T>::update()
134 SUIT_DataObject* obj = dataObject();
138 setText( 0, obj->name() );
140 int aIconW = obj->icon().width();
146 double aScale = 20.0 / aIconW;
147 aM.scale( aScale, aScale );
148 setPixmap( 0, obj->icon().xForm( aM ) );
151 setPixmap( 0, obj->icon() );
154 this->setDragEnabled( obj->isDragable() );
155 this->setDropEnabled( true );
160 Descr: List view item for OB_Browser.
163 OB_ListItem::OB_ListItem( SUIT_DataObject* obj, QListView* parent )
164 : ListItem<QListViewItem>( obj, parent )
168 OB_ListItem::OB_ListItem( SUIT_DataObject* obj, QListViewItem* parent )
169 : ListItem<QListViewItem>( obj, parent )
173 OB_ListItem::OB_ListItem( SUIT_DataObject* obj, QListView* parent, QListViewItem* after )
174 : ListItem<QListViewItem>( obj, parent, after )
178 OB_ListItem::OB_ListItem( SUIT_DataObject* obj, QListViewItem* parent, QListViewItem* after )
179 : ListItem<QListViewItem>( obj, parent, after )
183 OB_ListItem::~OB_ListItem()
187 int OB_ListItem::RTTI()
192 int OB_ListItem::rtti() const
198 Class: OB_CheckListItem
199 Descr: Check list view item for OB_Browser.
202 OB_CheckListItem::OB_CheckListItem( SUIT_DataObject* obj, QListView* parent, Type type )
203 : ListItem<QCheckListItem>( obj, parent, type )
207 OB_CheckListItem::OB_CheckListItem( SUIT_DataObject* obj, QListViewItem* parent, Type type )
208 : ListItem<QCheckListItem>( obj, parent, type )
212 OB_CheckListItem::OB_CheckListItem( SUIT_DataObject* obj, QListView* parent, QListViewItem* after, Type type )
213 : ListItem<QCheckListItem>( obj, parent, after, type )
217 OB_CheckListItem::OB_CheckListItem( SUIT_DataObject* obj, QListViewItem* parent, QListViewItem* after, Type type )
218 : ListItem<QCheckListItem>( obj, parent, after, type )
222 OB_CheckListItem::~OB_CheckListItem()
226 int OB_CheckListItem::RTTI()
228 return OB_ListItem::RTTI() + 1;
231 int OB_CheckListItem::rtti() const
236 void OB_CheckListItem::stateChange( bool on )
238 QCheckListItem::stateChange( on );
241 dataObject()->setOn( on );