#include "ui_ViewSourceUi.h"
+#include "Buffer.h"
#include "DockView.h"
-#include "GuiView.h"
-#include "qt_helpers.h"
-
-#include "support/debug.h"
+#include "TexRow.h"
#include <QDockWidget>
#include <QString>
-#include <QTextCharFormat>
+#include <QTimer>
class QTextDocument;
Q_OBJECT
public:
- ViewSourceWidget(GuiViewSource &);
+ ViewSourceWidget();
+ ///
+ void setBufferView(BufferView const * bv);
+ /// returns true if the string has changed
+ bool setText(QString const & qstr = QString());
+ ///
+ void saveSession(QString const & session_key) const;
+ ///
+ void restoreSession(QString const & session_key);
+
+protected:
+ ///
+ void resizeEvent (QResizeEvent * event);
public Q_SLOTS:
- // update content
+ /// schedule an update after delay
void updateView();
+ /// schedule an update now
+ void updateViewNow();
///
- void update(bool full_source);
+ void setViewFormat(int const index);
+ //
+ void updateDefaultFormat();
+ ///
+ void contentsChanged();
+ ///
+ void gotoCursor();
+
+private Q_SLOTS:
+ /// update content
+ void realUpdateView();
private:
+ /// 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);
///
- GuiViewSource & controller_;
+ BufferView const * bv_;
///
QTextDocument * document_;
/// LaTeX syntax highlighter
LaTeXHighlighter * highlighter_;
+ ///
+ QString view_format_;
+ ///
+ QTimer * update_timer_;
+ /// TexRow information from the last source view. If TexRow is unavailable
+ /// for the last format then texrow_ is null.
+ std::auto_ptr<TexRow> texrow_;
};
bool canApply() const { return true; }
bool canApplyToReadOnly() const { return true; }
void updateView();
+ void enableView(bool enable);
+ void saveSession() const;
+ void restoreSession();
+ bool wantInitialFocus() const { return false; }
///@}
/// The title displayed by the dialog reflects source type.
QString title() const;
- /** get the source code of selected paragraphs, or the whole document
- \param fullSource get full source code
- */
- QString getContent(bool fullSource);
- /** get the cursor position in the source code
- */
- std::pair<int, int> getRows() const;
-
private:
/// The encapsulated widget.
ViewSourceWidget * widget_;