]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/DockView.h
c56ceea4a6a29e51979f63e2d0e0a31ff7e5abab
[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 "Dialog.h"
16 #include "GuiView.h"
17 #include "qt_helpers.h"
18 #include "debug.h"
19
20 #include <QDockWidget>
21
22 namespace lyx {
23 namespace frontend {
24
25 /// Dock Widget container for LyX dialogs.
26 /// This template class that encapsulates a given Widget inside a
27 /// QDockWidget and presents a Dialog interface
28 class DockView : public QDockWidget, public Dialog, public Controller
29 {
30 public:
31         DockView(
32                 GuiViewBase & parent, ///< the main window where to dock.
33                 std::string const & name, ///< dialog identifier.
34                 Qt::DockWidgetArea area = Qt::LeftDockWidgetArea, ///< Position of the dock (and also drawer)
35                 Qt::WindowFlags flags = 0
36         )
37                 : QDockWidget(&parent, flags), name_(name), Controller(this)
38         {
39                 if (flags & Qt::Drawer)
40                         setFeatures(QDockWidget::NoDockWidgetFeatures);
41                 setLyXView(parent);
42                 parent.addDockWidget(area, this);
43         }
44
45         virtual ~DockView() {}
46
47         /// Dialog inherited methods
48         //@{
49         void applyView() {}
50         void hideView() { QDockWidget::hide(); }
51         void showData(std::string const & data)
52         {
53                 initialiseParams(data);
54                 showView();
55         }
56         void showView()
57         {
58                 updateView();  // make sure its up-to-date
59                 QDockWidget::show();
60         }
61         bool isVisibleView() const { return QDockWidget::isVisible(); }
62         void checkStatus() { updateView(); }
63         void redraw() { redrawView(); }
64         void redrawView() {}
65         void updateData(std::string const & data)
66         {
67                 initialiseParams(data);
68                 updateView();
69         }
70         bool isClosing() const { return false; }
71         void partialUpdateView(int /*id*/) {}
72         Controller & controller() { return *this; }
73         std::string name() const { return name_; }
74         //@}
75 private:
76         std::string name_;
77 };
78
79 } // frontend
80 } // lyx
81
82 #endif // DOCK_VIEW_H