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
Utilities
Kate
Commits
dae0ef14
Commit
dae0ef14
authored
May 20, 2021
by
Mark Nauwelaerts
Browse files
S&R: update highlight upon check toggle
parent
f9025736
Changes
2
Hide whitespace changes
Inline
Side-by-side
addons/search/plugin_search.cpp
View file @
dae0ef14
...
...
@@ -451,6 +451,10 @@ KatePluginSearchView::KatePluginSearchView(KTextEditor::Plugin *plugin, KTextEdi
m_diskSearchDoneTimer
.
setInterval
(
10
);
connect
(
&
m_diskSearchDoneTimer
,
&
QTimer
::
timeout
,
this
,
&
KatePluginSearchView
::
searchDone
);
m_updateCheckedStateTimer
.
setSingleShot
(
true
);
m_updateCheckedStateTimer
.
setInterval
(
10
);
connect
(
&
m_updateCheckedStateTimer
,
&
QTimer
::
timeout
,
this
,
&
KatePluginSearchView
::
updateMatchMarks
);
// queued connect to signals emitted outside of background thread
connect
(
&
m_folderFilesList
,
&
FolderFilesList
::
fileListReady
,
this
,
&
KatePluginSearchView
::
folderFileListChanged
,
Qt
::
QueuedConnection
);
connect
(
...
...
@@ -1535,6 +1539,22 @@ void KatePluginSearchView::addRangeAndMark(KTextEditor::Document *doc,
iface
->
addMark
(
match
.
range
.
start
().
line
(),
KTextEditor
::
MarkInterface
::
markType32
);
}
void
KatePluginSearchView
::
updateCheckState
(
const
QModelIndex
&
topLeft
,
const
QModelIndex
&
bottomRight
,
const
QVector
<
int
>
&
roles
)
{
Q_UNUSED
(
topLeft
);
Q_UNUSED
(
bottomRight
);
// check tailored to the way signal is raised by the model
// keep the check simple in case each one is one of many
if
(
roles
.
size
()
==
0
||
roles
.
size
()
>
1
||
roles
[
0
]
!=
Qt
::
CheckStateRole
)
{
return
;
}
// more updates might follow, let's batch those
if
(
!
m_updateCheckedStateTimer
.
isActive
())
{
m_updateCheckedStateTimer
.
start
();
}
}
void
KatePluginSearchView
::
updateMatchMarks
()
{
// We only keep marks & ranges for one document at a time so clear the rest
...
...
@@ -1562,6 +1582,8 @@ void KatePluginSearchView::updateMatchMarks()
// clang-format on
// Re-add the highlighting on document reload
connect
(
doc
,
&
KTextEditor
::
Document
::
reloaded
,
this
,
&
KatePluginSearchView
::
updateMatchMarks
,
Qt
::
UniqueConnection
);
// Re-do highlight upon check mark update
connect
(
&
res
->
matchModel
,
&
QAbstractItemModel
::
dataChanged
,
this
,
&
KatePluginSearchView
::
updateCheckState
,
Qt
::
UniqueConnection
);
KTextEditor
::
MovingInterface
*
miface
=
qobject_cast
<
KTextEditor
::
MovingInterface
*>
(
doc
);
...
...
addons/search/plugin_search.h
View file @
dae0ef14
...
...
@@ -149,6 +149,7 @@ private Q_SLOTS:
void
replaceDone
();
void
updateCheckState
(
const
QModelIndex
&
topLeft
,
const
QModelIndex
&
bottomRight
,
const
QVector
<
int
>
&
roles
);
void
updateMatchMarks
();
void
syncModelRanges
();
...
...
@@ -200,6 +201,7 @@ private:
QThreadPool
m_searchDiskFilePool
;
QTimer
m_diskSearchDoneTimer
;
QTimer
m_updateCheckedStateTimer
;
QAction
*
m_matchCase
=
nullptr
;
QAction
*
m_useRegExp
=
nullptr
;
Results
*
m_curResults
=
nullptr
;
...
...
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