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.
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 showData(std::string const & data)
58 controller_->initialiseParams(data);
63 widget_->updateView(); // make sure its up-to-date
66 bool isVisibleView() const { return QDockWidget::isVisible(); }
67 void checkStatus() { updateView(); }
68 void redraw() { redrawView(); }
70 void updateData(std::string const & data)
72 controller_->initialiseParams(data);
77 widget_->updateView();
78 QDockWidget::update();
80 bool isClosing() const { return false; }
81 void partialUpdateView(int /*id*/) {}
82 Controller & controller() { return *controller_; }
83 std::string name() const { return name_; }
86 /// The encapsulated widget.
88 Controller * controller_;