]> git.lyx.org Git - lyx.git/blob - src/frontends/qt/GuiSearch.h
GuiSearch: separate findClicked() slot from more general function
[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 initialiseParams(std::string const &);
42         ///
43         bool isMinimized() { return minimized_; }
44
45 private Q_SLOTS:
46         void findChanged();
47         void findBufferChanged();
48         void findClicked();
49         void findPrevClicked();
50         void replaceClicked();
51         void replacePrevClicked();
52         void replaceallClicked();
53         void minimizeClicked(bool const toggle = true);
54 Q_SIGNALS:
55         void needTitleBarUpdate() const;
56         void needSizeUpdate() const;
57
58 private:
59         ///
60         void keyPressEvent(QKeyEvent * e) override;
61         ///
62         void showEvent(QShowEvent * e) override;
63         ///
64         void doFind(bool const backwards = false,
65                     bool const instant = false);
66         ///
67         void doReplace(bool const backwards = false);
68         /// Searches occurrence of string
69         void find(docstring const & search,
70                   bool casesensitive, bool matchword,
71                   bool forward, bool instant, bool wrap, bool onlysel);
72         /// Replaces occurrence of string
73         void replace(docstring const & search, docstring const & replace,
74                      bool casesensitive, bool matchword,
75                      bool forward, bool all, bool wrap, bool onlysel);
76         ///
77         BufferView const * bv_ = nullptr;
78         ///
79         bool minimized_ = false;
80 };
81
82
83 class GuiSearch : public DockView
84 {
85         Q_OBJECT
86
87 public:
88         GuiSearch(
89                 GuiView & parent, ///< the main window where to dock.
90                 Qt::DockWidgetArea area = Qt::BottomDockWidgetArea, ///< Position of the dock (and also drawer)
91                 Qt::WindowFlags flags = {});
92
93         /// Controller inherited method.
94         ///@{
95         bool initialiseParams(std::string const & sdata) override
96                 { return widget_->initialiseParams(sdata); }
97         void clearParams() override {}
98         void dispatchParams() override {}
99         bool isBufferDependent() const override { return true; }
100         void updateView() override;
101         void saveSession(QSettings & settings) const override;
102         void restoreSession() override;
103         ///@}
104
105 protected:
106         bool wantInitialFocus() const override { return true; }
107
108 public Q_SLOTS:
109         ///
110         void onBufferViewChanged() override;
111
112 private Q_SLOTS:
113         /// update title display
114         void updateTitle();
115         /// update dock size
116         void updateSize();
117
118 private:
119         /// The encapsulated widget.
120         GuiSearchWidget * widget_;
121 };
122
123 } // namespace frontend
124 } // namespace lyx
125
126 #endif // GUISEARCH_H