Update the Advanced F&R document class when switching buffers.

This commit is contained in:
Richard Kimberly Heck 2018-05-04 13:05:36 -04:00
parent 5064c09e9f
commit 944b0ae55d
2 changed files with 15 additions and 2 deletions

View File

@ -67,6 +67,8 @@ FindAndReplaceWidget::FindAndReplaceWidget(GuiView & view)
// We don't want two cursors blinking.
find_work_area_->stopBlinkingCaret();
replace_work_area_->stopBlinkingCaret();
old_buffer_ = view_.documentBufferView() ?
&(view_.documentBufferView()->buffer()) : 0;
}
@ -605,8 +607,17 @@ bool FindAndReplace::initialiseParams(std::string const & params)
void FindAndReplaceWidget::updateGUI()
{
bool replace_enabled = view_.documentBufferView()
&& !view_.documentBufferView()->buffer().isReadonly();
BufferView * bv = view_.documentBufferView();
if (bv) {
if (old_buffer_ != &bv->buffer()) {
copy_params(*bv, find_work_area_->bufferView());
copy_params(*bv, replace_work_area_->bufferView());
old_buffer_ = &bv->buffer();
}
} else
old_buffer_ = 0;
bool const replace_enabled = bv && !bv->buffer().isReadonly();
replace_work_area_->setEnabled(replace_enabled);
replacePB->setEnabled(replace_enabled);
replaceallPB->setEnabled(replace_enabled);

View File

@ -40,6 +40,8 @@ public Q_SLOTS:
private:
///
GuiView & view_;
///
Buffer * old_buffer_;
/// add a string to the combo if needed
void remember(std::string const & find, QComboBox & combo);