• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

kaddressbook

  • sources
  • kde-4.12
  • kdepim
  • kaddressbook
quicksearchwidget.cpp
Go to the documentation of this file.
1 /*
2  This file is part of KAddressBook.
3 
4  Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
5 
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.
10 
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.
15 
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
19  02110-1301, USA.
20 */
21 
22 #include "quicksearchwidget.h"
23 
24 #include <KLineEdit>
25 #include <KLocale>
26 
27 #include <QtCore/QTimer>
28 #include <QKeyEvent>
29 #include <QVBoxLayout>
30 
31 QuickSearchWidget::QuickSearchWidget( QWidget *parent )
32  : QWidget( parent )
33 {
34  QVBoxLayout *layout = new QVBoxLayout( this );
35  layout->setMargin( 0 );
36 
37  mEdit = new KLineEdit;
38  mEdit->setClickMessage( i18nc( "@label Search contacts in list", "Search" ) );
39  mEdit->setClearButtonShown( true );
40  mEdit->setToolTip(
41  i18nc( "@info:tooltip", "Search contacts in list" ) );
42  mEdit->setWhatsThis(
43  i18nc( "@info:whatsthis",
44  "Start typing a search string in this box and the list of contacts "
45  "matching that string will be displayed. This is a quick way of searching "
46  "for contacts of interest." ) );
47  mEdit->installEventFilter( this );
48 
49  layout->addWidget( mEdit );
50 
51  mTimer = new QTimer( this );
52 
53  connect( mEdit, SIGNAL(textChanged(QString)), SLOT(resetTimer()) );
54  connect( mTimer, SIGNAL(timeout()), SLOT(delayedTextChanged()) );
55 }
56 
57 QuickSearchWidget::~QuickSearchWidget()
58 {
59 }
60 
61 QSize QuickSearchWidget::sizeHint() const
62 {
63  const QSize size = mEdit->sizeHint();
64  return QSize( 200, size.height() );
65 }
66 
67 void QuickSearchWidget::resetTimer()
68 {
69  mTimer->stop();
70  mTimer->start( 500 );
71 }
72 
73 void QuickSearchWidget::delayedTextChanged()
74 {
75  mTimer->stop();
76  emit filterStringChanged( mEdit->text() );
77 }
78 
79 void QuickSearchWidget::keyPressEvent( QKeyEvent *event )
80 {
81  if ( event->key() == Qt::Key_Down ) {
82  event->accept();
83  delayedTextChanged();
84  emit arrowDownKeyPressed();
85  return;
86  }
87 
88  QWidget::keyPressEvent( event );
89 }
90 
91 #include "quicksearchwidget.moc"
QuickSearchWidget::sizeHint
virtual QSize sizeHint() const
Returns the size hint of the quick search widget.
Definition: quicksearchwidget.cpp:61
QuickSearchWidget::filterStringChanged
void filterStringChanged(const QString &filterString)
This signal is emitted whenever the user has changed the filter string in the line edit...
QuickSearchWidget::~QuickSearchWidget
virtual ~QuickSearchWidget()
Destroys the quick search widget.
Definition: quicksearchwidget.cpp:57
QuickSearchWidget::arrowDownKeyPressed
void arrowDownKeyPressed()
This signal is emitted whenever the user pressed the arrow down key.
quicksearchwidget.h
QuickSearchWidget::QuickSearchWidget
QuickSearchWidget(QWidget *parent=0)
Creates the quick search widget.
Definition: quicksearchwidget.cpp:31
QuickSearchWidget::keyPressEvent
void keyPressEvent(QKeyEvent *)
Definition: quicksearchwidget.cpp:79
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:51 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kaddressbook

Skip menu "kaddressbook"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal