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