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 wrapActTriggered();
62 void needTitleBarUpdate() const;
63 void needSizeUpdate() const;
67 void keyPressEvent(QKeyEvent * e) override;
69 void showEvent(QShowEvent * e) override;
71 void hideEvent(QHideEvent * e) override;
73 void doFind(bool const backwards = false,
74 bool const instant = false);
76 void doReplace(bool const backwards = false);
77 /// Searches occurrence of string
78 void find(docstring const & search,
79 bool casesensitive, bool matchword,
80 bool forward, bool instant, bool wrap, bool onlysel);
81 /// Replaces occurrence of string
82 void replace(docstring const & search, docstring const & replace,
83 bool casesensitive, bool matchword,
84 bool forward, bool all, bool wrap, bool onlysel);
86 void handleIndicators();
88 BufferView const * bv_ = nullptr;
92 bool minimized_ = false;
93 /// contains the search box
94 FancyLineEdit * findLE_;
98 QAction * act_casesense_ = new QAction(this);
100 QAction * act_wholewords_ = new QAction(this);
102 QAction * act_selection_ = new QAction(this);
104 QAction * act_immediate_ = new QAction(this);
106 QAction * act_wrap_ = new QAction(this);
110 class GuiSearch : public DockView
116 GuiView & parent, ///< the main window where to dock.
117 Qt::DockWidgetArea area = Qt::BottomDockWidgetArea, ///< Position of the dock (and also drawer)
118 Qt::WindowFlags flags = {});
120 /// Controller inherited method.
122 bool initialiseParams(std::string const & sdata) override
123 { return widget_->initialiseParams(sdata); }
124 void clearParams() override {}
125 void dispatchParams() override {}
126 bool isBufferDependent() const override { return true; }
127 void updateView() override;
128 void saveSession(QSettings & settings) const override;
129 void restoreSession() override;
133 bool wantInitialFocus() const override { return true; }
134 void mouseMoveEvent(QMouseEvent * event) override;
135 void mousePressEvent(QMouseEvent * event) override;
136 void mouseDoubleClickEvent(QMouseEvent *event) override;
140 void onBufferViewChanged() override;
143 /// update title display
149 /// The encapsulated widget.
150 GuiSearchWidget * widget_;
155 } // namespace frontend
158 #endif // GUISEARCH_H