2 This file is part of KAddressBook.
4 Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
6 This library is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Library General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or (at your
9 option) any later version.
11 This library is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14 License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 #include "quicksearchwidget.h"
24 #include <QtCore/QTimer>
25 #include <QtGui/QKeyEvent>
26 #include <QtGui/QVBoxLayout>
28 #include <klineedit.h>
31 QuickSearchWidget::QuickSearchWidget( QWidget
*parent
)
34 QVBoxLayout
*layout
= new QVBoxLayout( this );
35 layout
->setMargin( 0 );
37 mEdit
= new KLineEdit
;
38 mEdit
->setClickMessage( i18nc( "Search contacts in list", "Search" ) );
39 mEdit
->setClearButtonShown( true );
41 mEdit
->installEventFilter( this );
43 layout
->addWidget( mEdit
);
45 mTimer
= new QTimer( this );
47 connect( mEdit
, SIGNAL( textChanged( const QString
& ) ), SLOT( resetTimer() ) );
48 connect( mTimer
, SIGNAL( timeout() ), SLOT( delayedTextChanged() ) );
52 QuickSearchWidget::~QuickSearchWidget()
56 QSize
QuickSearchWidget::sizeHint() const
58 const QSize size
= mEdit
->sizeHint();
59 return QSize( 200, size
.height() );
62 void QuickSearchWidget::resetTimer()
68 void QuickSearchWidget::delayedTextChanged()
71 emit
filterStringChanged( mEdit
->text() );
74 void QuickSearchWidget::keyPressEvent( QKeyEvent
*event
)
76 if ( event
->key() == Qt::Key_Down
) {
79 emit
arrowDownKeyPressed();
83 QWidget::keyPressEvent( event
);
86 #include "quicksearchwidget.moc"