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 & name, ///< dialog identifier.
39 Qt::DockWidgetArea area = Qt::LeftDockWidgetArea, ///< Position of the dock (and also drawer)
40 Qt::WindowFlags flags = 0
42 : QDockWidget(&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 setWindowTitle(widget_->windowTitle());
52 parent.addDockWidget(area, this);
55 /// Dialog inherited methods
58 void hideView() { QDockWidget::hide(); }
59 void showView() { QDockWidget::show(); }
60 bool isVisibleView() const { return QDockWidget::isVisible(); }
64 widget_->updateView();
65 QDockWidget::update();
69 /// The encapsulated widget.
70 boost::scoped_ptr<MyWidget> widget_;