1
/***************************************************************************
2
* Copyright (C) 2005 by Nicolas Ternisien *
3
* nicolas.ternisien@gmail.com *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19
***************************************************************************/
21
//For compatibility with old versions of KDE
22
#include <kdeversion.h>
24
//The filter is activated only if KDE version >= 3.3
25
#if defined(KDE_MAKE_VERSION) && KDE_VERSION >= KDE_MAKE_VERSION(3,3,0)
31
#include "logLineFilter.h"
33
LogLineFilter::LogLineFilter(QWidget* parent, KListView* listView, const char* name) :
34
KListViewSearchLine(parent, listView, name) {
36
drawFilterMessage = true;
42
void LogLineFilter::drawContents(QPainter *p) {
43
KListViewSearchLine::drawContents( p );
45
if ( drawFilterMessage == true && !hasFocus() ) {
47
p->setPen( palette().color( QPalette::Disabled, QColorGroup::Text ) );
48
QRect cr = contentsRect();
50
//p->drawPixmap( 3, 3, SmallIcon("filter") );
52
// Add two pixel margin on the left side
54
p->drawText( cr, AlignAuto | AlignVCenter, i18n("Filter here...") );
60
void LogLineFilter::focusInEvent( QFocusEvent *ev )
62
if ( drawFilterMessage == true ) {
63
drawFilterMessage = false;
66
KListViewSearchLine::focusInEvent( ev );
70
void LogLineFilter::focusOutEvent( QFocusEvent *ev )
72
if ( text().isEmpty() ) {
73
drawFilterMessage = true;
76
KListViewSearchLine::focusOutEvent( ev );