Move the include dialog to the new scheme

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6353 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2003-03-05 14:59:37 +00:00
parent 5f850b5cab
commit 61419611a0
36 changed files with 271 additions and 174 deletions

View File

@ -2,6 +2,7 @@
* ui/default.ui: use 'dialog-show-new-inset "external"' instead * ui/default.ui: use 'dialog-show-new-inset "external"' instead
of 'external-insert'. of 'external-insert'.
use "dialog-show-new-inset include" instead of "buffer-child-insert".
2003-03-03 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr> 2003-03-03 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>

View File

@ -213,7 +213,7 @@ Menuset
Item "Tabular Material...|b" "tabular-insert" Item "Tabular Material...|b" "tabular-insert"
Submenu "Floats|a" "insert_floats" Submenu "Floats|a" "insert_floats"
Separator Separator
Item "Include File...|d" "buffer-child-insert" Item "Include File...|d" "dialog-show-new-inset include"
Submenu "Insert File|e" "insert_file" Submenu "Insert File|e" "insert_file"
Item "External Material...|x" "dialog-show-new-inset external" Item "External Material...|x" "dialog-show-new-inset external"
End End

View File

@ -1204,23 +1204,6 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
} }
break; break;
case LFUN_CHILD_INSERT:
{
InsetInclude::Params p;
if (!ev.argument.empty())
p.cparams.setFromString(ev.argument);
p.masterFilename_ = buffer_->fileName();
InsetInclude * inset = new InsetInclude(p);
if (!insertInset(inset))
delete inset;
else {
updateInset(inset, true);
bv_->owner()->getDialogs().showInclude(inset);
}
}
break;
case LFUN_FLOAT_LIST: case LFUN_FLOAT_LIST:
if (tclass.floats().typeExist(ev.argument)) { if (tclass.floats().typeExist(ev.argument)) {
Inset * inset = new InsetFloatList(ev.argument); Inset * inset = new InsetFloatList(ev.argument);

View File

@ -1,3 +1,13 @@
2003-03-05 Angus Leeming <leeming@lyx.org>
* commandtags.h:
* LyXAction.C (init):
* BufferView_pimpl.C (dispatch):
* lyxfunc.C (getStatus):
remove LFUN_CHILD_INSERT.
* factory.C (createInset): add "include" to LFUN_INSET_APPLY.
2003-03-05 Angus Leeming <leeming@lyx.org> 2003-03-05 Angus Leeming <leeming@lyx.org>
* commandtags.h: * commandtags.h:

View File

@ -114,7 +114,6 @@ void LyXAction::init()
N_("Go to beginning of document"), ReadOnly }, N_("Go to beginning of document"), ReadOnly },
{ LFUN_BEGINNINGBUFSEL, "buffer-begin-select", { LFUN_BEGINNINGBUFSEL, "buffer-begin-select",
N_("Select to beginning of document"), ReadOnly }, N_("Select to beginning of document"), ReadOnly },
{ LFUN_CHILD_INSERT, "buffer-child-insert", "", Noop },
{ LFUN_CHILDOPEN, "buffer-child-open", "", ReadOnly }, { LFUN_CHILDOPEN, "buffer-child-open", "", ReadOnly },
{ LFUN_RUNCHKTEX, "buffer-chktex", N_("Check TeX"), ReadOnly }, { LFUN_RUNCHKTEX, "buffer-chktex", N_("Check TeX"), ReadOnly },
{ LFUN_CLOSEBUFFER, "buffer-close", N_("Close"), ReadOnly }, { LFUN_CLOSEBUFFER, "buffer-close", N_("Close"), ReadOnly },

View File

