]> cloud.milkyroute.net Git - dolphin.git/blob - src/filterbar.cpp
Use a KIO Job for applying the view properties recursively to sub directories.
[dolphin.git] / src / filterbar.cpp
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 <QBoxLayout>
23 #include <QKeyEvent>
24 #include <QLabel>
25 #include <QToolButton>
26
27 #include <kdialog.h>
28 #include <klocale.h>
29 #include <klineedit.h>
30 #include <kiconloader.h>
31
32 #include "dolphinmainwindow.h"
33
34 FilterBar::FilterBar(DolphinMainWindow* mainWindow, QWidget *parent, const char *name) :
35 QWidget(parent, name),
36 m_mainWindow(mainWindow)
37 {
38 const int gap = 3;
39
40 QVBoxLayout* foo = new QVBoxLayout(this);
41 foo->setMargin(0);
42 foo->addSpacing(gap);
43
44 QHBoxLayout* layout = new QHBoxLayout(foo);
45 layout->setMargin(0);
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 m_filter->setBuddy(m_filterInput);
54 layout->addWidget(m_filterInput);
55
56 m_close = new QToolButton(this);
57 m_close->setAutoRaise(true);
58 m_close->setIcon(QIcon(SmallIcon("fileclose")));
59 layout->addWidget(m_close);
60 layout->addSpacing(gap);
61
62 connect(m_filterInput, SIGNAL(textChanged(const QString&)),
63 this, SIGNAL(signalFilterChanged(const QString&)));
64 connect(m_close, SIGNAL(clicked()), this, SLOT(hide()));
65 connect(m_close, SIGNAL(clicked()),
66 mainWindow, SLOT(slotShowFilterBarChanged()));
67 }
68
69 FilterBar::~FilterBar()
70 {
71 }
72
73 void FilterBar::hideEvent(QHideEvent* event)
74 {
75 if (!event->spontaneous()) {
76 m_filterInput->clear();
77 m_filterInput->clearFocus();
78 }
79 }
80
81 void FilterBar::showEvent(QShowEvent* event)
82 {
83 if (!event->spontaneous()) {
84 m_filterInput->setFocus();
85 }
86 }
87
88 void FilterBar::keyReleaseEvent(QKeyEvent* event)
89 {
90 QWidget::keyReleaseEvent(event);
91 if ((event->key() == Qt::Key_Escape)) {
92 hide();
93 m_mainWindow->slotShowFilterBarChanged();
94 }
95 }
96
97 #include "filterbar.moc"