X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiViewSource.h;h=3d35587940de308ab2550d626cbf2e7b0d7fe2d4;hb=c203a842fce88f7313ceb6da99f6a4a10f50f365;hp=9f460aa105443ddd38904b784e2602f7ccad4e3c;hpb=2e968d06610325ad5b69cee0e93f99b8435d5542;p=lyx.git diff --git a/src/frontends/qt4/GuiViewSource.h b/src/frontends/qt4/GuiViewSource.h index 9f460aa105..3d35587940 100644 --- a/src/frontends/qt4/GuiViewSource.h +++ b/src/frontends/qt4/GuiViewSource.h @@ -16,40 +16,79 @@ #include "ui_ViewSourceUi.h" +#include "Buffer.h" #include "DockView.h" -#include "GuiView.h" -#include "qt_helpers.h" #include #include -#include +#include + class QTextDocument; + namespace lyx { + +class TexRow; + + namespace frontend { class GuiViewSource; class LaTeXHighlighter; + class ViewSourceWidget : public QWidget, public Ui::ViewSourceUi { Q_OBJECT public: - ViewSourceWidget(GuiViewSource &); + ViewSourceWidget(QWidget * parent); + /// returns true if the string has changed + bool setText(QString const & qstr = QString()); + /// + void saveSession(QSettings & settings, QString const & session_key) const; + /// + void restoreSession(QString const & session_key); + /// + int updateDelay() const; + +protected: + /// + void resizeEvent (QResizeEvent * event); public Q_SLOTS: - // update content - void updateView(); + /// + void updateView(BufferView const * bv); + /// + void setViewFormat(int const index); + // + void updateDefaultFormat(BufferView const & bv); + /// + void contentsChanged(); + /// + void goToCursor() const; + /// Name of the current format. Empty if none. + docstring currentFormatName(BufferView const * bv) const; + +Q_SIGNALS: + void needUpdate() const; private: - /// - GuiViewSource & controller_; + /// Get the source code of selected paragraphs, or the whole document. + void getContent(BufferView const & view, Buffer::OutputWhat output, + docstring & str, std::string const & format, bool master); + /// Grab double clicks on the viewport + bool eventFilter(QObject * obj, QEvent * event); /// QTextDocument * document_; /// LaTeX syntax highlighter LaTeXHighlighter * highlighter_; + /// + std::string view_format_; + /// TexRow information from the last source view. If TexRow is unavailable + /// for the last format then texrow_ is null. + unique_ptr texrow_; }; @@ -61,9 +100,7 @@ public: GuiViewSource( GuiView & parent, ///< the main window where to dock. Qt::DockWidgetArea area = Qt::BottomDockWidgetArea, ///< Position of the dock (and also drawer) - Qt::WindowFlags flags = 0); - - ~GuiViewSource(); + Qt::WindowFlags flags = {}); /// Controller inherited method. ///@{ @@ -75,24 +112,31 @@ public: bool canApplyToReadOnly() const { return true; } void updateView(); void enableView(bool enable); - void saveSession() const; + void saveSession(QSettings & settings) const; void restoreSession(); + bool wantInitialFocus() const { return false; } ///@} +public Q_SLOTS: + /// + void onBufferViewChanged();//override + +private Q_SLOTS: /// The title displayed by the dialog reflects source type. - QString title() const; + void updateTitle(); + /// schedule an update after delay + void scheduleUpdate(); + /// schedule an update now + void scheduleUpdateNow(); - /** get the source code of selected paragraphs, or the whole document - \param fullSource get full source code - */ - QString getContent(bool fullSource); - // cursor position in the source code - struct Row { int begin; int end; }; - Row getRows() const; + /// update content + void realUpdateView(); private: /// The encapsulated widget. ViewSourceWidget * widget_; + /// + QTimer * update_timer_; }; } // namespace frontend