From: Peter Penz Date: Tue, 10 Nov 2009 22:18:45 +0000 (+0000) Subject: Added some default search criterions. A lot of fine tuning of the UI has to be made... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/0d448fc6f31503731ec1bc57f65750263ccc4da5 Added some default search criterions. A lot of fine tuning of the UI has to be made ASAP, but all in all I think it is more efficient to have some default criterions already instead of the need to press the (+) icon for each option. svn path=/trunk/KDE/kdebase/apps/; revision=1047298 --- diff --git a/src/search/dolphinsearchoptionsconfigurator.cpp b/src/search/dolphinsearchoptionsconfigurator.cpp index cebf71cdb..6f4d83460 100644 --- a/src/search/dolphinsearchoptionsconfigurator.cpp +++ b/src/search/dolphinsearchoptionsconfigurator.cpp @@ -92,8 +92,17 @@ DolphinSearchOptionsConfigurator::DolphinSearchOptionsConfigurator(QWidget* pare hBoxLayout->addWidget(closeButton); hBoxLayout->addWidget(m_addSelectorButton); + // add default search criterions + SearchCriterionSelector* dateCriterion = new SearchCriterionSelector(SearchCriterionSelector::Date, this); + connect(dateCriterion, SIGNAL(removeCriterion()), this, SLOT(removeCriterion())); + + SearchCriterionSelector* fileSizeCriterion = new SearchCriterionSelector(SearchCriterionSelector::FileSize, this); + connect(fileSizeCriterion, SIGNAL(removeCriterion()), this, SLOT(removeCriterion())); + m_vBoxLayout->addWidget(new KSeparator(this)); m_vBoxLayout->addLayout(hBoxLayout); + m_vBoxLayout->addWidget(dateCriterion); + m_vBoxLayout->addWidget(fileSizeCriterion); m_vBoxLayout->addWidget(new KSeparator(this)); } @@ -103,7 +112,7 @@ DolphinSearchOptionsConfigurator::~DolphinSearchOptionsConfigurator() void DolphinSearchOptionsConfigurator::addSelector() { - SearchCriterionSelector* selector = new SearchCriterionSelector(this); + SearchCriterionSelector* selector = new SearchCriterionSelector(SearchCriterionSelector::Undefined, this); connect(selector, SIGNAL(removeCriterion()), this, SLOT(removeCriterion())); // insert the new selector before the KSeparator at the bottom diff --git a/src/search/searchcriterionselector.cpp b/src/search/searchcriterionselector.cpp index 831e743e7..34b8d0c51 100644 --- a/src/search/searchcriterionselector.cpp +++ b/src/search/searchcriterionselector.cpp @@ -30,7 +30,7 @@ #include #include -SearchCriterionSelector::SearchCriterionSelector(QWidget* parent) : +SearchCriterionSelector::SearchCriterionSelector(Type type, QWidget* parent) : QWidget(parent), m_layout(0), m_descriptionsBox(0), @@ -64,6 +64,20 @@ SearchCriterionSelector::SearchCriterionSelector(QWidget* parent) : m_layout->addWidget(m_removeButton); setLayout(m_layout); + + // preselect the used criterion dependent on the type + switch (type) { + case Date: + m_descriptionsBox->setCurrentIndex(1); + m_comparatorBox->setCurrentIndex(1); + break; + case FileSize: + m_descriptionsBox->setCurrentIndex(2); + break; + case Undefined: + default: + break; + } } SearchCriterionSelector::~SearchCriterionSelector() @@ -74,19 +88,27 @@ 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"), "<=", "+")); + QList comperators; + comperators.append(SearchCriterionDescription::Comparator(i18nc("@label", "Greater Than"), ">", "+")); + comperators.append(SearchCriterionDescription::Comparator(i18nc("@label", "Greater Than or Equal to"), ">=", "+")); + comperators.append(SearchCriterionDescription::Comparator(i18nc("@label", "Less Than"), "<", "+")); + comperators.append(SearchCriterionDescription::Comparator(i18nc("@label", "Less Than or Equal to"), "<=", "+")); // add "Date" description + QList dateComps; + dateComps.append(SearchCriterionDescription::Comparator(i18nc("@label", "Anytime"), "", "")); // TODO + dateComps.append(SearchCriterionDescription::Comparator(i18nc("@label", "Today"), ">", "+")); // TODO + dateComps.append(SearchCriterionDescription::Comparator(i18nc("@label", "This week"), ">", "+")); // TODO + dateComps.append(SearchCriterionDescription::Comparator(i18nc("@label", "This month"), ">", "+")); // TODO + foreach (const SearchCriterionDescription::Comparator& comp, comperators) { + dateComps.append(comp); + } + DateValue* dateValue = new DateValue(this); dateValue->hide(); SearchCriterionDescription date(i18nc("@label", "Date Modified"), "sourceModified", - comparators, + dateComps, dateValue); // add "File Size" description @@ -94,7 +116,7 @@ void SearchCriterionSelector::createDescriptions() fileSizeValue->hide(); SearchCriterionDescription size(i18nc("@label", "File Size"), "contentSize", - comparators, + comperators, fileSizeValue); m_descriptions.append(date); diff --git a/src/search/searchcriterionselector.h b/src/search/searchcriterionselector.h index 3720b53fb..f83d28df8 100644 --- a/src/search/searchcriterionselector.h +++ b/src/search/searchcriterionselector.h @@ -45,7 +45,14 @@ class SearchCriterionSelector : public QWidget Q_OBJECT public: - SearchCriterionSelector(QWidget* parent = 0); + enum Type + { + Undefined, + Date, + FileSize + }; + + SearchCriterionSelector(Type type, QWidget* parent = 0); virtual ~SearchCriterionSelector(); signals: