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
67
void
clearGrepMode
() {
m_mode
=
false
; }
68
73
auto
beginSearch
() ->
bool
{
74
m_cancelled
=
false
;
75
if
(!
m_busy
) {
76
m_busy
=
true
;
77
return
true
;
78
}
79
return
false
;
80
}
81
86
auto
cancelSearch
() ->
bool
{
87
m_cancelled
=
true
;
88
if
(
m_busy
) {
89
m_busy
=
false
;
90
return
true
;
91
}
92
return
false
;
93
}
94
100
auto
finishSearch
() ->
FinishOutcome
{
101
FinishOutcome
outcome{
m_busy
,
m_cancelled
};
102
m_busy
=
false
;
103
m_cancelled
=
false
;
104
return
outcome;
105
}
106
107
private
:
108
bool
m_mode
=
false
;
109
bool
m_busy
=
false
;
110
bool
m_cancelled
=
false
;
111
};
112
113
#endif
// SRC_GREPSEARCHCONTROLLER_H_
GrepSearchController
State machine for MainWindow's content-search (grep) mode.
Definition
grepsearchcontroller.h:24
GrepSearchController::clearGrepMode
void clearGrepMode()
Drop the mode flag only, without touching busy/cancelled state.
Definition
grepsearchcontroller.h:67
GrepSearchController::beginSearch
auto beginSearch() -> bool
Begin a search for a non-empty query.
Definition
grepsearchcontroller.h:73
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:100
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:86
GrepSearchController::m_cancelled
bool m_cancelled
Pending results should be discarded.
Definition
grepsearchcontroller.h:110
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:109
GrepSearchController::m_mode
bool m_mode
Content-search mode active.
Definition
grepsearchcontroller.h:108
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