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