QtPass
2.0.0
Developer documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
grepsearchcontroller.h
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2014 Anne Jan Brouwer
2
// SPDX-License-Identifier: GPL-3.0-or-later
8
#ifndef SRC_GREPSEARCHCONTROLLER_H_
9
#define SRC_GREPSEARCHCONTROLLER_H_
10
24
class
GrepSearchController
{
25
public
:
29
struct
FinishOutcome
{
30
bool
restoreCursor
;
31
bool
discard
;
32
};
33
38
auto
inGrepMode
() const ->
bool
{
return
m_mode
; }
39
43
void
enterGrepMode
() {
m_mode
=
true
; }
44
52
auto
leaveGrepMode
() ->
bool
{
53
m_mode
=
false
;
54
if
(
m_busy
) {
55
m_busy
=
false
;
56
m_cancelled
=
true
;
57
return
true
;
58
}
59
return
false
;
60
}
61
66
auto
beginSearch
() ->
bool
{
67
m_cancelled
=
false
;
68
if
(!
m_busy
) {
69
m_busy
=
true
;
70
return
true
;
71
}
72
return
false
;
73
}
74
79
auto
cancelSearch
() ->
bool
{
80
m_cancelled
=
true
;
81
if
(
m_busy
) {
82
m_busy
=
false
;
83
return
true
;
84
}
85
return
false
;
86
}
87
93
auto
finishSearch
() ->
FinishOutcome
{
94
FinishOutcome
outcome{
m_busy
,
m_cancelled
};
95
m_busy
=
false
;
96
m_cancelled
=
false
;
97
return
outcome;
98
}
99
100
private
:
101
bool
m_mode
=
false
;
102
bool
m_busy
=
false
;
103
bool
m_cancelled
=
false
;
104
};
105
106
#endif
// SRC_GREPSEARCHCONTROLLER_H_
GrepSearchController
State machine for MainWindow's content-search (grep) mode.
Definition
grepsearchcontroller.h:24
GrepSearchController::beginSearch
auto beginSearch() -> bool
Begin a search for a non-empty query.
Definition
grepsearchcontroller.h:66
GrepSearchController::leaveGrepMode
auto leaveGrepMode() -> bool
Leave content-search mode (search button toggled off).
Definition
grepsearchcontroller.h:52
GrepSearchController::finishSearch
auto finishSearch() -> FinishOutcome
Record that a search finished and report required side effects.
Definition
grepsearchcontroller.h:93
GrepSearchController::enterGrepMode
void enterGrepMode()
Enter content-search mode (search button toggled on).
Definition
grepsearchcontroller.h:43
GrepSearchController::cancelSearch
auto cancelSearch() -> bool
Cancel the current search (e.g. query cleared).
Definition
grepsearchcontroller.h:79
GrepSearchController::m_cancelled
bool m_cancelled
Pending results should be discarded.
Definition
grepsearchcontroller.h:103
GrepSearchController::inGrepMode
auto inGrepMode() const -> bool
Whether content-search mode is currently active.
Definition
grepsearchcontroller.h:38
GrepSearchController::m_busy
bool m_busy
A grep subprocess is in flight.
Definition
grepsearchcontroller.h:102
GrepSearchController::m_mode
bool m_mode
Content-search mode active.
Definition
grepsearchcontroller.h:101
GrepSearchController::FinishOutcome
Outcome of a search-completion transition.
Definition
grepsearchcontroller.h:29
GrepSearchController::FinishOutcome::discard
bool discard
The finished search was cancelled; ignore results.
Definition
grepsearchcontroller.h:31
GrepSearchController::FinishOutcome::restoreCursor
bool restoreCursor
A wait cursor was active and must be restored.
Definition
grepsearchcontroller.h:30
src
grepsearchcontroller.h
Generated by
1.18.0