#include "ui_ViewSourceUi.h"
+#include "Buffer.h"
#include "DockView.h"
-#include "GuiView.h"
-#include "qt_helpers.h"
#include <QDockWidget>
#include <QString>
-#include <QTextCharFormat>
+#include <QTimer>
+
class QTextDocument;
+
namespace lyx {
+
+class TexRow;
+
+
namespace frontend {
class GuiViewSource;
class LaTeXHighlighter;
+
class ViewSourceWidget : public QWidget, public Ui::ViewSourceUi
{
Q_OBJECT
public:
- ViewSourceWidget();
+ ViewSourceWidget(QWidget * parent);
+ /// returns true if the string has changed
+ bool setText(QString const & qstr = QString());
///
- void setBufferView(BufferView const * bv);
+ void saveSession(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 updateDefaultFormat();
+ void updateView(BufferView const * bv);
///
- void fullSourceChanged();
+ 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:
- ///
- BufferView const * bv_;
+ /// 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_;
///
- bool force_getcontent_;
+ 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> texrow_;
};
Qt::DockWidgetArea area = Qt::BottomDockWidgetArea, ///< Position of the dock (and also drawer)
Qt::WindowFlags flags = 0);
- ~GuiViewSource();
-
/// Controller inherited method.
///@{
bool initialiseParams(std::string const & source);
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();
+
+ /// update content
+ void realUpdateView();
private:
/// The encapsulated widget.
ViewSourceWidget * widget_;
+ ///
+ QTimer * update_timer_;
};
} // namespace frontend