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