]> cloud.milkyroute.net Git - dolphin.git/commitdiff
* adjust order of search options
authorPeter Penz <peter.penz19@gmail.com>
Thu, 12 Nov 2009 20:07:14 +0000 (20:07 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Thu, 12 Nov 2009 20:07:14 +0000 (20:07 +0000)
* load real tags instead of offering the dummy "feffi"

svn path=/trunk/KDE/kdebase/apps/; revision=1048145

src/search/dolphinsearchoptionsconfigurator.cpp
src/search/searchcriterionselector.cpp
src/search/searchcriterionselector.h
src/search/searchcriterionvalue.cpp
src/search/searchcriterionvalue.h

index 112c55d828c190136aa2a252e7322cd2f3b72325..81aee12a9d5e13113cf7e17ddfa4eaa3ecf85f19 100644 (file)
@@ -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<int>(SearchCriterionSelector::Date) == 0);
+        Q_ASSERT(static_cast<int>(SearchCriterionSelector::Size) == 1);
+        Q_ASSERT(static_cast<int>(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);
 }
 
index 6a900fa7a808015d061299d580c61f8d9708eefd..08987153a201c2bbeb3f4f1970ead978707190cd 100644 (file)
@@ -103,6 +103,17 @@ void SearchCriterionSelector::createDescriptions()
                                     dateComps,
                                     dateValue);
 
+    // add "Size" description
+    QList<SearchCriterionDescription::Comparator> 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<SearchCriterionDescription::Comparator> tagComps;
     tagComps.append(SearchCriterionDescription::Comparator(i18nc("@label All (tags)", "All")));
@@ -115,20 +126,12 @@ void SearchCriterionSelector::createDescriptions()
                                    tagComps,
                                    tagValue);
 
-    // add "Size" description
-    QList<SearchCriterionDescription::Comparator> 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<int>(SearchCriterionSelector::Date) == 0);
+    Q_ASSERT(static_cast<int>(SearchCriterionSelector::Size) == 1);
+    Q_ASSERT(static_cast<int>(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();
index 1ddc50d2514f211106f24f0764487016f7ce5cc7..abaed2d0a9bc478636363e5ab38d91b24264be34 100644 (file)
@@ -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();
index 5a903cbae140515388fdc7f2ecb201a7f2d241ec..531db3e01c6cb08aa26e10efe7c430d6cd2357e7 100644 (file)
 #include <klineedit.h>
 #include <klocale.h>
 
+#include <nepomuk/tag.h>
+
 #include <QComboBox>
 #include <QDateEdit>
 #include <QLabel>
 #include <QHBoxLayout>
+#include <QShowEvent>
 
 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<Nepomuk::Tag> 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) :
index 7bb79243d05eb87c15e80380fefb94c154c1f99d..5144c7181fe73b3d5a5ad17589c53f2f12621958 100644 (file)
@@ -73,6 +73,9 @@ public:
     virtual ~TagValue();
     virtual QString value() const;
 
+protected:
+    virtual void showEvent(QShowEvent* event);
+
 private:
     QComboBox* m_tags;
 };