#include "ButtonController.h"
#include "DockView.h"
-#include "GuiView.h"
#include "GuiAbout.h"
#include "GuiBibitem.h"
#include "GuiBibtex.h"
#include "GuiNomencl.h"
#include "GuiListings.h"
#include "GuiLog.h"
-#include "GuiViewSource.h"
#include "GuiNote.h"
#include "GuiParagraph.h"
#include "GuiPrefs.h"
#include "GuiTabularCreate.h"
#include "GuiTexinfo.h"
#include "GuiToc.h"
+#include "GuiView.h"
+#include "GuiViewSource.h"
#include "TocWidget.h"
#include "GuiURL.h"
#include "GuiVSpace.h"
BOOST_ASSERT(isValidName(name));
Dialog * dialog = 0;
+ GuiViewBase & guiview = static_cast<GuiViewBase &>(lyxview_);
if (name == "aboutlyx") {
dialog = new GuiAboutDialog(lyxview_);
} 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") {
#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(); }
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
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()));
viewSourceTV->setFont(font);
// again, personal taste
viewSourceTV->setWordWrapMode(QTextOption::NoWrap);
-
- bc().setPolicy(ButtonPolicy::OkCancelPolicy);
-}
-
-
-ControlViewSource & GuiViewSourceDialog::controller() const
-{
- return static_cast<ControlViewSource &>(Dialog::controller());
}
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);
void GuiViewSourceDialog::update(bool full_source)
{
- document_->setPlainText(toqstr(controller().updateContent(full_source)));
+ document_->setPlainText(toqstr(controller_.updateContent(full_source)));
}
};
-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
private:
///
- ControlViewSource & controller() const;
+ ControlViewSource & controller_;
///
QTextDocument * document_;
/// LaTeX syntax highlighter