From 983f2f1af4afeaa0539ffe533626233becf28a75 Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Fri, 19 Feb 2010 15:10:40 +0100 Subject: Workaround the bug of qtwebkit in the function findText(). An empty string doesn't clear the selection. --- src/mainwindow.cpp | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e3beb60a..f9f211ca 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -773,33 +773,57 @@ void MainWindow::find(const QString & search) if (!currentTab()) return; m_lastSearch = search; + + if(m_lastSearch.isEmpty()) + { + currentTab()->view()->page()->focusNextPrevChild(true); + return; + } findNext(); } void MainWindow::findNext() { - if (!currentTab() && m_lastSearch.isEmpty()) + if (!currentTab()) return; + if(m_lastSearch.isEmpty() || m_findBar->isHidden()) + { + currentTab()->view()->page()->focusNextPrevChild(true); + return; + } + QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument; if (m_findBar->matchCase()) options |= QWebPage::FindCaseSensitively; - m_findBar->notifyMatch(currentTab()->view()->findText(m_lastSearch, options)); + bool found = currentTab()->view()->findText(m_lastSearch, options); + m_findBar->notifyMatch(found); + if(!found) + currentTab()->view()->page()->focusNextPrevChild(true); } void MainWindow::findPrevious() { - if (!currentTab() && m_lastSearch.isEmpty()) + if (!currentTab()) return; + if(m_lastSearch.isEmpty() || m_findBar->isHidden()) + { + currentTab()->view()->page()->focusNextPrevChild(true); + return; + } + QWebPage::FindFlags options = QWebPage::FindBackward | QWebPage::FindWrapsAroundDocument; if (m_findBar->matchCase()) options |= QWebPage::FindCaseSensitively; - m_findBar->notifyMatch(currentTab()->view()->findText(m_lastSearch, options)); + bool found = currentTab()->view()->findText(m_lastSearch, options); + m_findBar->notifyMatch(found); + if(!found) + currentTab()->view()->page()->focusNextPrevChild(true); } -- cgit v1.2.1