]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/FindAndReplace.cpp
Amend f441590c
[lyx.git] / src / frontends / qt4 / FindAndReplace.cpp
index 892ca716c830ccf7edddb3ae83060b5d055e2a4b..f40666c39bfa34143babfbe8b06166a4ecb44a0b 100644 (file)
@@ -71,13 +71,13 @@ FindAndReplaceWidget::FindAndReplaceWidget(GuiView & view)
 
 void FindAndReplaceWidget::dockLocationChanged(Qt::DockWidgetArea area)
 {
-       if (area == Qt::RightDockWidgetArea || area == Qt::LeftDockWidgetArea) {
-               dynamicLayoutBasic_->setDirection(QBoxLayout::TopToBottom);
-               dynamicLayoutAdvanced_->setDirection(QBoxLayout::TopToBottom);
-       } else {
-               dynamicLayoutBasic_->setDirection(QBoxLayout::LeftToRight);
-               dynamicLayoutAdvanced_->setDirection(QBoxLayout::LeftToRight);
-       }
+       if (area == Qt::RightDockWidgetArea || area == Qt::LeftDockWidgetArea) {
+               dynamicLayoutBasic_->setDirection(QBoxLayout::TopToBottom);
+               dynamicLayoutAdvanced_->setDirection(QBoxLayout::TopToBottom);
+       } else {
+               dynamicLayoutBasic_->setDirection(QBoxLayout::LeftToRight);
+               dynamicLayoutAdvanced_->setDirection(QBoxLayout::LeftToRight);
+       }
 }
 
 
@@ -144,7 +144,7 @@ bool FindAndReplaceWidget::eventFilter(QObject * obj, QEvent * event)
 }
 
 
-static vector<string> const & allManualsFiles() 
+static vector<string> const & allManualsFiles()
 {
        static const char * files[] = {
                "Intro", "UserGuide", "Tutorial", "Additional",
@@ -169,7 +169,7 @@ static vector<string> const & allManualsFiles()
  **
  ** Return true if restarted from master-document buffer.
  **/
-static bool nextDocumentBuffer(Buffer * & buf) 
+static bool nextDocumentBuffer(Buffer * & buf)
 {
        ListOfBuffers const children = buf->allRelatives();
        LYXERR(Debug::FIND, "children.size()=" << children.size());
@@ -190,7 +190,7 @@ static bool nextDocumentBuffer(Buffer * & buf)
  **
  ** Return true if restarted from last child buffer.
  **/
-static bool prevDocumentBuffer(Buffer * & buf) 
+static bool prevDocumentBuffer(Buffer * & buf)
 {
        ListOfBuffers const children = buf->allRelatives();
        LYXERR(Debug::FIND, "children.size()=" << children.size());
@@ -289,7 +289,7 @@ docstring getQuestionString(FindAndReplaceOptions const & opt)
        docstring message = opt.forward ?
                bformat(_("%1$s: the end was reached while searching forward.\n"
                          "Continue searching from the beginning?"),
-                       scope) : 
+                       scope) :
                bformat(_("%1$s: the beginning was reached while searching backward.\n"
                          "Continue searching from the end?"),
                        scope);
@@ -340,6 +340,8 @@ bool FindAndReplaceWidget::findAndReplaceScope(FindAndReplaceOptions & opt, bool
                }
        }
 
+       UndoGroupHelper helper(buf);
+
        do {
                LYXERR(Debug::FIND, "Dispatching LFUN_WORD_FINDADV");
                dispatch(cmd);
@@ -384,6 +386,9 @@ bool FindAndReplaceWidget::findAndReplaceScope(FindAndReplaceOptions & opt, bool
                if (buf != &view_.documentBufferView()->buffer())
                        lyx::dispatch(FuncRequest(LFUN_BUFFER_SWITCH,
                                                  buf->absFileName()));
+
+               helper.resetBuffer(buf);
+
                bv = view_.documentBufferView();
                if (opt.forward) {
                        bv->cursor().clear();
@@ -397,6 +402,7 @@ bool FindAndReplaceWidget::findAndReplaceScope(FindAndReplaceOptions & opt, bool
                }
                bv->clearSelection();
        } while (wrap_answer != 1);
+
        if (buf_orig != &view_.documentBufferView()->buffer())
                lyx::dispatch(FuncRequest(LFUN_BUFFER_SWITCH,
                                          buf_orig->absFileName()));
@@ -498,7 +504,7 @@ void FindAndReplaceWidget::hideDialog()
 }
 
 
-void FindAndReplaceWidget::on_findNextPB_clicked() 
+void FindAndReplaceWidget::on_findNextPB_clicked()
 {
        findAndReplace(searchbackCB->isChecked(), false);
        find_work_area_->setFocus();
@@ -583,7 +589,7 @@ FindAndReplace::FindAndReplace(GuiView & parent,
        setFocusProxy(widget_);
 
        connect(this, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)),
-               widget_, SLOT(dockLocationChanged(Qt::DockWidgetArea)));
+               widget_, SLOT(dockLocationChanged(Qt::DockWidgetArea)));
 }