]> git.lyx.org Git - lyx.git/blob - src/frontends/qt/FindAndReplace.h
Fix up 6c20e5db: let PARAGRAPH_GOTO use SCROLL_TOP again
[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
22 namespace lyx {
23
24 class FindAndReplaceOptions;
25
26 namespace frontend {
27
28 class FindAndReplaceWidget : public QTabWidget, public Ui::FindAndReplaceUi
29 {
30         Q_OBJECT
31
32 public:
33         FindAndReplaceWidget(GuiView & view);
34         bool initialiseParams(std::string const & params);
35         void updateWorkAreas();
36         void updateButtons();
37
38         // return true if \c wa is one if the adv. F&R workareas
39         bool hasWorkArea(GuiWorkArea * wa) const;
40
41 public Q_SLOTS:
42         ///
43         void dockLocationChanged(Qt::DockWidgetArea area);
44
45 private:
46         ///
47         GuiView & view_;
48         ///
49         Buffer * old_buffer_;
50
51         /// add a string to the combo if needed
52         void remember(std::string const & find, QComboBox & combo);
53
54         /// Perform the scope-related buffer switch while searching
55         bool findAndReplaceScope(FindAndReplaceOptions & opt, bool replace_all = false);
56
57         /// Collect options from the GUI elements, then perform the search
58         bool findAndReplace(bool backwards, bool replace, bool replace_all = false);
59
60         /// FIXME Probably to be merged with findAndReplace(bool, bool, bool)
61         bool findAndReplace(bool casesensitive, bool matchword, bool backwards,
62                 bool expandmacros, bool ignoreformat, bool replace,
63                 bool keep_case, bool replace_all = false);
64
65         bool eventFilter(QObject *obj, QEvent *event) override;
66
67         void virtual showEvent(QShowEvent *ev) override;
68         void virtual hideEvent(QHideEvent *ev) override;
69
70         void hideDialog();
71
72         void setFormatIgnores(bool const b);
73
74         docstring const checkState(std::string const s, bool const b);
75
76 protected Q_SLOTS:
77         void on_findNextPB_clicked();
78         void on_replacePB_clicked();
79         void on_replaceallPB_clicked();
80         void on_searchbackCB_clicked();
81         void on_selectAllPB_clicked();
82         void on_deselectAllPB_clicked();
83 };
84
85
86 class FindAndReplace : public DockView
87 {
88         Q_OBJECT
89 public:
90         FindAndReplace(
91                 GuiView & parent, ///< the main window where to dock.
92                 Qt::DockWidgetArea area = Qt::RightDockWidgetArea, ///< Position of the dock (and also drawer)
93                 Qt::WindowFlags flags = {});
94
95         ~FindAndReplace();
96
97         bool initialiseParams(std::string const &) override;
98         void clearParams() override {}
99         void dispatchParams() override {}
100         bool isBufferDependent() const override { return false; }
101         bool canApplyToReadOnly() const override { return true; }
102         bool hasWorkArea(GuiWorkArea * wa) const { return widget_->hasWorkArea(wa); }
103         void selectAll();
104
105         /// update
106         void updateView() override;
107         //virtual void update_contents() {}
108
109 protected:
110         bool wantInitialFocus() const override { return true; }
111
112 private:
113         /// The encapsulated widget.
114         FindAndReplaceWidget * widget_;
115 };
116
117
118 } // namespace frontend
119 } // namespace lyx
120
121 #endif // QSEARCHADV_H