]> git.lyx.org Git - lyx.git/blob - src/frontends/qt/GuiSearch.h
Use explicit initialization for plain pointer to buffer view.
[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, bool forward);
64         /// Replaces occurrence of string
65         void replace(docstring const & search, docstring const & replace,
66                      bool casesensitive, bool matchword,
67                      bool forward, bool all);
68         ///
69         BufferView const * bv_ = nullptr;
70         ///
71         bool minimized_ = false;
72 };
73
74
75 class GuiSearch : public DockView
76 {
77         Q_OBJECT
78
79 public:
80         GuiSearch(
81                 GuiView & parent, ///< the main window where to dock.
82                 Qt::DockWidgetArea area = Qt::BottomDockWidgetArea, ///< Position of the dock (and also drawer)
83                 Qt::WindowFlags flags = {});
84
85         /// Controller inherited method.
86         ///@{
87         bool initialiseParams(std::string const &) override { return true; }
88         void clearParams() override {}
89         void dispatchParams() override {}
90         bool isBufferDependent() const override { return true; }
91         void updateView() override;
92         void saveSession(QSettings & settings) const override;
93         void restoreSession() override;
94         bool wantInitialFocus() const override { return true; }
95         ///@}
96
97 public Q_SLOTS:
98         ///
99         void onBufferViewChanged() override;
100
101 private Q_SLOTS:
102         /// update title display
103         void updateTitle();
104         /// update dock size
105         void updateSize();
106
107 private:
108         /// The encapsulated widget.
109         GuiSearchWidget * widget_;
110 };
111
112 } // namespace frontend
113 } // namespace lyx
114
115 #endif // GUISEARCH_H