* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
+
#include "dolphinsearchbox.h"
#include <config-nepomuk.h>
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"));
}
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)));
}
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);
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) {
// 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);
void DolphinSearchBox::emitSearchSignal()
{
- emit search(KUrl("nepomuksearch:/" + m_searchInput->text()));
+ emit search(m_searchInput->text());
}
#include "dolphinsearchbox.moc"