]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/search/dolphinsearchbox.cpp
Get back names, and use "using" keyword to keep GCC silent on "method foo on base...
[dolphin.git] / src / search / dolphinsearchbox.cpp
index c9a86111f643e5611678af7340c1250998731082..7eb7206acb850edfaccd2b50eeaa6e173093e75a 100644 (file)
@@ -61,8 +61,8 @@ DolphinSearchCompleter::DolphinSearchCompleter(KLineEdit* linedit) :
         foreach (const Nepomuk::Tag& tag, tags) {
             const QString tagText = tag.label();
             addCompletionItem(tagText,
-                              "tag:\"" + tagText + '\"',
-                              i18nc("Tag as in Nepomuk::Tag", "Tag"),
+                              "hasTag:\"" + tagText + '\"',
+                              i18nc("Tag as in Nepomuk::Tag", "Tag"), // TODO: change to "hasTag" after msg freeze
                               QString(),
                               KIcon("mail-tagged"));
         }
@@ -236,7 +236,6 @@ void DolphinSearchCompleter::highlighted(const QModelIndex& index)
 DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
     QWidget(parent),
     m_searchInput(0),
-    m_searchButton(0),
     m_completer(0)
 {
     QHBoxLayout* hLayout = new QHBoxLayout(this);
@@ -251,20 +250,21 @@ DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
     hLayout->addWidget(m_searchInput);
     connect(m_searchInput, SIGNAL(returnPressed()),
             this, SLOT(emitSearchSignal()));
-
-    m_searchButton = new QToolButton(this);
-    m_searchButton->setAutoRaise(true);
-    m_searchButton->setIcon(KIcon("edit-find"));
-    m_searchButton->setToolTip(i18nc("@info:tooltip", "Click to begin the search"));
-    hLayout->addWidget(m_searchButton);
-    connect(m_searchButton, SIGNAL(clicked()),
-            this, SLOT(emitSearchSignal()));
+    connect(m_searchInput, SIGNAL(textChanged(QString)),
+            this, SLOT(slotTextChanged(QString)));
+    connect(m_searchInput, SIGNAL(clearButtonClicked()),
+            this, SLOT(slotClearButtonClicked()));
 }
 
 DolphinSearchBox::~DolphinSearchBox()
 {
 }
 
+QString DolphinSearchBox::text() const
+{
+    return m_searchInput->text();
+}
+
 bool DolphinSearchBox::event(QEvent* event)
 {
     if (event->type() == QEvent::Polish) {
@@ -286,7 +286,9 @@ bool DolphinSearchBox::eventFilter(QObject* watched, QEvent* event)
         if (m_completer == 0) {
             m_completer = new DolphinSearchCompleter(m_searchInput);
         }
-        emit requestSearchOptions();
+        if (m_searchInput->text().isEmpty()) {
+            emit requestSearchOptions();
+        }
     }
 
     return QWidget::eventFilter(watched, event);
@@ -295,7 +297,15 @@ bool DolphinSearchBox::eventFilter(QObject* watched, QEvent* event)
 
 void DolphinSearchBox::emitSearchSignal()
 {
-    emit search(KUrl("nepomuksearch:/" + m_searchInput->text()));
+    emit search(m_searchInput->text());
+}
+
+void DolphinSearchBox::slotTextChanged(const QString& text)
+{
+    if (!text.isEmpty()) {
+        emit requestSearchOptions();
+    }
+    emit searchTextChanged(text);
 }
 
 #include "dolphinsearchbox.moc"