┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/search
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2009-11-13 21:03:19 +0000
committerPeter Penz <[email protected]>2009-11-13 21:03:19 +0000
commitbd30bb6ca98374b37db20d14a41542c21acdd5e0 (patch)
tree276188af9fe38b22cd6698a53269fcffac318736 /src/search
parenta87760d22c0213306380322ec6d9e23809ee4c93 (diff)
search finetuning:
* trigger progress information when starting a search * let the information panel hide the meta data for the search string * get the search string from the configurator svn path=/trunk/KDE/kdebase/apps/; revision=1048721
Diffstat (limited to 'src/search')
-rw-r--r--src/search/dolphinsearchbox.cpp7
-rw-r--r--src/search/dolphinsearchbox.h17
-rw-r--r--src/search/dolphinsearchoptionsconfigurator.cpp35
-rw-r--r--src/search/dolphinsearchoptionsconfigurator.h8
-rw-r--r--src/search/searchcriterionselector.cpp12
-rw-r--r--src/search/searchcriterionselector.h6
6 files changed, 65 insertions, 20 deletions
diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp
index 9f228140b..4375974a4 100644
--- a/src/search/dolphinsearchbox.cpp
+++ b/src/search/dolphinsearchbox.cpp
@@ -256,6 +256,11 @@ DolphinSearchBox::~DolphinSearchBox()
{
}
+QString DolphinSearchBox::text() const
+{
+ return m_searchInput->text();
+}
+
bool DolphinSearchBox::event(QEvent* event)
{
if (event->type() == QEvent::Polish) {
@@ -286,7 +291,7 @@ bool DolphinSearchBox::eventFilter(QObject* watched, QEvent* event)
void DolphinSearchBox::emitSearchSignal()
{
- emit search(KUrl("nepomuksearch:/" + m_searchInput->text()));
+ emit search(m_searchInput->text());
}
#include "dolphinsearchbox.moc"
diff --git a/src/search/dolphinsearchbox.h b/src/search/dolphinsearchbox.h
index fea7129b1..36bcb0e10 100644
--- a/src/search/dolphinsearchbox.h
+++ b/src/search/dolphinsearchbox.h
@@ -69,6 +69,12 @@ public:
DolphinSearchBox(QWidget* parent = 0);
virtual ~DolphinSearchBox();
+ /**
+ * Returns the text that should be used as input
+ * for searching.
+ */
+ QString text() const;
+
protected:
virtual bool event(QEvent* event);
virtual bool eventFilter(QObject* watched, QEvent* event);
@@ -76,11 +82,17 @@ protected:
signals:
/**
* Is emitted when the user pressed Return or Enter
- * and provides the Nepomuk URL that should be used
+ * and provides the text that should be used as input
* for searching.
*/
- void search(const KUrl& url);
+ void search(const QString& text);
+ /**
+ * Is emitted if the search box gets the focus and
+ * requests the need for a UI that allows to adjust
+ * search options. It is up to the application to ignore
+ * this request.
+ */
void requestSearchOptions();
private slots:
@@ -88,7 +100,6 @@ private slots:
private:
KLineEdit* m_searchInput;
-
DolphinSearchCompleter* m_completer;
};
diff --git a/src/search/dolphinsearchoptionsconfigurator.cpp b/src/search/dolphinsearchoptionsconfigurator.cpp
index d0b7cace2..db51f2c42 100644
--- a/src/search/dolphinsearchoptionsconfigurator.cpp
+++ b/src/search/dolphinsearchoptionsconfigurator.cpp
@@ -35,8 +35,6 @@
#include <QShowEvent>
#include <QVBoxLayout>
-#include <kdebug.h>
-
DolphinSearchOptionsConfigurator::DolphinSearchOptionsConfigurator(QWidget* parent) :
QWidget(parent),
m_initialized(false),
@@ -69,6 +67,7 @@ DolphinSearchOptionsConfigurator::DolphinSearchOptionsConfigurator(QWidget* pare
searchButton->setIcon(KIcon("edit-find"));
searchButton->setText(i18nc("@action:button", "Search"));
searchButton->setToolTip(i18nc("@info", "Start searching"));
+ connect(searchButton, SIGNAL(clicked()), this, SLOT(emitSearchOptionsChanged()));
// add button "Save"
QPushButton* saveButton = new QPushButton(this);
@@ -115,6 +114,21 @@ DolphinSearchOptionsConfigurator::~DolphinSearchOptionsConfigurator()
{
}
+QString DolphinSearchOptionsConfigurator::options() const
+{
+ QString searchOptions;
+ foreach (const SearchCriterionSelector* criterion, m_criterions) {
+ const QString criterionString = criterion->toString();
+ if (!criterionString.isEmpty()) {
+ if (!searchOptions.isEmpty()) {
+ searchOptions += ' ';
+ }
+ searchOptions += criterionString;
+ }
+ }
+ return searchOptions;
+}
+
void DolphinSearchOptionsConfigurator::showEvent(QShowEvent* event)
{
if (!event->spontaneous() && !m_initialized) {
@@ -143,14 +157,9 @@ void DolphinSearchOptionsConfigurator::slotAddSelectorButtonClicked()
addCriterion(selector);
}
-void DolphinSearchOptionsConfigurator::slotCriterionChanged()
+void DolphinSearchOptionsConfigurator::emitSearchOptionsChanged()
{
- QString searchOptions;
- foreach (const SearchCriterionSelector* criterion, m_criterions) {
- searchOptions += criterion->queryString() + ' ';
- }
- kDebug() << "Search option string:" << searchOptions;
- emit searchOptionsChanged(searchOptions);
+ emit searchOptionsChanged(options());
}
void DolphinSearchOptionsConfigurator::removeCriterion()
@@ -201,8 +210,12 @@ void DolphinSearchOptionsConfigurator::saveQuery()
void DolphinSearchOptionsConfigurator::addCriterion(SearchCriterionSelector* criterion)
{
- connect(criterion, SIGNAL(removeCriterion()), this, SLOT(removeCriterion()));
- connect(criterion, SIGNAL(criterionChanged()), this, SLOT(slotCriterionChanged()));
+ connect(criterion, SIGNAL(removeCriterion()), this, SLOT(removeCriterion()));
+ // TODO: It is unclear yet whether changing a criterion should also result in triggering
+ // a searchOptionsChanged() signal. This mainly depends on the performance achievable with
+ // Nepomuk. Currently the searchOptionsChanged() signal is only emitted when the search-button
+ // has been triggered by the user.
+ // connect(criterion, SIGNAL(criterionChanged()), this, SLOT(emitSearchOptionsChanged()));
// insert the new selector before the lastLineLayout and the KSeparator at the bottom
const int index = m_vBoxLayout->count() - 2;
diff --git a/src/search/dolphinsearchoptionsconfigurator.h b/src/search/dolphinsearchoptionsconfigurator.h
index 46950e422..5bceaceea 100644
--- a/src/search/dolphinsearchoptionsconfigurator.h
+++ b/src/search/dolphinsearchoptionsconfigurator.h
@@ -39,6 +39,12 @@ public:
DolphinSearchOptionsConfigurator(QWidget* parent = 0);
virtual ~DolphinSearchOptionsConfigurator();
+ /**
+ * Returns the configured options as compliant
+ * string that may be used as input for a nepomuk:/-URI.
+ */
+ QString options() const;
+
signals:
void searchOptionsChanged(const QString& options);
@@ -48,7 +54,7 @@ protected:
private slots:
void slotAddSelectorButtonClicked();
- void slotCriterionChanged();
+ void emitSearchOptionsChanged();
void removeCriterion();
diff --git a/src/search/searchcriterionselector.cpp b/src/search/searchcriterionselector.cpp
index f685e50fc..4b6112b9c 100644
--- a/src/search/searchcriterionselector.cpp
+++ b/src/search/searchcriterionselector.cpp
@@ -74,7 +74,7 @@ SearchCriterionSelector::~SearchCriterionSelector()
{
}
-QString SearchCriterionSelector::queryString() const
+QString SearchCriterionSelector::toString() const
{
if (m_valueWidget == 0) {
return QString();
@@ -85,9 +85,15 @@ QString SearchCriterionSelector::queryString() const
const int compIndex = m_comparatorBox->currentIndex();
const SearchCriterionDescription::Comparator& comp = descr.comparators()[compIndex];
+ if (comp.operation.isEmpty()) {
+ return QString();
+ }
- return comp.prefix + descr.identifier() + comp.operation +
- '"' + m_valueWidget->value() + '"';
+ QString criterion = comp.prefix + descr.identifier() + comp.operation;
+ if (!m_valueWidget->value().isEmpty()) {
+ criterion += '"' + m_valueWidget->value() + '"';
+ }
+ return criterion;
}
void SearchCriterionSelector::slotDescriptionChanged(int index)
diff --git a/src/search/searchcriterionselector.h b/src/search/searchcriterionselector.h
index c6c3b22e0..27cbb2e46 100644
--- a/src/search/searchcriterionselector.h
+++ b/src/search/searchcriterionselector.h
@@ -50,7 +50,11 @@ public:
SearchCriterionSelector(Type type, QWidget* parent = 0);
virtual ~SearchCriterionSelector();
- QString queryString() const;
+ /**
+ * Converts the string representation of the criterion.
+ * The string is conform to get added to a nepomuk:/-URI.
+ */
+ QString toString() const;
signals:
/**