7 #include "kmatmlistview.h"
8 #include <tqcheckbox.h>
11 KMAtmListViewItem::KMAtmListViewItem( TQListView *parent )
13 TQListViewItem( parent )
15 mCBCompress =
new TQCheckBox( listView()->viewport() );
16 mCBEncrypt =
new TQCheckBox( listView()->viewport() );
17 mCBSign =
new TQCheckBox( listView()->viewport() );
18 mCBCompress->setShown(
true );
19 updateAllCheckBoxes();
21 connect( mCBCompress, TQ_SIGNAL( clicked() ),
this, TQ_SLOT( slotCompress() ) );
22 connect( listView()->header(), TQ_SIGNAL( sizeChange(
int,
int,
int) ),
23 TQ_SLOT( slotHeaderChange(
int,
int,
int ) ) );
24 connect( listView()->header(), TQ_SIGNAL( indexChange(
int,
int,
int) ),
25 TQ_SLOT( slotHeaderChange(
int,
int,
int ) ) );
26 connect( listView()->header(), TQ_SIGNAL( clicked(
int ) ), TQ_SLOT( slotHeaderClick(
int ) ) );
29 KMAtmListViewItem::~KMAtmListViewItem()
39 void KMAtmListViewItem::updateCheckBox(
int headerSection, TQCheckBox *cb )
43 int sectionWidth = listView()->header()->sectionSize( headerSection );
44 int sectionPos = listView()->header()->sectionPos( headerSection );
45 int sectionOffset = sectionWidth / 2 - height() / 4;
48 cb->resize( sectionWidth - sectionOffset - 1, height() - 2 );
49 listView()->moveChild( cb, sectionPos + sectionOffset, itemPos() + 1 );
54 bg = listView()->colorGroup().highlight();
56 bg = listView()->colorGroup().base();
58 cb->setPaletteBackgroundColor( bg );
61 void KMAtmListViewItem::updateAllCheckBoxes()
63 updateCheckBox( 4, mCBCompress );
64 updateCheckBox( 5, mCBEncrypt );
65 updateCheckBox( 6, mCBSign );
79 void KMAtmListViewItem::paintCell ( TQPainter * p,
const TQColorGroup &cg,
80 int column,
int width,
int align )
83 case 4: updateCheckBox( 4, mCBCompress );
break;
84 case 5: updateCheckBox( 5, mCBEncrypt );
break;
85 case 6: updateCheckBox( 6, mCBSign );
break;
88 TQListViewItem::paintCell( p, cg, column, width, align );
91 int KMAtmListViewItem::compare( TQListViewItem *i,
int col,
bool ascending )
const
94 return TQListViewItem::compare( i, col, ascending );
97 return mAttachmentSize -
98 (
static_cast<KMAtmListViewItem*
>(i))->mAttachmentSize;
101 void KMAtmListViewItem::enableCryptoCBs(
bool on )
106 mCBEncrypt->setShown( on );
107 mCBSign->setShown( on );
110 void KMAtmListViewItem::setEncrypt(
bool on )
113 mCBEncrypt->setChecked( on );
117 bool KMAtmListViewItem::isEncrypt()
120 return mCBEncrypt->isChecked();
126 void KMAtmListViewItem::setSign(
bool on )
129 mCBSign->setChecked( on );
133 bool KMAtmListViewItem::isSign()
136 return mCBSign->isChecked();
142 void KMAtmListViewItem::setCompress(
bool on )
144 mCBCompress->setChecked( on );
147 bool KMAtmListViewItem::isCompress()
149 return mCBCompress->isChecked();
152 void KMAtmListViewItem::slotCompress()
154 if ( mCBCompress->isChecked() ) {
155 emit compress( itemPos() );
157 emit uncompress( itemPos() );
163 void KMAtmListViewItem::slotHeaderChange (
int,
int,
int )
165 updateAllCheckBoxes();
169 void KMAtmListViewItem::slotHeaderClick(
int )
171 updateAllCheckBoxes();
174 #include "kmatmlistview.moc"