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 "tdelistviewindexedsearchline.h"
00031 #include <kdebug.h>
00032 #include <sys/types.h>
00033 #include <sys/stat.h>
00034 #include "headeritem.h"
00035 #include "kmheaders.h"
00036 #include "kmfolder.h"
00037 #include "index.h"
00038
00039 using KMail::HeaderListQuickSearch;
00040
00041 TDEListViewIndexedSearchLine::TDEListViewIndexedSearchLine( TQWidget* parent, TDEListView* listView, TDEActionCollection* actionCollection, const char* name ):
00042 HeaderListQuickSearch( parent, listView, actionCollection, name ),
00043 mFiltering( false )
00044 {
00045 }
00046
00047 TDEListViewIndexedSearchLine::~TDEListViewIndexedSearchLine() {
00048 }
00049
00050
00051 void TDEListViewIndexedSearchLine::updateSearch( const TQString& s ) {
00052 kdDebug( 5006 ) << "updateSearch( -" << s << "- )" << endl;
00053 mFiltering = false;
00054 if ( !s.isNull() && !s.isEmpty() ) {
00055 bool ok = false;
00056 KMMsgIndex* index = kmkernel->msgIndex();
00057 if ( index ) {
00058 mResults = index->simpleSearch( s, &ok );
00059 std::sort( mResults.begin(), mResults.end() );
00060 mFiltering = ok;
00061 }
00062 }
00063 TDEListViewSearchLine::updateSearch( s );
00064 }
00065
00066 bool TDEListViewIndexedSearchLine::itemMatches( const TQListViewItem* item, const TQString& s ) const {
00067 if ( mFiltering &&
00068 std::binary_search( mResults.begin(), mResults.end(), static_cast<const KMail::HeaderItem*>( item )->msgSerNum() ) )
00069 return true;
00070 return KMail::HeaderListQuickSearch::itemMatches( item, s );
00071 }
00072
00073 #include "tdelistviewindexedsearchline.moc"
00074