kmail Library API Documentation

headerlistquicksearch.cpp

00001 /* 00002 This file is part of KMail, the KDE mail client. 00003 Copyright (c) 2004 Till Adam <adam@kde.org> 00004 00005 KMail is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 KMail is distributed in the hope that it will be useful, but 00011 WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 00019 In addition, as a special exception, the copyright holders give 00020 permission to link the code of this program with any edition of 00021 the Qt library by Trolltech AS, Norway (or with modified versions 00022 of Qt that use the same license as Qt), and distribute linked 00023 combinations including the two. You must obey the GNU General 00024 Public License in all respects for all of the code used other than 00025 Qt. If you modify this file, you may extend this exception to 00026 your version of the file, but you are not obligated to do so. If 00027 you do not wish to do so, delete this exception statement from 00028 your version. 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 HeaderListQuickSearch::~HeaderListQuickSearch() 00079 { 00080 } 00081 00082 00083 bool HeaderListQuickSearch::itemMatches(const QListViewItem *item, const QString &s) const 00084 { 00085 if ( mStatus != 0 ) { 00086 KMHeaders *headers = static_cast<KMHeaders*>( item->listView() ); 00087 const KMMsgBase *msg = headers->getMsgBaseForItem( item ); 00088 if ( !msg || ! ( msg->status() & mStatus ) ) 00089 return false; 00090 } 00091 return KListViewSearchLine::itemMatches(item, s); 00092 } 00093 00094 //----------------------------------------------------------------------------- 00095 void HeaderListQuickSearch::reset() 00096 { 00097 clear(); 00098 mStatusCombo->setCurrentItem( 0 ); 00099 slotStatusChanged( 0 ); 00100 } 00101 00102 void HeaderListQuickSearch::slotStatusChanged( int index ) 00103 { 00104 if ( index == 0 ) 00105 mStatus = 0; 00106 else 00107 mStatus = 00108 KMSearchRuleStatus::statusFromEnglishName( KMail::StatusValues[index-1] ); 00109 updateSearch(); 00110 } 00111 00112 } // namespace KMail 00113 00114 #include "headerlistquicksearch.moc"
KDE Logo
This file is part of the documentation for kmail Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 27 12:52:16 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003