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
da7b931c
Commit
da7b931c
authored
Mar 07, 2021
by
Kåre Särs
Committed by
Christoph Cullmann
Mar 08, 2021
Browse files
Disable search commands while searching/replacing
parent
e9e2353d
Changes
4
Hide whitespace changes
Inline
Side-by-side
addons/search/KateSearchCommand.cpp
View file @
da7b931c
...
...
@@ -16,8 +16,16 @@ KateSearchCommand::KateSearchCommand(QObject *parent)
{
}
void
KateSearchCommand
::
setBusy
(
bool
busy
)
{
m_busy
=
busy
;
}
bool
KateSearchCommand
::
exec
(
KTextEditor
::
View
*
/*view*/
,
const
QString
&
cmd
,
QString
&
/*msg*/
,
const
KTextEditor
::
Range
&
)
{
if
(
m_busy
)
{
return
false
;
}
// create a list of args
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
QStringList
args
(
cmd
.
split
(
QLatin1Char
(
' '
),
QString
::
KeepEmptyParts
));
...
...
addons/search/KateSearchCommand.h
View file @
da7b931c
...
...
@@ -22,6 +22,8 @@ class KateSearchCommand : public KTextEditor::Command
public:
KateSearchCommand
(
QObject
*
parent
);
void
setBusy
(
bool
busy
);
Q_SIGNALS:
void
setSearchPlace
(
int
place
);
void
setCurrentFolder
();
...
...
@@ -35,6 +37,9 @@ Q_SIGNALS:
public:
bool
exec
(
KTextEditor
::
View
*
view
,
const
QString
&
cmd
,
QString
&
msg
,
const
KTextEditor
::
Range
&
range
=
KTextEditor
::
Range
::
invalid
())
override
;
bool
help
(
KTextEditor
::
View
*
view
,
const
QString
&
cmd
,
QString
&
msg
)
override
;
private:
bool
m_busy
{
false
};
};
#endif
...
...
addons/search/plugin_search.cpp
View file @
da7b931c
...
...
@@ -222,6 +222,9 @@ QObject *KatePluginSearch::createView(KTextEditor::MainWindow *mainWindow)
connect
(
m_searchCommand
,
&
KateSearchCommand
::
setSearchString
,
view
,
&
KatePluginSearchView
::
setSearchString
);
connect
(
m_searchCommand
,
&
KateSearchCommand
::
startSearch
,
view
,
&
KatePluginSearchView
::
startSearch
);
connect
(
m_searchCommand
,
SIGNAL
(
newTab
()),
view
,
SLOT
(
addTab
()));
connect
(
view
,
&
KatePluginSearchView
::
searchBusy
,
m_searchCommand
,
&
KateSearchCommand
::
setBusy
);
return
view
;
}
...
...
@@ -971,6 +974,8 @@ void KatePluginSearchView::startSearch()
return
;
}
Q_EMIT
searchBusy
(
true
);
updateViewColors
();
m_curResults
->
regExp
=
reg
;
...
...
@@ -1138,6 +1143,8 @@ void KatePluginSearchView::startSearchWhileTyping()
return
;
}
Q_EMIT
searchBusy
(
true
);
m_curResults
->
regExp
=
reg
;
m_curResults
->
useRegExp
=
m_ui
.
useRegExp
->
isChecked
();
...
...
@@ -1212,6 +1219,8 @@ void KatePluginSearchView::searchDone()
m_ui
.
expandResults
->
setDisabled
(
false
);
m_ui
.
currentFolderButton
->
setDisabled
(
m_ui
.
searchPlaceCombo
->
currentIndex
()
!=
MatchModel
::
Folder
);
Q_EMIT
searchBusy
(
false
);
if
(
!
m_curResults
)
{
return
;
}
...
...
@@ -1245,6 +1254,8 @@ void KatePluginSearchView::searchDone()
void
KatePluginSearchView
::
searchWhileTypingDone
()
{
Q_EMIT
searchBusy
(
false
);
if
(
!
m_curResults
)
{
return
;
}
...
...
@@ -1335,6 +1346,8 @@ void KatePluginSearchView::replaceSingleMatch()
return
;
}
Q_EMIT
searchBusy
(
true
);
KTextEditor
::
Document
*
doc
=
m_mainWindow
->
activeView
()
->
document
();
// FIXME The document might have been edited after the search.
...
...
@@ -1365,6 +1378,8 @@ void KatePluginSearchView::replaceChecked()
return
;
}
Q_EMIT
searchBusy
(
true
);
m_ui
.
stopAndNext
->
setCurrentWidget
(
m_ui
.
stopButton
);
m_ui
.
displayOptions
->
setChecked
(
false
);
m_ui
.
displayOptions
->
setDisabled
(
true
);
...
...
@@ -1401,6 +1416,8 @@ void KatePluginSearchView::replaceDone()
m_ui
.
expandResults
->
setDisabled
(
false
);
m_ui
.
currentFolderButton
->
setDisabled
(
false
);
updateMatchMarks
();
Q_EMIT
searchBusy
(
false
);
}
/** Remove all moving ranges and document marks belonging to Search & Replace */
...
...
@@ -1554,7 +1571,7 @@ void KatePluginSearchView::expandResults()
// we expand recursively if we either are told so or we have just one toplevel match item
QModelIndex
rootItem
=
m_curResults
->
matchModel
.
index
(
0
,
0
);
if
(
m_ui
.
expandResults
->
isChecked
()
||
m_curResults
->
matchModel
.
rowCount
(
rootItem
)
==
1
)
{
if
(
(
m_ui
.
expandResults
->
isChecked
()
&&
m_curResults
->
matchModel
.
rowCount
(
rootItem
)
<
200
)
||
m_curResults
->
matchModel
.
rowCount
(
rootItem
)
==
1
)
{
m_curResults
->
treeView
->
expandAll
();
}
else
{
// first collapse all and the expand the root, much faster than collapsing all children manually
...
...
addons/search/plugin_search.h
View file @
da7b931c
...
...
@@ -164,6 +164,9 @@ private Q_SLOTS:
void
copySearchToClipboard
(
CopyResultType
type
);
void
customResMenuRequested
(
const
QPoint
&
pos
);
Q_SIGNALS:
void
searchBusy
(
bool
busy
);
protected:
bool
eventFilter
(
QObject
*
obj
,
QEvent
*
ev
)
override
;
...
...
Write
Preview
Supports
Markdown
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