Commit 7915ce6b authored by con's avatar con
Browse files

Show wrap indicator also for searches in help views.

Task-number: QTCREATORBUG-2753
parent ebb9e252
......@@ -167,9 +167,9 @@ void CentralWidget::setCurrentPage(HelpViewer *page)
}
bool CentralWidget::find(const QString &txt, Find::FindFlags flags,
bool incremental)
bool incremental, bool *wrapped)
{
return currentHelpViewer()->findText(txt, flags, incremental, false);
return currentHelpViewer()->findText(txt, flags, incremental, false, wrapped);
}
// -- public slots
......
......@@ -73,7 +73,7 @@ public:
void setCurrentPage(HelpViewer *page);
bool find(const QString &txt, Find::FindFlags findFlags,
bool incremental);
bool incremental, bool *wrapped = 0);
public slots:
void copy();
......
......@@ -75,16 +75,24 @@ QString HelpFindSupport::completedFindString() const
Find::IFindSupport::Result HelpFindSupport::findIncremental(const QString &txt,
Find::FindFlags findFlags)
{
QTC_ASSERT(m_centralWidget, return NotFound);
findFlags &= ~Find::FindBackward;
return m_centralWidget->find(txt, findFlags, true) ? Found : NotFound;
return find(txt, findFlags, true) ? Found : NotFound;
}
Find::IFindSupport::Result HelpFindSupport::findStep(const QString &txt,
Find::FindFlags findFlags)
{
QTC_ASSERT(m_centralWidget, return NotFound);
return m_centralWidget->find(txt, findFlags, false) ? Found : NotFound;
return find(txt, findFlags, false) ? Found : NotFound;
}
bool HelpFindSupport::find(const QString &txt, Find::FindFlags findFlags, bool incremental)
{
QTC_ASSERT(m_centralWidget, return false);
bool wrapped = false;
bool found = m_centralWidget->find(txt, findFlags, incremental, &wrapped);
if (wrapped)
showWrapIndicator(m_centralWidget);
return found;
}
// -- HelpViewerFindSupport
......@@ -125,5 +133,9 @@ bool HelpViewerFindSupport::find(const QString &txt,
Find::FindFlags findFlags, bool incremental)
{
QTC_ASSERT(m_viewer, return false);
return m_viewer->findText(txt, findFlags, incremental, false);
bool wrapped = false;
bool found = m_viewer->findText(txt, findFlags, incremental, false, &wrapped);
if (wrapped)
showWrapIndicator(m_viewer);
return found;
}
......@@ -87,7 +87,7 @@ public:
bool isBackwardAvailable() const;
bool findText(const QString &text, Find::FindFlags flags,
bool incremental, bool fromSearch);
bool incremental, bool fromSearch, bool *wrapped = 0);
static const QString NsNokia;
static const QString NsTrolltech;
......
......@@ -191,8 +191,10 @@ bool HelpViewer::isBackwardAvailable() const
}
bool HelpViewer::findText(const QString &text, Find::FindFlags flags,
bool incremental, bool fromSearch)
bool incremental, bool fromSearch, bool *wrapped)
{
if (wrapped)
*wrapped = false;
QTextDocument *doc = document();
QTextCursor cursor = textCursor();
if (!doc || cursor.isNull())
......@@ -210,6 +212,8 @@ bool HelpViewer::findText(const QString &text, Find::FindFlags flags,
else
cursor.movePosition(QTextCursor::End);
found = doc->find(text, cursor, f);
if (!found.isNull() && wrapped)
*wrapped = true;
}
if (fromSearch) {
......
......@@ -344,17 +344,25 @@ bool HelpViewer::isBackwardAvailable() const
}
bool HelpViewer::findText(const QString &text, Find::FindFlags flags,
bool incremental, bool fromSearch)
bool incremental, bool fromSearch, bool *wrapped)
{
Q_UNUSED(incremental);
Q_UNUSED(fromSearch);
QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument;
if (wrapped)
*wrapped = false;
QWebPage::FindFlags options;
if (flags & Find::FindBackward)
options |= QWebPage::FindBackward;
if (flags & Find::FindCaseSensitively)
options |= QWebPage::FindCaseSensitively;
bool found = QWebView::findText(text, options);
if (!found) {
options |= QWebPage::FindWrapsAroundDocument;
found = QWebView::findText(text, options);
if (found && wrapped)
*wrapped = true;
}
options = QWebPage::HighlightAllOccurrences;
QWebView::findText(QLatin1String(""), options); // clear first
QWebView::findText(text, options); // force highlighting of all other matches
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment