]> git.lyx.org Git - lyx.git/blob - src/frontends/qt/FindAndReplace.h
Fixup c30b0aac: protect against bad recursion
[lyx.git] / src / frontends / qt / FindAndReplace.h
1 // -*- C++ -*-
2 /**
3  * \file FindAndReplace.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Tommaso Cucinotta
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef QSEARCHADV_H
13 #define QSEARCHADV_H
14
15 #include "DockView.h"
16 // This is needed so that ui_FindAndReplaceUi.h can find qt_()
17 #include "qt_helpers.h"
18 #include "ui_FindAndReplaceUi.h"
19 #include "support/docstring.h"
20
21 #include <string>
22
23 namespace lyx {
24
25 class FindAndReplaceOptions;
26
27 namespace frontend {
28
29 class FindAndReplaceWidget : public QTabWidget, public Ui::FindAndReplaceUi
30 {
31         Q_OBJECT
32
33 public:
34         FindAndReplaceWidget(GuiView & view);
35         bool initialiseParams(std::string const & params);
36         void updateWorkAreas();
37         void updateButtons();
38
39         // return true if \c wa is one if the adv. F&R workareas
40         bool hasWorkArea(GuiWorkArea * wa) const;
41
42 public Q_SLOTS:
43         ///
44         void dockLocationChanged(Qt::DockWidgetArea area);
45
46 private:
47         ///
48         GuiView & view_;
49         ///
50         Buffer * old_buffer_;
51
52         /// add a string to the combo if needed
53         void remember(std::string const & find, QComboBox & combo);
54
55         /// Perform the scope-related buffer switch while searching
56         bool findAndReplaceScope(FindAndReplaceOptions & opt, bool replace_all = false);
57
58         /// Collect options from the GUI elements, then perform the search
59         bool findAndReplace(bool backwards, bool replace, bool replace_all = false);
60
61         /// FIXME Probably to be merged with findAndReplace(bool, bool, bool)
62         bool findAndReplace(bool casesensitive, bool matchword, bool backwards,
63                 bool expandmacros, bool ignoreformat, bool replace,
64                 bool keep_case, bool replace_all = false);
65
66         bool eventFilter(QObject *obj, QEvent *event) override;
67
68         void virtual showEvent(QShowEvent *ev) override;
69         void virtual hideEvent(QHideEvent *ev) override;
70
71         void hideDialog();
72
73         void setFormatIgnores(bool const b);
74
75         docstring const checkState(std::string const s, bool const b);
76
77 protected Q_SLOTS:
78         void on_findNextPB_clicked();
79         void on_replacePB_clicked();
80         void on_replaceallPB_clicked();
81         void on_searchbackCB_clicked();
82         void on_selectAllPB_clicked();
83         void on_deselectAllPB_clicked();
84 };
85
86
87 class FindAndReplace : public DockView
88 {
89         Q_OBJECT
90 public:
91         FindAndReplace(
92                 GuiView & parent, ///< the main window where to dock.
93                 Qt::DockWidgetArea area = Qt::RightDockWidgetArea, ///< Position of the dock (and also drawer)
94                 Qt::WindowFlags flags = {});
95
96         ~FindAndReplace();
97
98         bool initialiseParams(std::string const &) override;
99         void clearParams() override {}
100         void dispatchParams() override {}
101         bool isBufferDependent() const override { return false; }
102         bool canApplyToReadOnly() const override { return true; }
103         bool hasWorkArea(GuiWorkArea * wa) const { return widget_->hasWorkArea(wa); }
104         void selectAll();
105
106         /// update
107         void updateView() override;
108         //virtual void update_contents() {}
109
110 protected:
111         bool wantInitialFocus() const override { return true; }
112
113 private:
114         /// The encapsulated widget.
115         FindAndReplaceWidget * widget_;
116 };
117
118
119 } // namespace frontend
120 } // namespace lyx
121
122 #endif // QSEARCHADV_H