]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Imported Adam Kidders search configuration widgets from playground/base/nepomuk/searc...
authorPeter Penz <peter.penz19@gmail.com>
Fri, 23 Oct 2009 21:06:33 +0000 (21:06 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Fri, 23 Oct 2009 21:06:33 +0000 (21:06 +0000)
Currently the UI works quite well, but the creating of the query string has not been integrated yet.

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

src/CMakeLists.txt
src/search/dolphinsearchbox.h
src/search/dolphinsearchoptionsconfigurator.cpp
src/search/dolphinsearchoptionsconfigurator.h
src/search/searchcriteriondescription.cpp [new file with mode: 0644]
src/search/searchcriteriondescription.h [new file with mode: 0644]
src/search/searchcriterionselector.cpp [new file with mode: 0644]
src/search/searchcriterionselector.h [new file with mode: 0644]
src/search/searchcriterionvalue.cpp [new file with mode: 0644]
src/search/searchcriterionvalue.h [new file with mode: 0644]

index 429695f5ded64ebf2be072fd21e30b2123f74a83..ea6bda63ab3b3efe588ed4ca40421f698d6112fc 100644 (file)
@@ -123,6 +123,9 @@ set(dolphin_SRCS
     panels/folders/paneltreeview.cpp
     search/dolphinsearchbox.cpp
     search/dolphinsearchoptionsconfigurator.cpp
+    search/searchcriteriondescription.cpp
+    search/searchcriterionselector.cpp
+    search/searchcriterionvalue.cpp
     settings/behaviorsettingspage.cpp
     settings/columnviewsettingspage.cpp
     settings/contextmenusettingspage.cpp
index 2e4c6b85a37c9d9dae98f88373b0f9576aea83c6..018612564588bda5dc5440a0148d0842566a1511 100644 (file)
@@ -32,7 +32,7 @@ class QStandardItemModel;
 class QToolButton;
 
 /**
- * @brief used for completition for the DolphinSearchBox
+ * @brief Helper class used for completition for the DolphinSearchBox.
  */
 class DolphinSearchCompleter : public QObject
 {
index 4a92b7b45297588dd949fa005a0895dd7279d460..d7a620ac1b68f2945c75d4349124b8992662635b 100644 (file)
@@ -1,4 +1,5 @@
 /***************************************************************************
+ *   Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at>                  *
  *   Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at>                  *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
 
 #include "dolphinsearchoptionsconfigurator.h"
 
+#include "searchcriterionselector.h"
+
 #include <kcombobox.h>
+#include <kicon.h>
 #include <klocale.h>
+#include <kseparator.h>
 
 #include <QButtonGroup>
 #include <QHBoxLayout>
 #include <QVBoxLayout>
 
 DolphinSearchOptionsConfigurator::DolphinSearchOptionsConfigurator(QWidget* parent) :
-    QWidget(parent)
+    QWidget(parent),
+    m_searchFromBox(0),
+    m_searchWhatBox(0),
+    m_addSelectorButton(0),
+    m_vBoxLayout(0)
 {
-    QVBoxLayout* vBoxLayout = new QVBoxLayout(this);
+    m_vBoxLayout = new QVBoxLayout(this);
 
     // add "search" configuration
     QLabel* searchLabel = new QLabel(i18nc("@label", "Search:"));
 
-    KComboBox* searchFromBox = new KComboBox();
-    searchFromBox->addItem(i18nc("label", "Everywhere"));
-    searchFromBox->addItem(i18nc("label", "From Here"));
+    m_searchFromBox = new KComboBox(this);
+    m_searchFromBox->addItem(i18nc("@label", "Everywhere"));
+    m_searchFromBox->addItem(i18nc("@label", "From Here"));
 
     // add "what" configuration
     QLabel* whatLabel = new QLabel(i18nc("@label", "What:"));
 
-    KComboBox* searchWhatBox = new KComboBox();
-    searchWhatBox->addItem(i18nc("label", "All"));
-    searchWhatBox->addItem(i18nc("label", "Images"));
-    searchWhatBox->addItem(i18nc("label", "Text"));
-    searchWhatBox->addItem(i18nc("label", "Filenames"));
+    m_searchWhatBox = new KComboBox(this);
+    m_searchWhatBox->addItem(i18nc("@label", "All"));
+    m_searchWhatBox->addItem(i18nc("@label", "Images"));
+    m_searchWhatBox->addItem(i18nc("@label", "Text"));
+    m_searchWhatBox->addItem(i18nc("@label", "Filenames"));
 
-    QWidget* filler = new QWidget();
+    QWidget* filler = new QWidget(this);
 
     // add button "Save"
-    QPushButton* saveButton = new QPushButton();
+    QPushButton* saveButton = new QPushButton(this);
     saveButton->setText(i18nc("@action:button", "Save"));
 
+    // add "Add selector" button
+    m_addSelectorButton = new QPushButton(this);
+    m_addSelectorButton->setIcon(KIcon("list-add"));
+    m_addSelectorButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+    connect(m_addSelectorButton, SIGNAL(clicked()), this, SLOT(addSelector()));
+
     QHBoxLayout* hBoxLayout = new QHBoxLayout(this);
     hBoxLayout->addWidget(searchLabel);
-    hBoxLayout->addWidget(searchFromBox);
+    hBoxLayout->addWidget(m_searchFromBox);
     hBoxLayout->addWidget(whatLabel);
-    hBoxLayout->addWidget(searchWhatBox);
+    hBoxLayout->addWidget(m_searchWhatBox);
     hBoxLayout->addWidget(filler, 1);
     hBoxLayout->addWidget(saveButton);
+    hBoxLayout->addWidget(m_addSelectorButton);
 
-    vBoxLayout->addLayout(hBoxLayout);
+    m_vBoxLayout->addWidget(new KSeparator(this));
+    m_vBoxLayout->addLayout(hBoxLayout);
+    m_vBoxLayout->addWidget(new KSeparator(this));
 }
 
 DolphinSearchOptionsConfigurator::~DolphinSearchOptionsConfigurator()
 {
 }
 
+void DolphinSearchOptionsConfigurator::addSelector()
+{
+    SearchCriterionSelector* selector = new SearchCriterionSelector(this);
+    connect(selector, SIGNAL(removeCriterion()), this, SLOT(removeCriterion()));
+
+    // insert the new selector before the KSeparator at the bottom
+    const int index = m_vBoxLayout->count() - 1;
+    m_vBoxLayout->insertWidget(index, selector);
+    updateSelectorButton();
+}
+
+void DolphinSearchOptionsConfigurator::removeCriterion()
+{
+    QWidget* criterion = qobject_cast<QWidget*>(sender());
+    Q_ASSERT(criterion != 0);
+    m_vBoxLayout->removeWidget(criterion);
+    criterion->deleteLater();
+
+    updateSelectorButton();
+}
+
+void DolphinSearchOptionsConfigurator::updateSelectorButton()
+{
+    const int selectors = m_vBoxLayout->count() - 1;
+    m_addSelectorButton->setEnabled(selectors < 10);
+}
+
 #include "dolphinsearchoptionsconfigurator.moc"
index 9b5a70b031508596b4fe2a0a639e993184648586..7fc0b5a4b0f403146b31de2a08273194439a2d61 100644 (file)
@@ -1,4 +1,5 @@
 /***************************************************************************
+ *   Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at>                  *
  *   Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at>                  *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
 
 #include <QWidget>
 
+class KComboBox;
+class QPushButton;
+class QVBoxLayout;
+
+/**
+ * @brief Allows the user to configure a search query for Nepomuk.
+ */
 class DolphinSearchOptionsConfigurator : public QWidget
 {
     Q_OBJECT
@@ -29,6 +37,27 @@ class DolphinSearchOptionsConfigurator : public QWidget
 public:
     DolphinSearchOptionsConfigurator(QWidget* parent = 0);
     virtual ~DolphinSearchOptionsConfigurator();
+
+private slots:
+    /**
+     * Adds a new search description selector to the bottom
+     * of the layout.
+     */
+    void addSelector();
+
+    void removeCriterion();
+
+    /**
+     * Updates the 'enabled' property of the selector button
+     * dependent from the number of existing selectors.
+     */
+    void updateSelectorButton();
+
+private:
+    KComboBox* m_searchFromBox;
+    KComboBox* m_searchWhatBox;
+    QPushButton* m_addSelectorButton;
+    QVBoxLayout* m_vBoxLayout;
 };
 
 #endif
diff --git a/src/search/searchcriteriondescription.cpp b/src/search/searchcriteriondescription.cpp
new file mode 100644 (file)
index 0000000..bad53e8
--- /dev/null
@@ -0,0 +1,56 @@
+/***************************************************************************
+ *   Copyright (C) 2009 by Adam Kidder <thekidder@gmail.com>               *
+ *   Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at>                  *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
+ ***************************************************************************/
+
+#include "searchcriteriondescription.h"
+
+SearchCriterionDescription::SearchCriterionDescription(const QString& name,
+                                                       const QString& identifier,
+                                                       const QList<Comparator>& comparators,
+                                                       SearchCriterionValue* valueWidget) :
+    m_name(name),
+    m_identifier(identifier),
+    m_comparators(comparators),
+    m_valueWidget(valueWidget)
+{
+}
+
+SearchCriterionDescription::~SearchCriterionDescription()
+{
+}
+
+QString SearchCriterionDescription::name() const
+{
+    return m_name;
+}
+
+QString SearchCriterionDescription::identifier() const
+{
+    return m_identifier;
+}
+
+const QList<SearchCriterionDescription::Comparator>& SearchCriterionDescription::comparators() const
+{
+    return m_comparators;
+}
+
+SearchCriterionValue* SearchCriterionDescription::valueWidget() const
+{
+    return m_valueWidget;
+}
diff --git a/src/search/searchcriteriondescription.h b/src/search/searchcriteriondescription.h
new file mode 100644 (file)
index 0000000..2bf3d2f
--- /dev/null
@@ -0,0 +1,67 @@
+/***************************************************************************
+ *   Copyright (C) 2009 by Adam Kidder <thekidder@gmail.com>               *
+ *   Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at>                  *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
+ ***************************************************************************/
+
+#ifndef SEARCHCRITERIONDESCRIPTION_H
+#define SEARCHCRITERIONDESCRIPTION_H
+
+#include <QList>
+#include <QString>
+
+class SearchCriterionValue;
+class QWidget;
+
+/**
+ * @brief Helper class for SearchCriterionSelector.
+ *
+ * Describes a search criterion including the used
+ * widget for editing.
+ */
+class SearchCriterionDescription
+{
+public:
+    struct Comparator
+    {
+        Comparator(const QString& n, const QString& o, const QString& p) :
+            name(n), operation(o), prefix(p) {}
+        QString name;        // user visible and translated name
+        QString operation;   // Nepomuk operation that represents the comparator
+        QString prefix;      // prefix like "+" or "-" that is part of the Nepomuk query
+    };
+
+    SearchCriterionDescription(const QString& name,
+                               const QString& identifier,
+                               const QList<Comparator>& comparators,
+                               SearchCriterionValue* valueWidget);
+
+    virtual ~SearchCriterionDescription();
+
+    QString name() const;
+    QString identifier() const;
+    const QList<Comparator>& comparators() const;
+    SearchCriterionValue* valueWidget() const;
+
+private:
+    QString m_name;       // user visible name that gets translated
+    QString m_identifier; // internal Nepomuk identifier
+    QList<Comparator> m_comparators;
+    SearchCriterionValue* m_valueWidget;
+};
+
+#endif // SEARCHCRITERIONDESCRIPTION_H
diff --git a/src/search/searchcriterionselector.cpp b/src/search/searchcriterionselector.cpp
new file mode 100644 (file)
index 0000000..831e743
--- /dev/null
@@ -0,0 +1,167 @@
+/***************************************************************************
+ *   Copyright (C) 2009 by Adam Kidder <thekidder@gmail.com>               *
+ *   Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at>                  *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
+ ***************************************************************************/
+
+#include "searchcriterionselector.h"
+
+#include "searchcriterionvalue.h"
+
+#include <QComboBox>
+#include <QHBoxLayout>
+#include <QList>
+#include <QPushButton>
+
+#include <kicon.h>
+#include <klocale.h>
+
+SearchCriterionSelector::SearchCriterionSelector(QWidget* parent) :
+    QWidget(parent),
+    m_layout(0),
+    m_descriptionsBox(0),
+    m_comparatorBox(0),
+    m_valueWidget(0),
+    m_removeButton(0),
+    m_descriptions()
+{
+    m_descriptionsBox = new QComboBox(this);
+    m_descriptionsBox->addItem(i18nc("@label", "Select..."), -1);
+    createDescriptions();
+    connect(m_descriptionsBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotDescriptionChanged(int)));
+
+    m_comparatorBox = new QComboBox(this);
+    m_comparatorBox->hide();
+    connect(m_comparatorBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateQuery()));
+
+    QWidget* filler = new QWidget(this);
+    filler->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+
+    m_removeButton = new QPushButton(this);
+    m_removeButton->setIcon(KIcon("list-remove"));
+    m_removeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+    connect(m_removeButton, SIGNAL(clicked()), this, SIGNAL(removeCriterion()));
+
+    m_layout = new QHBoxLayout(this);
+    m_layout->setMargin(0);
+    m_layout->addWidget(m_descriptionsBox);
+    m_layout->addWidget(m_comparatorBox);
+    m_layout->addWidget(filler);
+    m_layout->addWidget(m_removeButton);
+
+    setLayout(m_layout);
+}
+
+SearchCriterionSelector::~SearchCriterionSelector()
+{
+}
+
+void SearchCriterionSelector::createDescriptions()
+{
+    // TODO: maybe this creation should be forwarded to a factory if
+    // the number of items increases in future
+
+    QList<SearchCriterionDescription::Comparator> comparators;
+    comparators.append(SearchCriterionDescription::Comparator(i18nc("@label", "greater than"), ">", "+"));
+    comparators.append(SearchCriterionDescription::Comparator(i18nc("@label", "greater than or equal to"), ">=", "+"));
+    comparators.append(SearchCriterionDescription::Comparator(i18nc("@label", "less than"), "<", "+"));
+    comparators.append(SearchCriterionDescription::Comparator(i18nc("@label", "less than or equal to"), "<=", "+"));
+
+    // add "Date" description
+    DateValue* dateValue = new DateValue(this);
+    dateValue->hide();
+    SearchCriterionDescription date(i18nc("@label", "Date Modified"),
+                                    "sourceModified",
+                                    comparators,
+                                    dateValue);
+
+    // add "File Size" description
+    FileSizeValue* fileSizeValue = new FileSizeValue(this);
+    fileSizeValue->hide();
+    SearchCriterionDescription size(i18nc("@label", "File Size"),
+                                    "contentSize",
+                                    comparators,
+                                    fileSizeValue);
+
+    m_descriptions.append(date);
+    m_descriptions.append(size);
+
+    // add all descriptions to the combo box
+    const int count = m_descriptions.count();
+    for (int i = 0; i < count; ++i) {
+        m_descriptionsBox->addItem(m_descriptions[i].name(), i);
+    }
+}
+
+void SearchCriterionSelector::slotDescriptionChanged(int index)
+{
+    m_comparatorBox->clear();
+    m_comparatorBox->show();
+    if (m_valueWidget != 0) {
+        m_layout->removeWidget(m_valueWidget);
+        // the value widget is obtained by the Search Criterion
+        // Selector instance and may not get deleted
+    }
+
+    // adjust the comparator box and the value widget dependent from the selected description
+    m_comparatorBox->addItem(i18nc("@label", "Select..."), -1);
+    const int descrIndex = m_descriptionsBox->itemData(index).toInt();
+    if (descrIndex >= 0) {
+        // add comparator items
+        const SearchCriterionDescription& description = m_descriptions[descrIndex];
+        foreach (const SearchCriterionDescription::Comparator& comp, description.comparators()) {
+            m_comparatorBox->addItem(comp.name);
+        }
+
+        // add value widget
+        m_valueWidget = description.valueWidget();
+        const int layoutIndex = m_layout->count() - 2;
+        m_layout->insertWidget(layoutIndex, m_valueWidget);
+        m_valueWidget->show();
+    }
+}
+
+void SearchCriterionSelector::updateQuery()
+{
+    const SearchCriterionDescription* descr = description();
+    if (descr == 0) {
+        // no description has been selected
+        return;
+    }
+
+    // get selected comparator related to the description
+    const int compBoxIndex = m_comparatorBox->currentIndex();
+    const int compIndex = m_comparatorBox->itemData(compBoxIndex).toInt();
+    if (compIndex < 0) {
+        // no comparator has been selected
+        return;
+    }
+
+    // create query string
+    const SearchCriterionDescription::Comparator& comp = descr->comparators()[compIndex];
+    const QString queryString = comp.prefix + descr->identifier() + comp.operation + m_valueWidget->value();
+    emit criterionChanged(queryString);
+}
+
+const SearchCriterionDescription* SearchCriterionSelector::description() const
+{
+    const int descrBoxIndex = m_descriptionsBox->currentIndex();
+    const int descrIndex = m_descriptionsBox->itemData(descrBoxIndex).toInt();
+    return (descrIndex < 0) ? 0 : &m_descriptions[descrIndex];
+}
+
+#include "searchcriterionselector.moc"
diff --git a/src/search/searchcriterionselector.h b/src/search/searchcriterionselector.h
new file mode 100644 (file)
index 0000000..3720b53
--- /dev/null
@@ -0,0 +1,95 @@
+/***************************************************************************
+ *   Copyright (C) 2009 by Adam Kidder <thekidder@gmail.com>               *
+ *   Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at>                  *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
+ ***************************************************************************/
+
+#ifndef SEARCHCRITERIONSELECTOR_H
+#define SEARCHCRITERIONSELECTOR_H
+
+#include <QList>
+#include <QString>
+#include <QWidget>
+
+#include <search/searchcriteriondescription.h>
+
+class SearchCriterionValue;
+class QComboBox;
+class QHBoxLayout;
+class QPushButton;
+class ValueWidget;
+
+/**
+ * @brief Allows the user to select a search criterion.
+ * The widget represents one row of the DolphinSearchOptionsConfigurator.
+ * Example: [File Size] [greater than] [10] [Byte]
+ *
+ * @see DolphinSearchOptionsConfigurator.
+ */
+class SearchCriterionSelector : public QWidget
+{
+    Q_OBJECT
+
+public:
+    SearchCriterionSelector(QWidget* parent = 0);
+    virtual ~SearchCriterionSelector();
+
+signals:
+    /**
+     * Is emitted if the criterion selector should be removed
+     * because the user clicked the "Remove" button.
+     */
+    void removeCriterion();
+
+    /**
+     * Is emitted if the user changed the search criterion.
+     * \p queryString represents a Nepomuk conform query string.
+     */
+    void criterionChanged(const QString& queryString);
+
+private slots:
+    void slotDescriptionChanged(int index);
+
+    /**
+     * Updates the query string and emits the signal criterionChanged().
+     */
+    void updateQuery();
+
+private:
+    /**
+     * Creates all available search criterion descriptions m_descriptions
+     * and adds them into the combobox m_descriptionsBox.
+     */
+    void createDescriptions();
+
+    /**
+     * Returns the currently selected searc criterion description. If nothing
+     * is selected, 0 is returned.
+     */
+    const SearchCriterionDescription* description() const;
+
+private:
+    QHBoxLayout* m_layout;
+    QComboBox* m_descriptionsBox;        // has items like "File Size", "Date Modified", ...
+    QComboBox* m_comparatorBox;          // has items like "greater than", "less than", ...
+    SearchCriterionValue* m_valueWidget; // contains the value of a file size or a date
+    QPushButton* m_removeButton;         // requests a removing of the search criterion instance
+
+    QList<SearchCriterionDescription> m_descriptions;
+};
+
+#endif // SEARCHCRITERIONSELECTOR_H
diff --git a/src/search/searchcriterionvalue.cpp b/src/search/searchcriterionvalue.cpp
new file mode 100644 (file)
index 0000000..301344d
--- /dev/null
@@ -0,0 +1,94 @@
+/***************************************************************************
+ *   Copyright (C) 2009 by Adam Kidder <thekidder@gmail.com>               *
+ *   Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at>                  *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
+ ***************************************************************************/
+
+#include "searchcriterionvalue.h"
+
+#include <klineedit.h>
+#include <klocale.h>
+
+#include <QComboBox>
+#include <QDateEdit>
+#include <QLabel>
+#include <QHBoxLayout>
+
+SearchCriterionValue::SearchCriterionValue(QWidget* parent) :
+    QWidget(parent)
+{
+}
+
+SearchCriterionValue::~SearchCriterionValue()
+{
+}
+
+
+
+DateValue::DateValue(QWidget* parent) :
+    SearchCriterionValue(parent),
+    m_dateEdit(0)
+{
+    m_dateEdit = new QDateEdit(this);
+
+    QHBoxLayout* layout = new QHBoxLayout(this);
+    layout->setMargin(0);
+    layout->addWidget(m_dateEdit);
+}
+
+DateValue::~DateValue()
+{
+}
+
+QString DateValue::value() const
+{
+    return QString();
+}
+
+
+
+FileSizeValue::FileSizeValue(QWidget* parent) :
+    SearchCriterionValue(parent),
+    m_lineEdit(0),
+    m_units(0)
+{
+    m_lineEdit = new KLineEdit(this);
+    m_lineEdit->setClearButtonShown(true);
+
+    m_units = new QComboBox(this);
+    // TODO: check the KByte vs. KiByte dilemma :-/
+    m_units->addItem(i18nc("@label", "Byte"));
+    m_units->addItem(i18nc("@label", "KByte"));
+    m_units->addItem(i18nc("@label", "MByte"));
+    m_units->addItem(i18nc("@label", "GByte"));
+
+    QHBoxLayout* layout = new QHBoxLayout(this);
+    layout->setMargin(0);
+    layout->addWidget(m_lineEdit);
+    layout->addWidget(m_units);
+}
+
+FileSizeValue::~FileSizeValue()
+{
+}
+
+QString FileSizeValue::value() const
+{
+    return QString();
+}
+
+#include "searchcriterionvalue.moc"
diff --git a/src/search/searchcriterionvalue.h b/src/search/searchcriterionvalue.h
new file mode 100644 (file)
index 0000000..cfabca2
--- /dev/null
@@ -0,0 +1,81 @@
+/***************************************************************************
+ *   Copyright (C) 2009 by Adam Kidder <thekidder@gmail.com>               *
+ *   Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at>                  *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
+ ***************************************************************************/
+
+#ifndef SEARCHCRITERIONVALUE_H
+#define SEARCHCRITERIONVALUE_H
+
+#include <QWidget>
+
+class QComboBox;
+class QDateEdit;
+class KLineEdit;
+
+/**
+ * @brief Helper class for SearchCriterionSelector.
+ * Represents an input widget for the value of a search criterion.
+ */
+class SearchCriterionValue : public QWidget
+{
+    Q_OBJECT
+
+public:
+    SearchCriterionValue(QWidget* parent = 0);
+    virtual ~SearchCriterionValue();
+
+    virtual QString value() const = 0;
+
+signals:
+    void valueChanged(const QString& value);
+};
+
+
+
+/** @brief Allows to input a date value as search criterion. */
+class DateValue : public SearchCriterionValue
+{
+    Q_OBJECT
+
+public:
+    DateValue(QWidget* parent = 0);
+    virtual ~DateValue();
+    virtual QString value() const;
+    
+private:
+    QDateEdit* m_dateEdit;
+};
+
+
+
+/** @brief Allows to input a file size value as search criterion. */
+class FileSizeValue : public SearchCriterionValue
+{
+    Q_OBJECT
+
+public:
+    FileSizeValue(QWidget* parent = 0);
+    virtual ~FileSizeValue();
+    virtual QString value() const;
+
+ private:
+    KLineEdit* m_lineEdit;
+    QComboBox* m_units;
+};
+
+#endif // SEARCHCRITERIONVALUE_H