]> git.lyx.org Git - features.git/commitdiff
next one
authorAndré Pönitz <poenitz@gmx.net>
Sat, 6 Oct 2007 20:54:31 +0000 (20:54 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Sat, 6 Oct 2007 20:54:31 +0000 (20:54 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20801 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/Dialogs.cpp
src/frontends/qt4/GuiSearch.cpp
src/frontends/qt4/GuiSearch.h
src/frontends/qt4/TocWidget.cpp
src/frontends/qt4/TocWidget.h

index 477ebed208754683069639be72b53b7e1c9d1fb8..1c2ee9337341a3bec7887f74a7aaac42b5cb9ac4 100644 (file)
@@ -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")
index 819d97baac23b07b310b9ba8d2f4d05e34f4b0d1..1d42dd852f8be9e0b4b9adfb9f1e58dfa9eea17e 100644 (file)
@@ -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 <QLineEdit>
@@ -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<ControlSearch &>(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
 
index 9ae3842ac1d9fef1abe5f9b92e9a2ae654f31779..d9f71252e921bd3af4ff8248725b8c2343d400dc 100644 (file)
@@ -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.
  */
 #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
index faa8b035bd867433ec3bb5adcd43bd890f016a50..7d36b2e3d99a7a087bcdfb5e22c5f9373d51d745 100644 (file)
@@ -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
index 830c0b1d4eeaa34acfd9c234d50778346e57be36..a4a41c6f1e83853fd6186848bf0451e9acdbee38 100644 (file)
@@ -14,7 +14,7 @@
 #define TOC_WIDGET_H
 
 #include "GuiDialog.h"
-#include "ControlToc.h"
+#include "GuiToc.h"
 #include "ui_TocUi.h"