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

KDEUI

kfilterproxysearchline.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2007-2008 Omat Holding B.V. <info@omat.nl>
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public License
00015  * along with this library; see the file COPYING.LIB.  If not, write to
00016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018  */
00019 
00020 #include "kfilterproxysearchline.h"
00021 
00022 #include <QHBoxLayout>
00023 #include <QTimer>
00024 #include <QSortFilterProxyModel>
00025 
00026 #include <klineedit.h>
00027 #include <klocale.h>
00028 
00033 //@cond PRIVATE
00034 class KFilterProxySearchLine::Private {
00035 public:
00036     Private( KFilterProxySearchLine* parent) :
00037                                 q(parent), proxy(0), searchLine(0)
00038     {
00039     timer = new QTimer( q );
00040     timer->setSingleShot( true );
00041     connect( timer, SIGNAL( timeout() ), q, SLOT( slotSearchLineActivate() ) );
00042     }
00043     QTimer* timer;
00044     KFilterProxySearchLine* q;
00045     QSortFilterProxyModel* proxy;
00046     KLineEdit* searchLine;
00047 
00048     void slotSearchLineChange( const QString& newText );
00049     void slotSearchLineActivate();
00050 };
00051 
00052 void KFilterProxySearchLine::Private::slotSearchLineChange( const QString& )
00053 {
00054     timer->start( 300 );
00055 }
00056 
00057 void KFilterProxySearchLine::Private::slotSearchLineActivate()
00058 {
00059     if ( !proxy )
00060         return;
00061 
00062     proxy->setFilterKeyColumn( -1 );
00063     proxy->setFilterCaseSensitivity( Qt::CaseInsensitive );
00064     proxy->setFilterFixedString( searchLine->text() );
00065 }
00066 //@endcond
00067 
00068 KFilterProxySearchLine::KFilterProxySearchLine( QWidget* parent )
00069         : QWidget( parent ), d( new Private( this ) )
00070 {
00071     d->searchLine = new KLineEdit( this );
00072     d->searchLine->setClearButtonShown( true );
00073     d->searchLine->setClickMessage(i18n("Search"));
00074 
00075     QHBoxLayout* layout = new QHBoxLayout( this );
00076     layout->setMargin( 0 );
00077     layout->addWidget( d->searchLine );
00078 
00079     connect( d->searchLine, SIGNAL( textChanged( const QString& ) ),
00080              SLOT( slotSearchLineChange( const QString& ) ) );
00081 }
00082 
00083 KFilterProxySearchLine::~KFilterProxySearchLine()
00084 {
00085     delete d;
00086 }
00087 
00088 void KFilterProxySearchLine::setText( const QString& text )
00089 {
00090     d->searchLine->setText( text );
00091 }
00092 
00093 void KFilterProxySearchLine::setProxy( QSortFilterProxyModel* proxy ) 
00094 {
00095     d->proxy = proxy;
00096 }
00097 
00098 KLineEdit* KFilterProxySearchLine::lineEdit() const
00099 {
00100     return d->searchLine;
00101 }
00102 
00103 #include "kfilterproxysearchline.moc"

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal