]> git.lyx.org Git - features.git/blob - src/frontends/qt4/FindAndReplace.h
3bb2b44394a7c95ce43ebc20f74bc1cf64259e84
[features.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 "Text.h"
24 #include "lyxfind.h"
25
26 #include <QDialog>
27
28 #include <string>
29
30 namespace lyx {
31 namespace frontend {
32
33 class FindAndReplaceWidget : public QWidget, public Ui::FindAndReplaceUi
34 {
35         Q_OBJECT
36
37 public:
38         FindAndReplaceWidget(GuiView & view);
39         bool initialiseParams(std::string const & params);
40
41 private:
42         ///
43         GuiView & view_;
44
45         /// add a string to the combo if needed
46         void remember(std::string const & find, QComboBox & combo);
47
48         /// FIXME Probably to be merged with findAndReplace(bool, bool)
49         void findAndReplace(
50                 bool casesensitive, bool matchword, bool backwards,
51                 bool expandmacros, bool ignoreformat, bool replace,
52                 bool keep_case
53         );
54
55         /// Perform the scope-related buffer switch while searching
56         void findAndReplaceScope(FindAndReplaceOptions & opt);
57
58         /// Collect options from the GUI elements, then perform the search
59         void findAndReplace(bool backwards, bool replace);
60
61         bool eventFilter(QObject *obj, QEvent *event);
62
63         void virtual showEvent(QShowEvent *ev);
64         void virtual hideEvent(QHideEvent *ev);
65
66         void hideDialog();
67
68 protected Q_SLOTS:
69         void on_findNextPB_clicked();
70         void on_replacePB_clicked();
71         void on_replaceallPB_clicked();
72         void insertRegexp(QAction *);
73 };
74
75
76 class FindAndReplace : public DockView
77 {
78         Q_OBJECT
79 public:
80         FindAndReplace(
81                 GuiView & parent, ///< the main window where to dock.
82                 Qt::DockWidgetArea area = Qt::RightDockWidgetArea, ///< Position of the dock (and also drawer)
83                 Qt::WindowFlags flags = 0);
84
85         ~FindAndReplace();
86
87         bool initialiseParams(std::string const &);
88         void clearParams() {}
89         void dispatchParams() {}
90         bool isBufferDependent() const { return true; }
91         void selectAll();
92
93         /// update
94         void updateView() {}
95         //virtual void update_contents() {}
96
97 protected:
98         virtual bool wantInitialFocus() const { return true; }
99
100 private:
101         /// The encapsulated widget.
102         FindAndReplaceWidget * widget_;
103 };
104
105
106 } // namespace frontend
107 } // namespace lyx
108
109 #endif // QSEARCHADV_H