Fix issues with xref dialog in read-only documents (#8177)

This commit is contained in:
Juergen Spitzmueller 2012-09-29 16:12:31 +02:00
parent 0b2c308a68
commit c9f9107a7f
2 changed files with 20 additions and 22 deletions

View File

@ -48,14 +48,6 @@ GuiRef::GuiRef(GuiView & lv)
at_ref_ = false; at_ref_ = false;
// Enabling is set in updateRefs. Disable for now in case no
// call to updateContents follows (e.g. read-only documents).
sortCB->setEnabled(false);
caseSensitiveCB->setEnabled(false);
caseSensitiveCB->setChecked(false);
refsTW->setEnabled(false);
gotoPB->setEnabled(false);
refsTW->setColumnCount(1); refsTW->setColumnCount(1);
refsTW->header()->setVisible(false); refsTW->header()->setVisible(false);
@ -98,19 +90,22 @@ GuiRef::GuiRef(GuiView & lv)
bc().setOK(okPB); bc().setOK(okPB);
bc().setApply(applyPB); bc().setApply(applyPB);
bc().setCancel(closePB); bc().setCancel(closePB);
bc().addReadOnly(refsTW);
bc().addReadOnly(sortCB);
bc().addReadOnly(caseSensitiveCB);
bc().addReadOnly(nameED);
bc().addReadOnly(referenceED);
bc().addReadOnly(typeCO); bc().addReadOnly(typeCO);
bc().addReadOnly(bufferCO);
restored_buffer_ = -1; restored_buffer_ = -1;
active_buffer_ = -1; active_buffer_ = -1;
} }
void GuiRef::enableView(bool enable)
{
if (!enable)
// In the opposite case, updateContents() will be called anyway.
updateContents();
GuiDialog::enableView(enable);
}
void GuiRef::changed_adaptor() void GuiRef::changed_adaptor()
{ {
changed(); changed();
@ -139,9 +134,6 @@ void GuiRef::selectionChanged()
void GuiRef::refHighlighted(QTreeWidgetItem * sel) void GuiRef::refHighlighted(QTreeWidgetItem * sel)
{ {
if (isBufferReadonly())
return;
if (sel->childCount() > 0) { if (sel->childCount() > 0) {
sel->setExpanded(true); sel->setExpanded(true);
return; return;
@ -158,7 +150,7 @@ void GuiRef::refHighlighted(QTreeWidgetItem * sel)
if (at_ref_) if (at_ref_)
gotoRef(); gotoRef();
gotoPB->setEnabled(true); gotoPB->setEnabled(true);
if (typeAllowed()) if (typeAllowed() && !isBufferReadonly())
typeCO->setEnabled(true); typeCO->setEnabled(true);
nameED->setHidden(!nameAllowed()); nameED->setHidden(!nameAllowed());
nameL->setHidden(!nameAllowed()); nameL->setHidden(!nameAllowed());
@ -235,11 +227,13 @@ void GuiRef::updateContents()
{ {
int orig_type = typeCO->currentIndex(); int orig_type = typeCO->currentIndex();
referenceED->setText(toqstr(params_["reference"])); referenceED->clear();
nameED->clear();
referenceED->setText(toqstr(params_["reference"]));
nameED->setText(toqstr(params_["name"])); nameED->setText(toqstr(params_["name"]));
nameED->setHidden(!nameAllowed() && !isBufferReadonly()); nameED->setHidden(!nameAllowed());
nameL->setHidden(!nameAllowed() && !isBufferReadonly()); nameL->setHidden(!nameAllowed());
// restore type settings for new insets // restore type settings for new insets
if (params_["reference"].empty()) if (params_["reference"].empty())

View File

@ -30,6 +30,10 @@ class GuiRef : public GuiDialog, public Ui::RefUi
public: public:
GuiRef(GuiView & lv); GuiRef(GuiView & lv);
/// Dialog inherited methods
//@{
void enableView(bool enable);
//@}
private Q_SLOTS: private Q_SLOTS:
void changed_adaptor(); void changed_adaptor();