Fixing consistency of replace actions in GUI with readonly status of target document buffer

(i.e., it was possible to replace in readonly buffers!)
See also http://comments.gmane.org/gmane.editors.lyx.devel/140074


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40548 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Tommaso Cucinotta 2011-12-30 15:31:56 +00:00
parent 26d7886cef
commit 7422c56d67
2 changed files with 13 additions and 1 deletions

View File

@ -1059,7 +1059,6 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
case LFUN_WORD_FIND:
case LFUN_WORD_FIND_FORWARD:
case LFUN_WORD_FIND_BACKWARD:
case LFUN_WORD_FINDADV:
case LFUN_WORD_REPLACE:
case LFUN_MARK_OFF:
case LFUN_MARK_ON:
@ -1077,6 +1076,14 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
flag.setEnabled(true);
break;
case LFUN_WORD_FINDADV: {
FindAndReplaceOptions opt;
istringstream iss(to_utf8(cmd.argument()));
iss >> opt;
flag.setEnabled(opt.repl_buf_name.empty()
|| !buffer_.isReadonly());
}
case LFUN_LABEL_GOTO: {
flag.setEnabled(!cmd.argument().empty()
|| getInsetByCode<InsetRef>(cur, REF_CODE));

View File

@ -67,6 +67,11 @@ FindAndReplaceWidget::FindAndReplaceWidget(GuiView & view)
bool FindAndReplaceWidget::eventFilter(QObject * obj, QEvent * event)
{
bool replace_enabled = view_.documentBufferView() && !view_.documentBufferView()->buffer().isReadonly();
replace_work_area_->setEnabled(replace_enabled);
replacePB->setEnabled(replace_enabled);
replaceallPB->setEnabled(replace_enabled);
if (event->type() != QEvent::KeyPress
|| (obj != find_work_area_ && obj != replace_work_area_))
return QWidget::eventFilter(obj, event);