From 8770174a52a655dc0028282d826b21676598359a Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Wed, 18 Feb 2004 14:02:49 +0000 Subject: [PATCH] various qt fixes (bug 1146, bug 1037, bug 1511) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8440 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt2/ChangeLog | 11 +++++++++++ src/frontends/qt2/QCitation.C | 19 +++++++++++++++++-- src/frontends/qt2/QCitation.h | 4 ++++ src/frontends/qt2/QCitationDialog.C | 18 ++++++++++++++++++ src/frontends/qt2/QCitationDialog.h | 2 ++ src/frontends/qt2/QRef.C | 7 ++++++- 6 files changed, 58 insertions(+), 3 deletions(-) diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index bffc44e6c6..77f6d849a4 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,14 @@ +2004-02-18 Jürgen Spitzmüller + + * QCitation.[Ch]: + * QCitationDialog.[Ch]: open the find dialog if an inset is + new (new method openFind()). Fixes bug 1146. + + * QCitation.C: restore the chosen natbib style. + + * QRef.C: Disable goto button if there is no ref (bug 1037) + Restore setting of the buffer combo (bug 1511) + 2004-02-01 Lars Gullik Bjonnes * floatplacement.C (set): "c" -> 'c' in calls to contains diff --git a/src/frontends/qt2/QCitation.C b/src/frontends/qt2/QCitation.C index 010bbedfaa..83e8632511 100644 --- a/src/frontends/qt2/QCitation.C +++ b/src/frontends/qt2/QCitation.C @@ -62,6 +62,9 @@ void QCitation::apply() string const after = fromqstr(dialog_->textAfterED->text()); controller().params().setOptions(after); + + style_ = choice; + open_find_ = false; } @@ -69,6 +72,7 @@ void QCitation::hide() { citekeys.clear(); bibkeys.clear(); + open_find_ = true; QDialogView::hide(); } @@ -94,6 +98,8 @@ void QCitation::build_dialog() // add when enabled ! //bcview().addReadOnly(dialog_->textBeforeED); bcview().addReadOnly(dialog_->textAfterED); + + open_find_ = true; } @@ -147,8 +153,12 @@ void QCitation::updateStyle() vector::const_iterator cit = find(styles.begin(), styles.end(), cs.style); - - dialog_->citationStyleCO->setCurrentItem(0); + + // restore the latest natbib style + if (style_ >= 0 && style_ < dialog_->citationStyleCO->count()) + dialog_->citationStyleCO->setCurrentItem(style_); + else + dialog_->citationStyleCO->setCurrentItem(0); dialog_->fulllistCB->setChecked(false); dialog_->forceuppercaseCB->setChecked(false); @@ -179,6 +189,11 @@ void QCitation::update_contents() fillStyles(); updateStyle(); + + // open the find dialog if nothing has been selected (yet) + // the bool prevents that this is also done after "apply" + if (open_find_) + dialog_->openFind(); } diff --git a/src/frontends/qt2/QCitation.h b/src/frontends/qt2/QCitation.h index 742f008c0e..446e7b2e65 100644 --- a/src/frontends/qt2/QCitation.h +++ b/src/frontends/qt2/QCitation.h @@ -47,11 +47,15 @@ private: void updateStyle(); void updateBrowser(QListBox *, std::vector const &) const; + /// check if apply has been pressed + bool open_find_; /// selected keys std::vector citekeys; /// available bib keys std::vector bibkeys; + /// selected natbib style + int style_; }; #endif // QCITATION_H diff --git a/src/frontends/qt2/QCitationDialog.C b/src/frontends/qt2/QCitationDialog.C index d5be3d1b1c..09715ca59f 100644 --- a/src/frontends/qt2/QCitationDialog.C +++ b/src/frontends/qt2/QCitationDialog.C @@ -4,6 +4,8 @@ * Licence details can be found in the file COPYING. * * \author Kalle Dalheimer + * \author John Levon + * \author Jürgen Spitzmüller * * Full author contact details are available in file CREDITS. */ @@ -12,6 +14,7 @@ #include "qt_helpers.h" #include "controllers/ControlCitation.h" +#include "ButtonController.h" #include #include @@ -71,6 +74,21 @@ void QCitationDialog::setButtons() } +void QCitationDialog::openFind() +{ + if (form_->readOnly()) + return; + + if (selectedLB->count() == 0 && add_->availableLB->count() != 0){ + // open the find dialog + add(); + // and let the user press ok after a selection + if (selectedLB->count() != 0) + form_->bc().valid(); + } +} + + void QCitationDialog::selectedChanged() { form_->fillStyles(); diff --git a/src/frontends/qt2/QCitationDialog.h b/src/frontends/qt2/QCitationDialog.h index a0131c64aa..7f987b0af4 100644 --- a/src/frontends/qt2/QCitationDialog.h +++ b/src/frontends/qt2/QCitationDialog.h @@ -28,6 +28,8 @@ public: ~QCitationDialog(); void setButtons(); + /// open the find dialog if nothing selected + void openFind(); QCitationFindDialogBase * add_; diff --git a/src/frontends/qt2/QRef.C b/src/frontends/qt2/QRef.C index 8ae515995a..695c439e75 100644 --- a/src/frontends/qt2/QRef.C +++ b/src/frontends/qt2/QRef.C @@ -73,6 +73,7 @@ void QRef::update_contents() dialog_->sortCB->setChecked(sort_); + int const orig = dialog_->bufferCO->currentItem(); // insert buffer list dialog_->bufferCO->clear(); vector const buffers = controller().getBufferList(); @@ -80,7 +81,10 @@ void QRef::update_contents() it != buffers.end(); ++it) { dialog_->bufferCO->insertItem(toqstr(*it)); } - dialog_->bufferCO->setCurrentItem(controller().getBufferNum()); + if (orig != -1 && orig < dialog_->bufferCO->count()) + dialog_->bufferCO->setCurrentItem(orig); + else + dialog_->bufferCO->setCurrentItem(controller().getBufferNum()); updateRefs(); } @@ -183,5 +187,6 @@ void QRef::updateRefs() refs_ = controller().getLabelList(name); dialog_->sortCB->setEnabled(!refs_.empty()); dialog_->refsLB->setEnabled(!refs_.empty()); + dialog_->gotoPB->setEnabled(!refs_.empty()); redoRefs(); } -- 2.39.2