• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • 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 <QLabel>
00024 #include <QTimer>
00025 #include <QSortFilterProxyModel>
00026 
00027 #include <klineedit.h>
00028 #include <klocale.h>
00029 
00034 //@cond PRIVATE
00035 class KFilterProxySearchLine::Private {
00036 public:
00037     Private( KFilterProxySearchLine* parent) :
00038                                 q(parent), proxy(0), searchLine(0)
00039     {
00040     timer = new QTimer( q );
00041     timer->setSingleShot( true );
00042     connect( timer, SIGNAL( timeout() ), q, SLOT( slotSearchLineActivate() ) );
00043     }
00044     QTimer* timer;
00045     KFilterProxySearchLine* q;
00046     QSortFilterProxyModel* proxy;
00047     KLineEdit* searchLine;
00048 
00049     void slotSearchLineChange( const QString& newText );
00050     void slotSearchLineActivate();
00051 };
00052 
00053 void KFilterProxySearchLine::Private::slotSearchLineChange( const QString& )
00054 {
00055     timer->start( 300 );
00056 }
00057 
00058 void KFilterProxySearchLine::Private::slotSearchLineActivate()
00059 {
00060     if ( !proxy )
00061         return;
00062 
00063     proxy->setFilterKeyColumn( -1 );
00064     proxy->setFilterCaseSensitivity( Qt::CaseInsensitive );
00065     proxy->setFilterFixedString( searchLine->text() );
00066 }
00067 //@endcond
00068 
00069 KFilterProxySearchLine::KFilterProxySearchLine( QWidget* parent )
00070         : QWidget( parent ), d( new Private( this ) )
00071 {
00072     QLabel *label = new QLabel( i18n( "S&earch:" ), this );
00073     label->setObjectName( QLatin1String( "kde toolbar widget" ) );
00074 
00075     d->searchLine = new KLineEdit( this );
00076     d->searchLine->setClearButtonShown( true );
00077 
00078     label->setBuddy( d->searchLine );
00079     label->show();
00080 
00081     QHBoxLayout* layout = new QHBoxLayout( this );
00082     layout->setMargin( 0 );
00083     layout->addWidget( label );
00084     layout->addWidget( d->searchLine );
00085 
00086     connect( d->searchLine, SIGNAL( textChanged( const QString& ) ),
00087              SLOT( slotSearchLineChange( const QString& ) ) );
00088 }
00089 
00090 KFilterProxySearchLine::~KFilterProxySearchLine()
00091 {
00092     delete d;
00093 }
00094 
00095 void KFilterProxySearchLine::setText( const QString& text )
00096 {
00097     d->searchLine->setText( text );
00098 }
00099 
00100 void KFilterProxySearchLine::setProxy( QSortFilterProxyModel* proxy ) 
00101 {
00102     d->proxy = proxy;
00103 }
00104 
00105 KLineEdit* KFilterProxySearchLine::lineEdit() const
00106 {
00107     return d->searchLine;
00108 }
00109 
00110 #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
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
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