]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiViewSource.h
Complete the removal of the embedding stuff. Maybe. It's hard to be sure we got every...
[lyx.git] / src / frontends / qt4 / GuiViewSource.h
1 // -*- C++ -*-
2 /**
3  * \file GuiViewSource.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author John Levon
8  * \author Bo Peng
9  * \author Abdelrazak Younes
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef GUIVIEWSOURCE_H
15 #define GUIVIEWSOURCE_H
16
17 #include "ui_ViewSourceUi.h"
18
19 #include "DockView.h"
20 #include "GuiView.h"
21 #include "qt_helpers.h"
22
23 #include "support/debug.h"
24
25 #include <QDockWidget>
26 #include <QString>
27 #include <QTextCharFormat>
28
29 class QTextDocument;
30
31 namespace lyx {
32 namespace frontend {
33
34 class GuiViewSource;
35 class LaTeXHighlighter;
36
37 class ViewSourceWidget : public QWidget, public Ui::ViewSourceUi
38 {
39         Q_OBJECT
40
41 public:
42         ViewSourceWidget(GuiViewSource &);
43
44 public Q_SLOTS:
45         // update content
46         void updateView();
47         ///
48         void update(bool full_source);
49
50 private:
51         ///
52         GuiViewSource & controller_;    
53         ///
54         QTextDocument * document_;
55         /// LaTeX syntax highlighter
56         LaTeXHighlighter * highlighter_;
57 };
58
59
60 class GuiViewSource : public DockView
61 {
62         Q_OBJECT
63
64 public:
65         GuiViewSource(
66                 GuiView & parent, ///< the main window where to dock.
67                 Qt::DockWidgetArea area = Qt::BottomDockWidgetArea, ///< Position of the dock (and also drawer)
68                 Qt::WindowFlags flags = 0);
69
70         ~GuiViewSource();
71
72         /// Controller inherited method.
73         ///@{
74         bool initialiseParams(std::string const & source);
75         void clearParams() {}
76         void dispatchParams() {}
77         bool isBufferDependent() const { return true; }
78         bool canApply() const { return true; }
79         bool canApplyToReadOnly() const { return true; }
80         void updateView();
81         ///@}
82
83         /// The title displayed by the dialog reflects source type.
84         QString title() const;
85
86         /** get the source code of selected paragraphs, or the whole document
87                 \param fullSource get full source code
88          */
89         QString getContent(bool fullSource);
90         // cursor position in the source code
91         struct Row { int begin; int end; };
92         Row getRows() const;
93
94 private:
95         /// The encapsulated widget.
96         ViewSourceWidget * widget_;
97 };
98
99 } // namespace frontend
100 } // namespace lyx
101
102 #endif // GUIVIEWSOURCE_H