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>
37 class LaTeXHighlighter;
40 class ViewSourceWidget : public QWidget, public Ui::ViewSourceUi
45 ViewSourceWidget(QWidget * parent);
46 /// returns true if the string has changed
47 bool setText(QString const & qstr = QString());
49 void saveSession(QSettings & settings, QString const & session_key) const;
51 void restoreSession(QString const & session_key);
53 int updateDelay() const;
57 void resizeEvent (QResizeEvent * event) override;
61 void updateView(BufferView const * bv);
63 void setViewFormat(int const index);
65 void updateDefaultFormat(BufferView const & bv);
67 void contentsChanged();
69 void goToCursor() const;
70 /// Name of the current format. Empty if none.
71 docstring currentFormatName(BufferView const * bv) const;
74 void needUpdate() const;
77 /// Get the source code of selected paragraphs, or the whole document.
78 void getContent(BufferView const & view, Buffer::OutputWhat output,
79 docstring & str, std::string const & format, bool master);
80 /// Grab double clicks on the viewport
81 bool eventFilter(QObject * obj, QEvent * event) override;
83 QTextDocument * document_;
84 /// LaTeX syntax highlighter
85 LaTeXHighlighter * highlighter_;
87 std::string view_format_;
88 /// TexRow information from the last source view. If TexRow is unavailable
89 /// for the last format then texrow_ is null.
90 unique_ptr<TexRow> texrow_;
94 class GuiViewSource : public DockView
100 GuiView & parent, ///< the main window where to dock.
101 Qt::DockWidgetArea area = Qt::BottomDockWidgetArea, ///< Position of the dock (and also drawer)
102 Qt::WindowFlags flags = 0);
104 /// Controller inherited method.
106 bool initialiseParams(std::string const & source) override;
107 void clearParams() override {}
108 void dispatchParams() override {}
109 bool isBufferDependent() const override { return true; }
110 bool canApply() const override { return true; }
111 bool canApplyToReadOnly() const override { return true; }
112 void updateView() override;
113 void enableView(bool enable) override;
114 void saveSession(QSettings & settings) const override;
115 void restoreSession() override;
116 bool wantInitialFocus() const override { return false; }
121 void onBufferViewChanged() override;
124 /// The title displayed by the dialog reflects source type.
126 /// schedule an update after delay
127 void scheduleUpdate();
128 /// schedule an update now
129 void scheduleUpdateNow();
132 void realUpdateView();
135 /// The encapsulated widget.
136 ViewSourceWidget * widget_;
138 QTimer * update_timer_;
141 } // namespace frontend
144 #endif // GUIVIEWSOURCE_H