From f044fc3dd0072d7bfe2ce2c5115bf580e795eef8 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Sat, 8 Sep 2007 16:04:25 +0000 Subject: [PATCH] Restore docked View source widget. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20142 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/Dialogs.cpp | 8 +++--- src/frontends/qt4/DockView.h | 39 +++++++++++++++-------------- src/frontends/qt4/GuiViewSource.cpp | 21 +++------------- src/frontends/qt4/GuiViewSource.h | 6 ++--- 4 files changed, 32 insertions(+), 42 deletions(-) diff --git a/src/frontends/qt4/Dialogs.cpp b/src/frontends/qt4/Dialogs.cpp index 26f1213ffc..05bcc8ed81 100644 --- a/src/frontends/qt4/Dialogs.cpp +++ b/src/frontends/qt4/Dialogs.cpp @@ -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(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( + guiview, name, Qt::BottomDockWidgetArea); } else if (name == "mathdelimiter") { dialog = new GuiDelimiterDialog(lyxview_); } else if (name == "mathmatrix") { diff --git a/src/frontends/qt4/DockView.h b/src/frontends/qt4/DockView.h index 0a2f6bb876..30e336119f 100644 --- a/src/frontends/qt4/DockView.h +++ b/src/frontends/qt4/DockView.h @@ -13,43 +13,45 @@ #define DOCK_VIEW_H #include "controllers/Dialog.h" +#include "GuiView.h" #include "qt_helpers.h" +#include "debug.h" + +#include #include -#include -#include +#include 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 DockView : public QDockWidget, public Dialog::View +/// QDockWidget and presents a Dialog interface +template +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_; + boost::scoped_ptr widget_; }; -*/ } // frontend } // lyx -#endif // TOC_WIDGET_H +#endif // DOCK_VIEW_H diff --git a/src/frontends/qt4/GuiViewSource.cpp b/src/frontends/qt4/GuiViewSource.cpp index 8b67fe23d1..2394e1c29f 100644 --- a/src/frontends/qt4/GuiViewSource.cpp +++ b/src/frontends/qt4/GuiViewSource.cpp @@ -24,16 +24,11 @@ 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(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(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))); } diff --git a/src/frontends/qt4/GuiViewSource.h b/src/frontends/qt4/GuiViewSource.h index 404020b183..60003bf701 100644 --- a/src/frontends/qt4/GuiViewSource.h +++ b/src/frontends/qt4/GuiViewSource.h @@ -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