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
46 ViewSourceWidget(QWidget * parent);
47 /// returns true if the string has changed
48 bool setText(QString const & qstr = QString());
50 void saveSession(QSettings & settings, QString const & session_key) const;
52 void restoreSession(QString const & session_key);
54 int updateDelay() const;
58 void resizeEvent (QResizeEvent * event);
62 void updateView(BufferView const * bv);
64 void setViewFormat(int const index);
66 void updateDefaultFormat(BufferView const & bv);
68 void contentsChanged();
70 void goToCursor() const;
71 /// Name of the current format. Empty if none.
72 docstring currentFormatName(BufferView const * bv) const;
75 void needUpdate() const;
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);
81 /// Grab double clicks on the viewport
82 bool eventFilter(QObject * obj, QEvent * event);
84 QTextDocument * document_;
85 /// LaTeX syntax highlighter
86 LaTeXHighlighter * highlighter_;
88 std::string view_format_;
89 /// TexRow information from the last source view. If TexRow is unavailable
90 /// for the last format then texrow_ is null.
91 unique_ptr<TexRow> texrow_;
95 class GuiViewSource : public DockView
101 GuiView & parent, ///< the main window where to dock.
102 Qt::DockWidgetArea area = Qt::BottomDockWidgetArea, ///< Position of the dock (and also drawer)
103 Qt::WindowFlags flags = 0);
105 /// Controller inherited method.
107 bool initialiseParams(std::string const & source);
108 void clearParams() {}
109 void dispatchParams() {}
110 bool isBufferDependent() const { return true; }
111 bool canApply() const { return true; }
112 bool canApplyToReadOnly() const { return true; }
114 void enableView(bool enable);
115 void saveSession(QSettings & settings) const;
116 void restoreSession();
117 bool wantInitialFocus() const { return false; }
122 void onBufferViewChanged();//override
125 /// The title displayed by the dialog reflects source type.
127 /// schedule an update after delay
128 void scheduleUpdate();
129 /// schedule an update now
130 void scheduleUpdateNow();
133 void realUpdateView();
136 /// The encapsulated widget.
137 ViewSourceWidget * widget_;
139 QTimer * update_timer_;
142 } // namespace frontend
145 #endif // GUIVIEWSOURCE_H