#include <config.h>
+#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 <qcheckbox.h>
#include <qlineedit.h>
#include <qmultilineedit.h>
#include <qpushbutton.h>
-#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),
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
{
int const sel = selectedLB->currentItem();
+ BOOST_ASSERT(sel > 0);
+
// Move the selected key up one line
- vector<string>::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();
{
int const sel = selectedLB->currentItem();
+ BOOST_ASSERT(sel < (int)form_->citekeys.size());
+
// Move the selected key down one line
- vector<string>::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();
// 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());
}
// 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