Commit dae0ef14 authored by Mark Nauwelaerts's avatar Mark Nauwelaerts
Browse files

S&R: update highlight upon check toggle

parent f9025736
......@@ -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);
......
......@@ -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;
......
Markdown is supported
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