forked from qt-creator/qt-creator
Show wrap indicator also for searches in help views.
Task-number: QTCREATORBUG-2753
This commit is contained in:
@@ -167,9 +167,9 @@ void CentralWidget::setCurrentPage(HelpViewer *page)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CentralWidget::find(const QString &txt, Find::FindFlags flags,
|
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
|
// -- public slots
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public:
|
|||||||
void setCurrentPage(HelpViewer *page);
|
void setCurrentPage(HelpViewer *page);
|
||||||
|
|
||||||
bool find(const QString &txt, Find::FindFlags findFlags,
|
bool find(const QString &txt, Find::FindFlags findFlags,
|
||||||
bool incremental);
|
bool incremental, bool *wrapped = 0);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void copy();
|
void copy();
|
||||||
|
|||||||
@@ -75,16 +75,24 @@ QString HelpFindSupport::completedFindString() const
|
|||||||
Find::IFindSupport::Result HelpFindSupport::findIncremental(const QString &txt,
|
Find::IFindSupport::Result HelpFindSupport::findIncremental(const QString &txt,
|
||||||
Find::FindFlags findFlags)
|
Find::FindFlags findFlags)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_centralWidget, return NotFound);
|
|
||||||
findFlags &= ~Find::FindBackward;
|
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::IFindSupport::Result HelpFindSupport::findStep(const QString &txt,
|
||||||
Find::FindFlags findFlags)
|
Find::FindFlags findFlags)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_centralWidget, return NotFound);
|
return find(txt, findFlags, false) ? Found : NotFound;
|
||||||
return m_centralWidget->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
|
// -- HelpViewerFindSupport
|
||||||
@@ -125,5 +133,9 @@ bool HelpViewerFindSupport::find(const QString &txt,
|
|||||||
Find::FindFlags findFlags, bool incremental)
|
Find::FindFlags findFlags, bool incremental)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_viewer, return false);
|
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 isBackwardAvailable() const;
|
||||||
|
|
||||||
bool findText(const QString &text, Find::FindFlags flags,
|
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 NsNokia;
|
||||||
static const QString NsTrolltech;
|
static const QString NsTrolltech;
|
||||||
|
|||||||
@@ -191,8 +191,10 @@ bool HelpViewer::isBackwardAvailable() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool HelpViewer::findText(const QString &text, Find::FindFlags flags,
|
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();
|
QTextDocument *doc = document();
|
||||||
QTextCursor cursor = textCursor();
|
QTextCursor cursor = textCursor();
|
||||||
if (!doc || cursor.isNull())
|
if (!doc || cursor.isNull())
|
||||||
@@ -210,6 +212,8 @@ bool HelpViewer::findText(const QString &text, Find::FindFlags flags,
|
|||||||
else
|
else
|
||||||
cursor.movePosition(QTextCursor::End);
|
cursor.movePosition(QTextCursor::End);
|
||||||
found = doc->find(text, cursor, f);
|
found = doc->find(text, cursor, f);
|
||||||
|
if (!found.isNull() && wrapped)
|
||||||
|
*wrapped = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fromSearch) {
|
if (fromSearch) {
|
||||||
|
|||||||
@@ -344,17 +344,25 @@ bool HelpViewer::isBackwardAvailable() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool HelpViewer::findText(const QString &text, Find::FindFlags flags,
|
bool HelpViewer::findText(const QString &text, Find::FindFlags flags,
|
||||||
bool incremental, bool fromSearch)
|
bool incremental, bool fromSearch, bool *wrapped)
|
||||||
{
|
{
|
||||||
Q_UNUSED(incremental);
|
Q_UNUSED(incremental);
|
||||||
Q_UNUSED(fromSearch);
|
Q_UNUSED(fromSearch);
|
||||||
QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument;
|
if (wrapped)
|
||||||
|
*wrapped = false;
|
||||||
|
QWebPage::FindFlags options;
|
||||||
if (flags & Find::FindBackward)
|
if (flags & Find::FindBackward)
|
||||||
options |= QWebPage::FindBackward;
|
options |= QWebPage::FindBackward;
|
||||||
if (flags & Find::FindCaseSensitively)
|
if (flags & Find::FindCaseSensitively)
|
||||||
options |= QWebPage::FindCaseSensitively;
|
options |= QWebPage::FindCaseSensitively;
|
||||||
|
|
||||||
bool found = QWebView::findText(text, options);
|
bool found = QWebView::findText(text, options);
|
||||||
|
if (!found) {
|
||||||
|
options |= QWebPage::FindWrapsAroundDocument;
|
||||||
|
found = QWebView::findText(text, options);
|
||||||
|
if (found && wrapped)
|
||||||
|
*wrapped = true;
|
||||||
|
}
|
||||||
options = QWebPage::HighlightAllOccurrences;
|
options = QWebPage::HighlightAllOccurrences;
|
||||||
QWebView::findText(QLatin1String(""), options); // clear first
|
QWebView::findText(QLatin1String(""), options); // clear first
|
||||||
QWebView::findText(text, options); // force highlighting of all other matches
|
QWebView::findText(text, options); // force highlighting of all other matches
|
||||||
|
|||||||
Reference in New Issue
Block a user