]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/search/dolphinfacetswidget.cpp
[dolphin/search] Reset search options when needed
[dolphin.git] / src / search / dolphinfacetswidget.cpp
index 21a45cd9b8ec2419a05540d67a746d30b97658d8..08fe567b1cdefd425f577f46b55b0d8409824150 100644 (file)
 #include "dolphinfacetswidget.h"
 
 #include <KLocalizedString>
+
 #include <QButtonGroup>
 #include <QCheckBox>
 #include <QDate>
-#include <QRadioButton>
+#include <QEvent>
 #include <QHBoxLayout>
+#include <QRadioButton>
 
 DolphinFacetsWidget::DolphinFacetsWidget(QWidget* parent) :
     QWidget(parent),
@@ -105,15 +107,27 @@ DolphinFacetsWidget::DolphinFacetsWidget(QWidget* parent) :
     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;
@@ -149,7 +163,7 @@ QString DolphinFacetsWidget::ratingTerm() const
         terms << QStringLiteral("modified>=%1").arg(date.toString(Qt::ISODate));
     }
 
-    return terms.join(QStringLiteral(" AND "));
+    return terms.join(QLatin1String(" AND "));
 }
 
 QString DolphinFacetsWidget::facetType() const
@@ -210,7 +224,9 @@ void DolphinFacetsWidget::setRatingTerm(const QString& term)
 
 void DolphinFacetsWidget::setFacetType(const QString& type)
 {
-    if (type == QLatin1String("Document")) {
+    if (type == QLatin1String("Folder")) {
+        m_folders->setChecked(true);
+    } else if (type == QLatin1String("Document")) {
         m_documents->setChecked(true);
     } else if (type == QLatin1String("Image")) {
         m_images->setChecked(true);