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

kaddressbook

  • sources
  • kde-4.14
  • 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 <KLocalizedString>
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  //If change shortcut changes it in mainwidget
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::slotFocusQuickSearch()
68 {
69  mEdit->setFocus();
70 }
71 
72 void QuickSearchWidget::resetTimer()
73 {
74  mTimer->stop();
75  mTimer->start( 500 );
76 }
77 
78 void QuickSearchWidget::delayedTextChanged()
79 {
80  mTimer->stop();
81  emit filterStringChanged( mEdit->text() );
82 }
83 
84 void QuickSearchWidget::keyPressEvent( QKeyEvent *event )
85 {
86  if ( event->key() == Qt::Key_Down ) {
87  event->accept();
88  delayedTextChanged();
89  emit arrowDownKeyPressed();
90  return;
91  }
92 
93  QWidget::keyPressEvent( event );
94 }
95 
96 void QuickSearchWidget::updateQuickSearchText( const QString &text )
97 {
98  mEdit->setClickMessage( text );
99 }
QWidget::layout
QLayout * layout() const
QWidget
QuickSearchWidget::slotFocusQuickSearch
void slotFocusQuickSearch()
Definition: quicksearchwidget.cpp:67
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
QWidget::size
QSize size() const
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
QTimer
QVBoxLayout
QString
QLayout::setMargin
void setMargin(int margin)
QuickSearchWidget::arrowDownKeyPressed
void arrowDownKeyPressed()
This signal is emitted whenever the user pressed the arrow down key.
QKeyEvent::key
int key() const
QSize
QTimer::stop
void stop()
quicksearchwidget.h
QKeyEvent
QSize::height
int height() const
QWidget::keyPressEvent
virtual void keyPressEvent(QKeyEvent *event)
QuickSearchWidget::updateQuickSearchText
void updateQuickSearchText(const QString &text)
Definition: quicksearchwidget.cpp:96
QTimer::start
void start(int msec)
QuickSearchWidget::QuickSearchWidget
QuickSearchWidget(QWidget *parent=0)
Creates the quick search widget.
Definition: quicksearchwidget.cpp:31
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QuickSearchWidget::keyPressEvent
void keyPressEvent(QKeyEvent *)
Definition: quicksearchwidget.cpp:84
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:32:34 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
  • pimprint

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