@ -196,7 +196,6 @@ enum kb_action {
LFUN_LAYOUT_COPY, // Asger 1997-05-04 LFUN_LAYOUT_COPY, // Asger 1997-05-04
LFUN_LAYOUT_PASTE, // Asger 1997-05-04 LFUN_LAYOUT_PASTE, // Asger 1997-05-04
LFUN_TABINSERT, // 180 // Ale 970515 LFUN_TABINSERT, // 180 // Ale 970515
LFUN_CHILD_INSERT, // Ale 970521
LFUN_CHILDOPEN, // Ale 970528 LFUN_CHILDOPEN, // Ale 970528
LFUN_TOC_INSERT, // Lgb 97-05-27 LFUN_TOC_INSERT, // Lgb 97-05-27
LFUN_FLOAT_LIST, // Lgb 20010503 LFUN_FLOAT_LIST, // Lgb 20010503

View File

@ -26,6 +26,7 @@
#include "insets/insetexternal.h" #include "insets/insetexternal.h"
#include "insets/insetfloat.h" #include "insets/insetfloat.h"
#include "insets/insetfoot.h" #include "insets/insetfoot.h"
#include "insets/insetinclude.h"
#include "insets/insetindex.h" #include "insets/insetindex.h"
#include "insets/insetlabel.h" #include "insets/insetlabel.h"
#include "insets/insetmarginal.h" #include "insets/insetmarginal.h"
@ -191,6 +192,11 @@ Inset * createInset(FuncRequest const & cmd)
inset->setFromParams(iep); inset->setFromParams(iep);
return inset; return inset;
} else if (name == "include") {
InsetInclude::Params iip;
InsetIncludeMailer::string2params(cmd.argument, iip);
return new InsetInclude(iip);
} else if (name == "index") { } else if (name == "index") {
InsetCommandParams icp; InsetCommandParams icp;
InsetCommandMailer::string2params(cmd.argument, icp); InsetCommandMailer::string2params(cmd.argument, icp);

View File

@ -1,3 +1,8 @@
2003-03-05 Angus Leeming <leeming@lyx.org>
* Dialogs.h: remove showInclude.
* guiapi.[Ch]: remove gui_ShowInclude.
2003-03-05 Angus Leeming <leeming@lyx.org> 2003-03-05 Angus Leeming <leeming@lyx.org>
* Dialogs.h: remove showExternal. * Dialogs.h: remove showExternal.

View File

@ -26,7 +26,6 @@ class LyXView;
class InsetFloat; class InsetFloat;
class InsetWrap; class InsetWrap;
class InsetGraphics; class InsetGraphics;
class InsetInclude;
class InsetInfo; class InsetInfo;
class InsetMinipage; class InsetMinipage;
class Paragraph; class Paragraph;
@ -96,8 +95,6 @@ public:
void showForks(); void showForks();
/// ///
void showGraphics(InsetGraphics *); void showGraphics(InsetGraphics *);
/// show the details of a LyX file include inset
void showInclude(InsetInclude *);
/// show the LaTeX log or build file /// show the LaTeX log or build file
void showLogFile(); void showLogFile();
/// display the top-level maths panel /// display the top-level maths panel

View File

@ -1,3 +1,7 @@
2003-03-05 Angus Leeming <leeming@lyx.org>
* ControlInclude.[Ch]: rewrite to use the Dialog-based scheme.
2003-03-05 Angus Leeming <leeming@lyx.org> 2003-03-05 Angus Leeming <leeming@lyx.org>
* ControlExternal.[Ch]: rewrite to use the Dialog-based scheme. * ControlExternal.[Ch]: rewrite to use the Dialog-based scheme.

View File

@ -12,7 +12,6 @@
#include <config.h> #include <config.h>
#include "ControlInclude.h" #include "ControlInclude.h"
#include "helper_funcs.h" #include "helper_funcs.h"
@ -32,18 +31,38 @@
using std::pair; using std::pair;
ControlInclude::ControlInclude(LyXView & lv, Dialogs & d) ControlInclude::ControlInclude(Dialog & parent)
: ControlInset<InsetInclude, InsetInclude::Params>(lv, d) : Dialog::Controller(parent)
{} {}
void ControlInclude::applyParamsToInset() void ControlInclude::initialiseParams(string const & data)
{ {
inset()->set(params()); InsetInclude::Params params;
bufferview()->updateInset(inset(), true); InsetIncludeMailer::string2params(data, params);
inset_.reset(new InsetInclude(params));
} }
void ControlInclude::clearParams()
{
inset_.reset();
}
void ControlInclude::dispatchParams()
{
InsetInclude::Params p = params();
string const lfun = InsetIncludeMailer::params2string("include", p);
kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
}
void ControlInclude::setParams(InsetInclude::Params const & params)
{
inset_->set(params);
}
string const ControlInclude::Browse(string const & in_name, Type in_type) string const ControlInclude::Browse(string const & in_name, Type in_type)
{ {
string const title = _("Select document to include"); string const title = _("Select document to include");
@ -75,7 +94,7 @@ string const ControlInclude::Browse(string const & in_name, Type in_type)
void ControlInclude::load(string const & file) void ControlInclude::load(string const & file)
{ {
lyxfunc().dispatch(FuncRequest(LFUN_CHILDOPEN, file)); kernel().dispatch(FuncRequest(LFUN_CHILDOPEN, file));
} }

View File

@ -15,14 +15,13 @@
#define CONTROLINCLUDE_H #define CONTROLINCLUDE_H
#include "ControlInset.h" #include "Dialog.h"
#include "insets/insetinclude.h" // InsetIncludeParams #include "insets/insetinclude.h" // InsetIncludeParams
/** A controller for the Include file dialog. /** A controller for the Include file dialog.
*/ */
class ControlInclude class ControlInclude : public Dialog::Controller {
: public ControlInset<InsetInclude, InsetInclude::Params>
{
public: public:
/// ///
enum Type { enum Type {
@ -34,7 +33,22 @@ public:
INCLUDE INCLUDE
}; };
/// ///
ControlInclude(LyXView &, Dialogs &); ControlInclude(Dialog &);
///
virtual void initialiseParams(string const & data);
/// clean-up on hide.
virtual void clearParams();
/// clean-up on hide.
virtual void dispatchParams();
///
virtual bool isBufferDependent() const { return true; }
///
InsetInclude::Params const & params() const
{ return inset_->params(); }
///
void setParams(InsetInclude::Params const &);
/// Browse for a file /// Browse for a file
string const Browse(string const &, Type); string const Browse(string const &, Type);
@ -45,17 +59,8 @@ public:
/// test if file exist /// test if file exist
bool fileExists(string const & file); bool fileExists(string const & file);
private: private:
/// Dispatch the changed parameters to the kernel. ///
virtual void applyParamsToInset(); boost::scoped_ptr<InsetInclude> inset_;
/// Should be used but currently isn't
virtual void applyParamsNoInset() {}
/// get the parameters from the string passed to createInset.
virtual InsetInclude::Params const getParams(string const &)
{ return InsetInclude::Params(); }
/// get the parameters from the inset passed to showInset.
virtual InsetInclude::Params const
getParams(InsetInclude const & inset) {
return inset.params();
}
}; };
#endif // CONTROLINCLUDE_H #endif // CONTROLINCLUDE_H

View File

@ -74,12 +74,6 @@ void gui_ShowGraphics(InsetGraphics * ig, Dialogs & d)
} }
void gui_ShowInclude(InsetInclude * ii, Dialogs & d)
{
d.showInclude(ii);
}
void gui_ShowLogFile(Dialogs & d) void gui_ShowLogFile(Dialogs & d)
{ {
d.showLogFile(); d.showLogFile();

View File

@ -19,7 +19,6 @@ class Dialogs;
class InsetFloat; class InsetFloat;
class InsetWrap; class InsetWrap;
class InsetGraphics; class InsetGraphics;
class InsetInclude;
class InsetMinipage; class InsetMinipage;
class InsetTabular; class InsetTabular;
@ -35,7 +34,6 @@ void gui_ShowFile(string const &, Dialogs &);
void gui_ShowFloat(InsetFloat *, Dialogs &); void gui_ShowFloat(InsetFloat *, Dialogs &);
void gui_ShowForks(Dialogs &); void gui_ShowForks(Dialogs &);
void gui_ShowGraphics(InsetGraphics *, Dialogs &); void gui_ShowGraphics(InsetGraphics *, Dialogs &);
void gui_ShowInclude(InsetInclude *, Dialogs &);
void gui_ShowLogFile(Dialogs &); void gui_ShowLogFile(Dialogs &);
void gui_ShowMathPanel(Dialogs &); void gui_ShowMathPanel(Dialogs &);
void gui_ShowMinipage(InsetMinipage *, Dialogs &); void gui_ShowMinipage(InsetMinipage *, Dialogs &);

View File

@ -1,3 +1,13 @@
2003-03-05 Angus Leeming <leeming@lyx.org>
* QInclude.[Ch]: changes to use the new Dialog-based scheme.
* Dialogs.C:
* Dialogs2.C:
* Dialogs_impl.h: remove include dialog.
* Dialogs3.C: add include dialog.
2003-03-05 Angus Leeming <leeming@lyx.org> 2003-03-05 Angus Leeming <leeming@lyx.org>
* QExternal.[Ch]: changes to use the new Dialog-based scheme. * QExternal.[Ch]: changes to use the new Dialog-based scheme.

View File

@ -33,7 +33,6 @@ Dialogs::Impl::Impl(LyXView & lv, Dialogs & d)
file(lv, d), file(lv, d),
floats(lv, d), floats(lv, d),
graphics(lv, d), graphics(lv, d),
include(lv, d),
logfile(lv, d), logfile(lv, d),
minipage(lv, d), minipage(lv, d),
paragraph(lv, d), paragraph(lv, d),

View File

@ -12,7 +12,6 @@
#include <config.h> #include <config.h>
#include "Dialogs_impl.h" #include "Dialogs_impl.h"
@ -68,12 +67,6 @@ void Dialogs::showGraphics(InsetGraphics * ig)
} }
void Dialogs::showInclude(InsetInclude * ii)
{
pimpl_->include.controller().showInset(ii);
}
void Dialogs::showLogFile() void Dialogs::showLogFile()
{ {
pimpl_->logfile.controller().show(); pimpl_->logfile.controller().show();

View File

@ -19,6 +19,7 @@
#include "ControlError.h" #include "ControlError.h"
#include "ControlERT.h" #include "ControlERT.h"
#include "ControlExternal.h" #include "ControlExternal.h"
#include "ControlInclude.h"
#include "ControlIndex.h" #include "ControlIndex.h"
#include "ControlLabel.h" #include "ControlLabel.h"
#include "ControlRef.h" #include "ControlRef.h"
@ -41,6 +42,8 @@
// of the Qt headers, those most fucked up of disgusting ratholes. // of the Qt headers, those most fucked up of disgusting ratholes.
// But I won't. // But I won't.
#undef signals #undef signals
#include "QInclude.h"
#include "QIncludeDialog.h"
#include "QIndex.h" #include "QIndex.h"
#include "QIndexDialog.h" #include "QIndexDialog.h"
#include "QRef.h" #include "QRef.h"
@ -67,12 +70,11 @@ typedef ButtonController<OkApplyCancelReadOnlyPolicy, Qt2BC>
typedef ButtonController<NoRepeatedApplyReadOnlyPolicy, Qt2BC> typedef ButtonController<NoRepeatedApplyReadOnlyPolicy, Qt2BC>
NoRepeatedApplyReadOnlyBC; NoRepeatedApplyReadOnlyBC;
namespace { namespace {
char const * const dialognames[] = { "bibitem", "bibtex", "citation", char const * const dialognames[] = { "bibitem", "bibtex", "citation",
"error", "ert", "external", "index", "error", "ert", "external", "include",
"label", "ref", "toc", "url" }; "index", "label", "ref", "toc", "url" };
char const * const * const end_dialognames = char const * const * const end_dialognames =
dialognames + (sizeof(dialognames) / sizeof(char *)); dialognames + (sizeof(dialognames) / sizeof(char *));
@ -128,6 +130,10 @@ Dialog * Dialogs::build(string const & name)
dialog->setController(new ControlExternal(*dialog)); dialog->setController(new ControlExternal(*dialog));
dialog->setView(new QExternal(*dialog)); dialog->setView(new QExternal(*dialog));
dialog->setButtonController(new OkApplyCancelReadOnlyBC); dialog->setButtonController(new OkApplyCancelReadOnlyBC);
} else if (name == "include") {
dialog->setController(new ControlInclude(*dialog));
dialog->setView(new QInclude(*dialog));
dialog->setButtonController(new OkApplyCancelReadOnlyBC);
} else if (name == "index") { } else if (name == "index") {
dialog->setController(new ControlIndex(*dialog)); dialog->setController(new ControlIndex(*dialog));
dialog->setView(new QIndex(*dialog, dialog->setView(new QIndex(*dialog,

View File

@ -11,7 +11,6 @@
#ifndef DIALOGS_IMPL_H #ifndef DIALOGS_IMPL_H
#define DIALOGS_IMP_H #define DIALOGS_IMP_H
#include "Dialogs.h" #include "Dialogs.h"
#include "controllers/GUI.h" #include "controllers/GUI.h"
@ -23,7 +22,6 @@
#include "ControlForks.h" #include "ControlForks.h"
#include "ControlGraphics.h" #include "ControlGraphics.h"
#include "insets/insetgraphicsParams.h" #include "insets/insetgraphicsParams.h"
#include "ControlInclude.h"
#include "ControlLog.h" #include "ControlLog.h"
#include "ControlMinipage.h" #include "ControlMinipage.h"
#include "ControlParagraph.h" #include "ControlParagraph.h"
@ -56,8 +54,6 @@
#undef signals #undef signals
#include "QGraphics.h" #include "QGraphics.h"
#include "QGraphicsDialog.h" #include "QGraphicsDialog.h"
#include "QInclude.h"
#include "QIncludeDialog.h"
#include "QLog.h" #include "QLog.h"
#include "QLogDialog.h" #include "QLogDialog.h"
#include "QMinipage.h" #include "QMinipage.h"
@ -119,9 +115,6 @@ FloatDialog;
typedef GUI<ControlGraphics, QGraphics, NoRepeatedApplyReadOnlyPolicy, Qt2BC> typedef GUI<ControlGraphics, QGraphics, NoRepeatedApplyReadOnlyPolicy, Qt2BC>
GraphicsDialog; GraphicsDialog;
typedef GUI<ControlInclude, QInclude, OkCancelReadOnlyPolicy, Qt2BC>
IncludeDialog;
typedef GUI<ControlLog, QLog, OkCancelPolicy, Qt2BC> typedef GUI<ControlLog, QLog, OkCancelPolicy, Qt2BC>
LogFileDialog; LogFileDialog;
@ -177,7 +170,6 @@ struct Dialogs::Impl {
FileDialog file; FileDialog file;
FloatDialog floats; FloatDialog floats;
GraphicsDialog graphics; GraphicsDialog graphics;
IncludeDialog include;
LogFileDialog logfile; LogFileDialog logfile;
MinipageDialog minipage; MinipageDialog minipage;
ParagraphDialog paragraph; ParagraphDialog paragraph;

View File

@ -25,13 +25,12 @@
#include <qcombobox.h> #include <qcombobox.h>
typedef Qt2CB<ControlInclude, Qt2DB<QIncludeDialog> > base_class; typedef QController<ControlInclude, QView<QIncludeDialog> > base_class;
QInclude::QInclude() QInclude::QInclude(Dialog & parent)
: base_class(qt_("LyX: Include File")) : base_class(parent, qt_("LyX: Include File"))
{ {}
}
void QInclude::build_dialog() void QInclude::build_dialog()
@ -82,7 +81,7 @@ void QInclude::update_contents()
void QInclude::apply() void QInclude::apply()
{ {
InsetInclude::Params & params = controller().params(); InsetInclude::Params params = controller().params();
params.cparams.setContents(fromqstr(dialog_->filenameED->text())); params.cparams.setContents(fromqstr(dialog_->filenameED->text()));
params.cparams.preview(dialog_->previewCB->isChecked()); params.cparams.preview(dialog_->previewCB->isChecked());
@ -98,6 +97,7 @@ void QInclude::apply()
else else
params.flag = InsetInclude::VERB; params.flag = InsetInclude::VERB;
} }
controller().setParams(params);
} }

View File

@ -13,20 +13,20 @@
#define QINCLUDE_H #define QINCLUDE_H
#include "Qt2Base.h" #include "QDialogView.h"
class ControlInclude; class ControlInclude;
class QIncludeDialog; class QIncludeDialog;
/// ///
class QInclude class QInclude : public QController<ControlInclude, QView<QIncludeDialog> >
: public Qt2CB<ControlInclude, Qt2DB<QIncludeDialog> >
{ {
public: public:
/// ///
friend class QIncludeDialog; friend class QIncludeDialog;
/// ///
QInclude(); QInclude(Dialog &);
protected: protected:
virtual bool isValid(); virtual bool isValid();
private: private:

View File

@ -1,3 +1,14 @@
2003-03-05 Angus Leeming <leeming@lyx.org>
* FormInclude.[Ch]:
* forms/form_include.fd: changes to use the new Dialog-based scheme.
* Dialogs.C:
* Dialogs2.C:
* Dialogs_impl.h: remove include dialog.
* Dialogs3.C: add include dialog.
2003-03-05 Angus Leeming <leeming@lyx.org> 2003-03-05 Angus Leeming <leeming@lyx.org>
* FormExternal.[Ch]: * FormExternal.[Ch]:

View File

@ -34,7 +34,6 @@ Dialogs::Impl::Impl(LyXView & lv, Dialogs & d)
floats(lv, d), floats(lv, d),
forks(lv, d), forks(lv, d),
graphics(lv, d), graphics(lv, d),
include(lv, d),
logfile(lv, d), logfile(lv, d),
mathpanel(lv, d), mathpanel(lv, d),
minipage(lv, d), minipage(lv, d),

View File

@ -12,7 +12,6 @@
#include <config.h> #include <config.h>
#include "Dialogs_impl.h" #include "Dialogs_impl.h"
@ -70,12 +69,6 @@ void Dialogs::showGraphics(InsetGraphics * ig)
} }
void Dialogs::showInclude(InsetInclude * ii)
{
pimpl_->include.controller().showInset(ii);
}
void Dialogs::showLogFile() void Dialogs::showLogFile()
{ {
pimpl_->logfile.controller().show(); pimpl_->logfile.controller().show();

View File

@ -39,6 +39,10 @@
#include "FormExternal.h" #include "FormExternal.h"
#include "forms/form_external.h" #include "forms/form_external.h"
#include "ControlInclude.h"
#include "FormInclude.h"
#include "forms/form_include.h"
#include "ControlIndex.h" #include "ControlIndex.h"
#include "ControlLabel.h" #include "ControlLabel.h"
@ -73,6 +77,7 @@ typedef ButtonController<OkApplyCancelReadOnlyPolicy, xformsBC>
typedef ButtonController<NoRepeatedApplyReadOnlyPolicy, xformsBC> typedef ButtonController<NoRepeatedApplyReadOnlyPolicy, xformsBC>
NoRepeatedApplyReadOnlyBC; NoRepeatedApplyReadOnlyBC;
namespace { namespace {
// char const * const dialognames[] = { "bibitem", "bibtex", "citation", // char const * const dialognames[] = { "bibitem", "bibtex", "citation",
@ -81,8 +86,8 @@ namespace {
// "minipage", "ref", "tabular", "toc", // "minipage", "ref", "tabular", "toc",
// "url", "wrap" }; // "url", "wrap" };
char const * const dialognames[] = { "bibitem", "bibtex", "citation", char const * const dialognames[] = { "bibitem", "bibtex", "citation",
"error", "ert", "external", "index", "error", "ert", "external", "include",
"label", "ref", "toc", "url" }; "index", "label", "ref", "toc", "url" };
char const * const * const end_dialognames = char const * const * const end_dialognames =
dialognames + (sizeof(dialognames) / sizeof(char *)); dialognames + (sizeof(dialognames) / sizeof(char *));
@ -138,6 +143,10 @@ Dialog * Dialogs::build(string const & name)
dialog->setController(new ControlExternal(*dialog)); dialog->setController(new ControlExternal(*dialog));
dialog->setView(new FormExternal(*dialog)); dialog->setView(new FormExternal(*dialog));
dialog->setButtonController(new OkApplyCancelReadOnlyBC); dialog->setButtonController(new OkApplyCancelReadOnlyBC);
} else if (name == "include") {
dialog->setController(new ControlInclude(*dialog));
dialog->setView(new FormInclude(*dialog));
dialog->setButtonController(new OkApplyCancelReadOnlyBC);
} else if (name == "index") { } else if (name == "index") {
dialog->setController(new ControlIndex(*dialog)); dialog->setController(new ControlIndex(*dialog));
dialog->setView(new FormText(*dialog, dialog->setView(new FormText(*dialog,

View File

@ -11,7 +11,6 @@
#ifndef DIALOGS_IMPL_H #ifndef DIALOGS_IMPL_H
#define DIALOGS_IMP_H #define DIALOGS_IMP_H
#include "Dialogs.h" #include "Dialogs.h"
#include "controllers/GUI.h" #include "controllers/GUI.h"
@ -50,10 +49,6 @@
#include "FormGraphics.h" #include "FormGraphics.h"
#include "forms/form_graphics.h" #include "forms/form_graphics.h"
#include "ControlInclude.h"
#include "FormInclude.h"
#include "forms/form_include.h"
#include "ControlLog.h" #include "ControlLog.h"
#include "FormLog.h" #include "FormLog.h"
@ -146,9 +141,6 @@ ForksDialog;
typedef GUI<ControlGraphics, FormGraphics, NoRepeatedApplyReadOnlyPolicy, xformsBC> typedef GUI<ControlGraphics, FormGraphics, NoRepeatedApplyReadOnlyPolicy, xformsBC>
GraphicsDialog; GraphicsDialog;
typedef GUI<ControlInclude, FormInclude, OkCancelReadOnlyPolicy, xformsBC>
IncludeDialog;
typedef GUI<ControlLog, FormLog, OkCancelPolicy, xformsBC> typedef GUI<ControlLog, FormLog, OkCancelPolicy, xformsBC>
LogFileDialog; LogFileDialog;
@ -210,7 +202,6 @@ struct Dialogs::Impl {
FloatDialog floats; FloatDialog floats;
ForksDialog forks; ForksDialog forks;
GraphicsDialog graphics; GraphicsDialog graphics;
IncludeDialog include;
LogFileDialog logfile; LogFileDialog logfile;
MathPanelDialog mathpanel; MathPanelDialog mathpanel;
MinipageDialog minipage; MinipageDialog minipage;

View File

@ -26,10 +26,10 @@
#include "support/lstrings.h" // strip #include "support/lstrings.h" // strip
#include FORMS_H_LOCATION #include FORMS_H_LOCATION
typedef FormCB<ControlInclude, FormDB<FD_include> > base_class; typedef FormController<ControlInclude, FormView<FD_include> > base_class;
FormInclude::FormInclude() FormInclude::FormInclude(Dialog & parent)
: base_class(_("Include file")) : base_class(parent, _("Include file"))
{} {}
@ -113,26 +113,29 @@ void FormInclude::update()
void FormInclude::apply() void FormInclude::apply()
{ {
controller().params().cparams InsetInclude::Params params = controller().params();
.preview(fl_get_button(dialog_->check_preview));
params.cparams.preview(fl_get_button(dialog_->check_preview));
string const file = fl_get_input(dialog_->input_filename); string const file = fl_get_input(dialog_->input_filename);
if (controller().fileExists(file)) if (controller().fileExists(file))
controller().params().cparams.setContents(file); params.cparams.setContents(file);
else else
controller().params().cparams.setContents(""); params.cparams.setContents("");
ControlInclude::Type const type = ControlInclude::Type(type_.get()); ControlInclude::Type const type = ControlInclude::Type(type_.get());
if (type == ControlInclude::INPUT) if (type == ControlInclude::INPUT)
controller().params().flag = InsetInclude::INPUT; params.flag = InsetInclude::INPUT;
else if (type == ControlInclude::INCLUDE) else if (type == ControlInclude::INCLUDE)
controller().params().flag = InsetInclude::INCLUDE; params.flag = InsetInclude::INCLUDE;
else if (type == ControlInclude::VERBATIM) { else if (type == ControlInclude::VERBATIM) {
if (fl_get_button(dialog_->check_visiblespace)) if (fl_get_button(dialog_->check_visiblespace))
controller().params().flag = InsetInclude::VERBAST; params.flag = InsetInclude::VERBAST;
else else
controller().params().flag = InsetInclude::VERB; params.flag = InsetInclude::VERB;
} }
controller().setParams(params);
} }
@ -151,7 +154,7 @@ ButtonPolicy::SMInput FormInclude::input(FL_OBJECT * ob, long)
} else if (ob == dialog_->button_load) { } else if (ob == dialog_->button_load) {
string const in_name = fl_get_input(dialog_->input_filename); string const in_name = fl_get_input(dialog_->input_filename);
if (!rtrim(in_name).empty() && controller().fileExists(in_name)) { if (!rtrim(in_name).empty() && controller().fileExists(in_name)) {
controller().OKButton(); dialog().OKButton();
controller().load(rtrim(in_name)); controller().load(rtrim(in_name));
action = ButtonPolicy::SMI_NOOP; action = ButtonPolicy::SMI_NOOP;
} }

View File

@ -14,18 +14,20 @@
#define FORMINCLUDE_H #define FORMINCLUDE_H
#include "FormBase.h" #include "FormDialogView.h"
#include "RadioButtonGroup.h" #include "RadioButtonGroup.h"
class ControlInclude; class ControlInclude;
struct FD_include; struct FD_include;
/** This class provides an XForms implementation of the Include Dialog. /** This class provides an XForms implementation of the Include Dialog.
*/ */
class FormInclude : public FormCB<ControlInclude, FormDB<FD_include> > { class FormInclude
: public FormController<ControlInclude, FormView<FD_include> > {
public: public:
/// ///
FormInclude(); FormInclude(Dialog &);
private: private:
/// Set the Params variable for the Controller. /// Set the Params variable for the Controller.
virtual void apply(); virtual void apply();

View File

@ -64,7 +64,7 @@ shortcut:
resize: FL_RESIZE_X resize: FL_RESIZE_X
gravity: FL_NorthEast FL_NorthEast gravity: FL_NorthEast FL_NorthEast
name: button_browse name: button_browse
callback: C_FormBaseInputCB callback: C_FormDialogView_InputCB
argument: 0 argument: 0
-------------------- --------------------
@ -82,7 +82,7 @@ shortcut: ^M
resize: FL_RESIZE_NONE resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast gravity: FL_SouthEast FL_SouthEast
name: button_ok name: button_ok
callback: C_FormBaseOKCB callback: C_FormDialogView_OKCB
argument: 0 argument: 0
-------------------- --------------------
@ -100,7 +100,7 @@ shortcut:
resize: FL_RESIZE_NONE resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast gravity: FL_SouthEast FL_SouthEast
name: button_close name: button_close
callback: C_FormBaseCancelCB callback: C_FormDialogView_CancelCB
argument: 0 argument: 0
-------------------- --------------------
@ -118,7 +118,7 @@ shortcut:
resize: FL_RESIZE_NONE resize: FL_RESIZE_NONE
gravity: FL_NorthWest FL_North gravity: FL_NorthWest FL_North
name: button_load name: button_load
callback: C_FormBaseInputCB callback: C_FormDialogView_InputCB
argument: 0 argument: 0
-------------------- --------------------
@ -136,7 +136,7 @@ shortcut:
resize: FL_RESIZE_X resize: FL_RESIZE_X
gravity: FL_NorthWest FL_NorthEast gravity: FL_NorthWest FL_NorthEast
name: input_filename name: input_filename
callback: C_FormBaseInputCB callback: C_FormDialogView_InputCB
argument: 0 argument: 0
-------------------- --------------------
@ -154,7 +154,7 @@ shortcut:
resize: FL_RESIZE_NONE resize: FL_RESIZE_NONE
gravity: FL_NorthWest FL_North gravity: FL_NorthWest FL_North
name: check_visiblespace name: check_visiblespace
callback: C_FormBaseInputCB callback: C_FormDialogView_InputCB
argument: 0 argument: 0
-------------------- --------------------
@ -190,7 +190,7 @@ shortcut:
resize: FL_RESIZE_NONE resize: FL_RESIZE_NONE
gravity: FL_NorthWest FL_NorthWest gravity: FL_NorthWest FL_NorthWest
name: radio_verbatim name: radio_verbatim
callback: C_FormBaseInputCB callback: C_FormDialogView_InputCB
argument: 0 argument: 0
-------------------- --------------------
@ -208,7 +208,7 @@ shortcut:
resize: FL_RESIZE_NONE resize: FL_RESIZE_NONE
gravity: FL_NorthWest FL_NorthWest gravity: FL_NorthWest FL_NorthWest
name: radio_useinput name: radio_useinput
callback: C_FormBaseInputCB callback: C_FormDialogView_InputCB
argument: 0 argument: 0
value: 1 value: 1
@ -227,7 +227,7 @@ shortcut:
resize: FL_RESIZE_NONE resize: FL_RESIZE_NONE
gravity: FL_NorthWest FL_NorthWest gravity: FL_NorthWest FL_NorthWest
name: radio_useinclude name: radio_useinclude
callback: C_FormBaseInputCB callback: C_FormDialogView_InputCB
argument: 0 argument: 0
-------------------- --------------------
@ -263,7 +263,7 @@ shortcut:
resize: FL_RESIZE_NONE resize: FL_RESIZE_NONE
gravity: FL_NorthWest FL_North gravity: FL_NorthWest FL_North
name: check_preview name: check_preview
callback: C_FormBaseInputCB callback: C_FormDialogView_InputCB
argument: 0 argument: 0
============================== ==============================

View File

@ -1,3 +1,10 @@
2003-03-05 Angus Leeming <leeming@lyx.org>
* insetcommandparams.[Ch] (getAsString, setFromString): remove.
* insetinclude.[Ch]: define a new class InsetIncludeMailer and use
it to communicate with the frontend dialogs.
2003-03-05 Angus Leeming <leeming@lyx.org> 2003-03-05 Angus Leeming <leeming@lyx.org>
* insetexternal.[Ch]: define a new class InsetExternalMailer and use * insetexternal.[Ch]: define a new class InsetExternalMailer and use

View File

@ -32,36 +32,6 @@ InsetCommandParams::InsetCommandParams(string const & n,
{} {}
string const InsetCommandParams::getAsString() const
{
return cmdname + "|++|" + contents + "|++|" + options;
}
void InsetCommandParams::setFromString(string const & b)
{
string::size_type idx = b.find("|++|");
if (idx == string::npos) {
cmdname = b;
contents = "";
options = "";
return;
}
cmdname = b.substr(0, idx);
string tmp = b.substr(idx+4);
idx = tmp.find("|++|");
if (idx == string::npos) {
contents = tmp;
options = "";
} else {
contents = tmp.substr(0, idx);
options = tmp.substr(idx+4);
}
}
void InsetCommandParams::scanCommand(string const & cmd) void InsetCommandParams::scanCommand(string const & cmd)
{ {
string tcmdname, toptions, tcontents; string tcmdname, toptions, tcontents;

View File

@ -51,10 +51,6 @@ public:
/// ///
void setContents(string const & c) { contents = c; } void setContents(string const & c) { contents = c; }
/// ///
string const getAsString() const;
///
void setFromString(string const &);
///
bool preview() const { return preview_; } bool preview() const { return preview_; }
/// ///
void preview(bool p) { preview_ = p; } void preview(bool p) { preview_ = p; }

View File

@ -176,5 +176,4 @@ private:
InsetERT & inset_; InsetERT & inset_;
}; };
#endif #endif

View File

@ -15,9 +15,11 @@
#include "bufferlist.h" #include "bufferlist.h"
#include "BufferView.h" #include "BufferView.h"
#include "debug.h" #include "debug.h"
#include "lyxrc.h" #include "funcrequest.h"
#include "LaTeXFeatures.h"
#include "gettext.h" #include "gettext.h"
#include "LaTeXFeatures.h"
#include "lyxlex.h"
#include "lyxrc.h"
#include "frontends/Dialogs.h" #include "frontends/Dialogs.h"
#include "frontends/LyXView.h" #include "frontends/LyXView.h"
@ -106,7 +108,26 @@ InsetInclude::InsetInclude(InsetCommandParams const & p, Buffer const & b)
InsetInclude::~InsetInclude() InsetInclude::~InsetInclude()
{ {
hideDialog(); InsetIncludeMailer mailer(*this);
mailer.hideDialog();
}
dispatch_result InsetInclude::localDispatch(FuncRequest const & cmd)
{
if (cmd.action != LFUN_INSET_MODIFY)
return UNDISPATCHED;
InsetInclude::Params p;
InsetIncludeMailer::string2params(cmd.argument, p);
if (p.cparams.getCmdName().empty())
return UNDISPATCHED;
set(p);
params_.masterFilename_ = cmd.view()->buffer()->fileName();
cmd.view()->updateInset(this, true);
return DISPATCHED;
} }
@ -172,9 +193,10 @@ Inset * InsetInclude::clone(Buffer const & buffer, bool) const
} }
void InsetInclude::edit(BufferView * bv, int, int, mouse_button::state) void InsetInclude::edit(BufferView *, int, int, mouse_button::state)
{ {
bv->owner()->getDialogs().showInclude(this); InsetIncludeMailer mailer(*this);
mailer.showDialog();
} }
@ -586,3 +608,57 @@ void InsetInclude::PreviewImpl::restartLoading()
view()->updateInset(&parent(), false); view()->updateInset(&parent(), false);
generatePreview(); generatePreview();
} }
InsetIncludeMailer::InsetIncludeMailer(InsetInclude & inset)
: name_("include"), inset_(inset)
{}
string const InsetIncludeMailer::inset2string() const
{
return params2string(name(), inset_.params());
}
void InsetIncludeMailer::string2params(string const & in,
InsetInclude::Params & params)
{
params = InsetInclude::Params();
string name;
string body = split(in, name, ' ');
if (name != "include" || body.empty())
return;
// This is part of the inset proper that is usually swallowed
// by Buffer::readInset
body = split(body, name, ' ');
if (name != "Include")
return;
istringstream data(body);
LyXLex lex(0,0);
lex.setStream(data);
InsetInclude inset(params);
inset.read(0, lex);
params = inset.params();
}
string const
InsetIncludeMailer::params2string(string const & name,
InsetInclude::Params const & params)
{
InsetInclude inset(params);
inset.set(params);
ostringstream data;
data << name << ' ';
inset.write(0, data);
data << "\\end_inset\n";
return data.str();
}

View File

@ -15,7 +15,6 @@
#include "insetcommand.h" #include "insetcommand.h"
#include <boost/signals/signal0.hpp>
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
class Buffer; class Buffer;
@ -58,6 +57,9 @@ public:
~InsetInclude(); ~InsetInclude();
///
virtual dispatch_result localDispatch(FuncRequest const & cmd);
/// Override these InsetButton methods if Previewing /// Override these InsetButton methods if Previewing
int ascent(BufferView *, LyXFont const &) const; int ascent(BufferView *, LyXFont const &) const;
/// ///
@ -119,8 +121,6 @@ public:
/// ///
void addPreview(grfx::PreviewLoader &) const; void addPreview(grfx::PreviewLoader &) const;
/// hide a dialog if about
boost::signal0<void> hideDialog;
private: private:
/// get the text displayed on the button /// get the text displayed on the button
string const getScreenLabel(Buffer const *) const; string const getScreenLabel(Buffer const *) const;
@ -149,4 +149,28 @@ inline bool InsetInclude::isVerbatim() const
return params_.flag == VERB || params_.flag == VERBAST; return params_.flag == VERB || params_.flag == VERBAST;
} }
#include "mailinset.h"
class InsetIncludeMailer : public MailInset {
public:
///
InsetIncludeMailer(InsetInclude & inset);
///
virtual Inset & inset() const { return inset_; }
///
virtual string const & name() const { return name_; }
///
virtual string const inset2string() const;
///
static void string2params(string const &, InsetInclude::Params &);
///
static string const params2string(string const & name,
InsetInclude::Params const &);
private:
///
string const name_;
///
InsetInclude & inset_;
};
#endif // INSETINCLUDE_H #endif // INSETINCLUDE_H

View File

@ -564,9 +564,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
case LFUN_INDEX_PRINT: case LFUN_INDEX_PRINT:
code = Inset::INDEX_PRINT_CODE; code = Inset::INDEX_PRINT_CODE;
break; break;
case LFUN_CHILD_INSERT:
code = Inset::INCLUDE_CODE;
break;
case LFUN_TOC_INSERT: case LFUN_TOC_INSERT:
code = Inset::TOC_CODE; code = Inset::TOC_CODE;
break; break;