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"
16 #include "qt_helpers.h"
18 #include <boost/scoped_ptr.hpp>
20 #include <QDockWidget>
21 #include <QMainWindow>
27 /// Dock Widget container for LyX dialogs.
28 /// This template class that encapsulates a given Widget inside a
29 /// DockWidget and presents a Dialog::View interface
30 template<class Controller, class Widget>
31 class DockView : public QDockWidget, public Dialog::View
35 Dialog & dialog, ///< The (one) parent Dialog class.
36 Controller * form, ///< Associated model/controller
37 QMainWindow * parent, ///< the main window where to dock.
38 docstring 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),
43 Dialog::View(dialog, title)
45 if (flags & Qt::Drawer)
46 setFeatures(QDockWidget::NoDockWidgetFeatures);
47 widget_.reset(new Widget(form));
48 setWidget(widget_.get());
49 parent->addDockWidget(area, this);
52 /// Dialog::View inherited methods
55 void hideView() { QDockWidget::hide(); }
56 void showView() { QDockWidget::show(); }
57 bool isVisibleView() const { return QDockWidget::isVisible(); }
62 QDockWidget::update();
66 /// The encapsulated widget.
67 boost::scoped_ptr<Widget> widget_;
74 #endif // TOC_WIDGET_H