make Controller a standalone class.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20161 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2007-09-08 21:16:54 +00:00
parent d19e684383
commit d21894949b
66 changed files with 105 additions and 95 deletions

View File

@ -532,7 +532,7 @@
2004-01-25 Angus Leeming <leeming@lyx.org>
* ControlSearch.[Ch]: derive from Dialog::Controller rather than
* ControlSearch.[Ch]: derive from Controller rather than
the deprecated ControlDialogBD.
2004-01-08 Alfredo Braunstein <abraunst@lyx.org>

View File

@ -23,7 +23,7 @@ namespace lyx {
namespace frontend {
ControlBox::ControlBox(Dialog & parent)
: Dialog::Controller(parent)
: Controller(parent)
{}

View File

@ -22,7 +22,7 @@ class InsetBoxParams;
namespace frontend {
class ControlBox : public Dialog::Controller {
class ControlBox : public Controller {
public:
///
ControlBox(Dialog &);

View File

@ -27,7 +27,7 @@ namespace lyx {
namespace frontend {
ControlBranch::ControlBranch(Dialog & parent)
: Dialog::Controller(parent)
: Controller(parent)
{}

View File

@ -23,7 +23,7 @@ class InsetBranchParams;
namespace frontend {
class ControlBranch : public Dialog::Controller {
class ControlBranch : public Controller {
public:
///
ControlBranch(Dialog &);

View File

@ -31,7 +31,7 @@ namespace frontend {
ControlChanges::ControlChanges(Dialog & parent)
: Dialog::Controller(parent)
: Controller(parent)
{}

View File

@ -23,7 +23,7 @@ namespace frontend {
/**
* A controller for the merge changes dialog.
*/
class ControlChanges : public Dialog::Controller {
class ControlChanges : public Controller {
public:
///
ControlChanges(Dialog &);

View File

@ -26,7 +26,7 @@ namespace lyx {
namespace frontend {
ControlCharacter::ControlCharacter(Dialog & parent)
: Dialog::Controller(parent),
: Controller(parent),
font_(0), toggleall_(false), reset_lang_(false)
{}

View File

@ -23,7 +23,7 @@ class Color_color;
namespace frontend {
class ControlCharacter : public Dialog::Controller {
class ControlCharacter : public Controller {
public:
///
ControlCharacter(Dialog &);

View File

@ -23,7 +23,7 @@ namespace frontend {
ControlCommand::ControlCommand(Dialog & dialog, string const & command_name,
string const & lfun_name)
: Dialog::Controller(dialog), params_(command_name),
: Controller(dialog), params_(command_name),
lfun_name_(lfun_name)
{}

View File

@ -22,7 +22,7 @@
namespace lyx {
namespace frontend {
class ControlCommand : public Dialog::Controller {
class ControlCommand : public Controller {
public:
/** LFUN_INSET_APPLY requires a name, "citation", "ref" etc so that
it knows what to do with the rest of the contents.

View File

@ -50,7 +50,7 @@ char const * ControlDocument::fontfamilies_gui[5] = {
ControlDocument::ControlDocument(Dialog & parent)
: Dialog::Controller(parent)
: Controller(parent)
{}

View File

@ -28,7 +28,7 @@ typedef void const * BufferId;
/** A controller for Document dialogs.
*/
class ControlDocument : public Dialog::Controller {
class ControlDocument : public Controller {
public:
/// font family names for BufferParams::fontsDefaultFamily
static char const * const fontfamilies[5];

View File

@ -21,7 +21,7 @@ namespace lyx {
namespace frontend {
ControlERT::ControlERT(Dialog & parent)
: Dialog::Controller(parent), status_(InsetERT::Collapsed)
: Controller(parent), status_(InsetERT::Collapsed)
{}

View File

@ -20,7 +20,7 @@
namespace lyx {
namespace frontend {
class ControlERT : public Dialog::Controller {
class ControlERT : public Controller {
public:
///
ControlERT(Dialog &);

View File

@ -35,7 +35,7 @@ using support::FileFilterList;
namespace frontend {
ControlEmbeddedFiles::ControlEmbeddedFiles(Dialog & parent)
: Dialog::Controller(parent)
: Controller(parent)
{}

View File

@ -19,7 +19,7 @@ namespace lyx {
namespace frontend {
class ControlEmbeddedFiles : public Dialog::Controller {
class ControlEmbeddedFiles : public Controller {
public:
///
ControlEmbeddedFiles(Dialog &);

View File

@ -34,7 +34,7 @@ namespace lyx {
namespace frontend {
ControlErrorList::ControlErrorList(Dialog & d)
: Dialog::Controller(d)
: Controller(d)
{}

View File

@ -20,7 +20,7 @@ namespace frontend {
/** A controller for the ErrorList dialog.
*/
class ControlErrorList : public Dialog::Controller {
class ControlErrorList : public Controller {
public:
///
ControlErrorList(Dialog & parent);

View File

@ -46,7 +46,7 @@ namespace frontend {
ControlExternal::ControlExternal(Dialog & parent)
: Dialog::Controller(parent),
: Controller(parent),
bb_changed_(false)
{}

View File

@ -38,7 +38,7 @@ class RotationDataType;
namespace frontend {
class ControlExternal : public Dialog::Controller {
class ControlExternal : public Controller {
public:
///
ControlExternal(Dialog &);

View File

@ -21,7 +21,7 @@ namespace lyx {
namespace frontend {
ControlFloat::ControlFloat(Dialog & parent)
: Dialog::Controller(parent)
: Controller(parent)
{}

View File

@ -20,7 +20,7 @@ class InsetFloatParams;
namespace frontend {
class ControlFloat : public Dialog::Controller {
class ControlFloat : public Controller {
public:
///
ControlFloat(Dialog &);

View File

@ -54,7 +54,7 @@ namespace frontend {
ControlGraphics::ControlGraphics(Dialog & parent)
: Dialog::Controller(parent)
: Controller(parent)
{}

View File

@ -33,7 +33,7 @@ class LyXView;
/** A controller for Graphics dialogs.
*/
class ControlGraphics : public Dialog::Controller {
class ControlGraphics : public Controller {
public:
///
ControlGraphics(Dialog &);

View File

@ -43,7 +43,7 @@ using support::onlyPath;
namespace frontend {
ControlInclude::ControlInclude(Dialog & parent)
: Dialog::Controller(parent), params_("include")
: Controller(parent), params_("include")
{}

View File

@ -25,7 +25,7 @@ namespace frontend {
/** A controller for the Include file dialog.
*/
class ControlInclude : public Dialog::Controller {
class ControlInclude : public Controller {
public:
///
enum Type {

View File

@ -22,7 +22,7 @@ namespace lyx {
namespace frontend {
ControlListings::ControlListings(Dialog & parent)
: Dialog::Controller(parent), params_()
: Controller(parent), params_()
{}

View File

@ -21,7 +21,7 @@ class InsetListingsParams;
namespace frontend {
class ControlListings : public Dialog::Controller {
class ControlListings : public Controller {
public:
///
ControlListings(Dialog &);

View File

@ -30,7 +30,7 @@ using support::FileName;
namespace frontend {
ControlLog::ControlLog(Dialog & parent)
: Dialog::Controller(parent),
: Controller(parent),
type_(LatexLog)
{}

View File

@ -23,7 +23,7 @@ namespace frontend {
/**
* A controller for a read-only text browser.
*/
class ControlLog : public Dialog::Controller {
class ControlLog : public Controller {
public:
///
ControlLog(Dialog &);

View File

@ -30,7 +30,7 @@ using support::subst;
namespace frontend {
ControlMath::ControlMath(Dialog & dialog)
: Dialog::Controller(dialog)
: Controller(dialog)
{
// FIXME: Ideally, those unicode codepoints would be defined
// in "lib/symbols". Unfortunately, some of those are already

View File

@ -32,7 +32,7 @@ struct MathSymbol {
Font::FONT_FAMILY fontfamily;
};
class ControlMath : public Dialog::Controller {
class ControlMath : public Controller {
public:
ControlMath(Dialog &);

View File

@ -22,7 +22,7 @@ namespace lyx {
namespace frontend {
ControlNote::ControlNote(Dialog & parent)
: Dialog::Controller(parent)
: Controller(parent)
{}

View File

@ -22,7 +22,7 @@ class InsetNoteParams;
namespace frontend {
class ControlNote : public Dialog::Controller {
class ControlNote : public Controller {
public:
///
ControlNote(Dialog &);

View File

@ -31,7 +31,7 @@ namespace lyx {
namespace frontend {
ControlParagraph::ControlParagraph(Dialog & parent)
: Dialog::Controller(parent), ininset_(false)
: Controller(parent), ininset_(false)
{}

View File

@ -21,7 +21,7 @@ class ParagraphParameters;
namespace frontend {
class ControlParagraph : public Dialog::Controller {
class ControlParagraph : public Controller {
public:
///
ControlParagraph(Dialog &);

View File

@ -37,7 +37,7 @@ namespace frontend {
ControlPrefs::ControlPrefs(Dialog & parent)
: Dialog::Controller(parent),
: Controller(parent),
update_screen_font_(false)
{}

View File

@ -27,7 +27,7 @@ class Color_color;
namespace frontend {
class ControlPrefs : public Dialog::Controller {
class ControlPrefs : public Controller {
public:
ControlPrefs(Dialog &);
///

View File

@ -35,7 +35,7 @@ namespace frontend {
ControlPrint::ControlPrint(Dialog & parent)
: Dialog::Controller(parent),
: Controller(parent),
params_(0)
{}

View File

@ -27,7 +27,7 @@ namespace frontend {
/** A controller for Print dialogs.
*/
class ControlPrint : public Dialog::Controller {
class ControlPrint : public Controller {
public:
///
ControlPrint(Dialog &);

View File

@ -19,7 +19,7 @@ namespace lyx {
namespace frontend {
ControlSearch::ControlSearch(Dialog & parent)
: Dialog::Controller(parent)
: Controller(parent)
{}

View File

@ -19,7 +19,7 @@ namespace frontend {
/** A controller for Search dialogs.
*/
class ControlSearch : public Dialog::Controller {
class ControlSearch : public Controller {
public:
ControlSearch(Dialog &);

View File

@ -32,7 +32,7 @@ namespace frontend {
ControlSendto::ControlSendto(Dialog & parent)
: Dialog::Controller(parent)
: Controller(parent)
{}

View File

@ -24,7 +24,7 @@ namespace frontend {
/** A controller for the Custom Export dialogs.
*/
class ControlSendto : public Dialog::Controller {
class ControlSendto : public Controller {
public:
///
ControlSendto(Dialog &);

View File

@ -25,7 +25,7 @@ namespace frontend {
ControlShowFile::ControlShowFile(Dialog & parent)
: Dialog::Controller(parent)
: Controller(parent)
{}

View File

@ -21,7 +21,7 @@ namespace frontend {
/** A controller for the ShowFile dialog. */
class ControlShowFile : public Dialog::Controller {
class ControlShowFile : public Controller {
public:
///
ControlShowFile(Dialog &);

View File

@ -59,7 +59,7 @@ namespace frontend {
ControlSpellchecker::ControlSpellchecker(Dialog & parent)
: Dialog::Controller(parent), exitEarly_(false),
: Controller(parent), exitEarly_(false),
oldval_(0), newvalue_(0), count_(0)
{
}

View File

@ -24,7 +24,7 @@ namespace frontend {
/** A controller for Spellchecker dialogs.
*/
class ControlSpellchecker : public Dialog::Controller {
class ControlSpellchecker : public Controller {
public:
enum State {
SPELL_PROGRESSED, //< update progress bar

View File

@ -24,7 +24,7 @@ namespace lyx {
namespace frontend {
ControlTabular::ControlTabular(Dialog & parent)
: Dialog::Controller(parent), active_cell_(Tabular::npos)
: Controller(parent), active_cell_(Tabular::npos)
{}

View File

@ -22,7 +22,7 @@
namespace lyx {
namespace frontend {
class ControlTabular : public Dialog::Controller {
class ControlTabular : public Controller {
public:
ControlTabular(Dialog &);

View File

@ -22,7 +22,7 @@ namespace lyx {
namespace frontend {
ControlTabularCreate::ControlTabularCreate(Dialog & parent)
: Dialog::Controller(parent)
: Controller(parent)
{}

View File

@ -20,7 +20,7 @@ namespace frontend {
/** A controller for the TabularCreate Dialog.
*/
class ControlTabularCreate : public Dialog::Controller {
class ControlTabularCreate : public Controller {
public:
///
ControlTabularCreate(Dialog &);

View File

@ -62,7 +62,7 @@ void getTexFileList(ControlTexinfo::texFileSuffix type,
ControlTexinfo::ControlTexinfo(Dialog & parent)
: Dialog::Controller(parent)
: Controller(parent)
{}

View File

@ -21,7 +21,7 @@ namespace frontend {
/** A controller for Texinfo dialogs. */
class ControlTexinfo : public Dialog::Controller {
class ControlTexinfo : public Controller {
public:
///
ControlTexinfo(Dialog &);

View File

@ -21,7 +21,7 @@ namespace lyx {
namespace frontend {
ControlThesaurus::ControlThesaurus(Dialog & parent)
: Dialog::Controller(parent)
: Controller(parent)
{}

View File

@ -21,7 +21,7 @@ namespace frontend {
/** A controller for Thesaurus dialogs.
*/
class ControlThesaurus : public Dialog::Controller {
class ControlThesaurus : public Controller {
public:
///
ControlThesaurus(Dialog &);

View File

@ -24,7 +24,7 @@ namespace lyx {
namespace frontend {
ControlVSpace::ControlVSpace(Dialog & parent)
: Dialog::Controller(parent)
: Controller(parent)
{}

View File

@ -19,7 +19,7 @@
namespace lyx {
namespace frontend {
class ControlVSpace : public Dialog::Controller {
class ControlVSpace : public Controller {
public:
///
ControlVSpace(Dialog &);

View File

@ -28,7 +28,7 @@ namespace lyx {
namespace frontend {
ControlViewSource::ControlViewSource(Dialog & parent)
: Dialog::Controller(parent)
: Controller(parent)
{}

View File

@ -22,7 +22,7 @@ namespace frontend {
/**
* A controller for a read-only text browser.
*/
class ControlViewSource : public Dialog::Controller {
class ControlViewSource : public Controller {
public:
///
ControlViewSource(Dialog &);

View File

@ -21,7 +21,7 @@ namespace lyx {
namespace frontend {
ControlWrap::ControlWrap(Dialog & parent)
: Dialog::Controller(parent)
: Controller(parent)
{}

View File

@ -21,7 +21,7 @@ class InsetWrapParams;
namespace frontend {
class ControlWrap : public Dialog::Controller {
class ControlWrap : public Controller {
public:
///
ControlWrap(Dialog &);

View File

@ -26,16 +26,14 @@ namespace lyx {
namespace frontend {
Dialog::Dialog(LyXView & lv, string const & name)
: is_closing_(false), kernel_(lv), name_(name)
: is_closing_(false), kernel_(lv), name_(name), controller_(0)
{}
Dialog::~Dialog()
{}
void Dialog::setButtonsValid(bool /*valid*/)
{}
{
delete controller_;
}
void Dialog::show(string const & data)
@ -120,30 +118,31 @@ void Dialog::redraw()
}
void Dialog::setController(Controller * i)
void Dialog::setController(Controller * controller)
{
BOOST_ASSERT(i && !controller_ptr_.get());
controller_ptr_.reset(i);
BOOST_ASSERT(controller);
BOOST_ASSERT(!controller_);
controller_ = controller;
}
Dialog::Controller::Controller(Dialog & parent)
Controller::Controller(Dialog & parent)
: parent_(parent)
{}
bool Dialog::Controller::canApply() const
bool Controller::canApply() const
{
FuncRequest const fr(getLfun(), dialog().name_);
FuncRequest const fr(getLfun(), dialog().name());
FuncStatus const fs(getStatus(fr));
return fs.enabled();
}
Dialog::Controller & Dialog::controller() const
Controller & Dialog::controller() const
{
BOOST_ASSERT(controller_ptr_.get());
return *controller_ptr_.get();
BOOST_ASSERT(controller_);
return *controller_;
}

View File

@ -17,18 +17,23 @@
#include "support/docstring.h"
#include <boost/utility.hpp>
#include <boost/scoped_ptr.hpp>
namespace lyx {
namespace frontend {
class LyXView;
/** Different dialogs will have different Controllers and Views.
* deriving from these base classes.
*/
//@{
class Controller;
//@}
/** \c Dialog collects the different parts of a Model-Controller-View
* split of a generic dialog together.
*/
class Dialog /*: boost::noncopyable*/ {
class Dialog
{
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
@ -84,13 +89,6 @@ public:
Kernel & kernel() { return kernel_; }
Kernel const & kernel() const { return kernel_; }
/** Different dialogs will have different Controllers and Views.
* deriving from these base classes.
*/
//@{
class Controller;
//@}
/** \name Dialog Specialization
* Methods to set the Controller and View and so specialise
* to a particular dialog.
@ -109,7 +107,7 @@ public:
/** \c Button controller part
*/
virtual void setButtonsValid(bool valid);
virtual void setButtonsValid(bool /*valid*/) {}
/** \c View part
@ -151,6 +149,13 @@ public:
void setViewTitle(docstring const &);
/// gets the title of the dialog (window caption)
docstring const & getViewTitle() const;
///
std::string name() const { return name_; }
private:
/// intentionally unimplemented, therefore uncopiable
Dialog(Dialog const &);
void operator=(Dialog const &);
protected:
void apply();
@ -161,16 +166,17 @@ protected:
* itself to the kernel.
*/
std::string name_;
boost::scoped_ptr<Controller> controller_ptr_;
Controller * controller_;
docstring title_;
};
/** \c Dialog::Controller is an abstract base class for the Controller
/** \c Controller is an abstract base class for the Controller
* of a Model-Controller-View split of a generic dialog.
*/
class Dialog::Controller : boost::noncopyable {
class Controller
{
public:
/// \param parent Dialog owning this Controller.
Controller(Dialog & parent);
@ -257,6 +263,11 @@ protected:
Kernel const & kernel() const { return parent_.kernel(); }
//@}
private:
/// intentionally unimplemented, therefore uncopiable
Controller(Controller const &);
void operator=(Controller const &);
private:
Dialog & parent_;
};

View File

@ -95,10 +95,10 @@ static QString version()
}
class ControlAbout : public Dialog::Controller
class ControlAbout : public Controller
{
public:
ControlAbout(Dialog & parent) : Dialog::Controller(parent) {}
ControlAbout(Dialog & parent) : Controller(parent) {}
bool initialiseParams(std::string const &) { return true; }
void clearParams() {}
void dispatchParams() {}