3 * \file GuiViewSource.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * \author Abdelrazak Younes
11 * Full author contact details are available in file CREDITS.
14 #ifndef GUIVIEWSOURCE_H
15 #define GUIVIEWSOURCE_H
17 #include "ui_ViewSourceUi.h"
22 #include <QDockWidget>
38 class LaTeXHighlighter;
41 class ViewSourceWidget : public QWidget, public Ui::ViewSourceUi
48 void setBufferView(BufferView const * bv);
49 /// returns true if the string has changed
50 bool setText(QString const & qstr = QString());
52 void saveSession(QString const & session_key) const;
54 void restoreSession(QString const & session_key);
58 void resizeEvent (QResizeEvent * event);
61 /// schedule an update after delay
63 /// schedule an update now
66 void setViewFormat(int const index);
68 void updateDefaultFormat();
70 void contentsChanged();
72 void goToCursor() const;
73 /// Name of the current format. Empty if none.
74 docstring currentFormatName(BufferView const * bv) const;
77 void formatChanged() const;
81 void realUpdateView();
84 /// Get the source code of selected paragraphs, or the whole document.
85 void getContent(BufferView const * view, Buffer::OutputWhat output,
86 docstring & str, std::string const & format, bool master);
87 /// Grab double clicks on the viewport
88 bool eventFilter(QObject * obj, QEvent * event);
90 BufferView const * bv_;
92 QTextDocument * document_;
93 /// LaTeX syntax highlighter
94 LaTeXHighlighter * highlighter_;
96 std::string view_format_;
98 QTimer * update_timer_;
99 /// TexRow information from the last source view. If TexRow is unavailable
100 /// for the last format then texrow_ is null.
101 unique_ptr<TexRow> texrow_;
105 class GuiViewSource : public DockView
111 GuiView & parent, ///< the main window where to dock.
112 Qt::DockWidgetArea area = Qt::BottomDockWidgetArea, ///< Position of the dock (and also drawer)
113 Qt::WindowFlags flags = 0);
117 /// Controller inherited method.
119 bool initialiseParams(std::string const & source);
120 void clearParams() {}
121 void dispatchParams() {}
122 bool isBufferDependent() const { return true; }
123 bool canApply() const { return true; }
124 bool canApplyToReadOnly() const { return true; }
126 void enableView(bool enable);
127 void saveSession() const;
128 void restoreSession();
129 bool wantInitialFocus() const { return false; }
133 /// The title displayed by the dialog reflects source type.
137 /// The encapsulated widget.
138 ViewSourceWidget * widget_;
141 } // namespace frontend
144 #endif // GUIVIEWSOURCE_H