X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiViewSource.h;h=d5553ac2ea49a606234bdb7f470f9a7f0fc48e95;hb=425d092204118ea6c24c28e85fdf03fcf2bb51a4;hp=cd96789be654ec54fd26680b2fb7d11bc06d9c14;hpb=3f554746dc8cbbdf244c053c24afa4bd4f215907;p=lyx.git diff --git a/src/frontends/qt4/GuiViewSource.h b/src/frontends/qt4/GuiViewSource.h index cd96789be6..d5553ac2ea 100644 --- a/src/frontends/qt4/GuiViewSource.h +++ b/src/frontends/qt4/GuiViewSource.h @@ -16,14 +16,12 @@ #include "ui_ViewSourceUi.h" -#include "Dialog.h" +#include "DockView.h" #include "GuiView.h" #include "qt_helpers.h" -#include "debug.h" #include -#include -#include +#include #include class QTextDocument; @@ -31,121 +29,65 @@ class QTextDocument; namespace lyx { namespace frontend { -class ControlViewSource; +class GuiViewSource; class LaTeXHighlighter; -class GuiViewSourceDialog : public QWidget, public Ui::ViewSourceUi +class ViewSourceWidget : public QWidget, public Ui::ViewSourceUi { Q_OBJECT public: - GuiViewSourceDialog(ControlViewSource &); + ViewSourceWidget(); + /// + void setBufferView(BufferView const * bv); public Q_SLOTS: // update content void updateView(); - /// - QTextDocument * document() { return document_; } - /// - void update(bool full_source); private: /// - ControlViewSource & controller_; + BufferView const * bv_; /// QTextDocument * document_; /// LaTeX syntax highlighter LaTeXHighlighter * highlighter_; }; -/** - * A controller for a read-only text browser. - */ -class ControlViewSource : public Controller { + +class GuiViewSource : public DockView +{ + Q_OBJECT + public: - /// - ControlViewSource(Dialog &); - /** \param source source code to be displayed - */ + 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(); + bool wantInitialFocus() const { return false; } + ///@} /// The title displayed by the dialog reflects source type. - docstring const title() const; - - /** get the source code of selected paragraphs, or the whole document - \param fullSource get full source code - */ - docstring const updateContent(bool fullSource); - /** get the cursor position in the source code - */ - std::pair getRows() const; -}; - + QString title() const; -class GuiViewSource : public QDockWidget, public Dialog -{ -public: - GuiViewSource(GuiViewBase & parent) - : QDockWidget(&parent, Qt::WindowFlags(0)), name_("view-source") - { - ControlViewSource * c = new ControlViewSource(*this); - controller_ = c; - controller_->setLyXView(parent); - widget_ = new GuiViewSourceDialog(*c); - setWidget(widget_); - setWindowTitle(widget_->windowTitle()); - parent.addDockWidget(Qt::BottomDockWidgetArea, this); - } - ~GuiViewSource() { delete widget_; delete controller_; } - - /// Dialog inherited methods - //@{ - void applyView() {} - void hideView() { QDockWidget::hide(); } - void showData(std::string const & data) - { - controller_->initialiseParams(data); - showView(); - } - void showView() - { - widget_->updateView(); // make sure its up-to-date - QDockWidget::show(); - } - bool isVisibleView() const { return QDockWidget::isVisible(); } - void checkStatus() { updateView(); } - void redraw() { redrawView(); } - void redrawView() {} - void updateData(std::string const & data) - { - controller_->initialiseParams(data); - updateView(); - } - void updateView() - { - widget_->updateView(); - QDockWidget::update(); - } - bool isClosing() const { return false; } - void partialUpdateView(int /*id*/) {} - Controller & controller() { return *controller_; } - std::string name() const { return name_; } - //@} private: /// The encapsulated widget. - GuiViewSourceDialog * widget_; - Controller * controller_; - std::string name_; + ViewSourceWidget * widget_; }; } // namespace frontend