headerlistquicksearch.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "headerlistquicksearch.h"
00031
00032 #include <qapplication.h>
00033 #include <qlabel.h>
00034 #include <qcombobox.h>
00035 #include <qtimer.h>
00036
00037 #include <kaction.h>
00038 #include <klistview.h>
00039 #include <klocale.h>
00040
00041 #include "kmheaders.h"
00042 #include "kmsearchpattern.h"
00043
00044 namespace KMail {
00045
00046 HeaderListQuickSearch::HeaderListQuickSearch( QWidget *parent,
00047 KListView *listView,
00048 KActionCollection *actionCollection,
00049 const char *name )
00050 : KListViewSearchLine(parent, listView, name), mStatusCombo(0), mStatus(0)
00051 {
00052 KAction *resetQuickSearch = new KAction( i18n( "Reset Quick Search" ),
00053 QApplication::reverseLayout()
00054 ? "clear_left"
00055 : "locationbar_erase",
00056 0, this,
00057 SLOT( reset() ),
00058 actionCollection,
00059 "reset_quicksearch" );
00060 resetQuickSearch->plug( parent );
00061 resetQuickSearch->setWhatsThis( i18n( "Reset Quick Search\n"
00062 "Resets the quick search so that "
00063 "all messages are shown again." ) );
00064
00065 QLabel *label = new QLabel( i18n("Stat&us:"), parent, "kde toolbar widget" );
00066
00067 mStatusCombo = new QComboBox( parent, "quick search status combo box" );
00068 mStatusCombo->insertItem( i18n("Any Status") );
00069 for ( int i = 0; i < KMail::StatusValueCount; i++ )
00070 mStatusCombo->insertItem( i18n( KMail::StatusValues[i] ) );
00071 mStatusCombo->setCurrentItem( 0 );
00072 connect( mStatusCombo, SIGNAL ( activated( int ) ),
00073 this, SLOT( slotStatusChanged( int ) ) );
00074
00075 label->setBuddy( mStatusCombo );
00076
00077
00078
00079
00080
00081 disconnect(listView, SIGNAL(itemAdded(QListViewItem *)),
00082 this, SLOT(itemAdded(QListViewItem *)));
00083 KMHeaders *headers = static_cast<KMHeaders*>( listView );
00084 connect( headers, SIGNAL( msgAddedToListView( QListViewItem * ) ),
00085 this, SLOT( itemAdded( QListViewItem* ) ) );
00086 }
00087
00088 HeaderListQuickSearch::~HeaderListQuickSearch()
00089 {
00090 }
00091
00092
00093 bool HeaderListQuickSearch::itemMatches(const QListViewItem *item, const QString &s) const
00094 {
00095 if ( mStatus != 0 ) {
00096 KMHeaders *headers = static_cast<KMHeaders*>( item->listView() );
00097 const KMMsgBase *msg = headers->getMsgBaseForItem( item );
00098 if ( !msg || ! ( msg->status() & mStatus ) )
00099 return false;
00100 }
00101 return KListViewSearchLine::itemMatches(item, s);
00102 }
00103
00104
00105 void HeaderListQuickSearch::reset()
00106 {
00107 clear();
00108 mStatusCombo->setCurrentItem( 0 );
00109 slotStatusChanged( 0 );
00110 }
00111
00112 void HeaderListQuickSearch::slotStatusChanged( int index )
00113 {
00114 if ( index == 0 )
00115 mStatus = 0;
00116 else
00117 mStatus =
00118 KMSearchRuleStatus::statusFromEnglishName( KMail::StatusValues[index-1] );
00119 updateSearch();
00120 }
00121
00122 }
00123
00124 #include "headerlistquicksearch.moc"
This file is part of the documentation for kmail Library Version 3.3.2.