~ubuntu-branches/ubuntu/dapper/ksystemlog/dapper

« back to all changes in this revision

Viewing changes to ksystemlog/src/logLineFilter.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-07-07 16:00:00 UTC
  • Revision ID: james.westby@ubuntu.com-20050707160000-a104d769ph3yfkg4
Tags: upstream-0.3.2
ImportĀ upstreamĀ versionĀ 0.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2005 by Nicolas Ternisien                               *
 
3
 *   nicolas.ternisien@gmail.com                                           *
 
4
 *                                                                         *
 
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.                                   *
 
9
 *                                                                         *
 
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.                          *
 
14
 *                                                                         *
 
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
 ***************************************************************************/
 
20
 
 
21
//For compatibility with old versions of KDE
 
22
#include <kdeversion.h>
 
23
 
 
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)
 
26
 
 
27
#include <qpainter.h>
 
28
 
 
29
#include <klocale.h>
 
30
 
 
31
#include "logLineFilter.h"
 
32
 
 
33
LogLineFilter::LogLineFilter(QWidget* parent, KListView* listView, const char* name) :
 
34
        KListViewSearchLine(parent, listView, name) {
 
35
 
 
36
        drawFilterMessage = true;
 
37
        
 
38
        repaint();
 
39
}
 
40
 
 
41
 
 
42
void LogLineFilter::drawContents(QPainter *p) {
 
43
    KListViewSearchLine::drawContents( p );
 
44
 
 
45
    if ( drawFilterMessage == true && !hasFocus() ) {
 
46
        QPen tmp = p->pen();
 
47
        p->setPen( palette().color( QPalette::Disabled, QColorGroup::Text ) );
 
48
        QRect cr = contentsRect();
 
49
 
 
50
        //p->drawPixmap( 3, 3, SmallIcon("filter") );
 
51
 
 
52
        // Add two pixel margin on the left side
 
53
        cr.rLeft() += 3;
 
54
        p->drawText( cr, AlignAuto | AlignVCenter, i18n("Filter here...") );
 
55
        p->setPen( tmp );
 
56
    }
 
57
}
 
58
 
 
59
 
 
60
void LogLineFilter::focusInEvent( QFocusEvent *ev )
 
61
{
 
62
    if ( drawFilterMessage == true ) {
 
63
        drawFilterMessage = false;
 
64
        repaint();
 
65
    }
 
66
    KListViewSearchLine::focusInEvent( ev );
 
67
}
 
68
 
 
69
 
 
70
void LogLineFilter::focusOutEvent( QFocusEvent *ev )
 
71
{
 
72
    if ( text().isEmpty() ) {
 
73
        drawFilterMessage = true;
 
74
        repaint();
 
75
    }
 
76
    KListViewSearchLine::focusOutEvent( ev );
 
77
}
 
78
 
 
79
 
 
80
#endif