mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
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
This commit is contained in:
parent
3e576a1659
commit
76e5fd4834
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -57,20 +57,13 @@ public:
|
|||
|
||||
#ifdef HAVE_BALOO
|
||||
Baloo::Term ratingTerm() const;
|
||||
QStringList facetTypes() const;
|
||||
QString facetType() const;
|
||||
#endif
|
||||
|
||||
signals:
|
||||
void facetChanged();
|
||||
|
||||
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
|
||||
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue