diff --git a/src/searchbar.cpp b/src/searchbar.cpp index bc330bd..0bfbf81 100644 --- a/src/searchbar.cpp +++ b/src/searchbar.cpp @@ -62,15 +62,11 @@ SearchBar::SearchBar(QWidget *parent) : { setPlaceholderText(tr("Search")); m_completer.setCompletionMode(QCompleter::UnfilteredPopupCompletion); + m_completer.setCaseSensitivity(Qt::CaseInsensitive); setCompleter(&m_completer); connect(this, &QLineEdit::textEdited, this, &SearchBar::updateCompletion); -#if 0 //The `activated` signal seems to not be emitted if user navigate in the page. - // Something is broken here .. :/ connect(&m_completer, QOverload::of(&QCompleter::activated), this, &SearchBar::openCompletion); -#else - connect(this, &QLineEdit::returnPressed, this, &SearchBar::openTitle); -#endif connect(KiwixApp::instance(), &KiwixApp::currentTitleChanged, this, &SearchBar::on_currentTitleChanged); } @@ -115,33 +111,6 @@ void SearchBar::updateCompletion(const QString &text) m_completionModel.setStringList(wordList); } -void SearchBar::openTitle() -{ - QString title = text(); - clear(); - auto tabWidget = KiwixApp::instance()->getTabWidget(); - auto zimId = tabWidget->currentZimId(); - auto reader = KiwixApp::instance()->getLibrary()->getReader(zimId); - if ( reader == nullptr) { - return; - } - std::string path; - try { - auto entry = reader->getEntryFromTitle(title.toStdString()); - path = entry.getPath(); - } catch (kiwix::NoEntry& e) - { - return; - } - - QUrl qurl; - qurl.setScheme("zim"); - qurl.setHost(zimId+".zim"); - qurl.setPath("/" + QString::fromStdString(path)); - QTimer::singleShot(0, [=](){KiwixApp::instance()->openUrl(qurl, false);}); - clearFocus(); -} - void SearchBar::openCompletion(const QModelIndex &index) { auto url = m_urlList.at(index.row()); diff --git a/src/searchbar.h b/src/searchbar.h index 21372ff..dfa99e3 100644 --- a/src/searchbar.h +++ b/src/searchbar.h @@ -40,7 +40,6 @@ private: private slots: void updateCompletion(const QString& text); void openCompletion(const QModelIndex& index); - void openTitle(); }; #endif // SEARCHBAR_H