Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
a8801d15
Commit
a8801d15
authored
Mar 30, 2010
by
kh1
Browse files
Implement text highlight support after full text search.
parent
6ea66ca3
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/plugins/help/helpviewer.h
View file @
a8801d15
...
...
@@ -83,7 +83,7 @@ public:
bool
isBackwardAvailable
()
const
;
bool
findText
(
const
QString
&
text
,
Find
::
IFindSupport
::
FindFlags
flags
,
bool
incremental
);
bool
incremental
,
bool
fromSearch
);
static
QString
AboutBlankPage
;
static
QString
PageNotFoundMessage
;
...
...
src/plugins/help/helpviewer_qtb.cpp
View file @
a8801d15
...
...
@@ -53,6 +53,13 @@ HelpViewer::HelpViewer(qreal zoom, QWidget *parent)
:
QTextBrowser
(
parent
)
,
d
(
new
HelpViewerPrivate
(
zoom
))
{
QPalette
p
=
palette
();
p
.
setColor
(
QPalette
::
Inactive
,
QPalette
::
Highlight
,
p
.
color
(
QPalette
::
Active
,
QPalette
::
Highlight
));
p
.
setColor
(
QPalette
::
Inactive
,
QPalette
::
HighlightedText
,
p
.
color
(
QPalette
::
Active
,
QPalette
::
HighlightedText
));
setPalette
(
p
);
installEventFilter
(
this
);
document
()
->
setDocumentMargin
(
8
);
...
...
@@ -173,16 +180,16 @@ bool HelpViewer::isBackwardAvailable() const
}
bool
HelpViewer
::
findText
(
const
QString
&
text
,
IFindSupport
::
FindFlags
flags
,
bool
incremental
)
bool
incremental
,
bool
fromSearch
)
{
QTextDocument
*
doc
=
document
();
QTextCursor
cursor
=
textCursor
();
if
(
!
doc
||
cursor
.
isNull
())
return
false
;
const
int
position
=
cursor
.
selectionStart
();
if
(
incremental
)
cursor
.
setPosition
(
cursor
.
selectionStart
()
);
cursor
.
setPosition
(
position
);
QTextDocument
::
FindFlags
f
=
IFindSupport
::
textDocumentFlagsForFindFlags
(
flags
);
QTextCursor
found
=
doc
->
find
(
text
,
cursor
,
f
);
...
...
@@ -192,14 +199,33 @@ bool HelpViewer::findText(const QString &text, IFindSupport::FindFlags flags,
else
cursor
.
movePosition
(
QTextCursor
::
End
);
found
=
doc
->
find
(
text
,
cursor
,
f
);
if
(
found
.
isNull
())
{
return
false
;
}
if
(
fromSearch
)
{
cursor
.
beginEditBlock
();
viewport
()
->
setUpdatesEnabled
(
false
);
QTextCharFormat
marker
;
marker
.
setForeground
(
Qt
::
red
);
cursor
.
movePosition
(
QTextCursor
::
Start
);
setTextCursor
(
cursor
);
while
(
find
(
text
))
{
QTextCursor
hit
=
textCursor
();
hit
.
mergeCharFormat
(
marker
);
}
viewport
()
->
setUpdatesEnabled
(
true
);
cursor
.
endEditBlock
();
}
if
(
!
found
.
isNull
())
{
setTextCursor
(
found
);
bool
cursorIsNull
=
found
.
isNull
();
if
(
cursorIsNull
)
{
found
=
textCursor
();
found
.
setPosition
(
position
);
}
return
true
;
setTextCursor
(
found
);
return
cursorIsNull
;
}
// -- public slots
...
...
src/plugins/help/helpviewer_qwv.cpp
View file @
a8801d15
...
...
@@ -140,8 +140,8 @@ QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/,
}
const
QHelpEngineCore
&
engine
=
HelpManager
::
helpEngineCore
();
const
QByteArray
&
data
=
engine
.
findFile
(
url
).
isValid
()
?
engine
.
fileData
(
url
)
:
HelpViewer
::
PageNotFoundMessage
.
arg
(
url
.
toString
()).
toUtf8
();
const
QByteArray
&
data
=
engine
.
findFile
(
url
).
isValid
()
?
engine
.
fileData
(
url
)
:
HelpViewer
::
PageNotFoundMessage
.
arg
(
url
.
toString
()).
toUtf8
();
return
new
HelpNetworkReply
(
request
,
data
,
mimeType
);
}
...
...
@@ -329,9 +329,9 @@ bool HelpViewer::isBackwardAvailable() const
}
bool
HelpViewer
::
findText
(
const
QString
&
text
,
IFindSupport
::
FindFlags
flags
,
bool
incremental
)
bool
incremental
,
bool
fromSearch
)
{
Q_UNUSED
(
incremental
)
Q_UNUSED
(
(
incremental
&&
fromSearch
)
)
QWebPage
::
FindFlags
options
=
QWebPage
::
FindWrapsAroundDocument
;
if
(
flags
&
Find
::
IFindSupport
::
FindBackward
)
options
|=
QWebPage
::
FindBackward
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment