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
#include <QButtonGroup>
#include <QCheckBox>
#include <QDate>
+#include <QEvent>
#include <QHBoxLayout>
#include <QRadioButton>
topLayout->addLayout(ratingLayout);
topLayout->addStretch();
- m_anyType->setChecked(true);
- m_anytime->setChecked(true);
- m_anyRating->setChecked(true);
+ resetOptions();
}
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
{
QStringList terms;
class QButtonGroup;
class QDate;
+class QEvent;
class QRadioButton;
/**
explicit DolphinFacetsWidget(QWidget* parent = nullptr);
~DolphinFacetsWidget() override;
+ void resetOptions();
+
QString ratingTerm() const;
QString facetType() const;
signals:
void facetChanged();
+protected:
+ void changeEvent(QEvent* event) override;
+
private:
void setRating(const int stars);
void setTimespan(const QDate& date);
setSearchPath(QUrl::fromLocalFile(QDir::homePath()));
}
+ m_facetsWidget->resetOptions();
+
setText(query.searchString());
QStringList types = query.types();