2006-03-05 17:24:44 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
2007-08-31 05:53:55 +00:00
|
|
|
* \file GuiDialogView.h
|
2006-03-05 17:24:44 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Angus Leeming
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
2007-08-31 22:16:11 +00:00
|
|
|
#ifndef GUIDIALOGVIEW_H
|
|
|
|
#define GUIDIALOGVIEW_H
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
#include "Dialog.h"
|
|
|
|
|
|
|
|
#include <boost/scoped_ptr.hpp>
|
|
|
|
|
|
|
|
#include <QApplication>
|
2007-02-15 10:16:35 +00:00
|
|
|
#include <QWidget>
|
2006-03-05 17:24:44 +00:00
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
|
|
|
class Qt2BC;
|
|
|
|
|
|
|
|
/** This class is an Qt2 GUI base class.
|
|
|
|
*/
|
2007-08-31 05:53:55 +00:00
|
|
|
class GuiDialogView : public QObject, public Dialog::View {
|
2006-03-05 17:24:44 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
///
|
2007-08-31 05:53:55 +00:00
|
|
|
GuiDialogView(Dialog &, docstring const &);
|
2006-03-05 17:24:44 +00:00
|
|
|
///
|
2007-08-31 05:53:55 +00:00
|
|
|
virtual ~GuiDialogView() {}
|
2006-03-05 17:24:44 +00:00
|
|
|
///
|
|
|
|
bool readOnly() const;
|
|
|
|
|
|
|
|
/// the dialog has changed contents
|
|
|
|
virtual void changed();
|
|
|
|
|
2006-03-22 18:59:17 +00:00
|
|
|
///
|
|
|
|
Qt2BC & bcview();
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
/// is the dialog currently valid ?
|
|
|
|
virtual bool isValid();
|
|
|
|
|
|
|
|
/// are we updating ?
|
|
|
|
bool updating_;
|
2006-03-22 18:59:17 +00:00
|
|
|
|
2006-06-30 14:37:33 +00:00
|
|
|
public Q_SLOTS:
|
2006-03-05 17:24:44 +00:00
|
|
|
// 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
|
2007-02-15 10:16:35 +00:00
|
|
|
virtual QWidget * form() const = 0;
|
2006-03-05 17:24:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <class GUIDialog>
|
2007-08-31 05:53:55 +00:00
|
|
|
class GuiView : public GuiDialogView {
|
2006-03-05 17:24:44 +00:00
|
|
|
protected:
|
2007-08-31 05:53:55 +00:00
|
|
|
GuiView(Dialog & p, docstring const & t)
|
|
|
|
: GuiDialogView(p, t)
|
2007-02-15 10:16:35 +00:00
|
|
|
{}
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
virtual ~GuiView() {}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
/// update the dialog
|
2007-02-15 10:16:35 +00:00
|
|
|
virtual void update() {
|
|
|
|
dialog_->setUpdatesEnabled(false);
|
|
|
|
|
|
|
|
// protect the BC from unwarranted state transitions
|
|
|
|
updating_ = true;
|
|
|
|
update_contents();
|
|
|
|
updating_ = false;
|
|
|
|
|
|
|
|
dialog_->setUpdatesEnabled(true);
|
|
|
|
dialog_->update();
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
/// Build the dialog
|
2007-02-15 10:16:35 +00:00
|
|
|
virtual void build() {
|
|
|
|
// protect the BC from unwarranted state transitions
|
|
|
|
updating_ = true;
|
|
|
|
build_dialog();
|
|
|
|
updating_ = false;
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
/// Pointer to the actual instantiation of the Qt dialog
|
2007-02-15 10:16:35 +00:00
|
|
|
virtual GUIDialog * form() const { return dialog_.get(); }
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
/// Real GUI implementation.
|
|
|
|
boost::scoped_ptr<GUIDialog> dialog_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
|
|
|
|
2007-08-31 22:16:11 +00:00
|
|
|
#endif // GUIDIALOGVIEW_H
|