diff options
| author | Peter Penz <[email protected]> | 2009-10-23 21:06:33 +0000 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2009-10-23 21:06:33 +0000 |
| commit | efecb5021cc7855caa05117ebbe74608f5c863f2 (patch) | |
| tree | 517df3bc5d22130997a5669a4c50c92a3ddb2865 /src/search/dolphinsearchoptionsconfigurator.cpp | |
| parent | 66995e1a8f0b8a4001c1d4500f807277d685ab7f (diff) | |
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
Diffstat (limited to 'src/search/dolphinsearchoptionsconfigurator.cpp')
| -rw-r--r-- | src/search/dolphinsearchoptionsconfigurator.cpp | 75 |
1 files changed, 60 insertions, 15 deletions
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,5 +1,6 @@ /*************************************************************************** * Copyright (C) 2009 by Peter Penz <[email protected]> * + * Copyright (C) 2009 by Peter Penz <[email protected]> * * * * 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 * @@ -19,8 +20,12 @@ #include "dolphinsearchoptionsconfigurator.h" +#include "searchcriterionselector.h" + #include <kcombobox.h> +#include <kicon.h> #include <klocale.h> +#include <kseparator.h> #include <QButtonGroup> #include <QHBoxLayout> @@ -29,45 +34,85 @@ #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" |
