On 12/02/2011 03:39 PM, Edwin Leuven wrote: > hi, > > atm our (quick) search shows an empy dialog (or the text from a > previous search) when hitting ctrl+F > > it is standard behavior to put selected text (if any) in the search dialog > > the attached patch does this > > comments/suggestions? > > ed. > From 230e650fd56069e1d5f00083ecd570982db6c744 Mon Sep 17 00:00:00 2001 > From: Edwin Leuven <e.leu...@gmail.com> > Date: Fri, 2 Dec 2011 21:26:42 +0100 > Subject: [PATCH] push selected text to search dialog > > --- > src/frontends/qt4/GuiSearch.cpp | 11 ++++++++++- > src/frontends/qt4/GuiSearch.h | 3 +++ > 2 files changed, 13 insertions(+), 1 deletions(-) > > diff --git a/src/frontends/qt4/GuiSearch.cpp b/src/frontends/qt4/GuiSearch.cpp > index a8f10e7..7fac107 100644 > --- a/src/frontends/qt4/GuiSearch.cpp > +++ b/src/frontends/qt4/GuiSearch.cpp > @@ -13,9 +13,12 @@ > #include <config.h> > > #include "GuiSearch.h" > +#include "GuiView.h" > > #include "qt_helpers.h" > > +#include "BufferView.h" > +#include "Cursor.h" > #include "FuncRequest.h" > #include "lyxfind.h" > > @@ -38,7 +41,7 @@ static void uniqueInsert(QComboBox * box, QString const & > text) > > > GuiSearch::GuiSearch(GuiView & lv) > - : GuiDialog(lv, "findreplace", qt_("Find and Replace")) > + : GuiDialog(lv, "findreplace", qt_("Find and Replace")), view_(&lv) > { > setupUi(this); > > @@ -64,6 +67,12 @@ GuiSearch::GuiSearch(GuiView & lv) > > void GuiSearch::showEvent(QShowEvent * e) > { > + BufferView const * bv = view_->currentBufferView(); > + QString const txt = toqstr(bv->cursor().selectionAsString(false)); > Probably just paranoid, as I doubt we can get here without a currentBufferView(). But is it worth making sure we have one?
Otherwise looks fine to me. Richard > + if (!txt.isEmpty()) { > + uniqueInsert(findCO, txt); > + findCO->setCurrentIndex(0); > + } > findPB->setFocus(); > findCO->lineEdit()->selectAll(); > GuiDialog::showEvent(e); > diff --git a/src/frontends/qt4/GuiSearch.h b/src/frontends/qt4/GuiSearch.h > index b565553..bfdda4b 100644 > --- a/src/frontends/qt4/GuiSearch.h > +++ b/src/frontends/qt4/GuiSearch.h > @@ -48,6 +48,9 @@ private: > void replace(docstring const & search, docstring const & replace, > bool casesensitive, bool matchword, > bool forward, bool all); > + > + /// owning view > + GuiView * view_; > }; > > } // namespace frontend > -- 1.7.7.1.msysgit.0