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"
23 #include <QDockWidget>
33 class LaTeXHighlighter;
35 class ViewSourceWidget : public QWidget, public Ui::ViewSourceUi
42 void setBufferView(BufferView const * bv);
43 /// returns true if the string has changed
44 bool setText(QString const & qstr = QString());
46 void saveSession(QSettings & settings, QString const & session_key) const;
48 void restoreSession(QString const & session_key);
52 void resizeEvent (QResizeEvent * event);
55 /// schedule an update after delay
57 /// schedule an update now
60 void setViewFormat(int const index);
62 void updateDefaultFormat();
64 void contentsChanged();
67 /// Name of the current format. Empty if none.
68 docstring currentFormatName(BufferView const * bv) const;
71 void formatChanged() const;
75 void realUpdateView();
78 /// Get the source code of selected paragraphs, or the whole document.
79 void getContent(BufferView const * view, Buffer::OutputWhat output,
80 docstring & str, std::string const & format, bool master);
82 BufferView const * bv_;
84 QTextDocument * document_;
85 /// LaTeX syntax highlighter
86 LaTeXHighlighter * highlighter_;
88 std::string view_format_;
90 QTimer * update_timer_;
91 /// TexRow information from the last source view. If TexRow is unavailable
92 /// for the last format then texrow_ is null.
93 std::auto_ptr<TexRow> texrow_;
97 class GuiViewSource : public DockView
103 GuiView & parent, ///< the main window where to dock.
104 Qt::DockWidgetArea area = Qt::BottomDockWidgetArea, ///< Position of the dock (and also drawer)
105 Qt::WindowFlags flags = 0);
109 /// Controller inherited method.
111 bool initialiseParams(std::string const & source);
112 void clearParams() {}
113 void dispatchParams() {}
114 bool isBufferDependent() const { return true; }
115 bool canApply() const { return true; }
116 bool canApplyToReadOnly() const { return true; }
118 void enableView(bool enable);
119 void saveSession(QSettings & settings) const;
120 void restoreSession();
121 bool wantInitialFocus() const { return false; }
125 /// The title displayed by the dialog reflects source type.
129 /// The encapsulated widget.
130 ViewSourceWidget * widget_;
133 } // namespace frontend
136 #endif // GUIVIEWSOURCE_H