]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/search/dolphinsearchbox.cpp
SVN_SILENT: removed commented codephin with the column view a wrong layout has been...
[dolphin.git] / src / search / dolphinsearchbox.cpp
index f88f16f0afaed5400fe382466432cfb102931887..1dcb381ddeea91f23f6f343842f891c902228c67 100644 (file)
@@ -17,6 +17,7 @@
  *   Free Software Foundation, Inc.,                                       *
  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
  ***************************************************************************/
+
 #include "dolphinsearchbox.h"
 
 #include <config-nepomuk.h>
@@ -60,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"));
         }
@@ -96,7 +97,6 @@ DolphinSearchCompleter::DolphinSearchCompleter(KLineEdit* linedit) :
     view->setHeaderHidden(true);
 
     connect(q, SIGNAL(textEdited(QString)), this, SLOT(slotTextEdited(QString)));
-    connect(m_completer, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex)));
     connect(m_completer, SIGNAL(highlighted(QModelIndex)), this, SLOT(highlighted(QModelIndex)));
 }
 
@@ -233,22 +233,9 @@ void DolphinSearchCompleter::highlighted(const QModelIndex& index)
     q->setCursorPosition(wordStart + replace.length());
 }
 
-void DolphinSearchCompleter::activated(const QModelIndex& index)
-{
-    if ((m_wordStart == -1) || (m_wordStart == -1)) {
-        return;
-    }
-
-    const QString replace = index.sibling(index.row(), 0).data(Qt::UserRole).toString();
-    QString newText = q->text();
-    newText.replace(m_wordStart, m_wordEnd - m_wordStart + 1, replace);
-    q->setText(newText);
-}
-
 DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
     QWidget(parent),
     m_searchInput(0),
-    m_searchButton(0),
     m_completer(0)
 {
     QHBoxLayout* hLayout = new QHBoxLayout(this);
@@ -261,24 +248,21 @@ DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
     m_searchInput->setClickMessage(i18nc("@label:textbox", "Search..."));
     m_searchInput->installEventFilter(this);
     hLayout->addWidget(m_searchInput);
-    connect(m_searchInput, SIGNAL(textChanged(const QString&)),
-            this, SIGNAL(textChanged(const QString&)));
     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, SIGNAL(searchTextChanged(QString)));
 }
 
 DolphinSearchBox::~DolphinSearchBox()
 {
 }
 
+QString DolphinSearchBox::text() const
+{
+    return m_searchInput->text();
+}
+
 bool DolphinSearchBox::event(QEvent* event)
 {
     if (event->type() == QEvent::Polish) {
@@ -297,9 +281,10 @@ bool DolphinSearchBox::eventFilter(QObject* watched, QEvent* event)
         // Postpone the creation of the search completer until
         // the search box is used. This decreases the startup time
         // of Dolphin.
-        Q_ASSERT(m_completer == 0);
-        m_completer = new DolphinSearchCompleter(m_searchInput);
-        m_searchInput->removeEventFilter(this);
+        if (m_completer == 0) {
+            m_completer = new DolphinSearchCompleter(m_searchInput);
+        }
+        emit requestSearchOptions();
     }
 
     return QWidget::eventFilter(watched, event);
@@ -308,7 +293,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"