~ubuntu-branches/ubuntu/karmic/kdepim/karmic-backports

« back to all changes in this revision

Viewing changes to kcontactmanager/quicksearchwidget.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi, Alessandro Ghersi, Harald Sitter
  • Date: 2009-06-27 04:40:05 UTC
  • mfrom: (1.1.39 upstream)
  • Revision ID: james.westby@ubuntu.com-20090627044005-4y2vm9xz7rvmzi4p
Tags: 4:4.2.95svn20090701-0ubuntu1
[ Alessandro Ghersi ]
* New upstream release
  - Bump build-deps
* Remove akonadi-kde and libmaildir4 packages
  - remove akonadi-kde.install and libmaildir4.install
  - remove libmaildir4 from debian/rules
  - remove akonadi-kde and libmaildir4 from depends
  - remove akonadi-kde and libmaildir4 from installgen
* Update kdepim-dev.install
* Update kpilot.install
* Add akonadi-kde and libmaildir4 transitional packages

[ Harald Sitter ]
* KAddressbook replaces Kontact << 4.2.85 (LP: #378373)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
    This file is part of KContactManager.
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 <QtCore/QTimer>
25
 
#include <QtGui/QKeyEvent>
26
 
#include <QtGui/QVBoxLayout>
27
 
 
28
 
#include <klineedit.h>
29
 
#include <klocale.h>
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( i18n( "Search" ) );
39
 
  mEdit->setClearButtonShown( true );
40
 
 
41
 
  mEdit->installEventFilter( this );
42
 
 
43
 
  layout->addWidget( mEdit );
44
 
 
45
 
  mTimer = new QTimer( this );
46
 
 
47
 
  connect( mEdit, SIGNAL( textChanged( const QString& ) ), SLOT( resetTimer() ) );
48
 
  connect( mTimer, SIGNAL( timeout() ), SLOT( delayedTextChanged() ) );
49
 
}
50
 
 
51
 
 
52
 
QuickSearchWidget::~QuickSearchWidget()
53
 
{
54
 
}
55
 
 
56
 
QSize QuickSearchWidget::sizeHint() const
57
 
{
58
 
  const QSize size = mEdit->sizeHint();
59
 
  return QSize( 200, size.height() );
60
 
}
61
 
 
62
 
void QuickSearchWidget::resetTimer()
63
 
{
64
 
  mTimer->stop();
65
 
  mTimer->start( 500 );
66
 
}
67
 
 
68
 
void QuickSearchWidget::delayedTextChanged()
69
 
{
70
 
  mTimer->stop();
71
 
  emit filterStringChanged( mEdit->text() );
72
 
}
73
 
 
74
 
void QuickSearchWidget::keyPressEvent( QKeyEvent *event )
75
 
{
76
 
  if ( event->key() == Qt::Key_Down ) {
77
 
    event->accept();
78
 
    delayedTextChanged();
79
 
    emit arrowDownKeyPressed();
80
 
    return;
81
 
  }
82
 
 
83
 
  QWidget::keyPressEvent( event );
84
 
}
85
 
 
86
 
#include "quicksearchwidget.moc"