3 * Copyright 2001 The LyX Team.
4 * See the file COPYING.
12 #include "searchdlgimpl.h"
13 #include "FormSearch.h"
16 #include "QtLyXView.h"
18 //#include "lyxtext.h"
20 //#include "language.h"
21 #include "support/lstrings.h"
23 using Liason::setMinibuffer;
25 FormSearch::FormSearch(LyXView *v, Dialogs *d)
26 : dialog_(0), lv_(v), d_(d), h_(0), u_(0)
28 // let the dialog be shown
29 // This is a permanent connection so we won't bother
30 // storing a copy because we won't be disconnecting.
31 d->showSearch.connect(SigC::slot(this, &FormSearch::show));
32 // perhaps in the future we'd like a
33 // "search again" button/keybinding
34 // d->searchAgain.connect(slot(this, &FormSearch::FindNext));
38 FormSearch::~FormSearch()
43 void FormSearch::show()
46 dialog_ = new SearchDlgImpl(this, 0, _("Find and Replace"), false);
49 if (!dialog_->isVisible()) {
50 h_ = d_->hideBufferDependent.connect(SigC::slot(this, &FormSearch::hide));
51 u_ = d_->updateBufferDependent.connect(SigC::slot(this, &FormSearch::update));
55 dialog_->setActiveWindow();
60 void FormSearch::find(string const & searchstr, bool const & casesensitive,
61 bool const & matchword, bool const & searchback)
63 bool found = LyXFind(lv_->view(), searchstr, casesensitive, matchword,
67 setMinibuffer(lv_, _("String not found!"));
70 void FormSearch::replace(string const & searchstr, string const & replacestr,
71 bool const & casesensitive, bool const & matchword,
72 bool const & searchback, bool const & replaceall)
74 int replace_count = LyXReplace(lv_->view(), searchstr, replacestr,
75 casesensitive, matchword, searchback,
78 if (replace_count == 0) {
79 setMinibuffer(lv_, _("String not found!"));
81 if (replace_count == 1) {
82 setMinibuffer(lv_, _("String has been replaced."));
84 string str = tostr(replace_count);
85 str += _(" strings have been replaced.");
86 setMinibuffer(lv_, str.c_str());
92 void FormSearch::close()
98 void FormSearch::hide()
104 void FormSearch::update(bool)
106 if (!lv_->view()->available())
109 dialog_->setReadOnly(lv_->buffer()->isReadonly());