]> git.lyx.org Git - features.git/commitdiff
Restore docked View source widget.
authorAbdelrazak Younes <younes@lyx.org>
Sat, 8 Sep 2007 16:04:25 +0000 (16:04 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sat, 8 Sep 2007 16:04:25 +0000 (16:04 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20142 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/Dialogs.cpp
src/frontends/qt4/DockView.h
src/frontends/qt4/GuiViewSource.cpp
src/frontends/qt4/GuiViewSource.h

index 26f1213ffc708a89e03356c49e03740d81ef656b..05bcc8ed818863fc1ccb0f58dc2bade15b646aed 100644 (file)
@@ -15,7 +15,6 @@
 
 #include "ButtonController.h"
 #include "DockView.h"
-#include "GuiView.h"
 #include "GuiAbout.h"
 #include "GuiBibitem.h"
 #include "GuiBibtex.h"
@@ -38,7 +37,6 @@
 #include "GuiNomencl.h"
 #include "GuiListings.h"
 #include "GuiLog.h"
-#include "GuiViewSource.h"
 #include "GuiNote.h"
 #include "GuiParagraph.h"
 #include "GuiPrefs.h"
@@ -52,6 +50,8 @@
 #include "GuiTabularCreate.h"
 #include "GuiTexinfo.h"
 #include "GuiToc.h"
+#include "GuiView.h"
+#include "GuiViewSource.h"
 #include "TocWidget.h"
 #include "GuiURL.h"
 #include "GuiVSpace.h"
@@ -115,6 +115,7 @@ Dialog * Dialogs::build(string const & name)
        BOOST_ASSERT(isValidName(name));
 
        Dialog * dialog = 0;
+       GuiViewBase & guiview = static_cast<GuiViewBase &>(lyxview_);
 
        if (name == "aboutlyx") {
                dialog = new GuiAboutDialog(lyxview_);
@@ -161,7 +162,8 @@ Dialog * Dialogs::build(string const & name)
        } else if (name == "log") {
                dialog = new GuiLogDialog(lyxview_);
        } else if (name == "view-source") {
-               dialog = new GuiViewSourceDialog(lyxview_);
+               dialog = new DockView<ControlViewSource, GuiViewSourceDialog>(
+                       guiview, name, Qt::BottomDockWidgetArea);
        } else if (name == "mathdelimiter") {
                dialog = new GuiDelimiterDialog(lyxview_);
        } else if (name == "mathmatrix") {
index 0a2f6bb876e02a19e81c2d601bb7065e54c6c455..30e336119fc462266f657ffcaa5657591ea7d2ab 100644 (file)
 #define DOCK_VIEW_H
 
 #include "controllers/Dialog.h"
+#include "GuiView.h"
 #include "qt_helpers.h"
+#include "debug.h"
+
+#include <QDockWidget>
 
 #include <boost/scoped_ptr.hpp>
 
-#include <QDockWidget>
-#include <QMainWindow>
+#include <string>
 
 namespace lyx {
 namespace frontend {
 
-/*
 /// Dock Widget container for LyX dialogs.
 /// This template class that encapsulates a given Widget inside a
-/// DockWidget and presents a Dialog::View interface
-template<class Controller, class Widget>
-class DockView : public QDockWidget, public Dialog::View
+/// QDockWidget and presents a Dialog interface
+template<class MyController, class MyWidget>
+class DockView : public QDockWidget, public Dialog
 {
 public:
        DockView(
-               Dialog & dialog, ///< The (one) parent Dialog class.
-               Controller * form, ///< Associated model/controller
-               QMainWindow * parent, ///< the main window where to dock.
-               docstring const & title, ///< Window title (shown in the top title bar).
+               GuiViewBase & parent, ///< the main window where to dock.
+               std::string const & title, ///< Window title (shown in the top title bar).
                Qt::DockWidgetArea area = Qt::LeftDockWidgetArea, ///< Position of the dock (and also drawer)
                Qt::WindowFlags flags = 0
                )
-               : QDockWidget(toqstr(title), parent, flags), 
-                       Dialog::View(dialog, title)
+               : QDockWidget(toqstr(title), &parent, flags),
+               Dialog(parent, title)
        {
                if (flags & Qt::Drawer)
                        setFeatures(QDockWidget::NoDockWidgetFeatures);
-               widget_.reset(new Widget(form));
+               MyController * controller = new MyController(*this);
+               setController(controller);
+               widget_.reset(new MyWidget(*controller));
                setWidget(widget_.get());
-               parent->addDockWidget(area, this);
+               parent.addDockWidget(area, this);
        }
 
-       /// Dialog::View inherited methods
+       /// Dialog inherited methods
        //@{
        void applyView() {}
        void hideView() { QDockWidget::hide(); }
@@ -58,17 +60,16 @@ public:
        void redrawView() {}
        void updateView()
        {
-               widget_->update();
+               widget_->updateView();
                QDockWidget::update();
        }
        //@}
 private:
        /// The encapsulated widget.
-       boost::scoped_ptr<Widget> widget_;
+       boost::scoped_ptr<MyWidget> widget_;
 };
-*/
 
 } // frontend
 } // lyx
 
-#endif // TOC_WIDGET_H
+#endif // DOCK_VIEW_H
index 8b67fe23d14eb210d153359cbc26da29e0c39566..2394e1c29f58a841366763af329315ce9d8ccec5 100644 (file)
 namespace lyx {
 namespace frontend {
 
-GuiViewSourceDialog::GuiViewSourceDialog(LyXView & lv)
-       : GuiDialog(lv, "view-source"),
-               document_(new QTextDocument(this)),
+GuiViewSourceDialog::GuiViewSourceDialog(ControlViewSource & controller)
+       :       controller_(controller), document_(new QTextDocument(this)),
                highlighter_(new LaTeXHighlighter(document_))
 {
        setupUi(this);
-       setController(new ControlViewSource(*this));
-
-       //      GuiViewBase & gui_view = static_cast<GuiViewBase &>(lyxview_);
-       //              *dialog, qvs, &gui_view, _("LaTeX Source"), Qt::BottomDockWidgetArea));
 
        connect(viewFullSourceCB, SIGNAL(clicked()),
                this, SLOT(update()));
@@ -57,14 +52,6 @@ GuiViewSourceDialog::GuiViewSourceDialog(LyXView & lv)
        viewSourceTV->setFont(font);
        // again, personal taste
        viewSourceTV->setWordWrapMode(QTextOption::NoWrap);
-
-       bc().setPolicy(ButtonPolicy::OkCancelPolicy);
-}
-
-
-ControlViewSource & GuiViewSourceDialog::controller() const
-{
-       return static_cast<ControlViewSource &>(Dialog::controller());
 }
 
 
@@ -74,7 +61,7 @@ void GuiViewSourceDialog::updateView()
                update(viewFullSourceCB->isChecked());
 
        int beg, end;
-       boost::tie(beg, end) = controller().getRows();
+       boost::tie(beg, end) = controller_.getRows();
        QTextCursor c = QTextCursor(viewSourceTV->document());
        c.movePosition(QTextCursor::NextBlock, QTextCursor::MoveAnchor, beg);
        c.select(QTextCursor::BlockUnderCursor);
@@ -86,7 +73,7 @@ void GuiViewSourceDialog::updateView()
 
 void GuiViewSourceDialog::update(bool full_source)
 {
-       document_->setPlainText(toqstr(controller().updateContent(full_source)));
+       document_->setPlainText(toqstr(controller_.updateContent(full_source)));
 }
 
 
index 404020b18376c1811024cea7ab357c21b3b3b014..60003bf70136051a89c9b3d161c529c8d3dab36e 100644 (file)
@@ -44,12 +44,12 @@ private:
 };
 
 
-class GuiViewSourceDialog : public GuiDialog, public Ui::ViewSourceUi
+class GuiViewSourceDialog : public QWidget, public Ui::ViewSourceUi
 {
        Q_OBJECT
 
 public:
-       GuiViewSourceDialog(LyXView & lv);
+       GuiViewSourceDialog(ControlViewSource &);
 
 public Q_SLOTS:
        // update content
@@ -61,7 +61,7 @@ public Q_SLOTS:
 
 private:
        ///
-       ControlViewSource & controller() const; 
+       ControlViewSource & controller_;        
        ///
        QTextDocument * document_;
        /// LaTeX syntax highlighter