]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/DockView.h
fix memory leaks
[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 "support/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
29 {
30 public:
31         DockView(
32                 GuiView & 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), Dialog(parent, name)
38         {
39                 if (flags & Qt::Drawer)
40                         setFeatures(QDockWidget::NoDockWidgetFeatures);
41                 parent.addDockWidget(area, this);
42         }
43
44         virtual ~DockView() {}
45
46         /// Dialog inherited methods
47         //@{
48         void applyView() {}
49         void hideView() { QDockWidget::hide(); }
50         void showData(std::string const & data)
51         {
52                 initialiseParams(data);
53                 showView();
54         }
55         void showView()
56         {
57                 updateView();  // make sure its up-to-date
58                 QDockWidget::show();
59         }
60         bool isVisibleView() const { return QDockWidget::isVisible(); }
61         void checkStatus() { updateView(); }
62         void updateData(std::string const & data)
63         {
64                 initialiseParams(data);
65                 updateView();
66         }
67         bool isClosing() const { return false; }
68         //@}
69 };
70
71 } // frontend
72 } // lyx
73
74 #endif // DOCK_VIEW_H