]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/FindAndReplace.h
b4bc3e1a8472947eec0099782215bffbbcb7edc7
[lyx.git] / src / frontends / qt4 / FindAndReplace.h
1 // -*- C++ -*-
2 /**
3  * \file FindAndReplace.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Tommaso Cucinotta
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef QSEARCHADV_H
13 #define QSEARCHADV_H
14
15 #include "GuiWorkArea.h"
16
17 #include "DockView.h"
18 #include "ui_FindAndReplaceUi.h"
19
20 #include "BufferView.h"
21 #include "Buffer.h"
22 #include "LyX.h"
23 #include "LyXFunc.h"
24 #include "Text.h"
25 #include "lyxfind.h"
26
27 #include <QDialog>
28
29 #include <string>
30
31 namespace lyx {
32 namespace frontend {
33
34 class FindAndReplaceWidget : public QWidget, public Ui::FindAndReplaceUi
35 {
36         Q_OBJECT
37
38 public:
39         FindAndReplaceWidget(GuiView & view);
40         bool initialiseParams(std::string const & params);
41
42 private:
43         ///
44         GuiView & view_;
45
46         /// add a string to the combo if needed
47         void remember(std::string const & find, QComboBox & combo);
48
49         /// FIXME Probably to be merged with findAndReplace(bool, bool)
50         void findAndReplace(
51                 bool casesensitive, bool matchword, bool backwards,
52                 bool expandmacros, bool ignoreformat, bool replace,
53                 bool keep_case
54         );
55
56         /// Perform the scope-related buffer switch while searching
57         void findAndReplaceScope(FindAndReplaceOptions & opt);
58
59         /// Collect options from the GUI elements, then perform the search
60         void findAndReplace(bool backwards, bool replace);
61
62         bool eventFilter(QObject *obj, QEvent *event);
63
64         void virtual showEvent(QShowEvent *ev);
65         void virtual hideEvent(QHideEvent *ev);
66
67 protected Q_SLOTS:
68         void on_findNextPB_clicked();
69         void on_findPrevPB_clicked();
70         void on_replaceNextPB_clicked();
71         void on_replacePrevPB_clicked();
72         void on_replaceallPB_clicked();
73         void on_closePB_clicked();
74         void insertRegexp(QAction *);
75 };
76
77
78 class FindAndReplace : public DockView
79 {
80         Q_OBJECT
81 public:
82         FindAndReplace(
83                 GuiView & parent, ///< the main window where to dock.
84                 Qt::DockWidgetArea area = Qt::RightDockWidgetArea, ///< Position of the dock (and also drawer)
85                 Qt::WindowFlags flags = 0);
86
87         ~FindAndReplace();
88
89         bool initialiseParams(std::string const &);
90         void clearParams() {}
91         void dispatchParams() {}
92         bool isBufferDependent() const { return true; }
93         void selectAll();
94
95         /// update
96         void updateView() {}
97         //virtual void update_contents() {}
98
99 protected:
100         virtual bool wantInitialFocus() const { return true; }
101
102 private:
103         /// The encapsulated widget.
104         FindAndReplaceWidget * widget_;
105 };
106
107
108 } // namespace frontend
109 } // namespace lyx
110
111 #endif // QSEARCHADV_H