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>
22 #include <boost/scoped_ptr.hpp>
29 /// Dock Widget container for LyX dialogs.
30 /// This template class that encapsulates a given Widget inside a
31 /// QDockWidget and presents a Dialog interface
32 template<class MyController, class MyWidget>
33 class DockView : public QDockWidget, public Dialog
37 GuiViewBase & parent, ///< the main window where to dock.
38 std::string const & title, ///< Window title (shown in the top title bar).
39 Qt::DockWidgetArea area = Qt::LeftDockWidgetArea, ///< Position of the dock (and also drawer)
40 Qt::WindowFlags flags = 0
42 : QDockWidget(toqstr(title), &parent, flags),
45 if (flags & Qt::Drawer)
46 setFeatures(QDockWidget::NoDockWidgetFeatures);
47 MyController * controller = new MyController(*this);
48 setController(controller);
49 widget_.reset(new MyWidget(*controller));
50 setWidget(widget_.get());
51 parent.addDockWidget(area, this);
54 /// Dialog inherited methods
57 void hideView() { QDockWidget::hide(); }
58 void showView() { QDockWidget::show(); }
59 bool isVisibleView() const { return QDockWidget::isVisible(); }
63 widget_->updateView();
64 QDockWidget::update();
68 /// The encapsulated widget.
69 boost::scoped_ptr<MyWidget> widget_;