2007-03-12 14:23:44 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \file DockView.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Abdelrazak Younes
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DOCK_VIEW_H
|
|
|
|
#define DOCK_VIEW_H
|
|
|
|
|
2007-03-12 15:11:18 +00:00
|
|
|
#include "controllers/Dialog.h"
|
2007-09-08 16:04:25 +00:00
|
|
|
#include "GuiView.h"
|
2007-03-12 15:11:18 +00:00
|
|
|
#include "qt_helpers.h"
|
2007-09-08 16:04:25 +00:00
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
#include <QDockWidget>
|
2007-03-12 14:23:44 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
|
|
|
/// Dock Widget container for LyX dialogs.
|
|
|
|
/// This template class that encapsulates a given Widget inside a
|
2007-09-08 16:04:25 +00:00
|
|
|
/// QDockWidget and presents a Dialog interface
|
|
|
|
template<class MyController, class MyWidget>
|
|
|
|
class DockView : public QDockWidget, public Dialog
|
2007-03-12 14:23:44 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
DockView(
|
2007-09-08 16:04:25 +00:00
|
|
|
GuiViewBase & parent, ///< the main window where to dock.
|
2007-09-08 16:31:28 +00:00
|
|
|
std::string const & name, ///< dialog identifier.
|
2007-05-29 11:38:28 +00:00
|
|
|
Qt::DockWidgetArea area = Qt::LeftDockWidgetArea, ///< Position of the dock (and also drawer)
|
|
|
|
Qt::WindowFlags flags = 0
|
2007-09-10 22:32:59 +00:00
|
|
|
)
|
|
|
|
: QDockWidget(&parent, flags), name_(name)
|
2007-03-12 14:23:44 +00:00
|
|
|
{
|
2007-05-29 11:38:28 +00:00
|
|
|
if (flags & Qt::Drawer)
|
|
|
|
setFeatures(QDockWidget::NoDockWidgetFeatures);
|
2007-09-10 22:32:59 +00:00
|
|
|
MyController * c = new MyController(*this);
|
|
|
|
controller_ = c;
|
|
|
|
controller_->setLyXView(parent);
|
|
|
|
widget_ = new MyWidget(*c);
|
|
|
|
setWidget(widget_);
|
2007-09-08 16:31:28 +00:00
|
|
|
setWindowTitle(widget_->windowTitle());
|
2007-09-08 16:04:25 +00:00
|
|
|
parent.addDockWidget(area, this);
|
2007-03-12 14:23:44 +00:00
|
|
|
}
|
2007-09-10 22:32:59 +00:00
|
|
|
~DockView() { delete widget_; delete controller_; }
|
2007-03-12 14:23:44 +00:00
|
|
|
|
2007-09-08 16:04:25 +00:00
|
|
|
/// Dialog inherited methods
|
2007-03-12 14:23:44 +00:00
|
|
|
//@{
|
2007-09-03 20:28:26 +00:00
|
|
|
void applyView() {}
|
|
|
|
void hideView() { QDockWidget::hide(); }
|
2007-09-26 14:37:26 +00:00
|
|
|
void showView()
|
|
|
|
{
|
|
|
|
widget_->updateView(); // make sure its up-to-date
|
|
|
|
QDockWidget::show();
|
|
|
|
}
|
2007-09-03 20:28:26 +00:00
|
|
|
bool isVisibleView() const { return QDockWidget::isVisible(); }
|
2007-09-10 22:32:59 +00:00
|
|
|
void checkStatus() {}
|
|
|
|
void redraw() { redrawView(); }
|
2007-09-03 20:28:26 +00:00
|
|
|
void redrawView() {}
|
2007-09-26 14:37:26 +00:00
|
|
|
void updateData(string const &) { updateView(); }
|
2007-09-03 20:28:26 +00:00
|
|
|
void updateView()
|
2007-03-12 14:23:44 +00:00
|
|
|
{
|
2007-09-08 16:04:25 +00:00
|
|
|
widget_->updateView();
|
2007-03-12 14:23:44 +00:00
|
|
|
QDockWidget::update();
|
|
|
|
}
|
2007-09-10 22:32:59 +00:00
|
|
|
bool isClosing() const { return false; }
|
|
|
|
void partialUpdateView(int /*id*/) {}
|
2007-09-11 18:33:42 +00:00
|
|
|
Controller & controller() { return *controller_; }
|
2007-09-10 22:32:59 +00:00
|
|
|
std::string name() const { return name_; }
|
2007-03-12 14:23:44 +00:00
|
|
|
//@}
|
|
|
|
private:
|
|
|
|
/// The encapsulated widget.
|
2007-09-10 22:32:59 +00:00
|
|
|
MyWidget * widget_;
|
|
|
|
Controller * controller_;
|
|
|
|
std::string name_;
|
2007-03-12 14:23:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // frontend
|
|
|
|
} // lyx
|
|
|
|
|
2007-09-08 16:04:25 +00:00
|
|
|
#endif // DOCK_VIEW_H
|