2007-09-03 05:59:32 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \file GuiDialog.h
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GUIDIALOG_H
|
|
|
|
#define GUIDIALOG_H
|
|
|
|
|
|
|
|
#include "Dialog.h"
|
|
|
|
#include "ButtonController.h"
|
|
|
|
|
2007-10-07 14:41:49 +00:00
|
|
|
#include "insets/InsetCommandParams.h"
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
#include <QDialog>
|
|
|
|
#include <QObject>
|
|
|
|
|
2007-09-27 14:35:12 +00:00
|
|
|
class QCloseEvent;
|
|
|
|
class QShowEvent;
|
|
|
|
|
2007-09-03 05:59:32 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
|
|
|
/** \c Dialog collects the different parts of a Model-Controller-View
|
|
|
|
* split of a generic dialog together.
|
|
|
|
*/
|
2007-10-09 19:34:27 +00:00
|
|
|
class GuiDialog : public QDialog, public Dialog, public Controller
|
2007-09-03 05:59:32 +00:00
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2007-09-03 05:59:32 +00:00
|
|
|
public:
|
|
|
|
/// \param lv is the access point for the dialog to the LyX kernel.
|
|
|
|
/// \param name is the identifier given to the dialog by its parent
|
|
|
|
/// container.
|
2007-09-10 22:32:59 +00:00
|
|
|
explicit GuiDialog(LyXView & lv, std::string const & name);
|
|
|
|
~GuiDialog();
|
2007-09-05 20:33:29 +00:00
|
|
|
|
|
|
|
public Q_SLOTS:
|
2007-09-11 17:06:15 +00:00
|
|
|
/** \name Buttons
|
|
|
|
* These methods are publicly accessible because they are invoked
|
|
|
|
* by the View when the user presses... guess what ;-)
|
|
|
|
*/
|
2007-09-05 20:33:29 +00:00
|
|
|
// Restore button clicked
|
|
|
|
void slotRestore();
|
|
|
|
// OK button clicked
|
|
|
|
void slotOK();
|
|
|
|
// Apply button clicked
|
|
|
|
void slotApply();
|
2007-09-11 17:06:15 +00:00
|
|
|
// Close button clicked or closed from WindowManager
|
2007-09-05 20:33:29 +00:00
|
|
|
void slotClose();
|
2007-09-03 05:59:32 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
public:
|
2007-09-03 05:59:32 +00:00
|
|
|
/** Check whether we may apply our data.
|
|
|
|
*
|
|
|
|
* The buttons are disabled if not and (re-)enabled if yes.
|
|
|
|
*/
|
|
|
|
void checkStatus();
|
|
|
|
void setButtonsValid(bool valid);
|
|
|
|
|
|
|
|
/** \name Dialog Components
|
|
|
|
* Methods to access the various components making up a dialog.
|
|
|
|
*/
|
|
|
|
//@{
|
|
|
|
ButtonController const & bc() const { return bc_; }
|
|
|
|
ButtonController & bc() { return bc_; }
|
|
|
|
//@}
|
|
|
|
|
2007-09-10 19:02:11 +00:00
|
|
|
void setViewTitle(docstring const & title);
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
|
|
|
/// the dialog has changed contents
|
|
|
|
virtual void changed();
|
|
|
|
|
|
|
|
/// default: do nothing
|
|
|
|
virtual void applyView() {}
|
|
|
|
/// default: do nothing
|
2007-09-11 18:33:42 +00:00
|
|
|
virtual void updateContents() {}
|
2007-09-27 14:35:12 +00:00
|
|
|
///
|
2007-09-28 09:45:50 +00:00
|
|
|
void closeEvent(QCloseEvent *);
|
|
|
|
///
|
|
|
|
void showEvent(QShowEvent *);
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
protected:
|
|
|
|
/// Hide the dialog.
|
|
|
|
virtual void hideView();
|
|
|
|
/// Create the dialog if necessary, update it and display it.
|
|
|
|
virtual void showView();
|
|
|
|
///
|
|
|
|
virtual bool isVisibleView() const;
|
|
|
|
/// is the dialog currently valid ?
|
2007-09-10 22:32:59 +00:00
|
|
|
virtual bool isValid() { return true; }
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** \name Container Access
|
|
|
|
* These methods are publicly accessible because they are invoked
|
|
|
|
* by the parent container acting on commands from the LyX kernel.
|
|
|
|
*/
|
|
|
|
//@{
|
|
|
|
/// \param data is a string encoding of the data to be displayed.
|
|
|
|
/// It is passed to the Controller to be translated into a useable form.
|
|
|
|
void showData(std::string const & data);
|
|
|
|
void updateData(std::string const & data);
|
|
|
|
|
|
|
|
void hide();
|
|
|
|
|
|
|
|
/** This function is called, for example, if the GUI colours
|
|
|
|
* have been changed.
|
|
|
|
*/
|
|
|
|
void redraw() { redrawView(); }
|
|
|
|
//@}
|
|
|
|
|
|
|
|
/** When applying, it's useful to know whether the dialog is about
|
|
|
|
* to close or not (no point refreshing the display for example).
|
|
|
|
*/
|
|
|
|
bool isClosing() const { return is_closing_; }
|
|
|
|
|
|
|
|
/** \name Dialog Components
|
|
|
|
* Methods to access the various components making up a dialog.
|
|
|
|
*/
|
|
|
|
//@{
|
2007-10-09 19:34:27 +00:00
|
|
|
virtual Controller & controller() { return *this; }
|
2007-09-10 22:32:59 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/** Defaults to nothing. Can be used by the Controller, however, to
|
|
|
|
* indicate to the View that something has changed and that the
|
|
|
|
* dialog therefore needs updating.
|
|
|
|
* \param id identifies what should be updated.
|
|
|
|
*/
|
|
|
|
virtual void partialUpdateView(int /*id*/) {}
|
|
|
|
|
|
|
|
///
|
|
|
|
std::string name() const { return name_; }
|
|
|
|
|
|
|
|
void apply();
|
|
|
|
void redrawView() {}
|
2007-09-05 20:33:29 +00:00
|
|
|
|
2007-09-03 05:59:32 +00:00
|
|
|
private:
|
2007-09-10 22:32:59 +00:00
|
|
|
/// Update the display of the dialog whilst it is still visible.
|
2007-09-05 20:33:29 +00:00
|
|
|
virtual void updateView();
|
|
|
|
|
2007-09-03 05:59:32 +00:00
|
|
|
ButtonController bc_;
|
2007-09-05 20:33:29 +00:00
|
|
|
/// are we updating ?
|
|
|
|
bool updating_;
|
2007-09-10 22:32:59 +00:00
|
|
|
|
|
|
|
bool is_closing_;
|
|
|
|
/** The Dialog's name is the means by which a dialog identifies
|
|
|
|
* itself to the kernel.
|
|
|
|
*/
|
|
|
|
std::string name_;
|
2007-09-03 05:59:32 +00:00
|
|
|
};
|
|
|
|
|
2007-10-07 14:41:49 +00:00
|
|
|
|
2007-10-09 19:34:27 +00:00
|
|
|
class GuiCommand : public GuiDialog
|
2007-10-07 14:41:49 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/// We need to know with what sort of inset we're associated.
|
|
|
|
GuiCommand(LyXView &, std::string const & name);
|
|
|
|
///
|
|
|
|
bool initialiseParams(std::string const & data);
|
|
|
|
/// clean-up on hide.
|
|
|
|
void clearParams() { params_.clear(); }
|
|
|
|
/// clean-up on hide.
|
|
|
|
void dispatchParams();
|
|
|
|
///
|
|
|
|
bool isBufferDependent() const { return true; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
///
|
|
|
|
InsetCommandParams params_;
|
|
|
|
//FIXME It should be possible to eliminate lfun_name_
|
|
|
|
//now and recover that information from params().insetType().
|
|
|
|
//But let's not do that quite yet.
|
|
|
|
/// Flags what action is taken by Kernel::dispatch()
|
|
|
|
std::string const lfun_name_;
|
|
|
|
};
|
|
|
|
|
2007-09-03 05:59:32 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
|
|
#endif // GUIDIALOG_H
|