mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-19 08:21:22 +00:00
If the searching has been triggered by clicking on a facet and the facet gets reset again, assure that not all indexed files are shown. Instead return to the previous state before the searching has been started.
svn path=/trunk/KDE/kdebase/apps/; revision=1214634
This commit is contained in:
parent
8ac62cc953
commit
1b30368506
|
@ -51,6 +51,7 @@ FilterPanel::FilterPanel(QWidget* parent) :
|
||||||
m_initialized(false),
|
m_initialized(false),
|
||||||
m_nepomukEnabled(false),
|
m_nepomukEnabled(false),
|
||||||
m_lastSetUrlStatJob(0),
|
m_lastSetUrlStatJob(0),
|
||||||
|
m_startedFromDir(),
|
||||||
m_facetWidget(0),
|
m_facetWidget(0),
|
||||||
m_unfacetedRestQuery()
|
m_unfacetedRestQuery()
|
||||||
{
|
{
|
||||||
|
@ -62,6 +63,13 @@ FilterPanel::~FilterPanel()
|
||||||
|
|
||||||
bool FilterPanel::urlChanged()
|
bool FilterPanel::urlChanged()
|
||||||
{
|
{
|
||||||
|
if (!url().protocol().startsWith("nepomuk")) {
|
||||||
|
// Remember the current directory before a searching is started.
|
||||||
|
// This is required to restore the directory in case that all facets
|
||||||
|
// have been reset by the user (see slotQueryTermChanged()).
|
||||||
|
m_startedFromDir = url();
|
||||||
|
}
|
||||||
|
|
||||||
if (isVisible() && m_nepomukEnabled) {
|
if (isVisible() && m_nepomukEnabled) {
|
||||||
setQuery(Nepomuk::Query::Query());
|
setQuery(Nepomuk::Query::Query());
|
||||||
|
|
||||||
|
@ -178,8 +186,29 @@ void FilterPanel::slotSetUrlStatFinished(KJob* job)
|
||||||
|
|
||||||
void FilterPanel::slotQueryTermChanged(const Nepomuk::Query::Term& term)
|
void FilterPanel::slotQueryTermChanged(const Nepomuk::Query::Term& term)
|
||||||
{
|
{
|
||||||
Nepomuk::Query::FileQuery query(m_unfacetedRestQuery && term);
|
if (term.isValid()) {
|
||||||
emit urlActivated(query.toSearchUrl());
|
// Default case: A facet has been changed by the user to restrict the query.
|
||||||
|
Nepomuk::Query::FileQuery query(m_unfacetedRestQuery && term);
|
||||||
|
emit urlActivated(query.toSearchUrl());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// All facets have been reset by the user to be unrestricted.
|
||||||
|
// Verify whether the unfaceted rest query contains any additional restriction
|
||||||
|
// (e.g. a filename in the search field). If no further restriction is given, exit
|
||||||
|
// the search mode by returning to the directory where the searching has been
|
||||||
|
// started from.
|
||||||
|
const Nepomuk::Query::Term rootTerm = m_unfacetedRestQuery.term();
|
||||||
|
if (rootTerm.type() == Nepomuk::Query::Term::Comparison) {
|
||||||
|
const Nepomuk::Query::ComparisonTerm& compTerm = static_cast<const Nepomuk::Query::ComparisonTerm&>(rootTerm);
|
||||||
|
if (compTerm.subTerm().isValid()) {
|
||||||
|
Nepomuk::Query::FileQuery query(m_unfacetedRestQuery);
|
||||||
|
emit urlActivated(query.toSearchUrl());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
emit urlActivated(m_startedFromDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilterPanel::setQuery(const Nepomuk::Query::Query& query)
|
void FilterPanel::setQuery(const Nepomuk::Query::Query& query)
|
||||||
|
|
|
@ -67,6 +67,7 @@ private:
|
||||||
bool m_nepomukEnabled;
|
bool m_nepomukEnabled;
|
||||||
KJob* m_lastSetUrlStatJob;
|
KJob* m_lastSetUrlStatJob;
|
||||||
|
|
||||||
|
KUrl m_startedFromDir;
|
||||||
Nepomuk::Utils::FacetWidget* m_facetWidget;
|
Nepomuk::Utils::FacetWidget* m_facetWidget;
|
||||||
Nepomuk::Query::Query m_unfacetedRestQuery;
|
Nepomuk::Query::Query m_unfacetedRestQuery;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue