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