]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/FindAndReplace.h
09bde38ca387443412a21a38ba7cc8e485a034e6
[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
26 #include <QDialog>
27
28 #include <string>
29
30 namespace lyx {
31 namespace frontend {
32
33 class FindAndReplace : public DockView, public Ui::FindAndReplaceUi
34 {
35         Q_OBJECT
36 public:
37         FindAndReplace(GuiView & parent);
38
39         ~FindAndReplace();
40
41         bool initialiseParams(std::string const &) { return true; }
42         void clearParams() {}
43         void dispatchParams() {}
44         bool isBufferDependent() const { return true; }
45         void selectAll();
46
47         void showEvent(QShowEvent * ev);
48         void hideEvent(QHideEvent * ev);
49
50         /// update
51         void updateView() {}
52         //virtual void update_contents() {}
53
54 protected Q_SLOTS:
55         void on_findNextPB_clicked();
56         void on_findPrevPB_clicked();
57         void on_replacePB_clicked();
58         void on_replaceallPB_clicked();
59         void on_closePB_clicked();
60         void on_regexpInsertCombo_currentIndexChanged(int index);
61
62 protected:
63         void find(bool backwards);
64         virtual bool wantInitialFocus() const { return true; }
65
66 private:
67         // add a string to the combo if needed
68         void remember(std::string const & find, QComboBox & combo);
69         void findAdv(bool casesensitive,
70                         bool matchword, bool backwards,
71                         bool expandmacros, bool ignoreformat);
72
73         GuiView & parent_view_;
74
75         Buffer *searchBuffer_;
76         BufferView *searchBufferView_;
77
78         GuiWorkArea * searchWorkArea_;  // The work area defining what to search
79
80         /// @TODO: Investigate on focus issue and remove this ugly hack, please !
81         QTimer delayedFocusTimer_;
82         void disableSearchWorkArea();
83
84 private:
85         /// Apply changes
86         virtual void apply() {}
87
88         void find(docstring const & str, int len, bool casesens,
89                   bool words, bool backwards, bool expandmacros);
90
91         void replace(docstring const & findstr,
92                      docstring const & replacestr,
93                      bool casesens, bool words, bool backwards, bool expandmacros, bool all);
94         bool eventFilter(QObject *obj, QEvent *event);
95
96 public Q_SLOTS:
97         /// this happens when the dialog is simply closed/hidden
98         void closeEvent(QCloseEvent * e);
99         /// this happens 100ms after dialog showEvent()
100         void onDelayedFocus();
101 };
102
103
104 } // namespace frontend
105 } // namespace lyx
106
107 #endif // QSEARCHADV_H