]> git.lyx.org Git - features.git/blob - src/frontends/qt4/GuiViewSource.h
6d16142249718b09f6d5ba6652e1df302bd97cda
[features.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 <QDockWidget>
24 #include <QString>
25
26 class QTextDocument;
27
28 namespace lyx {
29 namespace frontend {
30
31 class GuiViewSource;
32 class LaTeXHighlighter;
33
34 class ViewSourceWidget : public QWidget, public Ui::ViewSourceUi
35 {
36         Q_OBJECT
37
38 public:
39         ViewSourceWidget();
40         ///
41         void setBufferView(BufferView const * bv);
42
43 public Q_SLOTS:
44         /// update content
45         void updateView();
46         ///
47         void setViewFormat();
48         ///
49         void updateDefaultFormat();
50         ///
51         void contentsChanged();
52
53 private:
54         ///
55         BufferView const * bv_;
56         ///
57         QTextDocument * document_;
58         /// LaTeX syntax highlighter
59         LaTeXHighlighter * highlighter_;
60         ///
61         bool force_getcontent_;
62         ///
63         QString view_format_;
64 };
65
66
67 class GuiViewSource : public DockView
68 {
69         Q_OBJECT
70
71 public:
72         GuiViewSource(
73                 GuiView & parent, ///< the main window where to dock.
74                 Qt::DockWidgetArea area = Qt::BottomDockWidgetArea, ///< Position of the dock (and also drawer)
75                 Qt::WindowFlags flags = 0);
76
77         ~GuiViewSource();
78
79         /// Controller inherited method.
80         ///@{
81         bool initialiseParams(std::string const & source);
82         void clearParams() {}
83         void dispatchParams() {}
84         bool isBufferDependent() const { return true; }
85         bool canApply() const { return true; }
86         bool canApplyToReadOnly() const { return true; }
87         void updateView();
88         void enableView(bool enable);
89         void saveSession() const;
90         void restoreSession();
91         bool wantInitialFocus() const { return false; }
92         ///@}
93
94         /// The title displayed by the dialog reflects source type.
95         QString title() const;
96
97 private:
98         /// The encapsulated widget.
99         ViewSourceWidget * widget_;
100 };
101
102 } // namespace frontend
103 } // namespace lyx
104
105 #endif // GUIVIEWSOURCE_H