Convert the Search/Replace dialog to the cleaner MCV scheme.

The dispatch reaches the correct place in the core, but the core
doesn't seem to act on it properly. No doubt Andr�'s doing ;-)


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8370 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2004-01-26 00:43:56 +00:00
parent 35d08a9635
commit be2ce42c65
20 changed files with 85 additions and 89 deletions

View File

@ -1,3 +1,7 @@
2004-01-25 Angus Leeming <leeming@lyx.org>
* lyxfunc.C (dispatch): Dialogs::showSearch is no more.
2004-01-19 Georg Baum <Georg.Baum@post.rwth-aachen.de> 2004-01-19 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* LaTeXFeatures.h: add nice_ and nice() const * LaTeXFeatures.h: add nice_ and nice() const

View File

@ -1,3 +1,8 @@
2004-01-25 Angus Leeming <leeming@lyx.org>
* Dialogs.h (showSearch):
* guiapi.[Ch] (gui_ShowSearch): removed.
2004-01-08 Angus Leeming <leeming@lyx.org> 2004-01-08 Angus Leeming <leeming@lyx.org>
* FileDialog.h (open, save): the file filter mask is now passed * FileDialog.h (open, save): the file filter mask is now passed

View File

@ -76,8 +76,6 @@ public:
/// ///
void showPrint(); void showPrint();
/// ///
void showSearch();
///
void showSendto(); void showSendto();
/// bring up the spellchecker /// bring up the spellchecker
void showSpellchecker(); void showSpellchecker();

View File

