X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt2%2FQCitationDialog.C;h=70a245e6de9cc72deb3a96e3ccab6659062e828d;hb=414a11684e77aee713135ae65ec7438cfc4b162f;hp=020a50e85d7c70a898d90f5391fb4b1d3fe8e64e;hpb=68b7ef25fb7d2da230d3eb11d6737701abfc2e64;p=lyx.git diff --git a/src/frontends/qt2/QCitationDialog.C b/src/frontends/qt2/QCitationDialog.C index 020a50e85d..70a245e6de 100644 --- a/src/frontends/qt2/QCitationDialog.C +++ b/src/frontends/qt2/QCitationDialog.C @@ -12,9 +12,13 @@ #include +#include "QCitationDialog.h" +#include "ui/QCitationFindDialogBase.h" +#include "QCitation.h" #include "qt_helpers.h" + #include "controllers/ControlCitation.h" -#include "ButtonController.h" +#include "controllers/ButtonController.h" #include #include @@ -22,13 +26,13 @@ #include #include -#include "ui/QCitationFindDialogBase.h" -#include "QCitationDialog.h" -#include "QCitation.h" using std::vector; using std::string; +using std::swap; +namespace lyx { +namespace frontend { QCitationDialog::QCitationDialog(QCitation * form) : QCitationDialogBase(0, 0, false, 0), @@ -79,7 +83,8 @@ void QCitationDialog::openFind() if (form_->readOnly()) return; - if (selectedLB->count() == 0 && add_->availableLB->count() != 0){ + if (isVisible() && selectedLB->count() == 0 + && add_->availableLB->count() != 0){ // open the find dialog add(); // and let the user press ok after a selection @@ -184,16 +189,16 @@ void QCitationDialog::up() { int const sel = selectedLB->currentItem(); + BOOST_ASSERT(sel > 0); + // Move the selected key up one line - vector::iterator it = form_->citekeys.begin() + sel; - string const tmp = *it; + string const tmp = form_->citekeys[sel]; selectedLB->removeItem(sel); - form_->citekeys.erase(it); + swap(form_->citekeys[sel - 1], form_->citekeys[sel]); selectedLB->insertItem(toqstr(tmp), sel - 1); selectedLB->setSelected(sel - 1, true); - form_->citekeys.insert(it - 1, tmp); form_->changed(); form_->fillStyles(); @@ -205,16 +210,16 @@ void QCitationDialog::down() { int const sel = selectedLB->currentItem(); + BOOST_ASSERT(sel < (int)form_->citekeys.size()); + // Move the selected key down one line - vector::iterator it = form_->citekeys.begin() + sel; - string const tmp = *it; + string const tmp = form_->citekeys[sel]; selectedLB->removeItem(sel); - form_->citekeys.erase(it); + swap(form_->citekeys[sel + 1], form_->citekeys[sel]); selectedLB->insertItem(toqstr(tmp), sel + 1); selectedLB->setSelected(sel + 1, true); - form_->citekeys.insert(it + 1, tmp); form_->changed(); form_->fillStyles(); @@ -249,8 +254,6 @@ void QCitationDialog::find(biblio::Direction dir) // Find the NEXT instance... if (dir == biblio::FORWARD) start += 1; - else - start -= 1; bool const casesens = add_->searchCaseCB->isChecked(); string const str = fromqstr(add_->searchED->text()); @@ -279,6 +282,12 @@ void QCitationDialog::find(biblio::Direction dir) } // Update the display + // note that we have multi selection mode! + add_->availableLB->setSelected(sel, false); add_->availableLB->setSelected(found, true); + add_->availableLB->setCurrentItem(found); add_->availableLB->ensureCurrentVisible(); } + +} // namespace frontend +} // namespace lyx