8 #include "kmatmlistview.h" 9 #include <tqcheckbox.h> 12 KMAtmListViewItem::KMAtmListViewItem( TQListView *parent )
14 TQListViewItem( parent )
16 mCBCompress =
new TQCheckBox( listView()->viewport() );
17 mCBEncrypt =
new TQCheckBox( listView()->viewport() );
18 mCBSign =
new TQCheckBox( listView()->viewport() );
19 mCBCompress->setShown(
true );
20 updateAllCheckBoxes();
22 connect( mCBCompress, TQT_SIGNAL( clicked() ),
this, TQT_SLOT( slotCompress() ) );
23 connect( listView()->header(), TQT_SIGNAL( sizeChange(
int,
int,
int) ),
24 TQT_SLOT( slotHeaderChange(
int,
int,
int ) ) );
25 connect( listView()->header(), TQT_SIGNAL( indexChange(
int,
int,
int) ),
26 TQT_SLOT( slotHeaderChange(
int,
int,
int ) ) );
27 connect( listView()->header(), TQT_SIGNAL( clicked(
int ) ), TQT_SLOT( slotHeaderClick(
int ) ) );
30 KMAtmListViewItem::~KMAtmListViewItem()
40 void KMAtmListViewItem::updateCheckBox(
int headerSection, TQCheckBox *cb )
44 int sectionWidth = listView()->header()->sectionSize( headerSection );
45 int sectionPos = listView()->header()->sectionPos( headerSection );
46 int sectionOffset = sectionWidth / 2 - height() / 4;
49 cb->resize( sectionWidth - sectionOffset - 1, height() - 2 );
50 listView()->moveChild( cb, sectionPos + sectionOffset, itemPos() + 1 );
55 bg = listView()->colorGroup().highlight();
57 bg = listView()->colorGroup().base();
59 cb->setPaletteBackgroundColor( bg );
62 void KMAtmListViewItem::updateAllCheckBoxes()
64 updateCheckBox( 4, mCBCompress );
65 updateCheckBox( 5, mCBEncrypt );
66 updateCheckBox( 6, mCBSign );
80 void KMAtmListViewItem::paintCell ( TQPainter * p,
const TQColorGroup &cg,
81 int column,
int width,
int align )
84 case 4: updateCheckBox( 4, mCBCompress );
break;
85 case 5: updateCheckBox( 5, mCBEncrypt );
break;
86 case 6: updateCheckBox( 6, mCBSign );
break;
89 TQListViewItem::paintCell( p, cg, column, width, align );
92 int KMAtmListViewItem::compare( TQListViewItem *i,
int col,
bool ascending )
const 95 return TQListViewItem::compare( i, col, ascending );
98 return mAttachmentSize -
99 (
static_cast<KMAtmListViewItem*
>(i))->mAttachmentSize;
102 void KMAtmListViewItem::enableCryptoCBs(
bool on )
107 mCBEncrypt->setShown( on );
108 mCBSign->setShown( on );
111 void KMAtmListViewItem::setEncrypt(
bool on )
114 mCBEncrypt->setChecked( on );
118 bool KMAtmListViewItem::isEncrypt()
121 return mCBEncrypt->isChecked();
127 void KMAtmListViewItem::setSign(
bool on )
130 mCBSign->setChecked( on );
134 bool KMAtmListViewItem::isSign()
137 return mCBSign->isChecked();
143 void KMAtmListViewItem::setCompress(
bool on )
145 mCBCompress->setChecked( on );
148 bool KMAtmListViewItem::isCompress()
150 return mCBCompress->isChecked();
153 void KMAtmListViewItem::slotCompress()
155 if ( mCBCompress->isChecked() ) {
156 emit compress( itemPos() );
158 emit uncompress( itemPos() );
164 void KMAtmListViewItem::slotHeaderChange (
int,
int,
int )
166 updateAllCheckBoxes();
170 void KMAtmListViewItem::slotHeaderClick(
int )
172 updateAllCheckBoxes();
175 #include "kmatmlistview.moc"