#include "ui_ViewSourceUi.h"
-#include "ControlViewSource.h"
+#include "DockView.h"
+#include "GuiView.h"
+#include "qt_helpers.h"
-#include <QWidget>
-#include <QSyntaxHighlighter>
+#include <QDockWidget>
+#include <QString>
#include <QTextCharFormat>
class QTextDocument;
namespace lyx {
namespace frontend {
-// used already twice...
-class LaTeXHighlighter : public QSyntaxHighlighter
-{
-public:
- LaTeXHighlighter(QTextDocument * parent);
-
-protected:
- void highlightBlock(QString const & text);
+class GuiViewSource;
+class LaTeXHighlighter;
-private:
- QTextCharFormat commentFormat;
- QTextCharFormat keywordFormat;
- QTextCharFormat mathFormat;
-};
-
-
-class GuiViewSourceDialog : public QWidget, public Ui::ViewSourceUi
+class ViewSourceWidget : public QWidget, public Ui::ViewSourceUi
{
Q_OBJECT
public:
- GuiViewSourceDialog(ControlViewSource &);
+ ViewSourceWidget(GuiViewSource &);
public Q_SLOTS:
// update content
void updateView();
- ///
- QTextDocument * document() { return document_; }
- ///
- void update(bool full_source);
private:
///
- ControlViewSource & controller_;
+ GuiViewSource & controller_;
///
QTextDocument * document_;
/// LaTeX syntax highlighter
};
+class GuiViewSource : public DockView
+{
+ Q_OBJECT
+
+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();
+
+ /// Controller inherited method.
+ ///@{
+ bool initialiseParams(std::string const & source);
+ void clearParams() {}
+ void dispatchParams() {}
+ bool isBufferDependent() const { return true; }
+ bool canApply() const { return true; }
+ bool canApplyToReadOnly() const { return true; }
+ void updateView();
+ void enableView(bool enable);
+ void saveSession() const;
+ void restoreSession();
+ ///@}
+
+ /// 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);
+ // cursor position in the source code
+ struct Row { int begin; int end; };
+ Row getRows() const;
+
+private:
+ /// The encapsulated widget.
+ ViewSourceWidget * widget_;
+};
+
} // namespace frontend
} // namespace lyx