]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiSearch.cpp
Use <cstdint> instead of <boost/cstdint.hpp>
[lyx.git] / src / frontends / qt4 / GuiSearch.cpp
index e83cf00e4e1faffb055ab7c3cb074975acb5b9b4..4e0c354fc60efe4164691e3f3a9f36807e47c857 100644 (file)
@@ -47,7 +47,14 @@ GuiSearch::GuiSearch(GuiView & lv)
 {
        setupUi(this);
 
-       connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
+       // fix height to minimum
+       setFixedHeight(sizeHint().height());
+
+       // align items in grid on top
+       mainGridLayout->setAlignment(Qt::AlignTop);
+
+       connect(buttonBox, SIGNAL(clicked(QAbstractButton *)),
+               this, SLOT(slotButtonBox(QAbstractButton *)));
        connect(findPB, SIGNAL(clicked()), this, SLOT(findClicked()));
        connect(replacePB, SIGNAL(clicked()), this, SLOT(replaceClicked()));
        connect(replaceallPB, SIGNAL(clicked()), this, SLOT(replaceallClicked()));
@@ -57,7 +64,7 @@ GuiSearch::GuiSearch(GuiView & lv)
        setFocusProxy(findCO);
 
        bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
-       bc().setCancel(closePB);
+       bc().setCancel(buttonBox->button(QDialogButtonBox::Close));
        bc().addReadOnly(replaceCO);
        bc().addReadOnly(replacePB);
        bc().addReadOnly(replaceallPB);
@@ -120,49 +127,12 @@ void GuiSearch::replaceallClicked()
 }
 
 
-void GuiSearch::wrap_dispatch(const FuncRequest & func, bool forward) {
-       dispatch(func);
-
-       BufferView * bv = const_cast<BufferView *>(bufferview());
-       GuiView & lv = *const_cast<GuiView *>(&lyxview());
-
-       DocIterator cur_orig(bv->cursor());
-
-       if (!bv->cursor().result().dispatched()) {
-               docstring q;
-               if (forward)
-                       q = _("End of file reached while searching forward.\n"
-                         "Continue searching from the beginning?");
-               else
-                       q = _("Beginning of file reached while searching backward.\n"
-                         "Continue searching from the end?");
-               int wrap_answer = frontend::Alert::prompt(_("Wrap search?"),
-                       q, 0, 1, _("&Yes"), _("&No"));
-               if (wrap_answer == 0) {
-                       if (forward) {
-                               bv->cursor().clear();
-                               bv->cursor().push_back(CursorSlice(bv->buffer().inset()));
-                       } else {
-                               bv->cursor().setCursor(doc_iterator_end(&bv->buffer()));
-                               bv->cursor().backwardPos();
-                       }
-                       bv->clearSelection();
-                       dispatch(func);
-                       if (bv->cursor().result().dispatched())
-                               return;
-               }
-               bv->cursor().setCursor(cur_orig);
-               lv.message(_("String not found."));
-       }
-}
-
-
 void GuiSearch::find(docstring const & search, bool casesensitive,
                         bool matchword, bool forward)
 {
-       docstring const data =
+       docstring const sdata =
                find2string(search, casesensitive, matchword, forward);
-       wrap_dispatch(FuncRequest(LFUN_WORD_FIND, data), forward);
+       dispatch(FuncRequest(LFUN_WORD_FIND, sdata));
 }
 
 
@@ -170,10 +140,10 @@ void GuiSearch::replace(docstring const & search, docstring const & replace,
                            bool casesensitive, bool matchword,
                            bool forward, bool all)
 {
-       docstring const data =
+       docstring const sdata =
                replace2string(replace, search, casesensitive,
                                     matchword, all, forward);
-       wrap_dispatch(FuncRequest(LFUN_WORD_REPLACE, data), forward);
+       dispatch(FuncRequest(LFUN_WORD_REPLACE, sdata));
 }