3 * Copyright 2001 The LyX Team.
4 * See the file COPYING.
12 #include "QSearchDialog.h"
16 #include "QtLyXView.h"
19 #include "support/lstrings.h"
20 #include "BufferView.h"
22 using Liason::setMinibuffer;
24 QSearch::QSearch(LyXView *v, Dialogs *d)
25 : dialog_(0), lv_(v), d_(d), h_(0), u_(0)
27 d->showSearch.connect(SigC::slot(this, &QSearch::show));
28 // perhaps in the future we'd like a
29 // "search again" button/keybinding
30 // d->searchAgain.connect(slot(this, &QSearch::FindNext));
43 dialog_ = new QSearchDialog(this, 0, _("Find and Replace"), false);
46 if (!dialog_->isVisible()) {
47 h_ = d_->hideBufferDependent.connect(SigC::slot(this, &QSearch::hide));
48 u_ = d_->updateBufferDependent.connect(SigC::slot(this, &QSearch::update));
52 dialog_->setActiveWindow();
58 void QSearch::find(string const & searchstr, bool const & casesensitive,
59 bool const & matchword, bool const & searchback)
61 bool const found = LyXFind(lv_->view(), searchstr, searchback,
62 casesensitive, matchword);
65 setMinibuffer(lv_, _("String not found!"));
69 void QSearch::replace(string const & searchstr, string const & replacestr,
70 bool const & casesensitive, bool const & matchword,
71 bool const & searchback, bool const & replaceall)
73 int replace_count = LyXReplace(lv_->view(), searchstr, replacestr,
74 searchback, casesensitive, matchword,
77 if (replace_count == 0) {
78 setMinibuffer(lv_, _("String not found!"));
80 if (replace_count == 1) {
81 setMinibuffer(lv_, _("String has been replaced."));
83 string str = tostr(replace_count);
84 str += _(" strings have been replaced.");
85 setMinibuffer(lv_, str.c_str());
105 void QSearch::update(bool)
107 if (!lv_->view()->available())
110 dialog_->setReadOnly(lv_->buffer()->isReadonly());