kaddressbook Library API Documentation

incsearchwidget.cpp

00001 /*                                                                      
00002     This file is part of KAddressBook.                                  
00003     Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>                   
00004                                                                         
00005     This program 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     This program is distributed in the hope that it will be useful,     
00011     but 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., 675 Mass Ave, Cambridge, MA 02139, USA.           
00018                                                                         
00019     As a special exception, permission is given to link this program    
00020     with any edition of Qt, and distribute the resulting executable,    
00021     without including the source code for Qt in the source distribution.
00022 */
00023 
00024 #include <qlabel.h>
00025 #include <qlayout.h>
00026 #include <qtooltip.h>
00027 
00028 #include <kdialog.h>
00029 #include <klineedit.h>
00030 #include <klocale.h>
00031 
00032 #include "incsearchwidget.h"
00033 
00034 IncSearchWidget::IncSearchWidget( QWidget *parent, const char* )
00035     : QWidget( parent, "kde toolbar widget" )
00036 {
00037   setCaption( i18n( "Incremental Search" ) );
00038 
00039   initGUI();
00040 
00041   connect( mEdit, SIGNAL( textChanged( const QString& ) ),
00042            SLOT( slotAnnounce() ) );
00043   connect( mEdit, SIGNAL( returnPressed() ),
00044            SLOT( slotAnnounce() ) );
00045   connect( mCombo, SIGNAL( activated( const QString& ) ),
00046            SLOT( slotAnnounce() ) );
00047 }
00048 
00049 IncSearchWidget::~IncSearchWidget()
00050 {
00051 }
00052 
00053 void IncSearchWidget::slotAnnounce()
00054 {
00055   emit incSearch( mEdit->text(), mCombo->currentItem() );
00056 }
00057 
00058 void IncSearchWidget::setFields( const QStringList& fields )
00059 {
00060   mCombo->clear();
00061   mCombo->insertStringList( fields );
00062 }
00063 
00064 void IncSearchWidget::initGUI()
00065 {
00066   setName("kde toolbar widget");
00067 
00068   QHBoxLayout *layout = new QHBoxLayout( this, 2, KDialog::spacingHint() ); 
00069 
00070   QLabel *label = new QLabel( i18n( "Incremental search:" ), this, "kde toolbar widget" );
00071   label->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
00072   layout->addWidget( label );
00073 
00074   mEdit = new KLineEdit( this );
00075   layout->addWidget( mEdit );
00076 
00077   mCombo = new QComboBox( false, this );
00078   layout->addWidget( mCombo );
00079 
00080   QToolTip::add( mCombo, i18n( "Select Incremental Search Field" ) );
00081 
00082   resize( QSize(420, 50).expandedTo(sizeHint()) );
00083 }
00084 
00085 #include "incsearchwidget.moc"
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 15 11:40:37 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001