Commit fc6fecd6 authored by Carl Schwan's avatar Carl Schwan 🚴 Committed by Michael Pyne
Browse files

Refactor: Use Qt class for the SearchWidget

We don't use KCompletion features, so

* Use QLineEdit instead of KLineEdit
* Use QComboBox instead of QComboBox

Follow KDE HIG, prefer Search... as placeholderText instead of a Search
label.
parent 22054157
......@@ -21,18 +21,17 @@
#include "searchadaptor.h"
#include "juk_debug.h"
#include <klineedit.h>
#include <kiconloader.h>
#include <kcombobox.h>
#include <KLocalizedString>
#include <QAction>
#include <QLabel>
#include <QCheckBox>
#include <QComboBox>
#include <QHBoxLayout>
#include <QKeyEvent>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QToolButton>
#include <QKeyEvent>
#include <QHBoxLayout>
using namespace ActionCollection;
......@@ -41,7 +40,7 @@ using namespace ActionCollection;
////////////////////////////////////////////////////////////////////////////////
SearchLine::SearchLine(QWidget *parent, bool simple)
: QFrame(parent),
: QWidget(parent),
m_simple(simple),
m_searchFieldsBox(0)
{
......@@ -50,14 +49,14 @@ SearchLine::SearchLine(QWidget *parent, bool simple)
layout->setSpacing(5);
if(!m_simple) {
m_searchFieldsBox = new KComboBox(this);
m_searchFieldsBox = new QComboBox(this);
layout->addWidget(m_searchFieldsBox);
m_searchFieldsBox->setObjectName( QLatin1String( "searchFields" ) );
connect(m_searchFieldsBox, SIGNAL(activated(int)),
this, SIGNAL(signalQueryChanged()));
}
m_lineEdit = new KLineEdit(this);
m_lineEdit = new QLineEdit(this);
layout->addWidget(m_lineEdit);
m_lineEdit->setClearButtonEnabled(true);
m_lineEdit->installEventFilter(this);
......@@ -67,7 +66,7 @@ SearchLine::SearchLine(QWidget *parent, bool simple)
this, SLOT(slotActivate()));
if(!m_simple) {
m_caseSensitive = new KComboBox(this);
m_caseSensitive = new QComboBox(this);
layout->addWidget(m_caseSensitive);
m_caseSensitive->addItem(i18n("Normal Matching"));
m_caseSensitive->addItem(i18n("Case Sensitive"));
......@@ -144,13 +143,13 @@ void SearchLine::setFocus()
bool SearchLine::eventFilter(QObject *watched, QEvent *e)
{
if(watched != m_lineEdit || e->type() != QEvent::KeyPress)
return QFrame::eventFilter(watched, e);
return QWidget::eventFilter(watched, e);
QKeyEvent *key = static_cast<QKeyEvent *>(e);
if(key->key() == Qt::Key_Down)
emit signalDownPressed();
return QFrame::eventFilter(watched, e);
return QWidget::eventFilter(watched, e);
}
void SearchLine::slotActivate()
......@@ -202,9 +201,7 @@ SearchWidget::SearchWidget(QWidget *parent)
new SearchAdaptor(this);
QDBusConnection::sessionBus().registerObject("/Search", this);
QLabel *label = new QLabel(i18n("Search:"), this );
label->setBuddy(&m_searchLine);
addWidget(label);
m_searchLine.m_lineEdit->setPlaceholderText(i18n("Search..."));
addWidget(&m_searchLine);
connect(&m_searchLine, SIGNAL(signalQueryChanged()), this, SIGNAL(signalQueryChanged()));
......
......@@ -18,20 +18,19 @@
#ifndef SEARCHWIDGET_H
#define SEARCHWIDGET_H
#include <ktoolbar.h>
#include <KToolBar>
#include <QFrame>
#include <QList>
#include <QLineEdit>
#include "playlistsearch.h"
class QEvent;
class QComboBox;
class KComboBox;
class KLineEdit;
class SearchWidget;
class SearchLine : public QFrame
class SearchLine : public QWidget
{
Q_OBJECT
......@@ -63,9 +62,9 @@ private slots:
private:
bool m_simple;
KLineEdit *m_lineEdit;
KComboBox *m_searchFieldsBox;
KComboBox *m_caseSensitive;
QLineEdit *m_lineEdit;
QComboBox *m_searchFieldsBox;
QComboBox *m_caseSensitive;
QList<int> m_columnList;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment