From 9f330376ac85627bd0044e5a14a53f7bcbdb7042 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Wed, 26 Mar 2003 12:17:20 +0000 Subject: [PATCH] port the thesaurus dialog to the new scheme git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6583 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView_pimpl.C | 2 +- src/ChangeLog | 5 +++ src/frontends/ChangeLog | 5 +++ src/frontends/Dialogs.h | 2 - src/frontends/controllers/ChangeLog | 4 ++ src/frontends/controllers/ControlThesaurus.C | 26 +++++++----- src/frontends/controllers/ControlThesaurus.h | 26 ++++++------ src/frontends/guiapi.C | 6 --- src/frontends/guiapi.h | 1 - src/frontends/qt2/ChangeLog | 10 +++++ src/frontends/qt2/Dialogs.C | 6 +-- src/frontends/qt2/Dialogs2.C | 15 ------- src/frontends/qt2/Dialogs3.C | 44 ++++++++------------ src/frontends/qt2/Dialogs_impl.h | 15 ------- src/frontends/qt2/QThesaurus.C | 6 +-- src/frontends/qt2/QThesaurus.h | 7 ++-- src/frontends/xforms/ChangeLog | 11 +++++ src/frontends/xforms/Dialogs.C | 6 +-- src/frontends/xforms/Dialogs2.C | 15 ------- src/frontends/xforms/Dialogs3.C | 19 ++++++++- src/frontends/xforms/Dialogs_impl.h | 15 ------- src/frontends/xforms/FormThesaurus.C | 6 +-- src/frontends/xforms/FormThesaurus.h | 8 ++-- src/frontends/xforms/forms/form_thesaurus.fd | 10 ++--- 24 files changed, 123 insertions(+), 147 deletions(-) diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 0577ee7ae9..0789f2ddf1 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -1212,7 +1212,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in) } } - bv_->owner()->getDialogs().showThesaurus(arg); + bv_->owner()->getDialogs().show("thesaurus", arg); } break; diff --git a/src/ChangeLog b/src/ChangeLog index cf74b4067b..40dcc010c8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2003-03-26 Angus Leeming + + * BufferView_pimpl.C (dispatch): changes to the Dialogs interface for + the thesaurus dialog. + 2003-03-26 Lars Gullik Bjønnes * ParagraphList.C (erase): handle the case where it == begin diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index 1ae1d75343..1c96937f31 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,8 @@ +2003-03-26 Angus Leeming + + * Dialogs.h: remove showThesaurus. + * guiapi.[Ch]: remove the gui_ equivalents. + 2003-03-25 Angus Leeming * Dialogs.h: remove showFile, showLogFile, showVCLogFile. diff --git a/src/frontends/Dialogs.h b/src/frontends/Dialogs.h index 6f0519e2e5..1aa3eea30d 100644 --- a/src/frontends/Dialogs.h +++ b/src/frontends/Dialogs.h @@ -90,8 +90,6 @@ public: void showSpellchecker(); /// show the TexInfo void showTexinfo(); - /// show the thesaurus dialog - void showThesaurus(string const &); //@} /** \param name == "about" etc; an identifier used to diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 86027b2504..1b3528311e 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,7 @@ +2003-03-26 Angus Leeming + + * ControlThesaurus.[Ch]: rewrite to use the Dialog-based scheme. + 2003-03-25 John Levon * ControlSpellchecker.C: support for new aspell diff --git a/src/frontends/controllers/ControlThesaurus.C b/src/frontends/controllers/ControlThesaurus.C index 182b9c0bb1..457931c5ad 100644 --- a/src/frontends/controllers/ControlThesaurus.C +++ b/src/frontends/controllers/ControlThesaurus.C @@ -18,16 +18,21 @@ #include "frontends/LyXView.h" - -ControlThesaurus::ControlThesaurus(LyXView & lv, Dialogs & d) - : ControlDialogBD(lv, d) +ControlThesaurus::ControlThesaurus(Dialog & parent) + : Dialog::Controller(parent) {} -void ControlThesaurus::showEntry(string const & entry) +bool ControlThesaurus::initialiseParams(string const & data) +{ + oldstr_ = data; + return true; +} + + +void ControlThesaurus::clearParams() { - oldstr_ = entry; - show(); + oldstr_.erase(); } @@ -38,19 +43,20 @@ void ControlThesaurus::replace(string const & newstr) * deletion/change ! */ int const replace_count = - lyxfind::LyXReplace(bufferview(), oldstr_, newstr, + lyxfind::LyXReplace(kernel().bufferview(), oldstr_, newstr, true, true, true, false, true); oldstr_ = newstr; if (replace_count == 0) - lv_.message(_("String not found!")); + kernel().lyxview().message(_("String not found!")); else - lv_.message(_("String has been replaced.")); + kernel().lyxview().message(_("String has been replaced.")); } -Thesaurus::Meanings const & ControlThesaurus::getMeanings(string const & str) +Thesaurus::Meanings const & +ControlThesaurus::getMeanings(string const & str) { if (str != laststr_) meanings_ = thesaurus.lookup(str); diff --git a/src/frontends/controllers/ControlThesaurus.h b/src/frontends/controllers/ControlThesaurus.h index 856cf70607..4b9b585a11 100644 --- a/src/frontends/controllers/ControlThesaurus.h +++ b/src/frontends/controllers/ControlThesaurus.h @@ -13,33 +13,33 @@ #ifndef CONTROLTHESAURUS_H #define CONTROLTHESAURUS_H - -#include - -#include "LString.h" +#include "Dialog.h" #include "Thesaurus.h" -#include "ControlDialog_impl.h" +#include /** A controller for Thesaurus dialogs. */ -class ControlThesaurus : public ControlDialogBD { +class ControlThesaurus : public Dialog::Controller { public: /// - ControlThesaurus(LyXView &, Dialogs &); + ControlThesaurus(Dialog &); + /// + virtual bool initialiseParams(string const & data); + /// + virtual void clearParams(); + /// + virtual void dispatchParams() {} + /// + virtual bool isBufferDependent() const { return true; } /// replace the particular string void replace(string const & newstr); - /// show dialog - virtual void showEntry(string const & str); - /// get meanings Thesaurus::Meanings const & getMeanings(string const & str); /// the text - string const & text() { - return oldstr_; - } + string const & text() const { return oldstr_; } private: /// last string looked up diff --git a/src/frontends/guiapi.C b/src/frontends/guiapi.C index ea34d09fd3..824eca21e3 100644 --- a/src/frontends/guiapi.C +++ b/src/frontends/guiapi.C @@ -81,10 +81,4 @@ void gui_ShowTexinfo(Dialogs & d) } -void gui_ShowThesaurus(string const & s, Dialogs & d) -{ - d.showThesaurus(s); -} - - } // extern "C" diff --git a/src/frontends/guiapi.h b/src/frontends/guiapi.h index ebaa03b559..f98d61125d 100644 --- a/src/frontends/guiapi.h +++ b/src/frontends/guiapi.h @@ -31,7 +31,6 @@ void gui_ShowSearch(Dialogs &); void gui_ShowSendto(Dialogs &); void gui_ShowSpellchecker(Dialogs &); void gui_ShowTexinfo(Dialogs &); -void gui_ShowThesaurus(string const &, Dialogs &); } // extern "C" diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index e0718bad9e..00b14a6edf 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,13 @@ +2003-03-26 Angus Leeming + + * Dialogs.C: + * Dialogs2.C: + * Dialogs_impl.h: remove the thesaurus dialog. + + * Dialogs3.C: add it here. + + * QThesaurus.[Ch]: changes to use the new Dialog-based scheme. + 2003-03-25 Angus Leeming * Dialogs.C: diff --git a/src/frontends/qt2/Dialogs.C b/src/frontends/qt2/Dialogs.C index de108477ce..04eb5f80ad 100644 --- a/src/frontends/qt2/Dialogs.C +++ b/src/frontends/qt2/Dialogs.C @@ -27,11 +27,7 @@ Dialogs::~Dialogs() Dialogs::Impl::Impl(LyXView & lv, Dialogs & d) - : -#ifdef HAVE_LIBAIKSAURUS - thesaurus(lv, d), -#endif - document(lv, d), + : document(lv, d), prefs(lv, d), print(lv, d), search(lv, d), diff --git a/src/frontends/qt2/Dialogs2.C b/src/frontends/qt2/Dialogs2.C index 59d1dd8543..e658b97735 100644 --- a/src/frontends/qt2/Dialogs2.C +++ b/src/frontends/qt2/Dialogs2.C @@ -74,18 +74,3 @@ void Dialogs::showTexinfo() { pimpl_->texinfo.controller().show(); } - - -#ifdef HAVE_LIBAIKSAURUS - -void Dialogs::showThesaurus(string const & s) -{ - pimpl_->thesaurus.controller().showEntry(s); -} - -#else - -void Dialogs::showThesaurus(string const &) -{} - -#endif diff --git a/src/frontends/qt2/Dialogs3.C b/src/frontends/qt2/Dialogs3.C index 7668900146..804083b78f 100644 --- a/src/frontends/qt2/Dialogs3.C +++ b/src/frontends/qt2/Dialogs3.C @@ -36,58 +36,38 @@ #include "ControlWrap.h" #include "QAbout.h" -#include "QAboutDialog.h" #include "QBibitem.h" -#include "QBibitemDialog.h" #include "QBibtex.h" -#include "QBibtexDialog.h" #include "QChanges.h" -#include "QChangesDialog.h" #include "QCharacter.h" -#include "QCharacterDialog.h" #include "QCitation.h" -#include "QCitationDialog.h" #include "QError.h" -#include "QErrorDialog.h" #include "QERT.h" -#include "QERTDialog.h" #include "QExternal.h" -#include "QExternalDialog.h" #include "QFloat.h" -#include "QFloatDialog.h" // Here would be an appropriate point to lecture on the evils // of the Qt headers, those most fucked up of disgusting ratholes. // But I won't. #undef signals #include "QGraphics.h" -#include "QGraphicsDialog.h" #include "QInclude.h" -#include "QIncludeDialog.h" #include "QIndex.h" -#include "QIndexDialog.h" #include "QLog.h" -#include "QLogDialog.h" #include "QMinipage.h" -#include "QMinipageDialog.h" #include "QParagraph.h" -#include "QParagraphDialog.h" #include "QRef.h" -#include "QRefDialog.h" #include "QShowFile.h" -#include "QShowFileDialog.h" #include "QTabular.h" -#include "QTabularDialog.h" #include "QTabularCreate.h" -#include "QTabularCreateDialog.h" #include "QToc.h" -#include "QTocDialog.h" #include "QURL.h" -#include "QURLDialog.h" #include "QVCLog.h" -#include "QVCLogDialog.h" - #include "QWrap.h" -#include "QWrapDialog.h" + +#ifdef HAVE_LIBAIKSAURUS +#include "ControlThesaurus.h" +#include "QThesaurus.h" +#endif #include "Qt2BC.h" #include "ButtonController.h" @@ -99,7 +79,13 @@ namespace { char const * const dialognames[] = { "about", "bibitem", "bibtex", "changes", "character", "citation", "error", "ert", "external", "file", "float", "graphics", "include", "index", "label", "log", "minipage", "paragraph", -"ref", "tabular", "tabularcreate", "toc", "url", "vclog", "wrap" }; +"ref", "tabular", "tabularcreate", + +#ifdef HAVE_LIBAIKSAURUS +"thesaurus", +#endif + +"toc", "url", "vclog", "wrap" }; char const * const * const end_dialognames = dialognames + (sizeof(dialognames) / sizeof(char *)); @@ -220,6 +206,12 @@ Dialog * Dialogs::build(string const & name) dialog->setController(new ControlTabularCreate(*dialog)); dialog->setView(new QTabularCreate(*dialog)); dialog->bc().bp(new IgnorantPolicy); +#ifdef HAVE_LIBAIKSAURUS + } else if (name == "thesaurus") { + dialog->setController(new ControlThesaurus(*dialog)); + dialog->setView(new QThesaurus(*dialog)); + dialog->bc().bp(new OkApplyCancelReadOnlyPolicy); +#endif } else if (name == "toc") { dialog->setController(new ControlToc(*dialog)); dialog->setView(new QToc(*dialog)); diff --git a/src/frontends/qt2/Dialogs_impl.h b/src/frontends/qt2/Dialogs_impl.h index c1ab3de9a7..2f3845f1a7 100644 --- a/src/frontends/qt2/Dialogs_impl.h +++ b/src/frontends/qt2/Dialogs_impl.h @@ -45,12 +45,6 @@ #include "QTexinfo.h" #include "QTexinfoDialog.h" -#ifdef HAVE_LIBAIKSAURUS -#include "ControlThesaurus.h" -#include "QThesaurus.h" -#include "QThesaurusDialog.h" -#endif - #include "Qt2BC.h" @@ -76,11 +70,6 @@ SpellcheckerDialog; typedef GUI TexinfoDialog; -#ifdef HAVE_LIBAIKSAURUS -typedef GUI -ThesaurusDialog; -#endif - struct Dialogs::Impl { Impl(LyXView & lv, Dialogs & d); @@ -91,10 +80,6 @@ struct Dialogs::Impl { SendtoDialog sendto; SpellcheckerDialog spellchecker; TexinfoDialog texinfo; - -#ifdef HAVE_LIBAIKSAURUS - ThesaurusDialog thesaurus; -#endif }; #endif // DIALOGS_IMPL_H diff --git a/src/frontends/qt2/QThesaurus.C b/src/frontends/qt2/QThesaurus.C index 88a53ec0d8..81453baea0 100644 --- a/src/frontends/qt2/QThesaurus.C +++ b/src/frontends/qt2/QThesaurus.C @@ -21,11 +21,11 @@ #include #include -typedef Qt2CB > base_class; +typedef QController > base_class; -QThesaurus::QThesaurus() - : base_class(qt_("LyX: Thesaurus")) +QThesaurus::QThesaurus(Dialog & parent) + : base_class(parent, qt_("LyX: Thesaurus")) { } diff --git a/src/frontends/qt2/QThesaurus.h b/src/frontends/qt2/QThesaurus.h index 7d905372e5..a0f9212cf8 100644 --- a/src/frontends/qt2/QThesaurus.h +++ b/src/frontends/qt2/QThesaurus.h @@ -13,20 +13,21 @@ #define QTHESAURUS_H -#include "Qt2Base.h" +#include "QDialogView.h" + class ControlThesaurus; class QThesaurusDialog; /// class QThesaurus - : public Qt2CB > + : public QController > { public: /// friend class QThesaurusDialog; /// - QThesaurus(); + QThesaurus(Dialog &); private: /// Apply changes virtual void apply() {} diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 148061c3c8..82a5b31bcf 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,14 @@ +2003-03-26 Angus Leeming + + * Dialogs.C: + * Dialogs2.C: + * Dialogs_impl.h: remove the thesaurus dialog. + + * Dialogs3.C: add it here. + + * FormThesaurus.[Ch]: + * forms/form_thesaurus.fd: changes to use the new Dialog-based scheme. + 2003-03-25 Angus Leeming * Dialogs.C: diff --git a/src/frontends/xforms/Dialogs.C b/src/frontends/xforms/Dialogs.C index 3d302c46db..8bb519e1d4 100644 --- a/src/frontends/xforms/Dialogs.C +++ b/src/frontends/xforms/Dialogs.C @@ -27,11 +27,7 @@ Dialogs::~Dialogs() Dialogs::Impl::Impl(LyXView & lv, Dialogs & d) - : -#ifdef HAVE_LIBAIKSAURUS - thesaurus(lv, d), -#endif - document(lv, d), + : document(lv, d), forks(lv, d), mathpanel(lv, d), preamble(lv, d), diff --git a/src/frontends/xforms/Dialogs2.C b/src/frontends/xforms/Dialogs2.C index 10d2989954..44edb1b071 100644 --- a/src/frontends/xforms/Dialogs2.C +++ b/src/frontends/xforms/Dialogs2.C @@ -73,18 +73,3 @@ void Dialogs::showTexinfo() { pimpl_->texinfo.controller().show(); } - - -#ifdef HAVE_LIBAIKSAURUS - -void Dialogs::showThesaurus(string const & s) -{ - pimpl_->thesaurus.controller().showEntry(s); -} - -#else - -void Dialogs::showThesaurus(string const &) -{} - -#endif diff --git a/src/frontends/xforms/Dialogs3.C b/src/frontends/xforms/Dialogs3.C index a1a8595a8d..10d47c6d12 100644 --- a/src/frontends/xforms/Dialogs3.C +++ b/src/frontends/xforms/Dialogs3.C @@ -63,6 +63,11 @@ #include "FormVCLog.h" #include "FormWrap.h" +#ifdef HAVE_LIBAIKSAURUS +#include "ControlThesaurus.h" +#include "FormThesaurus.h" +#endif + #include "xformsBC.h" #include "ButtonController.h" @@ -72,7 +77,13 @@ namespace { char const * const dialognames[] = { "about", "bibitem", "bibtex", "changes", "character", "citation", "error", "ert", "external", "file", "float", "graphics", "include", "index", "label", "log", "minipage", "paragraph", -"ref", "tabular", "tabularcreate", "toc", "url", "vclog", "wrap" }; +"ref", "tabular", "tabularcreate", + +#ifdef HAVE_LIBAIKSAURUS +"thesaurus", +#endif + +"toc", "url", "vclog", "wrap" }; char const * const * const end_dialognames = dialognames + (sizeof(dialognames) / sizeof(char *)); @@ -191,6 +202,12 @@ Dialog * Dialogs::build(string const & name) dialog->setController(new ControlTabularCreate(*dialog)); dialog->setView(new FormTabularCreate(*dialog)); dialog->bc().bp(new IgnorantPolicy); +#ifdef HAVE_LIBAIKSAURUS + } else if (name == "thesaurus") { + dialog->setController(new ControlThesaurus(*dialog)); + dialog->setView(new FormThesaurus(*dialog)); + dialog->bc().bp(new OkApplyCancelReadOnlyPolicy); +#endif } else if (name == "toc") { dialog->setController(new ControlToc(*dialog)); dialog->setView(new FormToc(*dialog)); diff --git a/src/frontends/xforms/Dialogs_impl.h b/src/frontends/xforms/Dialogs_impl.h index 6d8ff0056e..aa1982ba33 100644 --- a/src/frontends/xforms/Dialogs_impl.h +++ b/src/frontends/xforms/Dialogs_impl.h @@ -58,12 +58,6 @@ #include "FormTexinfo.h" #include "forms/form_texinfo.h" -#ifdef HAVE_LIBAIKSAURUS -#include "ControlThesaurus.h" -#include "FormThesaurus.h" -#include "forms/form_thesaurus.h" -#endif - typedef GUI DocumentDialog; @@ -94,11 +88,6 @@ SpellcheckerDialog; typedef GUI TexinfoDialog; -#ifdef HAVE_LIBAIKSAURUS -typedef GUI -ThesaurusDialog; -#endif - struct Dialogs::Impl { Impl(LyXView & lv, Dialogs & d); @@ -112,10 +101,6 @@ struct Dialogs::Impl { SendtoDialog sendto; SpellcheckerDialog spellchecker; TexinfoDialog texinfo; - -#ifdef HAVE_LIBAIKSAURUS - ThesaurusDialog thesaurus; -#endif }; #endif // DIALOGS_IMPL_H diff --git a/src/frontends/xforms/FormThesaurus.C b/src/frontends/xforms/FormThesaurus.C index b7ec39b076..6afed99d97 100644 --- a/src/frontends/xforms/FormThesaurus.C +++ b/src/frontends/xforms/FormThesaurus.C @@ -29,11 +29,11 @@ using std::islower; using std::vector; -typedef FormCB > base_class; +typedef FormController > base_class; -FormThesaurus::FormThesaurus() - : base_class(_("Thesaurus"), false), +FormThesaurus::FormThesaurus(Dialog & parent) + : base_class(parent, _("Thesaurus"), false), clickline_(-1) { } diff --git a/src/frontends/xforms/FormThesaurus.h b/src/frontends/xforms/FormThesaurus.h index 86623a612d..42c1dffa8e 100644 --- a/src/frontends/xforms/FormThesaurus.h +++ b/src/frontends/xforms/FormThesaurus.h @@ -13,17 +13,19 @@ #define FORMTHESAURUS_H -#include "FormBase.h" +#include "FormDialogView.h" + class ControlThesaurus; struct FD_thesaurus; /** This class provides an XForms implementation of the Thesaurus dialog. */ -class FormThesaurus : public FormCB > { +class FormThesaurus + : public FormController > { public: /// - FormThesaurus(); + FormThesaurus(Dialog &); private: /// not needed. virtual void apply() {} diff --git a/src/frontends/xforms/forms/form_thesaurus.fd b/src/frontends/xforms/forms/form_thesaurus.fd index 70a49d4aa7..a24a3d8d0b 100644 --- a/src/frontends/xforms/forms/form_thesaurus.fd +++ b/src/frontends/xforms/forms/form_thesaurus.fd @@ -46,7 +46,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NorthWest FL_NorthWest name: button_replace -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -64,7 +64,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NorthWest FL_NorthWest name: button_close -callback: C_FormBaseOKCB +callback: C_FormDialogView_OKCB argument: 0 -------------------- @@ -82,7 +82,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NorthWest FL_NorthWest name: input_entry -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -100,7 +100,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NorthWest FL_NorthWest name: input_replace -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -118,7 +118,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: browser_meanings -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 ============================== -- 2.39.2