]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/FindAndReplace.h
Fix handling of the add branch textfield in GuiBranches
[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 // This is needed so that ui_FindAndReplaceUi.h can find qt_()
19 #include "qt_helpers.h"
20 #include "ui_FindAndReplaceUi.h"
21
22 #include "BufferView.h"
23 #include "Buffer.h"
24 #include "LyX.h"
25 #include "Text.h"
26 #include "lyxfind.h"
27
28 #include <QDialog>
29
30 #include <string>
31
32 namespace lyx {
33 namespace frontend {
34
35 class FindAndReplaceWidget : public QTabWidget, public Ui::FindAndReplaceUi
36 {
37         Q_OBJECT
38
39 public:
40         FindAndReplaceWidget(GuiView & view);
41         bool initialiseParams(std::string const & params);
42         void updateGUI();
43
44 private:
45         ///
46         GuiView & view_;
47
48         /// add a string to the combo if needed
49         void remember(std::string const & find, QComboBox & combo);
50
51         /// Perform the scope-related buffer switch while searching
52         bool findAndReplaceScope(FindAndReplaceOptions & opt, bool replace_all = false);
53
54         /// Collect options from the GUI elements, then perform the search
55         bool findAndReplace(bool backwards, bool replace, bool replace_all = false);
56
57         /// FIXME Probably to be merged with findAndReplace(bool, bool, bool)
58         bool findAndReplace(bool casesensitive, bool matchword, bool backwards,
59                 bool expandmacros, bool ignoreformat, bool replace,
60                 bool keep_case, bool replace_all = false);
61
62         bool eventFilter(QObject *obj, QEvent *event);
63
64         void virtual showEvent(QShowEvent *ev);
65         void virtual hideEvent(QHideEvent *ev);
66
67         void hideDialog();
68
69 protected Q_SLOTS:
70         void on_findNextPB_clicked();
71         void on_replacePB_clicked();
72         void on_replaceallPB_clicked();
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 false; }
91         bool canApplyToReadOnly() const { return true; }
92         void selectAll();
93
94         /// update
95         void updateView();
96         //virtual void update_contents() {}
97
98 protected:
99         virtual bool wantInitialFocus() const { return true; }
100
101 private:
102         /// The encapsulated widget.
103         FindAndReplaceWidget * widget_;
104 };
105
106
107 } // namespace frontend
108 } // namespace lyx
109
110 #endif // QSEARCHADV_H