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 <boost/scoped_ptr.hpp>
19 #include <QDockWidget>
20 #include <QMainWindow>
25 /// Dock Widget container for LyX dialogs.
26 /// This template class that encapsulates a given Widget inside a
27 /// DockWidget and presents a Dialog::View interface
28 template<class Controller, class Widget>
29 class DockView : public QDockWidget, public Dialog::View
33 Dialog & dialog, ///< The (one) parent Dialog class.
34 Controller * form, ///< Associated model/controller
35 QMainWindow * parent, ///< the main window where to dock.
36 docstring const & title ///< Window title (shown in the top title bar).
38 : QDockWidget(toqstr(title), parent), Dialog::View(dialog, title)
40 widget_.reset(new Widget(form));
41 setWidget(widget_.get());
42 parent->addDockWidget(Qt::LeftDockWidgetArea, this);
45 /// Dialog::View inherited methods
48 void hide() { QDockWidget::hide(); }
49 void show() { QDockWidget::show(); }
50 bool isVisible() const
51 { return QDockWidget::isVisible(); }
56 QDockWidget::update();
60 /// The encapsulated widget.
61 boost::scoped_ptr<Widget> widget_;
67 #endif // TOC_WIDGET_H