mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
[dolphin/search] Reset search options when needed
Summary: Adds a method to reset the options in `facetsWidget` in two cases: when disabled and before parsing a new search URL. Otherwise, controls for a parameter (ex. `rating`) which are not found in the new URL would stay on the old positions, instead of the default "any". See D24422 Test Plan: Controls on `facetsWidget` go back to the default in such two cases. Reviewers: #dolphin, elvisangelaccio, meven, ngraham Reviewed By: ngraham Subscribers: kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D24450
This commit is contained in:
parent
167d5184ed
commit
c540b4eef1
|
@ -24,6 +24,7 @@
|
||||||
#include <QButtonGroup>
|
#include <QButtonGroup>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QDate>
|
#include <QDate>
|
||||||
|
#include <QEvent>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
|
|
||||||
|
@ -106,15 +107,27 @@ DolphinFacetsWidget::DolphinFacetsWidget(QWidget* parent) :
|
||||||
topLayout->addLayout(ratingLayout);
|
topLayout->addLayout(ratingLayout);
|
||||||
topLayout->addStretch();
|
topLayout->addStretch();
|
||||||
|
|
||||||
m_anyType->setChecked(true);
|
resetOptions();
|
||||||
m_anytime->setChecked(true);
|
|
||||||
m_anyRating->setChecked(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DolphinFacetsWidget::~DolphinFacetsWidget()
|
DolphinFacetsWidget::~DolphinFacetsWidget()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DolphinFacetsWidget::changeEvent(QEvent *event)
|
||||||
|
{
|
||||||
|
if (event->type() == QEvent::EnabledChange && !isEnabled()) {
|
||||||
|
resetOptions();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DolphinFacetsWidget::resetOptions()
|
||||||
|
{
|
||||||
|
m_anyType->setChecked(true);
|
||||||
|
m_anytime->setChecked(true);
|
||||||
|
m_anyRating->setChecked(true);
|
||||||
|
}
|
||||||
|
|
||||||
QString DolphinFacetsWidget::ratingTerm() const
|
QString DolphinFacetsWidget::ratingTerm() const
|
||||||
{
|
{
|
||||||
QStringList terms;
|
QStringList terms;
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
class QButtonGroup;
|
class QButtonGroup;
|
||||||
class QDate;
|
class QDate;
|
||||||
|
class QEvent;
|
||||||
class QRadioButton;
|
class QRadioButton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,6 +51,8 @@ public:
|
||||||
explicit DolphinFacetsWidget(QWidget* parent = nullptr);
|
explicit DolphinFacetsWidget(QWidget* parent = nullptr);
|
||||||
~DolphinFacetsWidget() override;
|
~DolphinFacetsWidget() override;
|
||||||
|
|
||||||
|
void resetOptions();
|
||||||
|
|
||||||
QString ratingTerm() const;
|
QString ratingTerm() const;
|
||||||
QString facetType() const;
|
QString facetType() const;
|
||||||
|
|
||||||
|
@ -61,6 +64,9 @@ public:
|
||||||
signals:
|
signals:
|
||||||
void facetChanged();
|
void facetChanged();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void changeEvent(QEvent* event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setRating(const int stars);
|
void setRating(const int stars);
|
||||||
void setTimespan(const QDate& date);
|
void setTimespan(const QDate& date);
|
||||||
|
|
|
@ -526,6 +526,8 @@ void DolphinSearchBox::fromBalooSearchUrl(const QUrl& url)
|
||||||
setSearchPath(QUrl::fromLocalFile(QDir::homePath()));
|
setSearchPath(QUrl::fromLocalFile(QDir::homePath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_facetsWidget->resetOptions();
|
||||||
|
|
||||||
setText(query.searchString());
|
setText(query.searchString());
|
||||||
|
|
||||||
QStringList types = query.types();
|
QStringList types = query.types();
|
||||||
|
|
Loading…
Reference in a new issue