00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "plvitem.h"
00012 #include "variant.h"
00013
00014 #include <klistview.h>
00015 #include <qpainter.h>
00016 #include <qvariant.h>
00017
00018
00019 PLVItem::PLVItem(KListView *listview, const QString &id, Variant *data)
00020 : KListViewItem(listview, data->editorCaption())
00021 {
00022 p_data = data;
00023 m_id = id;
00024 setText(1,p_data->displayString() );
00025
00026 connect(data,SIGNAL(valueChanged(QVariant, QVariant )),this,SLOT(updateData(QVariant )));
00027
00028
00029 }
00030
00031
00032 PLVItem::~PLVItem()
00033 {
00034 }
00035
00036 void PLVItem::updateData(QVariant )
00037 {
00038 if (!p_data)
00039 return;
00040 setText(1,p_data->displayString() );
00041 }
00042
00043
00044 int PLVItem::width ( const QFontMetrics & fm, const QListView * lv, int c ) const
00045 {
00046 if ( c == 0 )
00047 return 100;
00048
00049 else
00050 return 200;
00051 }
00052
00053
00054
00055
00056
00057 PLVColorItem::PLVColorItem(KListView *listview, const QString &id, Variant *data)
00058 : PLVItem(listview,id,data)
00059 {
00060 }
00061
00062
00063 PLVColorItem::~PLVColorItem()
00064 {
00065 }
00066
00067 void PLVColorItem::paintCell ( QPainter * p, const QColorGroup & cg, int column, int width, int align )
00068 {
00069 if (!p_data)
00070 return;
00071
00072
00073 if (column == 1)
00074 {
00075 p->setBackgroundColor( p_data->value().toColor() );
00076 QBrush brush( p_data->value().toColor() );
00077 p->fillRect(QRect(0,0,listView()->columnWidth(1),KListViewItem::height()),brush);
00078 }
00079 else
00080 KListViewItem::paintCell(p,cg,column,width,align);
00081 }
00082
00083 void PLVColorItem::updateData(QVariant value)
00084 {
00085 listView()->triggerUpdate();
00086 PLVItem::updateData(value);
00087 }
00088
00089
00090 #include "plvitem.moc"