4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Abdelrazak Younes
9 * Full author contact details are available in file CREDITS.
15 #include "controllers/Dialog.h"
17 #include "qt_helpers.h"
20 #include <QDockWidget>
25 /// Dock Widget container for LyX dialogs.
26 /// This template class that encapsulates a given Widget inside a
27 /// QDockWidget and presents a Dialog interface
28 template<class MyController, class MyWidget>
29 class DockView : public QDockWidget, public Dialog
33 GuiViewBase & parent, ///< the main window where to dock.
34 std::string const & name, ///< dialog identifier.
35 Qt::DockWidgetArea area = Qt::LeftDockWidgetArea, ///< Position of the dock (and also drawer)
36 Qt::WindowFlags flags = 0
38 : QDockWidget(&parent, flags), name_(name)
40 if (flags & Qt::Drawer)
41 setFeatures(QDockWidget::NoDockWidgetFeatures);
42 MyController * c = new MyController(*this);
44 controller_->setLyXView(parent);
45 widget_ = new MyWidget(*c);
47 setWindowTitle(widget_->windowTitle());
48 parent.addDockWidget(area, this);
50 ~DockView() { delete widget_; delete controller_; }
52 /// Dialog inherited methods
55 void hideView() { QDockWidget::hide(); }
56 void showView() { QDockWidget::show(); }
57 bool isVisibleView() const { return QDockWidget::isVisible(); }
59 void redraw() { redrawView(); }
63 widget_->updateView();
64 QDockWidget::update();
66 bool isClosing() const { return false; }
67 void partialUpdateView(int /*id*/) {}
68 Controller & controller() { return *controller_; }
69 std::string name() const { return name_; }
72 /// The encapsulated widget.
74 Controller * controller_;