4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
8 * \author Angus Leeming
10 * Full author contact details are available in file CREDITS.
16 #include "GuiDialog.h"
18 #include "FancyLineEdit.h"
21 #include <QDockWidget>
23 #include "ui_SearchUi.h"
30 class GuiSearchWidget : public QWidget, public Ui::SearchUi
35 GuiSearchWidget(QWidget * parent, GuiView & view);
37 void saveSession(QSettings & settings, QString const & session_key) const;
39 void restoreSession(QString const & session_key);
41 void setBufferView(BufferView const * bv) { bv_ = bv; }
43 bool initialiseParams(std::string const &);
45 bool isMinimized() { return minimized_; }
49 void findBufferChanged();
51 void findPrevClicked();
52 void replaceClicked();
53 void replacePrevClicked();
54 void replaceallClicked();
55 void minimizeClicked(bool const toggle = true);
56 void caseSenseActTriggered();
57 void wholeWordsActTriggered();
58 void searchSelActTriggered();
59 void immediateActTriggered();
60 void immediateClicked();
61 void wrapActTriggered();
63 void needTitleBarUpdate() const;
64 void needSizeUpdate() const;
68 void keyPressEvent(QKeyEvent * e) override;
70 void showEvent(QShowEvent * e) override;
72 void hideEvent(QHideEvent * e) override;
74 void doFind(bool const backwards = false,
75 bool const instant = false);
77 void doReplace(bool const backwards = false);
78 /// Searches occurrence of string
79 void find(docstring const & search,
80 bool casesensitive, bool matchword,
81 bool forward, bool instant, bool wrap, bool onlysel);
82 /// Replaces occurrence of string
83 void replace(docstring const & search, docstring const & replace,
84 bool casesensitive, bool matchword,
85 bool forward, bool all, bool wrap, bool onlysel);
87 void handleIndicators();
89 BufferView const * bv_ = nullptr;
93 bool minimized_ = false;
94 /// contains the search box
95 FancyLineEdit * findLE_;
99 QAction * act_casesense_ = new QAction(this);
101 QAction * act_wholewords_ = new QAction(this);
103 QAction * act_selection_ = new QAction(this);
105 QAction * act_immediate_ = new QAction(this);
107 QAction * act_wrap_ = new QAction(this);
111 class GuiSearch : public DockView
117 GuiView & parent, ///< the main window where to dock.
118 Qt::DockWidgetArea area = Qt::BottomDockWidgetArea, ///< Position of the dock (and also drawer)
119 Qt::WindowFlags flags = {});
121 /// Controller inherited method.
123 bool initialiseParams(std::string const & sdata) override
124 { return widget_->initialiseParams(sdata); }
125 void clearParams() override {}
126 void dispatchParams() override {}
127 bool isBufferDependent() const override { return true; }
128 void updateView() override;
129 void saveSession(QSettings & settings) const override;
130 void restoreSession() override;
134 bool wantInitialFocus() const override { return true; }
135 void mouseMoveEvent(QMouseEvent * event) override;
136 void mousePressEvent(QMouseEvent * event) override;
137 void mouseDoubleClickEvent(QMouseEvent *event) override;
141 void onBufferViewChanged() override;
144 /// update title display
150 /// The encapsulated widget.
151 GuiSearchWidget * widget_;
156 } // namespace frontend
159 #endif // GUISEARCH_H