00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "ocheckitem.h"
00015
00023 OCheckItem::OCheckItem( QTable *t, const QString &key )
00024 : QTableItem( t, Never, "" ), m_checked( FALSE ), m_sortKey( key )
00025 {
00026 }
00027
00033 QString OCheckItem::key() const
00034 {
00035 return m_sortKey;
00036 }
00037
00044 void OCheckItem::setChecked( bool b )
00045 {
00046 m_checked = b;
00047 table()->updateCell( row(), col() );
00048 }
00049
00054 void OCheckItem::toggle()
00055 {
00056 m_checked = !m_checked;
00057 }
00058
00064 bool OCheckItem::isChecked() const
00065 {
00066 return m_checked;
00067 }
00068
00073 void OCheckItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr,
00074 bool )
00075 {
00076 p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) );
00077
00078 int marg = ( cr.width() - BoxSize ) / 2;
00079 int x = 0;
00080 int y = ( cr.height() - BoxSize ) / 2;
00081 p->setPen( QPen( cg.text() ) );
00082 p->drawRect( x + marg, y, BoxSize, BoxSize );
00083 p->drawRect( x + marg+1, y+1, BoxSize-2, BoxSize-2 );
00084 p->setPen( darkGreen );
00085 x += 1;
00086 y += 1;
00087 if ( m_checked ) {
00088 QPointArray a( 7*2 );
00089 int i, xx, yy;
00090 xx = x+1+marg;
00091 yy = y+2;
00092 for ( i=0; i<3; i++ ) {
00093 a.setPoint( 2*i, xx, yy );
00094 a.setPoint( 2*i+1, xx, yy+2 );
00095 xx++; yy++;
00096 }
00097 yy -= 2;
00098 for ( i=3; i<7; i++ ) {
00099 a.setPoint( 2*i, xx, yy );
00100 a.setPoint( 2*i+1, xx, yy+2 );
00101 xx++; yy--;
00102 }
00103 p->drawLineSegments( a );
00104 }
00105 }