From f5eb303b4bf73b72938bf87a0ab4514eedc322f3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Sat, 6 Oct 2007 20:54:31 +0000 Subject: [PATCH] next one git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20801 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/Dialogs.cpp | 3 +- src/frontends/qt4/GuiSearch.cpp | 58 ++++++++++++++++++--------------- src/frontends/qt4/GuiSearch.h | 29 ++++++++++------- src/frontends/qt4/TocWidget.cpp | 7 ++-- src/frontends/qt4/TocWidget.h | 2 +- 5 files changed, 52 insertions(+), 47 deletions(-) diff --git a/src/frontends/qt4/Dialogs.cpp b/src/frontends/qt4/Dialogs.cpp index 477ebed208..1c2ee93373 100644 --- a/src/frontends/qt4/Dialogs.cpp +++ b/src/frontends/qt4/Dialogs.cpp @@ -27,7 +27,6 @@ #include "GuiParagraph.h" #include "GuiPrefs.h" #include "GuiPrint.h" -#include "GuiSearch.h" #include "GuiShowFile.h" #include "GuiView.h" #include "TocWidget.h" @@ -165,7 +164,7 @@ Dialog * Dialogs::build(string const & name) if (name == "file") return createGuiShowFile(lyxview_); if (name == "findreplace") - return new GuiSearchDialog(lyxview_); + return createGuiSearch(lyxview_); if (name == "float") return createGuiFloat(lyxview_); if (name == "graphics") diff --git a/src/frontends/qt4/GuiSearch.cpp b/src/frontends/qt4/GuiSearch.cpp index 819d97baac..1d42dd852f 100644 --- a/src/frontends/qt4/GuiSearch.cpp +++ b/src/frontends/qt4/GuiSearch.cpp @@ -5,6 +5,7 @@ * * \author John Levon * \author Edwin Leuven + * \author Angus Leeming * * Full author contact details are available in file CREDITS. */ @@ -13,7 +14,9 @@ #include "GuiSearch.h" -#include "ControlSearch.h" +#include "FuncRequest.h" +#include "lyxfind.h" + #include "qt_helpers.h" #include @@ -36,11 +39,11 @@ static void uniqueInsert(QComboBox * box, QString const & text) } -GuiSearchDialog::GuiSearchDialog(LyXView & lv) - : GuiDialog(lv, "findreplace") +GuiSearch::GuiSearch(LyXView & lv) + : GuiDialog(lv, "findreplace"), Controller(this) { setupUi(this); - setController(new ControlSearch(*this)); + setController(this, false); setViewTitle(_("Find and Replace")); connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose())); @@ -63,27 +66,21 @@ GuiSearchDialog::GuiSearchDialog(LyXView & lv) } -ControlSearch & GuiSearchDialog::controller() -{ - return static_cast(GuiDialog::controller()); -} - - -void GuiSearchDialog::showView() +void GuiSearch::showView() { findCO->lineEdit()->setSelection(0, findCO->lineEdit()->text().length()); GuiDialog::showView(); } -void GuiSearchDialog::closeEvent(QCloseEvent * e) +void GuiSearch::closeEvent(QCloseEvent * e) { slotClose(); GuiDialog::closeEvent(e); } -void GuiSearchDialog::findChanged() +void GuiSearch::findChanged() { if (findCO->currentText().isEmpty()) { findPB->setEnabled(false); @@ -97,52 +94,59 @@ void GuiSearchDialog::findChanged() } -void GuiSearchDialog::findClicked() +void GuiSearch::findClicked() { docstring const needle = qstring_to_ucs4(findCO->currentText()); find(needle, caseCB->isChecked(), wordsCB->isChecked(), - backwardsCB->isChecked()); + !backwardsCB->isChecked()); uniqueInsert(findCO, findCO->currentText()); findCO->lineEdit()->setSelection(0, findCO->lineEdit()->text().length()); } -void GuiSearchDialog::replaceClicked() +void GuiSearch::replaceClicked() { docstring const needle = qstring_to_ucs4(findCO->currentText()); docstring const repl = qstring_to_ucs4(replaceCO->currentText()); replace(needle, repl, caseCB->isChecked(), wordsCB->isChecked(), - backwardsCB->isChecked(), false); + !backwardsCB->isChecked(), false); uniqueInsert(findCO, findCO->currentText()); uniqueInsert(replaceCO, replaceCO->currentText()); } -void GuiSearchDialog::replaceallClicked() +void GuiSearch::replaceallClicked() { replace(qstring_to_ucs4(findCO->currentText()), qstring_to_ucs4(replaceCO->currentText()), - caseCB->isChecked(), wordsCB->isChecked(), false, true); + caseCB->isChecked(), wordsCB->isChecked(), true, true); uniqueInsert(findCO, findCO->currentText()); uniqueInsert(replaceCO, replaceCO->currentText()); } -void GuiSearchDialog::find(docstring const & str, bool casesens, - bool words, bool backwards) +void GuiSearch::find(docstring const & search, bool casesensitive, + bool matchword, bool forward) { - controller().find(str, casesens, words, !backwards); + docstring const data = find2string(search, casesensitive, + matchword, forward); + dispatch(FuncRequest(LFUN_WORD_FIND, data)); } -void GuiSearchDialog::replace(docstring const & findstr, - docstring const & replacestr, - bool casesens, bool words, bool backwards, bool all) +void GuiSearch::replace(docstring const & search, docstring const & replace, + bool casesensitive, bool matchword, + bool forward, bool all) { - controller().replace(findstr, replacestr, casesens, words, - !backwards, all); + docstring const data = + replace2string(search, replace, casesensitive, + matchword, all, forward); + dispatch(FuncRequest(LFUN_WORD_REPLACE, data)); } +Dialog * createGuiSearch(LyXView & lv) { return new GuiSearch(lv); } + + } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt4/GuiSearch.h b/src/frontends/qt4/GuiSearch.h index 9ae3842ac1..d9f71252e9 100644 --- a/src/frontends/qt4/GuiSearch.h +++ b/src/frontends/qt4/GuiSearch.h @@ -5,6 +5,7 @@ * Licence details can be found in the file COPYING. * * \author John Levon + * \author Angus Leeming * * Full author contact details are available in file CREDITS. */ @@ -13,20 +14,17 @@ #define GUISEARCH_H #include "GuiDialog.h" -#include "ControlSearch.h" #include "ui_SearchUi.h" namespace lyx { namespace frontend { -class ControlSearch; - -class GuiSearchDialog : public GuiDialog, public Ui::SearchUi +class GuiSearch : public GuiDialog, public Ui::SearchUi, public Controller { Q_OBJECT public: - GuiSearchDialog(LyXView & lv); + GuiSearch(LyXView & lv); private Q_SLOTS: void findChanged(); @@ -38,14 +36,21 @@ private: void showView(); void closeEvent(QCloseEvent * e); /// parent controller - ControlSearch & controller(); - /// - void find(docstring const & str, bool casesens, - bool words, bool backwards); + Controller & controller() { return *this; } /// - void replace(docstring const & findstr, - docstring const & replacestr, - bool casesens, bool words, bool backwards, bool all); + bool initialiseParams(std::string const &) { return true; } + void clearParams() {} + void dispatchParams() {} + bool isBufferDependent() const { return true; } + + /// Searches occurence of string + void find(docstring const & search, + bool casesensitive, bool matchword, bool forward); + + /// Replaces occurence of string + void replace(docstring const & search, docstring const & replace, + bool casesensitive, bool matchword, + bool forward, bool all); }; } // namespace frontend diff --git a/src/frontends/qt4/TocWidget.cpp b/src/frontends/qt4/TocWidget.cpp index faa8b035bd..7d36b2e3d9 100644 --- a/src/frontends/qt4/TocWidget.cpp +++ b/src/frontends/qt4/TocWidget.cpp @@ -315,11 +315,8 @@ void TocWidget::reconnectSelectionModel() void TocWidget::disconnectSelectionModel() { disconnect(tocTV->selectionModel(), - SIGNAL(currentChanged(const QModelIndex &, - const QModelIndex &)), - this, - SLOT(selectionChanged(const QModelIndex &, - const QModelIndex &))); + SIGNAL(currentChanged(QModelIndex, QModelIndex)), + this, SLOT(selectionChanged(QModelIndex, QModelIndex))); } } // namespace frontend diff --git a/src/frontends/qt4/TocWidget.h b/src/frontends/qt4/TocWidget.h index 830c0b1d4e..a4a41c6f1e 100644 --- a/src/frontends/qt4/TocWidget.h +++ b/src/frontends/qt4/TocWidget.h @@ -14,7 +14,7 @@ #define TOC_WIDGET_H #include "GuiDialog.h" -#include "ControlToc.h" +#include "GuiToc.h" #include "ui_TocUi.h" -- 2.39.5