From efecb5021cc7855caa05117ebbe74608f5c863f2 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Fri, 23 Oct 2009 21:06:33 +0000 Subject: [PATCH] Imported Adam Kidders search configuration widgets from playground/base/nepomuk/search_widgets_test. I adjusted some names of classes and members and also changed some parts of the implementation, but conceptually the concept is 1:1 like provided by Adam in playground. 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 | 3 + src/search/dolphinsearchbox.h | 2 +- .../dolphinsearchoptionsconfigurator.cpp | 75 ++++++-- src/search/dolphinsearchoptionsconfigurator.h | 29 +++ src/search/searchcriteriondescription.cpp | 56 ++++++ src/search/searchcriteriondescription.h | 67 +++++++ src/search/searchcriterionselector.cpp | 167 ++++++++++++++++++ src/search/searchcriterionselector.h | 95 ++++++++++ src/search/searchcriterionvalue.cpp | 94 ++++++++++ src/search/searchcriterionvalue.h | 81 +++++++++ 10 files changed, 653 insertions(+), 16 deletions(-) create mode 100644 src/search/searchcriteriondescription.cpp create mode 100644 src/search/searchcriteriondescription.h create mode 100644 src/search/searchcriterionselector.cpp create mode 100644 src/search/searchcriterionselector.h create mode 100644 src/search/searchcriterionvalue.cpp create mode 100644 src/search/searchcriterionvalue.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 429695f5d..ea6bda63a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 diff --git a/src/search/dolphinsearchbox.h b/src/search/dolphinsearchbox.h index 2e4c6b85a..018612564 100644 --- a/src/search/dolphinsearchbox.h +++ b/src/search/dolphinsearchbox.h @@ -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 { diff --git a/src/search/dolphinsearchoptionsconfigurator.cpp b/src/search/dolphinsearchoptionsconfigurator.cpp index 4a92b7b45..d7a620ac1 100644 --- a/src/search/dolphinsearchoptionsconfigurator.cpp +++ b/src/search/dolphinsearchoptionsconfigurator.cpp @@ -1,4 +1,5 @@ /*************************************************************************** + * Copyright (C) 2009 by Peter Penz * * Copyright (C) 2009 by Peter Penz * * * * This program is free software; you can redistribute it and/or modify * @@ -19,8 +20,12 @@ #include "dolphinsearchoptionsconfigurator.h" +#include "searchcriterionselector.h" + #include +#include #include +#include #include #include @@ -29,45 +34,85 @@ #include 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(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" diff --git a/src/search/dolphinsearchoptionsconfigurator.h b/src/search/dolphinsearchoptionsconfigurator.h index 9b5a70b03..7fc0b5a4b 100644 --- a/src/search/dolphinsearchoptionsconfigurator.h +++ b/src/search/dolphinsearchoptionsconfigurator.h @@ -1,4 +1,5 @@ /*************************************************************************** + * Copyright (C) 2009 by Peter Penz * * Copyright (C) 2009 by Peter Penz * * * * This program is free software; you can redistribute it and/or modify * @@ -22,6 +23,13 @@ #include +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 index 000000000..bad53e851 --- /dev/null +++ b/src/search/searchcriteriondescription.cpp @@ -0,0 +1,56 @@ +/*************************************************************************** + * Copyright (C) 2009 by Adam Kidder * + * Copyright (C) 2009 by Peter Penz * + * * + * 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& 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::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 index 000000000..2bf3d2f91 --- /dev/null +++ b/src/search/searchcriteriondescription.h @@ -0,0 +1,67 @@ +/*************************************************************************** + * Copyright (C) 2009 by Adam Kidder * + * Copyright (C) 2009 by Peter Penz * + * * + * 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 +#include + +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& comparators, + SearchCriterionValue* valueWidget); + + virtual ~SearchCriterionDescription(); + + QString name() const; + QString identifier() const; + const QList& comparators() const; + SearchCriterionValue* valueWidget() const; + +private: + QString m_name; // user visible name that gets translated + QString m_identifier; // internal Nepomuk identifier + QList m_comparators; + SearchCriterionValue* m_valueWidget; +}; + +#endif // SEARCHCRITERIONDESCRIPTION_H diff --git a/src/search/searchcriterionselector.cpp b/src/search/searchcriterionselector.cpp new file mode 100644 index 000000000..831e743e7 --- /dev/null +++ b/src/search/searchcriterionselector.cpp @@ -0,0 +1,167 @@ +/*************************************************************************** + * Copyright (C) 2009 by Adam Kidder * + * Copyright (C) 2009 by Peter Penz * + * * + * 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 +#include +#include +#include + +#include +#include + +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 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 index 000000000..3720b53fb --- /dev/null +++ b/src/search/searchcriterionselector.h @@ -0,0 +1,95 @@ +/*************************************************************************** + * Copyright (C) 2009 by Adam Kidder * + * Copyright (C) 2009 by Peter Penz * + * * + * 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 +#include +#include + +#include + +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 m_descriptions; +}; + +#endif // SEARCHCRITERIONSELECTOR_H diff --git a/src/search/searchcriterionvalue.cpp b/src/search/searchcriterionvalue.cpp new file mode 100644 index 000000000..301344df6 --- /dev/null +++ b/src/search/searchcriterionvalue.cpp @@ -0,0 +1,94 @@ +/*************************************************************************** + * Copyright (C) 2009 by Adam Kidder * + * Copyright (C) 2009 by Peter Penz * + * * + * 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 +#include + +#include +#include +#include +#include + +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 index 000000000..cfabca24b --- /dev/null +++ b/src/search/searchcriterionvalue.h @@ -0,0 +1,81 @@ +/*************************************************************************** + * Copyright (C) 2009 by Adam Kidder * + * Copyright (C) 2009 by Peter Penz * + * * + * 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 + +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 -- 2.47.3