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 ) );
102 if ( myObject->color( SUIT_DataObject::HighlightedText ).isValid() )
103 colorGrp.setColor( QColorGroup::HighlightedText, myObject->color( SUIT_DataObject::HighlightedText ) );
107 p->fillRect( 0, 0, w, this->height(), colorGrp.brush( QColorGroup::Base ) );
108 int itemW = width( p->fontMetrics(), this->listView(), c );
110 T::paintCell( p, colorGrp, c, itemW, align );
114 void ListItem<T>::paintFocus( QPainter* p, const QColorGroup& cg, const QRect& r )
117 rect.setWidth( width( p->fontMetrics(), this->listView(), 0 ) );
118 T::paintFocus( p, cg, rect );
122 void ListItem<T>::setSelected( bool s )
124 QListView* lv = T::listView();
125 if ( s && lv && lv->inherits( "OB_ListView" ) )
127 OB_ListView* objlv = (OB_ListView*)lv;
128 s = s && objlv->isOk( this );
131 QListViewItem::setSelected( s );
135 void ListItem<T>::update()
137 SUIT_DataObject* obj = dataObject();
141 setText( 0, obj->name() );
143 int aIconW = obj->icon().width();
149 double aScale = 20.0 / aIconW;
150 aM.scale( aScale, aScale );
151 setPixmap( 0, obj->icon().xForm( aM ) );
154 setPixmap( 0, obj->icon() );
157 this->setDragEnabled( obj->isDragable() );
158 this->setDropEnabled( true );
163 Descr: List view item for OB_Browser.
166 OB_ListItem::OB_ListItem( SUIT_DataObject* obj, QListView* parent )
167 : ListItem<QListViewItem>( obj, parent )
171 OB_ListItem::OB_ListItem( SUIT_DataObject* obj, QListViewItem* parent )
172 : ListItem<QListViewItem>( obj, parent )
176 OB_ListItem::OB_ListItem( SUIT_DataObject* obj, QListView* parent, QListViewItem* after )
177 : ListItem<QListViewItem>( obj, parent, after )
181 OB_ListItem::OB_ListItem( SUIT_DataObject* obj, QListViewItem* parent, QListViewItem* after )
182 : ListItem<QListViewItem>( obj, parent, after )
186 OB_ListItem::~OB_ListItem()
190 int OB_ListItem::RTTI()
195 int OB_ListItem::rtti() const
201 Class: OB_CheckListItem
202 Descr: Check list view item for OB_Browser.
205 OB_CheckListItem::OB_CheckListItem( SUIT_DataObject* obj, QListView* parent, Type type )
206 : ListItem<QCheckListItem>( obj, parent, type )
210 OB_CheckListItem::OB_CheckListItem( SUIT_DataObject* obj, QListViewItem* parent, Type type )
211 : ListItem<QCheckListItem>( obj, parent, type )
215 OB_CheckListItem::OB_CheckListItem( SUIT_DataObject* obj, QListView* parent, QListViewItem* after, Type type )
216 : ListItem<QCheckListItem>( obj, parent, after, type )
220 OB_CheckListItem::OB_CheckListItem( SUIT_DataObject* obj, QListViewItem* parent, QListViewItem* after, Type type )
221 : ListItem<QCheckListItem>( obj, parent, after, type )
225 OB_CheckListItem::~OB_CheckListItem()
229 int OB_CheckListItem::RTTI()
231 return OB_ListItem::RTTI() + 1;
234 int OB_CheckListItem::rtti() const
239 void OB_CheckListItem::stateChange( bool on )
241 QCheckListItem::stateChange( on );
244 dataObject()->setOn( on );