mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-22 01:40:02 +00:00
Revert "Use the Baloo Query Builder widget to add syntax-highlighting in Dolphin search"
The natural query parser is too unstable for the release atm, we'll readd the
query parser when the code is mature enough.
This reverts commit e3578ee3b7
.
This commit is contained in:
parent
2b895e7e2b
commit
6787467a7b
|
@ -141,7 +141,6 @@ if(HAVE_BALOO)
|
||||||
dolphinprivate PUBLIC
|
dolphinprivate PUBLIC
|
||||||
KF5::FileMetaData
|
KF5::FileMetaData
|
||||||
KF5::Baloo
|
KF5::Baloo
|
||||||
KF5::BalooNaturalQueryParser
|
|
||||||
KF5::BalooWidgets
|
KF5::BalooWidgets
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -38,9 +38,8 @@
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
#include <config-baloo.h>
|
||||||
#ifdef HAVE_BALOO
|
#ifdef HAVE_BALOO
|
||||||
#include <Baloo/NaturalFileQueryParser>
|
|
||||||
#include <Baloo/QueryBuilder>
|
|
||||||
#include <Baloo/Query>
|
#include <Baloo/Query>
|
||||||
#include <Baloo/Term>
|
#include <Baloo/Term>
|
||||||
#include <Baloo/IndexerConfig>
|
#include <Baloo/IndexerConfig>
|
||||||
|
@ -251,9 +250,8 @@ void DolphinSearchBox::slotConfigurationChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinSearchBox::slotSearchTextChanged()
|
void DolphinSearchBox::slotSearchTextChanged(const QString& text)
|
||||||
{
|
{
|
||||||
const QString text = m_searchInput->text();
|
|
||||||
|
|
||||||
if (text.isEmpty()) {
|
if (text.isEmpty()) {
|
||||||
m_startSearchTimer->stop();
|
m_startSearchTimer->stop();
|
||||||
|
@ -266,14 +264,7 @@ void DolphinSearchBox::slotSearchTextChanged()
|
||||||
void DolphinSearchBox::slotReturnPressed()
|
void DolphinSearchBox::slotReturnPressed()
|
||||||
{
|
{
|
||||||
emitSearchRequest();
|
emitSearchRequest();
|
||||||
emit returnPressed(m_searchInput->text());
|
emit returnPressed();
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinSearchBox::updateSearchInputParsing()
|
|
||||||
{
|
|
||||||
#ifdef HAVE_BALOO
|
|
||||||
m_searchInput->setParsingEnabled(m_contentButton->isChecked());
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinSearchBox::slotFacetsButtonToggled()
|
void DolphinSearchBox::slotFacetsButtonToggled()
|
||||||
|
@ -314,7 +305,6 @@ void DolphinSearchBox::loadSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
m_facetsWidget->setVisible(SearchSettings::showFacetsWidget());
|
m_facetsWidget->setVisible(SearchSettings::showFacetsWidget());
|
||||||
updateSearchInputParsing();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinSearchBox::saveSettings()
|
void DolphinSearchBox::saveSettings()
|
||||||
|
@ -338,14 +328,6 @@ void DolphinSearchBox::init()
|
||||||
m_searchLabel = new QLabel(this);
|
m_searchLabel = new QLabel(this);
|
||||||
|
|
||||||
// Create search box
|
// Create search box
|
||||||
#ifdef HAVE_BALOO
|
|
||||||
m_queryParser.reset(new Baloo::NaturalFileQueryParser);
|
|
||||||
m_searchInput = new Baloo::QueryBuilder(m_queryParser.data(), this);
|
|
||||||
connect(m_searchInput, &Baloo::QueryBuilder::editingFinished,
|
|
||||||
this, &DolphinSearchBox::slotReturnPressed);
|
|
||||||
connect(m_searchInput, &Baloo::QueryBuilder::textChanged,
|
|
||||||
this, &DolphinSearchBox::slotSearchTextChanged);
|
|
||||||
#else
|
|
||||||
m_searchInput = new QLineEdit(this);
|
m_searchInput = new QLineEdit(this);
|
||||||
m_searchInput->installEventFilter(this);
|
m_searchInput->installEventFilter(this);
|
||||||
m_searchInput->setClearButtonEnabled(true);
|
m_searchInput->setClearButtonEnabled(true);
|
||||||
|
@ -354,7 +336,6 @@ void DolphinSearchBox::init()
|
||||||
this, &DolphinSearchBox::slotReturnPressed);
|
this, &DolphinSearchBox::slotReturnPressed);
|
||||||
connect(m_searchInput, &QLineEdit::textChanged,
|
connect(m_searchInput, &QLineEdit::textChanged,
|
||||||
this, &DolphinSearchBox::slotSearchTextChanged);
|
this, &DolphinSearchBox::slotSearchTextChanged);
|
||||||
#endif
|
|
||||||
setFocusProxy(m_searchInput);
|
setFocusProxy(m_searchInput);
|
||||||
|
|
||||||
// Apply layout for the search input
|
// Apply layout for the search input
|
||||||
|
@ -376,8 +357,6 @@ void DolphinSearchBox::init()
|
||||||
QButtonGroup* searchWhatGroup = new QButtonGroup(this);
|
QButtonGroup* searchWhatGroup = new QButtonGroup(this);
|
||||||
searchWhatGroup->addButton(m_fileNameButton);
|
searchWhatGroup->addButton(m_fileNameButton);
|
||||||
searchWhatGroup->addButton(m_contentButton);
|
searchWhatGroup->addButton(m_contentButton);
|
||||||
connect(searchWhatGroup, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked),
|
|
||||||
this, &DolphinSearchBox::updateSearchInputParsing);
|
|
||||||
|
|
||||||
m_separator = new KSeparator(Qt::Vertical, this);
|
m_separator = new KSeparator(Qt::Vertical, this);
|
||||||
|
|
||||||
|
@ -454,31 +433,28 @@ QUrl DolphinSearchBox::balooUrlForSearching() const
|
||||||
const QString text = m_searchInput->text();
|
const QString text = m_searchInput->text();
|
||||||
|
|
||||||
Baloo::Query query;
|
Baloo::Query query;
|
||||||
|
|
||||||
if (m_contentButton->isChecked()) {
|
|
||||||
query = m_queryParser->parse(text, Baloo::NaturalQueryParser::DetectFilenamePattern);
|
|
||||||
} else {
|
|
||||||
query.setTerm(Baloo::Term(QLatin1String("filename"), text));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure the query so that it returns files and takes the rating into account
|
|
||||||
query.addType("File");
|
query.addType("File");
|
||||||
query.addType(m_facetsWidget->facetType());
|
query.addType(m_facetsWidget->facetType());
|
||||||
|
|
||||||
Baloo::Term term(Baloo::Term::And);
|
Baloo::Term term(Baloo::Term::And);
|
||||||
|
|
||||||
Baloo::Term ratingTerm = m_facetsWidget->ratingTerm();
|
Baloo::Term ratingTerm = m_facetsWidget->ratingTerm();
|
||||||
|
|
||||||
if (ratingTerm.isValid()) {
|
if (ratingTerm.isValid()) {
|
||||||
term.addSubTerm(query.term());
|
|
||||||
term.addSubTerm(ratingTerm);
|
term.addSubTerm(ratingTerm);
|
||||||
|
}
|
||||||
|
|
||||||
query.setTerm(term);
|
if (m_contentButton->isChecked()) {
|
||||||
|
query.setSearchString(text);
|
||||||
|
} else if (!text.isEmpty()) {
|
||||||
|
term.addSubTerm(Baloo::Term(QLatin1String("filename"), text));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_fromHereButton->isChecked()) {
|
if (m_fromHereButton->isChecked()) {
|
||||||
query.setIncludeFolder(m_searchPath.toLocalFile());
|
query.setIncludeFolder(m_searchPath.toLocalFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
query.setTerm(term);
|
||||||
|
|
||||||
return query.toSearchUrl(i18nc("@title UDS_DISPLAY_NAME for a KIO directory listing. %1 is the query the user entered.",
|
return query.toSearchUrl(i18nc("@title UDS_DISPLAY_NAME for a KIO directory listing. %1 is the query the user entered.",
|
||||||
"Query Results from '%1'", text));
|
"Query Results from '%1'", text));
|
||||||
#else
|
#else
|
||||||
|
@ -503,9 +479,7 @@ void DolphinSearchBox::fromBalooSearchUrl(const QUrl& url)
|
||||||
setSearchPath(QDir::homePath());
|
setSearchPath(QDir::homePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!query.searchString().isEmpty()) {
|
|
||||||
setText(query.searchString());
|
setText(query.searchString());
|
||||||
}
|
|
||||||
|
|
||||||
QStringList types = query.types();
|
QStringList types = query.types();
|
||||||
types.removeOne("File"); // We are only interested in facet widget types
|
types.removeOne("File"); // We are only interested in facet widget types
|
||||||
|
@ -525,6 +499,8 @@ void DolphinSearchBox::fromBalooSearchUrl(const QUrl& url)
|
||||||
|
|
||||||
m_startSearchTimer->stop();
|
m_startSearchTimer->stop();
|
||||||
blockSignals(false);
|
blockSignals(false);
|
||||||
|
#else
|
||||||
|
Q_UNUSED(url);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,6 @@
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include <config-baloo.h>
|
|
||||||
|
|
||||||
class DolphinFacetsWidget;
|
class DolphinFacetsWidget;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class KSeparator;
|
class KSeparator;
|
||||||
|
@ -33,11 +31,6 @@ class QScrollArea;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QVBoxLayout;
|
class QVBoxLayout;
|
||||||
|
|
||||||
namespace Baloo {
|
|
||||||
class QueryBuilder;
|
|
||||||
class NaturalQueryParser;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Input box for searching files with or without Baloo.
|
* @brief Input box for searching files with or without Baloo.
|
||||||
*
|
*
|
||||||
|
@ -122,7 +115,7 @@ signals:
|
||||||
*/
|
*/
|
||||||
void searchTextChanged(const QString& text);
|
void searchTextChanged(const QString& text);
|
||||||
|
|
||||||
void returnPressed(const QString& text);
|
void returnPressed();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emitted as soon as the search box should get closed.
|
* Emitted as soon as the search box should get closed.
|
||||||
|
@ -140,11 +133,10 @@ private slots:
|
||||||
void emitSearchRequest();
|
void emitSearchRequest();
|
||||||
void emitCloseRequest();
|
void emitCloseRequest();
|
||||||
void slotConfigurationChanged();
|
void slotConfigurationChanged();
|
||||||
void slotSearchTextChanged();
|
void slotSearchTextChanged(const QString& text);
|
||||||
void slotReturnPressed();
|
void slotReturnPressed();
|
||||||
void slotFacetsButtonToggled();
|
void slotFacetsButtonToggled();
|
||||||
void slotFacetChanged();
|
void slotFacetChanged();
|
||||||
void updateSearchInputParsing();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initButton(QToolButton* button);
|
void initButton(QToolButton* button);
|
||||||
|
@ -164,6 +156,7 @@ private:
|
||||||
void fromBalooSearchUrl(const QUrl& url);
|
void fromBalooSearchUrl(const QUrl& url);
|
||||||
|
|
||||||
void updateFacetsToggleButton();
|
void updateFacetsToggleButton();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_startedSearching;
|
bool m_startedSearching;
|
||||||
bool m_active;
|
bool m_active;
|
||||||
|
@ -171,12 +164,7 @@ private:
|
||||||
QVBoxLayout* m_topLayout;
|
QVBoxLayout* m_topLayout;
|
||||||
|
|
||||||
QLabel* m_searchLabel;
|
QLabel* m_searchLabel;
|
||||||
#ifdef HAVE_BALOO
|
|
||||||
Baloo::QueryBuilder* m_searchInput;
|
|
||||||
QScopedPointer<Baloo::NaturalQueryParser> m_queryParser;
|
|
||||||
#else
|
|
||||||
QLineEdit* m_searchInput;
|
QLineEdit* m_searchInput;
|
||||||
#endif
|
|
||||||
QScrollArea* m_optionsScrollArea;
|
QScrollArea* m_optionsScrollArea;
|
||||||
QToolButton* m_fileNameButton;
|
QToolButton* m_fileNameButton;
|
||||||
QToolButton* m_contentButton;
|
QToolButton* m_contentButton;
|
||||||
|
|
Loading…
Reference in a new issue