2003-02-25 14:51:38 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \file QDialogView.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Angus Leeming
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-02-25 14:51:38 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef QDIALOGVIEW_H
|
|
|
|
#define QDIALOGVIEW_H
|
|
|
|
|
|
|
|
#include "Dialog.h"
|
|
|
|
#include <boost/scoped_ptr.hpp>
|
|
|
|
|
2003-09-07 21:25:37 +00:00
|
|
|
#include <qapplication.h>
|
2003-02-25 14:51:38 +00:00
|
|
|
#include <qdialog.h>
|
|
|
|
#include <qobject.h>
|
|
|
|
|
|
|
|
class Qt2BC;
|
|
|
|
|
|
|
|
/** This class is an Qt2 GUI base class.
|
|
|
|
*/
|
|
|
|
class QDialogView : public QObject, public Dialog::View {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
QDialogView(Dialog &, std::string const &);
|
2003-02-25 14:51:38 +00:00
|
|
|
///
|
|
|
|
virtual ~QDialogView() {}
|
|
|
|
///
|
|
|
|
bool readOnly() const;
|
|
|
|
protected:
|
|
|
|
/// build the actual dialog
|
|
|
|
virtual void build_dialog() = 0;
|
|
|
|
///
|
|
|
|
virtual void build() = 0;
|
|
|
|
/// Hide the dialog.
|
|
|
|
virtual void hide();
|
|
|
|
/// Create the dialog if necessary, update it and display it.
|
|
|
|
virtual void show();
|
|
|
|
/// update the dialog's contents
|
|
|
|
virtual void update_contents() = 0;
|
|
|
|
///
|
|
|
|
virtual bool isVisible() const;
|
|
|
|
|
|
|
|
/// the dialog has changed contents
|
|
|
|
virtual void changed();
|
|
|
|
|
|
|
|
/// is the dialog currently valid ?
|
|
|
|
virtual bool isValid();
|
|
|
|
|
|
|
|
///
|
2003-03-10 03:13:28 +00:00
|
|
|
Qt2BC & bcview();
|
2003-02-25 14:51:38 +00:00
|
|
|
|
|
|
|
/// are we updating ?
|
|
|
|
bool updating_;
|
|
|
|
protected slots:
|
|
|
|
// dialog closed from WM
|
|
|
|
void slotWMHide();
|
|
|
|
|
|
|
|
// Restore button clicked
|
|
|
|
void slotRestore();
|
|
|
|
|
|
|
|
// OK button clicked
|
|
|
|
void slotOK();
|
|
|
|
|
|
|
|
// Apply button clicked
|
|
|
|
void slotApply();
|
|
|
|
|
|
|
|
// Close button clicked
|
|
|
|
void slotClose();
|
|
|
|
private:
|
|
|
|
/// Pointer to the actual instantiation of the Qt dialog
|
|
|
|
virtual QDialog * form() const = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <class GUIDialog>
|
|
|
|
class QView: public QDialogView {
|
|
|
|
protected:
|
2003-10-06 15:43:21 +00:00
|
|
|
QView(Dialog &, std::string const &);
|
2003-02-25 14:51:38 +00:00
|
|
|
|
|
|
|
/// update the dialog
|
|
|
|
virtual void update();
|
|
|
|
|
|
|
|
/// Build the dialog
|
|
|
|
virtual void build();
|
|
|
|
|
|
|
|
/// Pointer to the actual instantiation of the Qt dialog
|
|
|
|
virtual QDialog * form() const;
|
|
|
|
|
|
|
|
/// Real GUI implementation.
|
|
|
|
boost::scoped_ptr<GUIDialog> dialog_;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <class GUIDialog>
|
2003-10-06 15:43:21 +00:00
|
|
|
QView<GUIDialog>::QView(Dialog & p, std::string const & t)
|
2003-02-25 14:51:38 +00:00
|
|
|
: QDialogView(p, t)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
template <class GUIDialog>
|
|
|
|
QDialog * QView<GUIDialog>::form() const
|
|
|
|
{
|
|
|
|
return dialog_.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <class GUIDialog>
|
|
|
|
void QView<GUIDialog>::update()
|
|
|
|
{
|
|
|
|
form()->setUpdatesEnabled(false);
|
|
|
|
|
|
|
|
// protect the BC from unwarranted state transitions
|
|
|
|
|
|
|
|
qApp->processEvents();
|
|
|
|
updating_ = true;
|
|
|
|
update_contents();
|
|
|
|
qApp->processEvents();
|
|
|
|
updating_ = false;
|
|
|
|
|
|
|
|
form()->setUpdatesEnabled(true);
|
|
|
|
form()->update();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <class GUIDialog>
|
|
|
|
void QView<GUIDialog>::build()
|
|
|
|
{
|
|
|
|
// protect the BC from unwarranted state transitions
|
|
|
|
|
|
|
|
qApp->processEvents();
|
|
|
|
updating_ = true;
|
|
|
|
build_dialog();
|
|
|
|
qApp->processEvents();
|
|
|
|
updating_ = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <class Controller, class Base>
|
|
|
|
class QController: public Base
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
QController(Dialog &, std::string const &);
|
2003-03-09 10:08:22 +00:00
|
|
|
public:
|
2003-02-25 14:51:38 +00:00
|
|
|
/// The parent controller
|
|
|
|
Controller & controller();
|
|
|
|
/// The parent controller
|
|
|
|
Controller const & controller() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <class Controller, class Base>
|
2003-10-06 15:43:21 +00:00
|
|
|
QController<Controller, Base>::QController(Dialog & p, std::string const & t)
|
2003-02-25 14:51:38 +00:00
|
|
|
: Base(p, t)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
template <class Controller, class Base>
|
|
|
|
Controller & QController<Controller, Base>::controller()
|
|
|
|
{
|
2003-07-18 08:46:00 +00:00
|
|
|
return static_cast<Controller &>(this->getController());
|
2003-02-25 14:51:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <class Controller, class Base>
|
|
|
|
Controller const & QController<Controller, Base>::controller() const
|
|
|
|
{
|
2003-07-18 08:46:00 +00:00
|
|
|
return static_cast<Controller const &>(this->getController());
|
2003-02-25 14:51:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif // QDIALOGVIEW_H
|