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);
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 doFind(bool const backwards = false,
72 bool const instant = false);
74 void doReplace(bool const backwards = false);
75 /// Searches occurrence of string
76 void find(docstring const & search,
77 bool casesensitive, bool matchword,
78 bool forward, bool instant, bool wrap, bool onlysel);
79 /// Replaces occurrence of string
80 void replace(docstring const & search, docstring const & replace,
81 bool casesensitive, bool matchword,
82 bool forward, bool all, bool wrap, bool onlysel);
84 void handleIndicators();
86 BufferView const * bv_ = nullptr;
88 bool minimized_ = false;
89 /// contains the search box
90 FancyLineEdit * findLE_;
94 QAction * act_casesense_ = new QAction(this);
96 QAction * act_wholewords_ = new QAction(this);
98 QAction * act_selection_ = new QAction(this);
100 QAction * act_immediate_ = new QAction(this);
102 QAction * act_wrap_ = new QAction(this);
106 class GuiSearch : public DockView
112 GuiView & parent, ///< the main window where to dock.
113 Qt::DockWidgetArea area = Qt::BottomDockWidgetArea, ///< Position of the dock (and also drawer)
114 Qt::WindowFlags flags = {});
116 /// Controller inherited method.
118 bool initialiseParams(std::string const & sdata) override
119 { return widget_->initialiseParams(sdata); }
120 void clearParams() override {}
121 void dispatchParams() override {}
122 bool isBufferDependent() const override { return true; }
123 void updateView() override;
124 void saveSession(QSettings & settings) const override;
125 void restoreSession() override;
129 bool wantInitialFocus() const override { return true; }
133 void onBufferViewChanged() override;
136 /// update title display
142 /// The encapsulated widget.
143 GuiSearchWidget * widget_;
146 } // namespace frontend
149 #endif // GUISEARCH_H