]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/DockView.h
c93e4e9a7b836d2b1a6d884ce0012d09133b5fb1
[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
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_(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 redraw() { redrawView(); }
63         void redrawView() {}
64         void updateData(std::string const & data)
65         {
66                 initialiseParams(data);
67                 updateView();
68         }
69         bool isClosing() const { return false; }
70         void partialUpdateView(int /*id*/) {}
71         std::string name() const { return name_; }
72         //@}
73 private:
74         std::string name_;
75 };
76
77 } // frontend
78 } // lyx
79
80 #endif // DOCK_VIEW_H