]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiViewSource.h
Complete the removal of the embedding stuff. Maybe. It's hard to be sure we got every...
[lyx.git] / src / frontends / qt4 / GuiViewSource.h
index 1f3e56e76973f22bddd73dba9d8e231dd2618944..51a3e94cb65e6ed11148d479e10b5fc68d5715d5 100644 (file)
 #ifndef GUIVIEWSOURCE_H
 #define GUIVIEWSOURCE_H
 
-#include "ControlViewSource.h"
-#include "Application.h"
 #include "ui_ViewSourceUi.h"
 
-#include <QWidget>
-#include <QSyntaxHighlighter>
+#include "DockView.h"
+#include "GuiView.h"
+#include "qt_helpers.h"
+
+#include "support/debug.h"
+
+#include <QDockWidget>
+#include <QString>
 #include <QTextCharFormat>
 
 class QTextDocument;
@@ -27,49 +31,25 @@ class QTextDocument;
 namespace lyx {
 namespace frontend {
 
-// used already twice...
-class LaTeXHighlighter : public QSyntaxHighlighter
-{
-public:
-       LaTeXHighlighter(QTextDocument * parent);
-
-protected:
-       void highlightBlock(QString const & text);
-
-private:
-       QTextCharFormat commentFormat;
-       QTextCharFormat keywordFormat;
-       QTextCharFormat mathFormat;
-};
-
-
 class GuiViewSource;
+class LaTeXHighlighter;
 
-class GuiViewSourceDialog : public QWidget, public Ui::ViewSourceUi {
+class ViewSourceWidget : public QWidget, public Ui::ViewSourceUi
+{
        Q_OBJECT
+
 public:
-       GuiViewSourceDialog(GuiViewSource * form);
+       ViewSourceWidget(GuiViewSource &);
 
 public Q_SLOTS:
        // update content
-       void update();
-
-private:
-       GuiViewSource * form_;
-};
-
-
-///
-class GuiViewSource : public QObject, public ControlViewSource {
-public:
-       ///
-       GuiViewSource(Dialog &);
-       ///
-       QTextDocument * document() { return document_; }
+       void updateView();
        ///
        void update(bool full_source);
 
 private:
+       ///
+       GuiViewSource & controller_;    
        ///
        QTextDocument * document_;
        /// LaTeX syntax highlighter
@@ -77,6 +57,45 @@ private:
 };
 
 
+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();
+       ///@}
+
+       /// 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