12 #include "kmpopfiltercnfrmdlg.h"
13 #include "kmheaders.h"
18 #include <tqcheckbox.h>
19 #include <tqvgroupbox.h>
22 #include <tdelocale.h>
23 #include <tdeio/global.h>
30 : TDEListView(aParent)
33 int mDownIndex=addColumn(TQIconSet(TQPixmap(mDown)), TQString(), 24);
34 assert( mDownIndex == Down );
36 addColumn(TQIconSet(TQPixmap(mLater)), TQString(), 24);
37 addColumn(TQIconSet(TQPixmap(mDel)), TQString(), 24);
39 addColumn(i18n( "Subject"), 180);
40 addColumn(i18n( "Sender"), 150);
41 addColumn(i18n( "Receiver"), 150);
42 int dateCol = addColumn(i18n( "Date"), 120);
43 int sizeCol = addColumn(i18n( "Size"), 80);
45 setAllColumnsShowFocus( true);
47 setColumnAlignment(Down, TQt::AlignHCenter);
48 setColumnAlignment(Later, TQt::AlignHCenter);
49 setColumnAlignment(Delete, TQt::AlignHCenter);
50 setColumnAlignment(sizeCol, TQt::AlignRight);
52 setSorting(dateCol, false);
53 setShowSortIndicator( true);
54 header()->setResizeEnabled( false, Down);
55 header()->setResizeEnabled( false, Later);
56 header()->setResizeEnabled( false, Delete);
57 header()->setClickEnabled( false, Down);
58 header()->setClickEnabled( false, Later);
59 header()->setClickEnabled( false, Delete);
62 header()->setMovingEnabled( false);
64 connect( this, TQ_SIGNAL(pressed(TQListViewItem*, const TQPoint&, int)),
65 TQ_SLOT(slotPressed(TQListViewItem*, const TQPoint&, int)));
68 KMPopHeadersView::~KMPopHeadersView()
73 void KMPopHeadersView::keyPressEvent( TQKeyEvent *e )
75 if (e->key() == Key_Left) {
76 KMPopHeadersViewItem *item = dynamic_cast<KMPopHeadersViewItem* >( selectedItem() );
79 item->setAction((KMPopFilterAction)((int)item->action()-1));
80 mDialog->setAction( selectedItem(), item->action());
83 } else if (e->key() == Key_Right) {
84 KMPopHeadersViewItem *item = dynamic_cast<KMPopHeadersViewItem* >( selectedItem() );
86 if (item->action()<NoAction-1) {
87 item->setAction((KMPopFilterAction)((int)item->action()+1));
88 mDialog->setAction( selectedItem(), item->action());
92 TQListView::keyPressEvent( e );
96 void KMPopHeadersView::slotPressed(TQListViewItem* aItem, const TQPoint&, int aColumn) {
97 if ( !( aItem && aColumn>=0 && aColumn<NoAction ) ) return;
98 KMPopHeadersViewItem *item = dynamic_cast<KMPopHeadersViewItem* >(aItem);
100 item->setAction(mapToAction(aColumn));
103 const char *KMPopHeadersView::mUnchecked[26] = {
131 const char *KMPopHeadersView::mChecked[26] = {
159 const char *KMPopHeadersView::mLater[25] = {
186 const char *KMPopHeadersView::mDown[20] = {
208 const char *KMPopHeadersView::mDel[19] = {
235 KMPopHeadersViewItem::KMPopHeadersViewItem( KMPopHeadersView *aParent, KMPopFilterAction aAction)
236 : TDEListViewItem(aParent)
241 setPixmap(mParent->mapToColumn(Delete), TQPixmap(KMPopHeadersView::mUnchecked));
242 setPixmap(mParent->mapToColumn(Down), TQPixmap(KMPopHeadersView::mUnchecked));
243 setPixmap(mParent->mapToColumn(Later), TQPixmap(KMPopHeadersView::mUnchecked));
245 setAction( aAction );
248 KMPopHeadersViewItem::~KMPopHeadersViewItem()
252 void KMPopHeadersViewItem::setAction(KMPopFilterAction aAction)
254 if(aAction != NoAction && aAction!=mAction)
256 if ( mAction!=NoAction ) setPixmap(mParent->mapToColumn(mAction), TQPixmap(KMPopHeadersView::mUnchecked));
257 setPixmap(mParent->mapToColumn(aAction), TQPixmap(KMPopHeadersView::mChecked));
262 void KMPopHeadersViewItem::paintFocus(TQPainter *, const TQColorGroup &, const TQRect &)
266 TQString KMPopHeadersViewItem::key( int col, bool) const
268 if (col == 3) return KMMsgBase::skipKeyword(text(col).lower());
269 if (col == 6) return text(8);
271 return text(col).rightJustify( 10, '0', false);
280 KMPopFilterCnfrmDlg::KMPopFilterCnfrmDlg(TQPtrList<KMPopHeaders> *aHeaders, const TQString &aAccount, bool aShowLaterMsgs, TQWidget *aParent, const char *aName)
281 : KDialogBase(aParent, aName, true, i18n( "POP Filter"), Ok | Help, Ok, false)
283 unsigned int rulesetCount = 0;
285 mShowLaterMsgs = aShowLaterMsgs;
286 mLowerBoxVisible = false;
288 TQWidget *w = new TQWidget( this);
291 TQVBoxLayout *vbl = new TQVBoxLayout(w, 0, spacingHint());
293 TQLabel *l = new TQLabel(i18n( "Messages to filter found on POP Account: <b>%1</b><p>"
294 "The messages shown exceed the maximum size limit you defined for this account.<br>You can select "
295 "what you want to do with them by checking the appropriate button.").arg(aAccount), w);
298 TQVGroupBox *upperBox = new TQVGroupBox(i18n( "Messages Exceeding Size"), w);
301 vbl->addWidget(upperBox);
303 TQVGroupBox *lowerBox = new TQVGroupBox(i18n( "Ruleset Filtered Messages: none"), w);
304 TQString checkBoxText((aShowLaterMsgs)?
305 i18n( "Show messages matched by a ruleset and tagged 'Download' or 'Delete'"):
306 i18n( "Show messages matched by a filter ruleset"));
307 TQCheckBox* cb = new TQCheckBox(checkBoxText, lowerBox);
308 cb->setEnabled( false);
310 mFilteredHeaders->hide();
311 vbl->addWidget(lowerBox);
313 mFilteredHeaders->header()->setResizeEnabled( false, 8);
314 mFilteredHeaders->setColumnWidth(8, 0);
317 KMPopHeaders *headers;
318 for(headers = aHeaders->first(); headers; headers = aHeaders->next())
320 KMPopHeadersViewItem *lvi = 0;
322 if(headers->ruleMatched())
324 if(aShowLaterMsgs && headers->action() == Later)
327 lvi = new KMPopHeadersViewItem(mFilteredHeaders, headers->action());
328 mFilteredHeaders->show();
329 mLowerBoxVisible = true;
331 else if(aShowLaterMsgs)
335 mDDLList.append(headers);
336 cb->setEnabled( true);
338 else if(!aShowLaterMsgs)
342 lvi = new KMPopHeadersViewItem(mFilteredHeaders, headers->action());
343 cb->setEnabled( true);
351 lvi = new KMPopHeadersViewItem(lv, headers->action());
357 mItemMap[lvi] = headers;
358 setupLVI(lvi,headers->header());
363 lowerBox->setTitle(i18n( "Ruleset Filtered Messages: %1").arg(rulesetCount));
366 connect(lv, TQ_SIGNAL(pressed(TQListViewItem*, const TQPoint&, int)),
367 this, TQ_SLOT(slotPressed(TQListViewItem*, const TQPoint&, int)));
368 connect(mFilteredHeaders, TQ_SIGNAL(pressed(TQListViewItem*, const TQPoint&, int)),
369 this, TQ_SLOT(slotPressed(TQListViewItem*, const TQPoint&, int)));
370 connect(cb, TQ_SIGNAL(toggled( bool)),
371 this, TQ_SLOT(slotToggled( bool)));
374 TQTimer::singleShot(0, this, TQ_SLOT(slotUpdateMinimumSize()));
377 KMPopFilterCnfrmDlg::~KMPopFilterCnfrmDlg()
381 void KMPopFilterCnfrmDlg::setupLVI(KMPopHeadersViewItem *lvi, KMMessage *msg)
386 tmp = i18n( "no subject");
387 lvi->setText(3, tmp);
390 tmp = msg->fromStrip();
392 tmp = i18n( "unknown");
393 lvi->setText(4, tmp);
396 tmp = msg->toStrip();
398 tmp = i18n( "unknown");
399 lvi->setText(5, tmp);
402 lvi->setText(6, KMime::DateFormatter::formatDate( KMime::DateFormatter::Fancy, msg->date() ) );
404 lvi->setText(7, TDEIO::convertSize(msg-> msgLength()));
406 lvi->setText(8, msg->dateIsoStr());
409 void KMPopFilterCnfrmDlg::setAction(TQListViewItem *aItem, KMPopFilterAction aAction)
411 mItemMap[aItem]->setAction(aAction);
419 void KMPopFilterCnfrmDlg::slotPressed(TQListViewItem *aItem, const TQPoint &, int aColumn)
421 if ( aColumn>=0 && aColumn<NoAction ) setAction(aItem,KMPopHeadersView::mapToAction(aColumn));
424 void KMPopFilterCnfrmDlg::slotToggled( bool aOn)
431 for(KMPopHeaders* headers = mDDLList.first(); headers; headers = mDDLList.next())
433 KMPopHeadersViewItem *lvi = new KMPopHeadersViewItem(mFilteredHeaders, headers->action());
434 mItemMap[lvi] = headers;
435 mDelList.append(lvi);
436 setupLVI(lvi,headers->header());
440 if(!mLowerBoxVisible)
442 mFilteredHeaders->show();
450 for(KMPopHeadersViewItem* item = mDelList.first(); item; item = mDelList.next())
452 mFilteredHeaders->takeItem(item);
457 if(!mLowerBoxVisible)
459 mFilteredHeaders->hide();
462 TQTimer::singleShot(0, this, TQ_SLOT(slotUpdateMinimumSize()));
465 void KMPopFilterCnfrmDlg::slotUpdateMinimumSize()
467 mainWidget()->setMinimumSize(mainWidget()->sizeHint());
470 #include "kmpopfiltercnfrmdlg.moc"
TQString subject() const Get or set the 'Subject' header field.
size_t msgLength() const Unlike the above function this works also, if the message is not in a folder.
@ Ok The user rights/ACL have been fetched from the server sucessfully.
|