]> git.lyx.org Git - lyx.git/blob - src/frontends/qt/GuiSearch.h
GuiSearch: Add auto-wrap option
[lyx.git] / src / frontends / qt / GuiSearch.h
1 // -*- C++ -*-
2 /**
3  * \file GuiSearch.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author John Levon
8  * \author Angus Leeming
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef GUISEARCH_H
14 #define GUISEARCH_H
15
16 #include "GuiDialog.h"
17 #include "DockView.h"
18
19 #include <QDockWidget>
20
21 #include "ui_SearchUi.h"
22
23 namespace lyx {
24 namespace frontend {
25
26 class GuiSearch;
27
28 class GuiSearchWidget : public QWidget, public Ui::SearchUi
29 {
30         Q_OBJECT
31
32 public:
33         GuiSearchWidget(QWidget * parent);
34         ///
35         void saveSession(QSettings & settings, QString const & session_key) const;
36         ///
37         void restoreSession(QString const & session_key);
38         ///
39         void setBufferView(BufferView const * bv) { bv_ = bv; }
40         ///
41         bool isMinimized() { return minimized_; }
42
43 private Q_SLOTS:
44         void findChanged();
45         void findBufferChanged();
46         void findClicked(bool const backwards = false);
47         void findPrevClicked();
48         void replaceClicked(bool const backwards = false);
49         void replacePrevClicked();
50         void replaceallClicked();
51         void minimizeClicked(bool const toggle = true);
52 Q_SIGNALS:
53         void needTitleBarUpdate() const;
54         void needSizeUpdate() const;
55
56 private:
57         ///
58         void keyPressEvent(QKeyEvent * e) override;
59         ///
60         void showEvent(QShowEvent * e) override;
61         /// Searches occurrence of string
62         void find(docstring const & search,
63                   bool casesensitive, bool matchword,
64                   bool forward, bool instant, bool wrap);
65         /// Replaces occurrence of string
66         void replace(docstring const & search, docstring const & replace,
67                      bool casesensitive, bool matchword,
68                      bool forward, bool all, bool wrap);
69         ///
70         BufferView const * bv_ = nullptr;
71         ///
72         bool minimized_ = false;
73 };
74
75
76 class GuiSearch : public DockView
77 {
78         Q_OBJECT
79
80 public:
81         GuiSearch(
82                 GuiView & parent, ///< the main window where to dock.
83                 Qt::DockWidgetArea area = Qt::BottomDockWidgetArea, ///< Position of the dock (and also drawer)
84                 Qt::WindowFlags flags = {});
85
86         /// Controller inherited method.
87         ///@{
88         bool initialiseParams(std::string const &) override { return true; }
89         void clearParams() override {}
90         void dispatchParams() override {}
91         bool isBufferDependent() const override { return true; }
92         void updateView() override;
93         void saveSession(QSettings & settings) const override;
94         void restoreSession() override;
95         bool wantInitialFocus() const override { return true; }
96         ///@}
97
98 public Q_SLOTS:
99         ///
100         void onBufferViewChanged() override;
101
102 private Q_SLOTS:
103         /// update title display
104         void updateTitle();
105         /// update dock size
106         void updateSize();
107
108 private:
109         /// The encapsulated widget.
110         GuiSearchWidget * widget_;
111 };
112
113 } // namespace frontend
114 } // namespace lyx
115
116 #endif // GUISEARCH_H