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