@ -1,3 +1,8 @@
2004-01-25 Angus Leeming <leeming@lyx.org>
* ControlSearch.[Ch]: derive from Dialog::Controller rather than
the deprecated ControlDialogBD.
2004-01-08 Alfredo Braunstein <abraunst@lyx.org> 2004-01-08 Alfredo Braunstein <abraunst@lyx.org>
* Dialog.C (hide): disconnect dialog/inset on hide (partial fix * Dialog.C (hide): disconnect dialog/inset on hide (partial fix

View File

@ -25,7 +25,7 @@ public:
virtual bool initialiseParams(std::string const & data); virtual bool initialiseParams(std::string const & data);
/// clean-up on hide. /// clean-up on hide.
virtual void clearParams(); virtual void clearParams();
/// clean-up on hide. ///
virtual void dispatchParams(); virtual void dispatchParams();
/// ///
virtual bool isBufferDependent() const { return true; } virtual bool isBufferDependent() const { return true; }

View File

@ -15,34 +15,29 @@
#include "funcrequest.h" #include "funcrequest.h"
#include "lyxfind.h" #include "lyxfind.h"
#include "frontends/LyXView.h"
using std::string; using std::string;
/* The ControlSeach class is now in a fit state to derive from ControlSearch::ControlSearch(Dialog & parent)
Dialog::Controller : Dialog::Controller(parent)
*/
ControlSearch::ControlSearch(LyXView & lv, Dialogs & d)
: ControlDialogBD(lv, d)
{} {}
void ControlSearch::find(string const & search, void ControlSearch::find(string const & search, bool casesensitive,
bool casesensitive, bool matchword, bool forward) bool matchword, bool forward)
{ {
string const data = string const data = lyx::find::find2string(search, casesensitive,
lyx::find::find2string(search, matchword, forward);
casesensitive, matchword, forward); kernel().dispatch(FuncRequest(LFUN_WORD_FIND, data));
lv_.dispatch(FuncRequest(LFUN_WORD_FIND, data));
} }
void ControlSearch::replace(string const & search, string const & replace, void ControlSearch::replace(string const & search, string const & replace,
bool casesensitive, bool matchword, bool forward, bool all) bool casesensitive, bool matchword,
bool forward, bool all)
{ {
string const data = string const data =
lyx::find::replace2string(search, replace, lyx::find::replace2string(search, replace, casesensitive,
casesensitive, matchword, all, forward); matchword, all, forward);
lv_.dispatch(FuncRequest(LFUN_WORD_REPLACE, data)); kernel().dispatch(FuncRequest(LFUN_WORD_REPLACE, data));
} }

View File

@ -12,15 +12,19 @@
#ifndef CONTROLSEARCH_H #ifndef CONTROLSEARCH_H
#define CONTROLSEARCH_H #define CONTROLSEARCH_H
#include "Dialog.h"
#include "ControlDialog_impl.h"
/** A controller for Search dialogs. /** A controller for Search dialogs.
*/ */
class ControlSearch : public ControlDialogBD { class ControlSearch : public Dialog::Controller {
public: public:
/// ControlSearch(Dialog &);
ControlSearch(LyXView &, Dialogs &);
virtual bool initialiseParams(std::string const &) { return true; }
virtual void clearParams() {}
virtual void dispatchParams() {}
virtual bool isBufferDependent() const { return true; }
/// Searches occurence of string /// Searches occurence of string
void find(std::string const & search, void find(std::string const & search,
@ -30,9 +34,6 @@ public:
void replace(std::string const & search, std::string const & replace, void replace(std::string const & search, std::string const & replace,
bool casesensitive, bool matchword, bool casesensitive, bool matchword,
bool forward, bool all); bool forward, bool all);
private:
/// not needed.
virtual void apply() {}
}; };
#endif // CONTROLSEARCH_H #endif // CONTROLSEARCH_H

View File

@ -52,12 +52,6 @@ void gui_ShowPrint(Dialogs & d)
} }
void gui_ShowSearch(Dialogs & d)
{
d.showSearch();
}
void gui_ShowSendto(Dialogs & d) void gui_ShowSendto(Dialogs & d)
{ {
d.showSendto(); d.showSendto();

View File

@ -25,7 +25,6 @@ void gui_ShowForks(Dialogs &);
void gui_ShowPreamble(Dialogs &); void gui_ShowPreamble(Dialogs &);
void gui_ShowPreferences(Dialogs &); void gui_ShowPreferences(Dialogs &);
void gui_ShowPrint(Dialogs &); void gui_ShowPrint(Dialogs &);
void gui_ShowSearch(Dialogs &);
void gui_ShowSendto(Dialogs &); void gui_ShowSendto(Dialogs &);
void gui_ShowSpellchecker(Dialogs &); void gui_ShowSpellchecker(Dialogs &);

View File

@ -1,3 +1,10 @@
2004-01-25 Angus Leeming <leeming@lyx.org>
* Dialog.C (build): add the "findreplace" dialog.
* Dialogs2.C (showSearch): removed.
* QSearch.[Ch]: derive from QDialogView rather than from Qt2Base.
2004-01-15 Ronald Florence <ron@18james.com> 2004-01-15 Ronald Florence <ron@18james.com>
* Menubar_pimpl.C: change Q_WS_MAC conditional define to * Menubar_pimpl.C: change Q_WS_MAC conditional define to

View File

@ -30,6 +30,7 @@
#include "ControlNote.h" #include "ControlNote.h"
#include "ControlParagraph.h" #include "ControlParagraph.h"
#include "ControlRef.h" #include "ControlRef.h"
#include "ControlSearch.h"
#include "ControlShowFile.h" #include "ControlShowFile.h"
#include "ControlTabular.h" #include "ControlTabular.h"
#include "ControlTabularCreate.h" #include "ControlTabularCreate.h"
@ -63,6 +64,7 @@
#include "QNote.h" #include "QNote.h"
#include "QParagraph.h" #include "QParagraph.h"
#include "QRef.h" #include "QRef.h"
#include "QSearch.h"
#include "QShowFile.h" #include "QShowFile.h"
#include "QTabular.h" #include "QTabular.h"
#include "QTabularCreate.h" #include "QTabularCreate.h"
@ -84,10 +86,11 @@ using std::string;
namespace { namespace {
char const * const dialognames[] = { "aboutlyx", "bibitem", "bibtex", "box", char const * const dialognames[] = {
"branch", "changes", "character", "citation", "error", "errorlist", "ert", "external", "aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
"file", "float", "graphics", "include", "index", "label", "log", "citation", "error", "errorlist", "ert", "external", "file", "findreplace",
"mathpanel", "mathdelimiter", "mathmatrix", "float", "graphics", "include", "index", "label", "log", "mathpanel",
"mathdelimiter", "mathmatrix",
"note", "paragraph", "ref", "tabular", "tabularcreate", "texinfo", "note", "paragraph", "ref", "tabular", "tabularcreate", "texinfo",
#ifdef HAVE_LIBAIKSAURUS #ifdef HAVE_LIBAIKSAURUS
@ -175,6 +178,10 @@ Dialog * Dialogs::build(string const & name)
dialog->setController(new ControlShowFile(*dialog)); dialog->setController(new ControlShowFile(*dialog));
dialog->setView(new QShowFile(*dialog)); dialog->setView(new QShowFile(*dialog));
dialog->bc().bp(new OkCancelPolicy); dialog->bc().bp(new OkCancelPolicy);
} else if (name == "findreplace") {
dialog->setController(new ControlSearch(*dialog));
dialog->setView(new QSearch(*dialog));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
} else if (name == "float") { } else if (name == "float") {
dialog->setController(new ControlFloat(*dialog)); dialog->setController(new ControlFloat(*dialog));
dialog->setView(new QFloat(*dialog)); dialog->setView(new QFloat(*dialog));

View File

@ -19,7 +19,6 @@
#include "ControlDocument.h" #include "ControlDocument.h"
#include "ControlPrint.h" #include "ControlPrint.h"
#include "ControlSearch.h"
#include "ControlSendto.h" #include "ControlSendto.h"
#include "ControlSpellchecker.h" #include "ControlSpellchecker.h"
@ -34,8 +33,6 @@
#include "QPrefsDialog.h" #include "QPrefsDialog.h"
#include "QPrint.h" #include "QPrint.h"
#include "QLPrintDialog.h" #include "QLPrintDialog.h"
#include "QSearch.h"
#include "QSearchDialog.h"
#include "QSendto.h" #include "QSendto.h"
#include "QSendtoDialog.h" #include "QSendtoDialog.h"
#include "QSpellchecker.h" #include "QSpellchecker.h"
@ -53,9 +50,6 @@ PrefsDialog;
typedef GUI<ControlPrint, QPrint, OkApplyCancelPolicy, Qt2BC> typedef GUI<ControlPrint, QPrint, OkApplyCancelPolicy, Qt2BC>
PrintDialog; PrintDialog;
typedef GUI<ControlSearch, QSearch, NoRepeatedApplyReadOnlyPolicy, Qt2BC>
SearchDialog;
typedef GUI<ControlSendto, QSendto, OkApplyCancelPolicy, Qt2BC> typedef GUI<ControlSendto, QSendto, OkApplyCancelPolicy, Qt2BC>
SendtoDialog; SendtoDialog;
@ -68,7 +62,6 @@ struct Dialogs::Impl {
DocumentDialog document; DocumentDialog document;
PrefsDialog prefs; PrefsDialog prefs;
PrintDialog print; PrintDialog print;
SearchDialog search;
SendtoDialog sendto; SendtoDialog sendto;
SpellcheckerDialog spellchecker; SpellcheckerDialog spellchecker;
}; };
@ -78,7 +71,6 @@ Dialogs::Impl::Impl(LyXView & lv, Dialogs & d)
: document(lv, d), : document(lv, d),
prefs(lv, d), prefs(lv, d),
print(lv, d), print(lv, d),
search(lv, d),
sendto(lv, d), sendto(lv, d),
spellchecker(lv, d) spellchecker(lv, d)
{} {}
@ -126,12 +118,6 @@ void Dialogs::showPrint()
} }
void Dialogs::showSearch()
{
pimpl_->search.controller().show();
}
void Dialogs::showSendto() void Dialogs::showSendto()
{ {
pimpl_->sendto.controller().show(); pimpl_->sendto.controller().show();

View File

@ -23,11 +23,11 @@
using std::string; using std::string;
typedef Qt2CB<ControlSearch, Qt2DB<QSearchDialog> > base_class; typedef QController<ControlSearch, QView<QSearchDialog> > base_class;
QSearch::QSearch() QSearch::QSearch(Dialog & parent)
: base_class(_("LyX: Find and Replace")) : base_class(parent, _("LyX: Find and Replace"))
{ {
} }

View File

@ -12,8 +12,7 @@
#ifndef QSEARCH_H #ifndef QSEARCH_H
#define QSEARCH_H #define QSEARCH_H
#include "QDialogView.h"
#include "Qt2Base.h"
class ControlSearch; class ControlSearch;
class QSearchDialog; class QSearchDialog;
@ -21,13 +20,13 @@ class QSearchDialog;
/// ///
class QSearch class QSearch
: public Qt2CB<ControlSearch, Qt2DB<QSearchDialog> > : public QController<ControlSearch, QView<QSearchDialog> >
{ {
public: public:
/// ///
friend class QSearchDialog; friend class QSearchDialog;
/// ///
QSearch(); QSearch(Dialog &);
private: private:
/// Apply changes /// Apply changes
virtual void apply() {} virtual void apply() {}

View File

@ -1,3 +1,10 @@
2004-01-25 Angus Leeming <leeming@lyx.org>
* Dialog.C (build): add the "findreplace" dialog.
* Dialogs2.C (showSearch): removed.
* FormSearch.[Ch]: derive from FormDialogView rather than from FormBase.
2004-01-08 Angus Leeming <leeming@lyx.org> 2004-01-08 Angus Leeming <leeming@lyx.org>
* FileDialog.C (open, save): * FileDialog.C (open, save):

View File

@ -31,6 +31,7 @@
#include "ControlNote.h" #include "ControlNote.h"
#include "ControlParagraph.h" #include "ControlParagraph.h"
#include "ControlRef.h" #include "ControlRef.h"
#include "ControlSearch.h"
#include "ControlShowFile.h" #include "ControlShowFile.h"
#include "ControlTabular.h" #include "ControlTabular.h"
#include "ControlTabularCreate.h" #include "ControlTabularCreate.h"
@ -64,6 +65,7 @@
#include "FormRef.h" #include "FormRef.h"
#include "FormTabular.h" #include "FormTabular.h"
#include "FormTexinfo.h" #include "FormTexinfo.h"
#include "FormSearch.h"
#include "FormShowFile.h" #include "FormShowFile.h"
#include "FormTabularCreate.h" #include "FormTabularCreate.h"
#include "FormText.h" #include "FormText.h"
@ -110,13 +112,13 @@ FormMathsBitmap * createFormBitmap(Dialog & parent, string const & title,
char const * const dialognames[] = { char const * const dialognames[] = {
"aboutlyx", "bibitem", "bibtex", "branch", "box", "changes", "aboutlyx", "bibitem", "bibtex", "branch", "box", "changes", "character",
"character", "citation", "error", "errorlist" , "ert", "external", "file", "citation", "error", "errorlist" , "ert", "external", "file", "findreplace",
"float", "graphics", "include", "index", "label", "log", "mathpanel", "float", "graphics", "include", "index", "label", "log", "mathpanel",
"mathaccents", "matharrows", "mathoperators", "mathrelations", "mathgreek", "mathaccents", "matharrows", "mathoperators", "mathrelations",
"mathmisc", "mathdots", "mathbigoperators", "mathamsmisc", "mathgreek", "mathmisc", "mathdots", "mathbigoperators", "mathamsmisc",
"mathamsarrows", "mathamsrelations", "mathamsnegatedrelations", "mathamsoperators", "mathamsarrows", "mathamsrelations", "mathamsnegatedrelations",
"mathdelimiter", "mathmatrix", "mathspace", "mathstyle", "mathamsoperators", "mathdelimiter", "mathmatrix", "mathspace", "mathstyle",
"note", "paragraph", "ref", "tabular", "tabularcreate", "texinfo", "note", "paragraph", "ref", "tabular", "tabularcreate", "texinfo",
#ifdef HAVE_LIBAIKSAURUS #ifdef HAVE_LIBAIKSAURUS
@ -203,6 +205,10 @@ Dialog * Dialogs::build(string const & name)
dialog->setController(new ControlShowFile(*dialog)); dialog->setController(new ControlShowFile(*dialog));
dialog->setView(new FormShowFile(*dialog)); dialog->setView(new FormShowFile(*dialog));
dialog->bc().bp(new OkCancelPolicy); dialog->bc().bp(new OkCancelPolicy);
} else if (name == "findreplace") {
dialog->setController(new ControlSearch(*dialog));
dialog->setView(new FormSearch(*dialog));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
} else if (name == "float") { } else if (name == "float") {
dialog->setController(new ControlFloat(*dialog)); dialog->setController(new ControlFloat(*dialog));
dialog->setView(new FormFloat(*dialog)); dialog->setView(new FormFloat(*dialog));

View File

@ -39,10 +39,6 @@
#include "FormPrint.h" #include "FormPrint.h"
#include "forms/form_print.h" #include "forms/form_print.h"
#include "ControlSearch.h"
#include "FormSearch.h"
#include "forms/form_search.h"
#include "ControlSendto.h" #include "ControlSendto.h"
#include "FormSendto.h" #include "FormSendto.h"
#include "forms/form_sendto.h" #include "forms/form_sendto.h"
@ -66,9 +62,6 @@ PreferencesDialog;
typedef GUI<ControlPrint, FormPrint, OkApplyCancelPolicy, xformsBC> typedef GUI<ControlPrint, FormPrint, OkApplyCancelPolicy, xformsBC>
PrintDialog; PrintDialog;
typedef GUI<ControlSearch, FormSearch, NoRepeatedApplyReadOnlyPolicy, xformsBC>
SearchDialog;
typedef GUI<ControlSendto, FormSendto, OkApplyCancelPolicy, xformsBC> typedef GUI<ControlSendto, FormSendto, OkApplyCancelPolicy, xformsBC>
SendtoDialog; SendtoDialog;
@ -84,7 +77,6 @@ struct Dialogs::Impl {
PreambleDialog preamble; PreambleDialog preamble;
PreferencesDialog preferences; PreferencesDialog preferences;
PrintDialog print; PrintDialog print;
SearchDialog search;
SendtoDialog sendto; SendtoDialog sendto;
SpellcheckerDialog spellchecker; SpellcheckerDialog spellchecker;
}; };
@ -96,7 +88,6 @@ Dialogs::Impl::Impl(LyXView & lv, Dialogs & d)
preamble(lv, d), preamble(lv, d),
preferences(lv, d), preferences(lv, d),
print(lv, d), print(lv, d),
search(lv, d),
sendto(lv, d), sendto(lv, d),
spellchecker(lv, d) spellchecker(lv, d)
{} {}
@ -144,12 +135,6 @@ void Dialogs::showPrint()
} }
void Dialogs::showSearch()
{
pimpl_->search.controller().show();
}
void Dialogs::showSendto() void Dialogs::showSendto()
{ {
pimpl_->sendto.controller().show(); pimpl_->sendto.controller().show();

View File

@ -24,10 +24,10 @@
using std::string; using std::string;
typedef FormCB<ControlSearch, FormDB<FD_search> > base_class; typedef FormController<ControlSearch, FormView<FD_search> > base_class;
FormSearch::FormSearch() FormSearch::FormSearch(Dialog & parent)
: base_class(_("Find and Replace")) : base_class(parent, _("Find and Replace"))
{} {}

View File

@ -12,18 +12,18 @@
#ifndef FORMSEARCH_H #ifndef FORMSEARCH_H
#define FORMSEARCH_H #define FORMSEARCH_H
#include "FormDialogView.h"
#include "FormBase.h"
class ControlSearch; class ControlSearch;
struct FD_search; struct FD_search;
/** This class provides an XForms implementation of the FormSearch Dialog. /** This class provides an XForms implementation of the FormSearch Dialog.
*/ */
class FormSearch : public FormCB<ControlSearch, FormDB<FD_search> > { class FormSearch
: public FormController<ControlSearch, FormView<FD_search> > {
public: public:
/// ///
FormSearch(); FormSearch(Dialog &);
private: private:
/// not needed. /// not needed.
virtual void apply() {} virtual void apply() {}

View File

@ -1200,8 +1200,6 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
} }
else if (name == "document") else if (name == "document")
owner->getDialogs().showDocument(); owner->getDialogs().showDocument();
else if (name == "findreplace")
owner->getDialogs().showSearch();
else if (name == "forks") else if (name == "forks")
owner->getDialogs().showForks(); owner->getDialogs().showForks();
else if (name == "preamble") else if (name == "preamble")