]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/DockView.h
rename a few view functions from foo() to fooView()
[lyx.git] / src / frontends / qt4 / DockView.h
1 // -*- C++ -*-
2 /**
3  * \file DockView.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Abdelrazak Younes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef DOCK_VIEW_H
13 #define DOCK_VIEW_H
14
15 #include "controllers/Dialog.h"
16 #include "qt_helpers.h"
17
18 #include <boost/scoped_ptr.hpp>
19
20 #include <QDockWidget>
21 #include <QMainWindow>
22
23 namespace lyx {
24 namespace frontend {
25
26 /// Dock Widget container for LyX dialogs.
27 /// This template class that encapsulates a given Widget inside a
28 /// DockWidget and presents a Dialog::View interface
29 template<class Controller, class Widget>
30 class DockView : public QDockWidget, public Dialog::View
31 {
32 public:
33         DockView(
34                 Dialog & dialog, ///< The (one) parent Dialog class.
35                 Controller * form, ///< Associated model/controller
36                 QMainWindow * parent, ///< the main window where to dock.
37                 docstring const & title, ///< Window title (shown in the top title bar).
38                 Qt::DockWidgetArea area = Qt::LeftDockWidgetArea, ///< Position of the dock (and also drawer)
39                 Qt::WindowFlags flags = 0
40                 )
41                 : QDockWidget(toqstr(title), parent, flags), 
42                         Dialog::View(dialog, title)
43         {
44                 if (flags & Qt::Drawer)
45                         setFeatures(QDockWidget::NoDockWidgetFeatures);
46                 widget_.reset(new Widget(form));
47                 setWidget(widget_.get());
48                 parent->addDockWidget(area, this);
49         }
50
51         /// Dialog::View inherited methods
52         //@{
53         void applyView() {}
54         void hideView() { QDockWidget::hide(); }
55         void showView() { QDockWidget::show(); }
56         bool isVisibleView() const { return QDockWidget::isVisible(); }
57         void redrawView() {}
58         void updateView()
59         {
60                 widget_->update();
61                 QDockWidget::update();
62         }
63         //@}
64 private:
65         /// The encapsulated widget.
66         boost::scoped_ptr<Widget> widget_;
67 };
68
69 } // frontend
70 } // lyx
71
72 #endif // TOC_WIDGET_H