From: Dominik Haumann Date: Tue, 28 Nov 2006 17:22:02 +0000 (+0000) Subject: port to Qt4 X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/c86d00c8be2081b7815f641a0d29eb770c713018 port to Qt4 svn path=/trunk/playground/utils/dolphin/; revision=608854 --- diff --git a/src/filterbar.cpp b/src/filterbar.cpp index eb7be1b2d..0982a61c7 100644 --- a/src/filterbar.cpp +++ b/src/filterbar.cpp @@ -19,16 +19,13 @@ ***************************************************************************/ #include "filterbar.h" -#include -#include -//Added by qt3to4: -#include +#include #include -#include +#include +#include #include #include -#include #include #include @@ -39,10 +36,12 @@ FilterBar::FilterBar(QWidget *parent, const char *name) : { const int gap = 3; - Q3VBoxLayout* foo = new Q3VBoxLayout(this); + QVBoxLayout* foo = new QVBoxLayout(this); + foo->setMargin(0); foo->addSpacing(gap); - Q3HBoxLayout* layout = new Q3HBoxLayout(foo); + QHBoxLayout* layout = new QHBoxLayout(foo); + layout->setMargin(0); layout->addSpacing(gap); m_filter = new QLabel(i18n("Filter:"), this); @@ -50,11 +49,12 @@ FilterBar::FilterBar(QWidget *parent, const char *name) : layout->addSpacing(KDialog::spacingHint()); m_filterInput = new KLineEdit(this); + m_filter->setBuddy(m_filterInput); layout->addWidget(m_filterInput); - m_close = new KPushButton(this); - m_close->setIconSet(SmallIcon("fileclose")); - m_close->setFlat(true); + m_close = new QToolButton(this); + m_close->setAutoRaise(true); + m_close->setIcon(QIcon(SmallIcon("fileclose"))); layout->addWidget(m_close); layout->addSpacing(gap); @@ -69,17 +69,19 @@ FilterBar::~FilterBar() { } -void FilterBar::hide() +void FilterBar::hideEvent(QHideEvent* event) { - m_filterInput->clear(); - m_filterInput->clearFocus(); - QWidget::hide(); + if (!event->spontaneous()) { + m_filterInput->clear(); + m_filterInput->clearFocus(); + } } -void FilterBar::show() +void FilterBar::showEvent(QShowEvent* event) { - m_filterInput->setFocus(); - QWidget::show(); + if (!event->spontaneous()) { + m_filterInput->setFocus(); + } } void FilterBar::keyReleaseEvent(QKeyEvent* event) diff --git a/src/filterbar.h b/src/filterbar.h index 5f5ca9dc1..3f5c3cbfd 100644 --- a/src/filterbar.h +++ b/src/filterbar.h @@ -20,14 +20,11 @@ #ifndef FILTERBAR_H #define FILTERBAR_H -#include -//Added by qt3to4: -#include -#include +#include class QLabel; +class QToolButton; class KLineEdit; -class KPushButton; /** * @brief Provides an input field for filtering the currently shown items. @@ -44,25 +41,20 @@ public: signals: /** - * Signal that reports the name filter has been - * changed to \a nameFilter. - */ + * Signal that reports the name filter has been + * changed to \a nameFilter. + */ void signalFilterChanged(const QString& nameFilter); -public slots: - /** @see QWidget::hide() */ - virtual void hide(); - - /** @see QWidget::show() */ - virtual void show(); - protected: + virtual void hideEvent(QHideEvent* event); + virtual void showEvent(QShowEvent* event); virtual void keyReleaseEvent(QKeyEvent* event); private: QLabel* m_filter; KLineEdit* m_filterInput; - KPushButton* m_close; + QToolButton* m_close; }; #endif