~blue-shell/blue-shell/folderview-qml

« back to all changes in this revision

Viewing changes to dolphin/src/filterbar.cpp

  • Committer: Peter Penz
  • Date: 2006-11-21 06:02:05 UTC
  • Revision ID: git-v1:daace0e789c3ea5e8a89e514abb717c9c360fc7f
commited initial version of Dolphin

svn path=/trunk/playground/utils/dolphin/; revision=606622

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at>                  *
 
3
 *   Copyright (C) 2006 by Gregor Kališnik <gregor@podnapisi.net>          *
 
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
#include "filterbar.h"
 
21
 
 
22
#include <qlabel.h>
 
23
#include <qlayout.h>
 
24
//Added by qt3to4:
 
25
#include <Q3VBoxLayout>
 
26
#include <QKeyEvent>
 
27
#include <Q3HBoxLayout>
 
28
 
 
29
#include <kdialog.h>
 
30
#include <klocale.h>
 
31
#include <kpushbutton.h>
 
32
#include <klineedit.h>
 
33
#include <kiconloader.h>
 
34
 
 
35
#include "dolphin.h"
 
36
 
 
37
FilterBar::FilterBar(QWidget *parent, const char *name) :
 
38
    QWidget(parent, name)
 
39
{
 
40
    const int gap = 3;
 
41
 
 
42
    Q3VBoxLayout* foo = new Q3VBoxLayout(this);
 
43
    foo->addSpacing(gap);
 
44
 
 
45
    Q3HBoxLayout* layout = new Q3HBoxLayout(foo);
 
46
    layout->addSpacing(gap);
 
47
 
 
48
    m_filter = new QLabel(i18n("Filter:"), this);
 
49
    layout->addWidget(m_filter);
 
50
    layout->addSpacing(KDialog::spacingHint());
 
51
 
 
52
    m_filterInput = new KLineEdit(this);
 
53
    layout->addWidget(m_filterInput);
 
54
 
 
55
    m_close = new KPushButton(this);
 
56
    m_close->setIconSet(SmallIcon("fileclose"));
 
57
    m_close->setFlat(true);
 
58
    layout->addWidget(m_close);
 
59
    layout->addSpacing(gap);
 
60
 
 
61
    connect(m_filterInput, SIGNAL(textChanged(const QString&)),
 
62
            this, SIGNAL(signalFilterChanged(const QString&)));
 
63
    connect(m_close, SIGNAL(clicked()), this, SLOT(hide()));
 
64
    connect(m_close, SIGNAL(clicked()),
 
65
            &Dolphin::mainWin(), SLOT(slotShowFilterBarChanged()));
 
66
}
 
67
 
 
68
FilterBar::~FilterBar()
 
69
{
 
70
}
 
71
 
 
72
void FilterBar::hide()
 
73
{
 
74
    m_filterInput->clear();
 
75
    m_filterInput->clearFocus();
 
76
    QWidget::hide();
 
77
}
 
78
 
 
79
void FilterBar::show()
 
80
{
 
81
    m_filterInput->setFocus();
 
82
    QWidget::show();
 
83
}
 
84
 
 
85
void FilterBar::keyReleaseEvent(QKeyEvent* event)
 
86
{
 
87
    QWidget::keyReleaseEvent(event);
 
88
    if ((event->key() == Qt::Key_Escape)) {
 
89
        hide();
 
90
        Dolphin::mainWin().slotShowFilterBarChanged();
 
91
    }
 
92
}
 
93
 
 
94
#include "filterbar.moc"