mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
Fix some search issues
- Always merge the query from the "Find:"-field with the current facet-query. This assures that the facet-query never gets overwritten if the user changes the "Find:"-field. - Always trigger a searching if the text of the "Find:"-field has been cleared. Still a lot of usability issues are left, but this is at least a first step...
This commit is contained in:
parent
1aa14306fc
commit
6e0583f988
2 changed files with 33 additions and 23 deletions
|
@ -72,8 +72,16 @@ bool SearchPanel::urlChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isVisible() && DolphinSearchInformation::instance().isIndexingEnabled()) {
|
if (isVisible() && DolphinSearchInformation::instance().isIndexingEnabled()) {
|
||||||
setQuery(Nepomuk::Query::Query());
|
const Nepomuk::Query::FileQuery query(m_unfacetedRestQuery && m_facetWidget->queryTerm());
|
||||||
|
if (query.toSearchUrl() == url()) {
|
||||||
|
// The new URL has been triggered by the SearchPanel itself in
|
||||||
|
// slotQueryTermChanged() and no further handling is required.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset the current query and disable the facet-widget until
|
||||||
|
// the new query has been determined by KIO::stat():
|
||||||
|
setQuery(Nepomuk::Query::Query());
|
||||||
delete m_lastSetUrlStatJob;
|
delete m_lastSetUrlStatJob;
|
||||||
|
|
||||||
m_lastSetUrlStatJob = KIO::stat(url(), KIO::HideProgressInfo);
|
m_lastSetUrlStatJob = KIO::stat(url(), KIO::HideProgressInfo);
|
||||||
|
@ -178,9 +186,12 @@ void SearchPanel::slotSetUrlStatFinished(KJob* job)
|
||||||
|
|
||||||
const KIO::UDSEntry uds = static_cast<KIO::StatJob*>(job)->statResult();
|
const KIO::UDSEntry uds = static_cast<KIO::StatJob*>(job)->statResult();
|
||||||
const QString nepomukQueryStr = uds.stringValue(KIO::UDSEntry::UDS_NEPOMUK_QUERY);
|
const QString nepomukQueryStr = uds.stringValue(KIO::UDSEntry::UDS_NEPOMUK_QUERY);
|
||||||
|
const Nepomuk::Query::Term facetQueryTerm = m_facetWidget->queryTerm();
|
||||||
Nepomuk::Query::FileQuery nepomukQuery;
|
Nepomuk::Query::FileQuery nepomukQuery;
|
||||||
if (!nepomukQueryStr.isEmpty()) {
|
if (!nepomukQueryStr.isEmpty()) {
|
||||||
nepomukQuery = Nepomuk::Query::Query::fromString(nepomukQueryStr);
|
// Always merge the query that has been retrieved by SearchPanel::setUrl() with
|
||||||
|
// the current facet-query, so that the user settings don't get lost.
|
||||||
|
nepomukQuery = Nepomuk::Query::Query::fromString(nepomukQueryStr) && facetQueryTerm;
|
||||||
} else if (url().isLocalFile()) {
|
} else if (url().isLocalFile()) {
|
||||||
// Fallback query for local file URLs: List all files
|
// Fallback query for local file URLs: List all files
|
||||||
Nepomuk::Query::ComparisonTerm compTerm(
|
Nepomuk::Query::ComparisonTerm compTerm(
|
||||||
|
@ -192,7 +203,13 @@ void SearchPanel::slotSetUrlStatFinished(KJob* job)
|
||||||
}
|
}
|
||||||
nepomukQuery.setTerm(compTerm);
|
nepomukQuery.setTerm(compTerm);
|
||||||
}
|
}
|
||||||
|
|
||||||
setQuery(nepomukQuery);
|
setQuery(nepomukQuery);
|
||||||
|
|
||||||
|
if (facetQueryTerm.isValid()) {
|
||||||
|
Nepomuk::Query::FileQuery query(m_unfacetedRestQuery && facetQueryTerm);
|
||||||
|
emit urlActivated(query.toSearchUrl());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchPanel::slotQueryTermChanged(const Nepomuk::Query::Term& term)
|
void SearchPanel::slotQueryTermChanged(const Nepomuk::Query::Term& term)
|
||||||
|
|
|
@ -205,11 +205,7 @@ void DolphinSearchBox::slotConfigurationChanged()
|
||||||
|
|
||||||
void DolphinSearchBox::slotSearchTextChanged(const QString& text)
|
void DolphinSearchBox::slotSearchTextChanged(const QString& text)
|
||||||
{
|
{
|
||||||
if (text.isEmpty()) {
|
m_startSearchTimer->start();
|
||||||
m_startSearchTimer->stop();
|
|
||||||
} else {
|
|
||||||
m_startSearchTimer->start();
|
|
||||||
}
|
|
||||||
emit searchTextChanged(text);
|
emit searchTextChanged(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,23 +351,20 @@ KUrl DolphinSearchBox::nepomukUrlForSearching() const
|
||||||
#ifdef HAVE_NEPOMUK
|
#ifdef HAVE_NEPOMUK
|
||||||
Nepomuk::Query::AndTerm andTerm;
|
Nepomuk::Query::AndTerm andTerm;
|
||||||
|
|
||||||
// Add input from search filter
|
|
||||||
const QString text = m_searchInput->text();
|
const QString text = m_searchInput->text();
|
||||||
if (!text.isEmpty()) {
|
if (m_fileNameButton->isChecked()) {
|
||||||
if (m_fileNameButton->isChecked()) {
|
QString regex = QRegExp::escape(text);
|
||||||
QString regex = QRegExp::escape(text);
|
regex.replace("\\*", QLatin1String(".*"));
|
||||||
regex.replace("\\*", QLatin1String(".*"));
|
regex.replace("\\?", QLatin1String("."));
|
||||||
regex.replace("\\?", QLatin1String("."));
|
regex.replace("\\", "\\\\");
|
||||||
regex.replace("\\", "\\\\");
|
andTerm.addSubTerm(Nepomuk::Query::ComparisonTerm(
|
||||||
andTerm.addSubTerm(Nepomuk::Query::ComparisonTerm(
|
Nepomuk::Vocabulary::NFO::fileName(),
|
||||||
Nepomuk::Vocabulary::NFO::fileName(),
|
Nepomuk::Query::LiteralTerm(regex),
|
||||||
Nepomuk::Query::LiteralTerm(regex),
|
Nepomuk::Query::ComparisonTerm::Regexp));
|
||||||
Nepomuk::Query::ComparisonTerm::Regexp));
|
} else {
|
||||||
} else {
|
const Nepomuk::Query::Query customQuery = Nepomuk::Query::QueryParser::parseQuery(text, Nepomuk::Query::QueryParser::DetectFilenamePattern);
|
||||||
const Nepomuk::Query::Query customQuery = Nepomuk::Query::QueryParser::parseQuery(text, Nepomuk::Query::QueryParser::DetectFilenamePattern);
|
if (customQuery.isValid()) {
|
||||||
if (customQuery.isValid()) {
|
andTerm.addSubTerm(customQuery.term());
|
||||||
andTerm.addSubTerm(customQuery.term());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue