From c71c23dd78c240cbae8d7099c400db865daaf148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Thu, 19 Feb 2004 09:07:43 +0000 Subject: [PATCH] Real fix for bug 1511 and bug 1512 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8445 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt2/ChangeLog | 5 +++++ src/frontends/qt2/QRef.C | 41 +++++++++++++++++++++++++++---------- src/frontends/qt2/QRef.h | 3 +++ 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 77f6d849a4..1a02268438 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,8 @@ +2004-02-19 Jürgen Spitzmüller + + * QRef.[Ch]: Real fix for bug 1511 (restore latest settings); + fix for bug 1512 (restore ref format settings). + 2004-02-18 Jürgen Spitzmüller * QCitation.[Ch]: diff --git a/src/frontends/qt2/QRef.C b/src/frontends/qt2/QRef.C index 695c439e75..5b6c0ff117 100644 --- a/src/frontends/qt2/QRef.C +++ b/src/frontends/qt2/QRef.C @@ -4,6 +4,7 @@ * Licence details can be found in the file COPYING. * * \author John Levon + * \author Jürgen Spitzmüller * * Full author contact details are available in file CREDITS. */ @@ -54,26 +55,33 @@ void QRef::build_dialog() bcview().addReadOnly(dialog_->referenceED); bcview().addReadOnly(dialog_->typeCO); bcview().addReadOnly(dialog_->bufferCO); + + restored_buffer_ = -1; } void QRef::update_contents() { InsetCommandParams const & params = controller().params(); - + + int orig_type = dialog_->typeCO->currentItem(); + dialog_->referenceED->setText(toqstr(params.getContents())); dialog_->nameED->setText(toqstr(params.getOptions())); dialog_->nameED->setReadOnly(!nameAllowed() && !readOnly()); - - dialog_->typeCO->setCurrentItem(InsetRef::getType(params.getCmdName())); + + // restore type settings for new insets + if (params.getContents().empty()) + dialog_->typeCO->setCurrentItem(orig_type); + else + dialog_->typeCO->setCurrentItem(InsetRef::getType(params.getCmdName())); dialog_->typeCO->setEnabled(typeAllowed() && !readOnly()); if (!typeAllowed()) dialog_->typeCO->setCurrentItem(0); dialog_->sortCB->setChecked(sort_); - int const orig = dialog_->bufferCO->currentItem(); // insert buffer list dialog_->bufferCO->clear(); vector const buffers = controller().getBufferList(); @@ -81,8 +89,10 @@ void QRef::update_contents() it != buffers.end(); ++it) { dialog_->bufferCO->insertItem(toqstr(*it)); } - if (orig != -1 && orig < dialog_->bufferCO->count()) - dialog_->bufferCO->setCurrentItem(orig); + // restore the buffer combo setting for new insets + if (params.getContents().empty() && restored_buffer_ != -1 + && restored_buffer_ < dialog_->bufferCO->count()) + dialog_->bufferCO->setCurrentItem(restored_buffer_); else dialog_->bufferCO->setCurrentItem(controller().getBufferNum()); @@ -97,6 +107,8 @@ void QRef::apply() params.setCmdName(InsetRef::getName(dialog_->typeCO->currentItem())); params.setContents(fromqstr(dialog_->referenceED->text())); params.setOptions(fromqstr(dialog_->nameED->text())); + + restored_buffer_ = dialog_->bufferCO->currentItem(); } @@ -151,6 +163,8 @@ void QRef::gotoRef() void QRef::redoRefs() { + int lastref = dialog_->refsLB->currentItem(); + dialog_->refsLB->setAutoUpdate(false); dialog_->refsLB->clear(); @@ -167,11 +181,16 @@ void QRef::redoRefs() dialog_->refsLB->sort(); dialog_->referenceED->setText(tmp); - - for (unsigned int i = 0; i < dialog_->refsLB->count(); ++i) { - if (tmp == dialog_->refsLB->text(i)) - dialog_->refsLB->setCurrentItem(i); - } + + // restore the last selection for new insets + if (tmp.isEmpty() && lastref != -1 + && lastref < dialog_->refsLB->count()) + dialog_->refsLB->setCurrentItem(lastref); + else + for (unsigned int i = 0; i < dialog_->refsLB->count(); ++i) { + if (tmp == dialog_->refsLB->text(i)) + dialog_->refsLB->setCurrentItem(i); + } dialog_->refsLB->setAutoUpdate(true); dialog_->refsLB->update(); diff --git a/src/frontends/qt2/QRef.h b/src/frontends/qt2/QRef.h index ed53f9d15c..ac77af1835 100644 --- a/src/frontends/qt2/QRef.h +++ b/src/frontends/qt2/QRef.h @@ -62,6 +62,9 @@ private: /// at a reference ? bool at_ref_; + + /// store the buffer settings + int restored_buffer_; /// the references std::vector refs_;