From ebba84fbdd1effc828f88e08966dad5982371ecc Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Thu, 12 Nov 2009 20:07:14 +0000 Subject: [PATCH] * adjust order of search options * load real tags instead of offering the dummy "feffi" svn path=/trunk/KDE/kdebase/apps/; revision=1048145 --- .../dolphinsearchoptionsconfigurator.cpp | 11 +++++--- src/search/searchcriterionselector.cpp | 27 ++++++++++--------- src/search/searchcriterionselector.h | 2 +- src/search/searchcriterionvalue.cpp | 20 +++++++++++++- src/search/searchcriterionvalue.h | 3 +++ 5 files changed, 46 insertions(+), 17 deletions(-) diff --git a/src/search/dolphinsearchoptionsconfigurator.cpp b/src/search/dolphinsearchoptionsconfigurator.cpp index 112c55d82..81aee12a9 100644 --- a/src/search/dolphinsearchoptionsconfigurator.cpp +++ b/src/search/dolphinsearchoptionsconfigurator.cpp @@ -110,12 +110,17 @@ void DolphinSearchOptionsConfigurator::showEvent(QShowEvent* event) if (!event->spontaneous() && !m_initialized) { // add default search criterions SearchCriterionSelector* dateCriterion = new SearchCriterionSelector(SearchCriterionSelector::Date, this); - SearchCriterionSelector* tagCriterion = new SearchCriterionSelector(SearchCriterionSelector::Tag, this); SearchCriterionSelector* sizeCriterion = new SearchCriterionSelector(SearchCriterionSelector::Size, this); + SearchCriterionSelector* tagCriterion = new SearchCriterionSelector(SearchCriterionSelector::Tag, this); + // Add the items in the same order as available in the description combo (verified by Q_ASSERTs). This + // is not mandatory from an implementation point of view, but preferable from a usability point of view. + Q_ASSERT(static_cast(SearchCriterionSelector::Date) == 0); + Q_ASSERT(static_cast(SearchCriterionSelector::Size) == 1); + Q_ASSERT(static_cast(SearchCriterionSelector::Tag) == 2); addSelector(dateCriterion); - addSelector(tagCriterion); addSelector(sizeCriterion); + addSelector(tagCriterion); m_initialized = true; } @@ -124,7 +129,7 @@ void DolphinSearchOptionsConfigurator::showEvent(QShowEvent* event) void DolphinSearchOptionsConfigurator::slotAddSelectorButtonClicked() { - SearchCriterionSelector* selector = new SearchCriterionSelector(SearchCriterionSelector::Size, this); + SearchCriterionSelector* selector = new SearchCriterionSelector(SearchCriterionSelector::Tag, this); addSelector(selector); } diff --git a/src/search/searchcriterionselector.cpp b/src/search/searchcriterionselector.cpp index 6a900fa7a..08987153a 100644 --- a/src/search/searchcriterionselector.cpp +++ b/src/search/searchcriterionselector.cpp @@ -103,6 +103,17 @@ void SearchCriterionSelector::createDescriptions() dateComps, dateValue); + // add "Size" description + QList sizeComps = defaultComps; + sizeComps.insert(0, SearchCriterionDescription::Comparator(i18nc("@label Any (file size)", "Any"))); + + SizeValue* sizeValue = new SizeValue(this); + sizeValue->hide(); + SearchCriterionDescription size(i18nc("@label", "Size"), + "contentSize", + sizeComps, + sizeValue); + // add "Tag" description QList tagComps; tagComps.append(SearchCriterionDescription::Comparator(i18nc("@label All (tags)", "All"))); @@ -115,20 +126,12 @@ void SearchCriterionSelector::createDescriptions() tagComps, tagValue); - // add "Size" description - QList sizeComps = defaultComps; - sizeComps.insert(0, SearchCriterionDescription::Comparator(i18nc("@label Any (file size)", "Any"))); - - SizeValue* sizeValue = new SizeValue(this); - sizeValue->hide(); - SearchCriterionDescription size(i18nc("@label", "Size"), - "contentSize", - sizeComps, - sizeValue); - + Q_ASSERT(static_cast(SearchCriterionSelector::Date) == 0); + Q_ASSERT(static_cast(SearchCriterionSelector::Size) == 1); + Q_ASSERT(static_cast(SearchCriterionSelector::Tag) == 2); m_descriptions.append(date); - m_descriptions.append(tag); m_descriptions.append(size); + m_descriptions.append(tag); // add all descriptions to the combo box const int count = m_descriptions.count(); diff --git a/src/search/searchcriterionselector.h b/src/search/searchcriterionselector.h index 1ddc50d25..abaed2d0a 100644 --- a/src/search/searchcriterionselector.h +++ b/src/search/searchcriterionselector.h @@ -45,7 +45,7 @@ class SearchCriterionSelector : public QWidget Q_OBJECT public: - enum Type { Date, Tag, Size }; + enum Type { Date, Size, Tag }; SearchCriterionSelector(Type type, QWidget* parent = 0); virtual ~SearchCriterionSelector(); diff --git a/src/search/searchcriterionvalue.cpp b/src/search/searchcriterionvalue.cpp index 5a903cbae..531db3e01 100644 --- a/src/search/searchcriterionvalue.cpp +++ b/src/search/searchcriterionvalue.cpp @@ -23,10 +23,13 @@ #include #include +#include + #include #include #include #include +#include SearchCriterionValue::SearchCriterionValue(QWidget* parent) : QWidget(parent) @@ -66,7 +69,7 @@ TagValue::TagValue(QWidget* parent) : m_tags(0) { m_tags = new QComboBox(this); - m_tags->addItem("feffi"); + m_tags->setInsertPolicy(QComboBox::InsertAlphabetically); QHBoxLayout* layout = new QHBoxLayout(this); layout->setMargin(0); @@ -82,6 +85,21 @@ QString TagValue::value() const return QString(); } +void TagValue::showEvent(QShowEvent* event) +{ + if (!event->spontaneous() && (m_tags->count() == 0)) { + const QList tags = Nepomuk::Tag::allTags(); + foreach (const Nepomuk::Tag& tag, tags) { + m_tags->addItem(tag.label()); + } + + if (tags.count() == 0) { + m_tags->addItem(i18nc("@label", "No Tags Available")); + } + } + SearchCriterionValue::showEvent(event); +} + // ------------------------------------------------------------------------- SizeValue::SizeValue(QWidget* parent) : diff --git a/src/search/searchcriterionvalue.h b/src/search/searchcriterionvalue.h index 7bb79243d..5144c7181 100644 --- a/src/search/searchcriterionvalue.h +++ b/src/search/searchcriterionvalue.h @@ -73,6 +73,9 @@ public: virtual ~TagValue(); virtual QString value() const; +protected: + virtual void showEvent(QShowEvent* event); + private: QComboBox* m_tags; }; -- 2.47.3