From 869f6d33c650c85b68dd864c22070299beb54c58 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Wed, 24 Mar 2010 15:49:06 +0000 Subject: [PATCH] Revert r33852 and try something else. The problem here, which can be seen in branch, too, is that if you change the style combo and then do anything else, such as click on an entry, the combo reverts. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33858 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiCitation.cpp | 35 +++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/frontends/qt4/GuiCitation.cpp b/src/frontends/qt4/GuiCitation.cpp index f56045fb69..4bab50a204 100644 --- a/src/frontends/qt4/GuiCitation.cpp +++ b/src/frontends/qt4/GuiCitation.cpp @@ -193,7 +193,8 @@ void GuiCitation::updateControls() // such as when addPB is pressed, as the list of fields, entries, etc, // will not have changed. At the moment, however, the division between // fillStyles() and updateStyle() doesn't lend itself to dividing the -// two methods, though they should be divisible. +// two methods, though they should be divisible. That is, we should +// not have to call fillStyles() every time through here. void GuiCitation::updateControls(BiblioInfo const & bi) { QModelIndex idx = selectionManager->getSelectedIndex(); @@ -249,11 +250,16 @@ void GuiCitation::updateStyle() std::find(styles.begin(), styles.end(), cs.style); if (cit != styles.end()) { - int const i = int(cit - styles.begin()); - citationStyleCO->setCurrentIndex(i); fulllistCB->setChecked(cs.full); forceuppercaseCB->setChecked(cs.forceUpperCase); } else { + // restore the last used natbib style + if (style_ >= 0 && style_ < citationStyleCO->count()) { + // the necessary update will be performed later + citationStyleCO->blockSignals(true); + citationStyleCO->setCurrentIndex(style_); + citationStyleCO->blockSignals(false); + } fulllistCB->setChecked(false); forceuppercaseCB->setChecked(false); } @@ -302,9 +308,6 @@ void GuiCitation::fillStyles(BiblioInfo const & bi) citationStyleCO->setCurrentIndex(oldIndex); citationStyleCO->blockSignals(false); - - // simulate a change of index to trigger updateFormatting(). - on_citationStyleCO_currentIndexChanged(citationStyleCO->currentIndex()); } @@ -528,16 +531,26 @@ void GuiCitation::init() selectedLV->selectionModel()->select(idx, QItemSelectionModel::ClearAndSelect); selectedLV->blockSignals(false); + + // set the style combo appropriately + string const & command = params_.getCmdName(); + vector const & styles = citeStyles_; + CitationStyle const cs = citationStyleFromString(command); + + vector::const_iterator cit = + std::find(styles.begin(), styles.end(), cs.style); + if (cit != styles.end()) { + int const i = int(cit - styles.begin()); + // the necessary update will be performed later + citationStyleCO->blockSignals(true); + citationStyleCO->setCurrentIndex(i); + citationStyleCO->blockSignals(false); + } } else availableLV->setFocus(); fillFields(bi); fillEntries(bi); updateControls(bi); - // restore the last used natbib style - if (style_ >= 0 && style_ < citationStyleCO->count()) - citationStyleCO->setCurrentIndex(style_); - else - citationStyleCO->setCurrentIndex(0); } -- 2.39.2