diff options
| author | Vishesh Handa <[email protected]> | 2014-03-24 10:48:53 +0100 |
|---|---|---|
| committer | Vishesh Handa <[email protected]> | 2014-03-24 14:38:15 +0100 |
| commit | 76e5fd48349bb521e5403d694f1dc45f2d22d1ae (patch) | |
| tree | 26cb8385f157984e901487363aee5793d7b081cb /src | |
| parent | 3e576a16597b154a137604efd16323e1a1338f60 (diff) | |
Dolphin Facet Widget: Convert type selection into radio buttons
They were previously checkboxes. Most files cannot have more than 1 type
considering that the exposed types were "Document", "Image", "Video" and
"Audio".
Also, it is not very simple in baloo to search through ORs for types.
Not through the exposed API anyway.
REVIEW: 117015
Diffstat (limited to 'src')
| -rw-r--r-- | src/search/dolphinfacetswidget.cpp | 43 | ||||
| -rw-r--r-- | src/search/dolphinfacetswidget.h | 18 | ||||
| -rw-r--r-- | src/search/dolphinsearchbox.cpp | 2 |
3 files changed, 23 insertions, 40 deletions
diff --git a/src/search/dolphinfacetswidget.cpp b/src/search/dolphinfacetswidget.cpp index aec84d321..3824eb94c 100644 --- a/src/search/dolphinfacetswidget.cpp +++ b/src/search/dolphinfacetswidget.cpp @@ -46,13 +46,16 @@ DolphinFacetsWidget::DolphinFacetsWidget(QWidget* parent) : m_fourOrMore(0), m_maxRating(0) { - m_documents = createCheckBox(i18nc("@option:check", "Documents")); - m_images = createCheckBox(i18nc("@option:check", "Images")); - m_audio = createCheckBox(i18nc("@option:check", "Audio Files")); - m_videos = createCheckBox(i18nc("@option:check", "Videos")); + QButtonGroup* filetypeGroup = new QButtonGroup(this); + m_anyType = createRadioButton(i18nc("@option:check", "Any"), filetypeGroup); + m_documents = createRadioButton(i18nc("@option:check", "Documents"), filetypeGroup); + m_images = createRadioButton(i18nc("@option:check", "Images"), filetypeGroup); + m_audio = createRadioButton(i18nc("@option:check", "Audio Files"), filetypeGroup); + m_videos = createRadioButton(i18nc("@option:check", "Videos"), filetypeGroup); QVBoxLayout* typeLayout = new QVBoxLayout(); typeLayout->setSpacing(0); + typeLayout->addWidget(m_anyType); typeLayout->addWidget(m_documents); typeLayout->addWidget(m_images); typeLayout->addWidget(m_audio); @@ -160,38 +163,24 @@ Baloo::Term DolphinFacetsWidget::ratingTerm() const return Baloo::Term(); } -QStringList DolphinFacetsWidget::facetTypes() const +QString DolphinFacetsWidget::facetType() const { - QStringList types; if (m_documents->isChecked()) { - types << "Document"; + return QLatin1String("Document"); + } else if (m_images->isChecked()) { + return QLatin1String("Image"); + } else if (m_audio->isChecked()) { + return QLatin1String("Audio"); + } else if (m_videos->isChecked()) { + return QLatin1String("Video"); } - if (m_images->isChecked()) { - types << "Image"; - } - - if (m_audio->isChecked()) { - types << "Audio"; - } - - if (m_videos->isChecked()) { - types << "Video"; - } - - return types; + return QString(); } #endif -QCheckBox* DolphinFacetsWidget::createCheckBox(const QString& text) -{ - QCheckBox* checkBox = new QCheckBox(text); - connect(checkBox, SIGNAL(clicked()), this, SIGNAL(facetChanged())); - return checkBox; -} - QRadioButton* DolphinFacetsWidget::createRadioButton(const QString& text, QButtonGroup* group) { diff --git a/src/search/dolphinfacetswidget.h b/src/search/dolphinfacetswidget.h index 526fe1c79..1fd1683da 100644 --- a/src/search/dolphinfacetswidget.h +++ b/src/search/dolphinfacetswidget.h @@ -57,7 +57,7 @@ public: #ifdef HAVE_BALOO Baloo::Term ratingTerm() const; - QStringList facetTypes() const; + QString facetType() const; #endif signals: @@ -65,13 +65,6 @@ signals: private: /** - * @return New checkbox which is connected to the - * slotFacedChanged() slot whenever it has - * been toggled. - */ - QCheckBox* createCheckBox(const QString& text); - - /** * @return New radiobutton which is connected to the * slotFacedChanged() slot whenever it has * been toggled. @@ -80,10 +73,11 @@ private: QButtonGroup* group); private: - QCheckBox* m_documents; - QCheckBox* m_images; - QCheckBox* m_audio; - QCheckBox* m_videos; + QRadioButton* m_anyType; + QRadioButton* m_documents; + QRadioButton* m_images; + QRadioButton* m_audio; + QRadioButton* m_videos; QRadioButton* m_anytime; QRadioButton* m_today; diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp index 9aba4c954..0a7056682 100644 --- a/src/search/dolphinsearchbox.cpp +++ b/src/search/dolphinsearchbox.cpp @@ -436,7 +436,7 @@ KUrl DolphinSearchBox::balooUrlForSearching() const Baloo::Query query; query.addType("File"); - query.addTypes(m_facetsWidget->facetTypes()); + query.addType(m_facetsWidget->facetType()); Baloo::Term term(Baloo::Term::And); |
