2006-03-05 17:24:44 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file QCitationDialog.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Kalle Dalheimer
|
|
|
|
|
* \author John Levon
|
|
|
|
|
* \author J<EFBFBD>rgen Spitzm<EFBFBD>ller
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "QCitationDialog.h"
|
|
|
|
|
#include "ui/QCitationFindUi.h"
|
|
|
|
|
#include "QCitation.h"
|
2006-03-25 21:26:09 +00:00
|
|
|
|
#include "Qt2BC.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
#include "bufferparams.h"
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
#include "controllers/ControlCitation.h"
|
|
|
|
|
#include "controllers/ButtonController.h"
|
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
#include "support/lstrings.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
#include <iostream>
|
|
|
|
|
using std::cout;
|
|
|
|
|
using std::endl;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
using std::find;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
using std::string;
|
2006-03-25 21:26:09 +00:00
|
|
|
|
using std::vector;
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
2006-03-25 21:26:09 +00:00
|
|
|
|
|
|
|
|
|
using support::getStringFromVector;
|
|
|
|
|
using support::getVectorFromString;
|
|
|
|
|
using support::trim;
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
namespace frontend {
|
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
|
2006-04-11 08:26:43 +00:00
|
|
|
|
QCitationDialog::QCitationDialog(Dialog & dialog, QCitation * form)
|
|
|
|
|
: Dialog::View(dialog, "Citation"), form_(form)
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
|
|
|
|
setupUi(this);
|
2006-04-05 23:56:29 +00:00
|
|
|
|
|
2006-04-11 08:26:43 +00:00
|
|
|
|
setCaption(toqstr("LyX: " + getTitle()));
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
// Manage the ok, apply, restore and cancel/close buttons
|
2006-04-11 08:26:43 +00:00
|
|
|
|
bcview().setOK(okPB);
|
|
|
|
|
bcview().setApply(applyPB);
|
|
|
|
|
bcview().setCancel(closePB);
|
|
|
|
|
bcview().setRestore(restorePB);
|
|
|
|
|
|
|
|
|
|
bcview().addReadOnly(addPB);
|
|
|
|
|
bcview().addReadOnly(deletePB);
|
|
|
|
|
bcview().addReadOnly(upPB);
|
|
|
|
|
bcview().addReadOnly(downPB);
|
|
|
|
|
bcview().addReadOnly(citationStyleCO);
|
|
|
|
|
bcview().addReadOnly(forceuppercaseCB);
|
|
|
|
|
bcview().addReadOnly(fulllistCB);
|
|
|
|
|
bcview().addReadOnly(textBeforeED);
|
|
|
|
|
bcview().addReadOnly(textAfterED);
|
|
|
|
|
*/
|
2006-03-25 21:26:09 +00:00
|
|
|
|
|
|
|
|
|
selectedLV->setModel(form_->selected());
|
|
|
|
|
availableLV->setModel(form_->available());
|
|
|
|
|
|
|
|
|
|
// foundLV.setModel(form_->found());
|
|
|
|
|
|
|
|
|
|
connect( citationStyleCO, SIGNAL( activated(int) ), this, SLOT( changed() ) );
|
|
|
|
|
connect( fulllistCB, SIGNAL( clicked() ), this, SLOT( changed() ) );
|
|
|
|
|
connect( forceuppercaseCB, SIGNAL( clicked() ), this, SLOT( changed() ) );
|
|
|
|
|
connect( textBeforeED, SIGNAL( textChanged(const QString&) ), this, SLOT( changed() ) );
|
|
|
|
|
connect( textAfterED, SIGNAL( textChanged(const QString&) ), this, SLOT( changed() ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// find_ = new QCitationFind(form_, this);
|
2006-04-11 08:26:43 +00:00
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
// connect(selectedLV, SIGNAL(doubleClicked(const QModelIndex & index)),
|
|
|
|
|
// form_, SLOT(on_okPB_clicked()));//SLOT(slotOK()));
|
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
QCitationDialog::~QCitationDialog()
|
|
|
|
|
{
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-04-11 08:26:43 +00:00
|
|
|
|
void QCitationDialog::apply()
|
|
|
|
|
{
|
|
|
|
|
int const choice = std::max(0, citationStyleCO->currentItem());
|
|
|
|
|
bool const full = fulllistCB->isChecked();
|
|
|
|
|
bool const force = forceuppercaseCB->isChecked();
|
|
|
|
|
|
|
|
|
|
QString const before = textBeforeED->text();
|
|
|
|
|
QString const after = textAfterED->text();
|
|
|
|
|
|
|
|
|
|
form_->apply(choice, full, force, before, after);
|
|
|
|
|
}
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-04-11 08:26:43 +00:00
|
|
|
|
void QCitationDialog::hide()
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2006-03-25 21:26:09 +00:00
|
|
|
|
accept();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-04-11 08:26:43 +00:00
|
|
|
|
|
|
|
|
|
void QCitationDialog::show()
|
2006-03-25 21:26:09 +00:00
|
|
|
|
{
|
2006-04-11 08:26:43 +00:00
|
|
|
|
QDialog::show();
|
2006-03-25 21:26:09 +00:00
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-04-11 08:26:43 +00:00
|
|
|
|
|
|
|
|
|
bool QCitationDialog::isVisible() const
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2006-04-11 08:26:43 +00:00
|
|
|
|
return QDialog::isVisible();
|
2006-03-25 21:26:09 +00:00
|
|
|
|
}
|
2006-04-11 08:26:43 +00:00
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
|
2006-04-11 08:26:43 +00:00
|
|
|
|
void QCitationDialog::on_okPB_clicked()
|
2006-03-25 21:26:09 +00:00
|
|
|
|
{
|
2006-04-11 08:26:43 +00:00
|
|
|
|
apply();
|
|
|
|
|
accept();
|
2006-03-25 21:26:09 +00:00
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-04-11 08:26:43 +00:00
|
|
|
|
void QCitationDialog::on_cancelPB_clicked()
|
2006-03-25 21:26:09 +00:00
|
|
|
|
{
|
2006-04-11 08:26:43 +00:00
|
|
|
|
accept();
|
|
|
|
|
// reject();
|
|
|
|
|
}
|
2006-03-25 21:26:09 +00:00
|
|
|
|
|
2006-04-11 08:26:43 +00:00
|
|
|
|
void QCitationDialog::on_applyPB_clicked()
|
|
|
|
|
{
|
|
|
|
|
apply();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-04-11 08:26:43 +00:00
|
|
|
|
void QCitationDialog::on_restorePB_clicked()
|
|
|
|
|
{
|
|
|
|
|
update();
|
|
|
|
|
bc().valid(form_->isValid() );
|
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-04-11 08:26:43 +00:00
|
|
|
|
void QCitationDialog::update()
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2006-04-11 08:26:43 +00:00
|
|
|
|
form_->updateModel();
|
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
// No keys have been selected yet, so...
|
|
|
|
|
infoML->document()->clear();
|
|
|
|
|
setButtons();
|
|
|
|
|
|
2006-04-11 08:26:43 +00:00
|
|
|
|
textBeforeED->setText(form_->textBefore());
|
|
|
|
|
textAfterED->setText(form_->textAfter());
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
fillStyles();
|
|
|
|
|
updateStyle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QCitationDialog::updateStyle()
|
|
|
|
|
{
|
2006-04-11 08:26:43 +00:00
|
|
|
|
biblio::CiteEngine const engine = form_->getEngine();
|
2006-03-25 21:26:09 +00:00
|
|
|
|
bool const natbib_engine =
|
|
|
|
|
engine == biblio::ENGINE_NATBIB_AUTHORYEAR ||
|
|
|
|
|
engine == biblio::ENGINE_NATBIB_NUMERICAL;
|
|
|
|
|
bool const basic_engine = engine == biblio::ENGINE_BASIC;
|
|
|
|
|
|
|
|
|
|
fulllistCB->setEnabled(natbib_engine);
|
|
|
|
|
forceuppercaseCB->setEnabled(natbib_engine);
|
|
|
|
|
textBeforeED->setEnabled(!basic_engine);
|
|
|
|
|
|
2006-04-11 08:26:43 +00:00
|
|
|
|
string const & command = form_->params().getCmdName();
|
2006-03-25 21:26:09 +00:00
|
|
|
|
|
|
|
|
|
// Find the style of the citekeys
|
|
|
|
|
vector<biblio::CiteStyle> const & styles =
|
|
|
|
|
ControlCitation::getCiteStyles();
|
|
|
|
|
biblio::CitationStyle const cs(command);
|
|
|
|
|
|
|
|
|
|
vector<biblio::CiteStyle>::const_iterator cit =
|
|
|
|
|
std::find(styles.begin(), styles.end(), cs.style);
|
|
|
|
|
|
|
|
|
|
// restore the latest natbib style
|
|
|
|
|
if (style_ >= 0 && style_ < citationStyleCO->count())
|
|
|
|
|
citationStyleCO->setCurrentItem(style_);
|
|
|
|
|
else
|
|
|
|
|
citationStyleCO->setCurrentItem(0);
|
2006-04-11 08:26:43 +00:00
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
fulllistCB->setChecked(false);
|
|
|
|
|
forceuppercaseCB->setChecked(false);
|
|
|
|
|
|
|
|
|
|
if (cit != styles.end()) {
|
|
|
|
|
int const i = int(cit - styles.begin());
|
|
|
|
|
citationStyleCO->setCurrentItem(i);
|
|
|
|
|
fulllistCB->setChecked(cs.full);
|
|
|
|
|
forceuppercaseCB->setChecked(cs.forceUCase);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
void QCitationDialog::fillStyles()
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2006-03-25 21:26:09 +00:00
|
|
|
|
int const orig = citationStyleCO->currentItem();
|
|
|
|
|
|
|
|
|
|
citationStyleCO->clear();
|
|
|
|
|
|
|
|
|
|
QStringList selected_keys = form_->selected()->stringList();
|
2006-04-11 08:26:43 +00:00
|
|
|
|
if (selected_keys.empty()) {
|
|
|
|
|
citationStyleCO->setEnabled(false);
|
|
|
|
|
citationStyleLA->setEnabled(false);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
return;
|
2006-04-11 08:26:43 +00:00
|
|
|
|
}
|
2006-03-25 21:26:09 +00:00
|
|
|
|
|
|
|
|
|
if (selectedLV->selectionModel()->selectedIndexes().empty())
|
|
|
|
|
return;
|
2006-04-11 08:26:43 +00:00
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
int curr = selectedLV->selectionModel()->selectedIndexes()[0].row();//selectedLV->currentItem();
|
|
|
|
|
|
2006-04-11 08:26:43 +00:00
|
|
|
|
QStringList sty = form_->citationStyles(curr);
|
2006-03-25 21:26:09 +00:00
|
|
|
|
|
2006-04-11 08:26:43 +00:00
|
|
|
|
bool const basic_engine =
|
|
|
|
|
(form_->getEngine() == biblio::ENGINE_BASIC);
|
2006-03-25 21:26:09 +00:00
|
|
|
|
|
2006-04-11 08:26:43 +00:00
|
|
|
|
citationStyleCO->setEnabled(!sty.isEmpty() && !basic_engine);
|
|
|
|
|
citationStyleLA->setEnabled(!sty.isEmpty() && !basic_engine);
|
2006-03-25 21:26:09 +00:00
|
|
|
|
|
2006-04-11 08:26:43 +00:00
|
|
|
|
citationStyleCO->insertItems(0, sty);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
if (orig != -1 && orig < citationStyleCO->count())
|
|
|
|
|
citationStyleCO->setCurrentItem(orig);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
void QCitationDialog::setButtons()
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2006-04-11 08:26:43 +00:00
|
|
|
|
// if (form_->readOnly())
|
|
|
|
|
// return;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
int const row_count = selectedLV->model()->rowCount();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
int sel_nr=-1;
|
|
|
|
|
if (! selectedLV->selectionModel()->selectedIndexes().empty()) {
|
2006-04-11 08:26:43 +00:00
|
|
|
|
sel_nr =
|
2006-03-25 21:26:09 +00:00
|
|
|
|
selectedLV->selectionModel()->selectedIndexes()[0].row();
|
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
deletePB->setEnabled(sel_nr >= 0);
|
|
|
|
|
upPB->setEnabled(sel_nr > 0);
|
|
|
|
|
downPB->setEnabled(sel_nr >= 0 && sel_nr < row_count - 1);
|
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
/*
|
2006-05-07 10:20:43 +00:00
|
|
|
|
void QCitationDialog::on_selectedLV_currentChanged(QListWidgetItem*)
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2006-03-25 21:26:09 +00:00
|
|
|
|
fillStyles();
|
|
|
|
|
infoML->document()->clear();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-05-07 10:20:43 +00:00
|
|
|
|
int const sel = selectedLW->currentItem();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
if (sel < 0) {
|
|
|
|
|
setButtons();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
infoML->document()->setPlainText(form_->getKeyInfo(sel));
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
setButtons();
|
|
|
|
|
}
|
2006-03-25 21:26:09 +00:00
|
|
|
|
*/
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
void QCitationDialog::on_addPB_clicked()
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2006-03-25 21:26:09 +00:00
|
|
|
|
form_->addKeys(availableLV->selectionModel()->selectedIndexes());
|
2006-04-11 08:26:43 +00:00
|
|
|
|
changed();
|
2006-03-25 21:26:09 +00:00
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
void QCitationDialog::on_deletePB_clicked()
|
|
|
|
|
{
|
2006-04-11 08:26:43 +00:00
|
|
|
|
form_->deleteKeys(selectedLV->selectionModel()->selectedIndexes());
|
2006-03-25 21:26:09 +00:00
|
|
|
|
changed();
|
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
void QCitationDialog::on_upPB_clicked()
|
|
|
|
|
{
|
|
|
|
|
form_->upKey(selectedLV->selectionModel()->selectedIndexes());
|
|
|
|
|
changed();
|
|
|
|
|
}
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
void QCitationDialog::on_downPB_clicked()
|
|
|
|
|
{
|
|
|
|
|
form_->downKey(selectedLV->selectionModel()->selectedIndexes());
|
|
|
|
|
changed();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
void QCitationDialog::on_findLE_textChanged(const QString & text)
|
|
|
|
|
{
|
|
|
|
|
QModelIndex const index = form_->findKey(text);
|
|
|
|
|
if (! index.isValid())
|
|
|
|
|
return;
|
2006-03-26 18:35:15 +00:00
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
// QItemSelection selection(index, index);
|
|
|
|
|
availableLV->selectionModel()->select(index, QItemSelectionModel::Select);
|
|
|
|
|
changed();
|
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
void QCitationDialog::on_advancedSearchPB_clicked()
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2006-03-25 21:26:09 +00:00
|
|
|
|
// find_->exec();
|
|
|
|
|
changed();
|
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
void QCitationDialog::changed()
|
|
|
|
|
{
|
|
|
|
|
fillStyles();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
setButtons();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-05-07 10:20:43 +00:00
|
|
|
|
void updateBrowser(QListWidget * browser,
|
2006-04-11 08:26:43 +00:00
|
|
|
|
vector<string> const & keys)
|
|
|
|
|
{
|
|
|
|
|
browser->clear();
|
|
|
|
|
|
|
|
|
|
for (vector<string>::const_iterator it = keys.begin();
|
|
|
|
|
it < keys.end(); ++it) {
|
|
|
|
|
string const key = trim(*it);
|
|
|
|
|
// FIXME: why the .empty() test ?
|
|
|
|
|
if (!key.empty())
|
2006-05-07 10:20:43 +00:00
|
|
|
|
browser->addItem(toqstr(key));
|
2006-04-11 08:26:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
|
|
|
|
|
QCitationFind::QCitationFind(QCitation * form, QWidget * parent, Qt::WFlags f)
|
|
|
|
|
: form_(form), QDialog(parent, f)
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2006-03-25 21:26:09 +00:00
|
|
|
|
setupUi(this);
|
2006-05-07 10:20:43 +00:00
|
|
|
|
connect(addPB, SIGNAL(clicked()), this, SLOT(accept()));
|
|
|
|
|
connect(closePB, SIGNAL(clicked()), this, SLOT(reject()));
|
2006-03-25 21:26:09 +00:00
|
|
|
|
connect(previousPB, SIGNAL(clicked()), this, SLOT(previous()));
|
|
|
|
|
connect(nextPB, SIGNAL(clicked()), this, SLOT(next()));
|
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
void QCitationFind::update()
|
|
|
|
|
{
|
2006-05-07 10:20:43 +00:00
|
|
|
|
// updateBrowser(availableLW, form_->availableKeys());
|
2006-03-25 21:26:09 +00:00
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-05-07 10:20:43 +00:00
|
|
|
|
void QCitationFind::on_availableLW_currentItemChanged(QListWidgetItem *)
|
2006-03-25 21:26:09 +00:00
|
|
|
|
{
|
|
|
|
|
infoML->document()->clear();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-05-07 10:20:43 +00:00
|
|
|
|
int const sel = availableLW->currentRow();
|
2006-03-25 21:26:09 +00:00
|
|
|
|
if (sel < 0) {
|
|
|
|
|
addPB->setEnabled(false);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
addPB->setEnabled(true);
|
|
|
|
|
// infoML->document()->setPlainText(form_->getKeyInfo(sel));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-05-07 10:20:43 +00:00
|
|
|
|
void QCitationFind::on_availableLW_itemActivated(QListWidgetItem *)
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2006-05-07 10:20:43 +00:00
|
|
|
|
// int const sel = availableLW->currentRow();
|
2006-03-25 21:26:09 +00:00
|
|
|
|
foundkeys.clear();
|
|
|
|
|
// foundkeys.push_back(form_->availableKeys()[sel]);
|
|
|
|
|
emit newCitations();
|
|
|
|
|
accept();
|
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
void QCitationFind::on_addPB_clicked()
|
|
|
|
|
{
|
2006-05-07 10:20:43 +00:00
|
|
|
|
// form_->addKeys(availableLW->selectionModel()->selectedIndexes());
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-05-07 10:20:43 +00:00
|
|
|
|
int const sel = availableLW->currentRow();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
if (sel < 0)
|
|
|
|
|
return;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
QStringList bibkeys = form_->available()->stringList();
|
|
|
|
|
|
|
|
|
|
// Add the selected browser_bib keys to browser_cite
|
|
|
|
|
// multiple selections are possible
|
2006-05-07 10:20:43 +00:00
|
|
|
|
for (unsigned int i = 0; i != availableLW->count(); i++) {
|
|
|
|
|
if (availableLW->isItemSelected(availableLW->item(i))) {
|
2006-03-25 21:26:09 +00:00
|
|
|
|
foundkeys.push_back(fromqstr(bibkeys[i]));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
emit newCitations();
|
|
|
|
|
accept();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
void QCitationFind::previous()
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2006-03-25 21:26:09 +00:00
|
|
|
|
find(biblio::BACKWARD);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
void QCitationFind::next()
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2006-03-25 21:26:09 +00:00
|
|
|
|
find(biblio::FORWARD);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
void QCitationFind::find(biblio::Direction dir)
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2006-03-25 21:26:09 +00:00
|
|
|
|
/* QStringList bibkeys = form_->available()->stringList();
|
|
|
|
|
|
2006-04-11 08:26:43 +00:00
|
|
|
|
biblio::InfoMap const & theMap = form_->bibkeysInfo();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
biblio::Search const type = searchTypeCB->isChecked()
|
2006-03-05 17:24:44 +00:00
|
|
|
|
? biblio::REGEX : biblio::SIMPLE;
|
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
vector<string>::const_iterator start = bibkeys.begin();
|
2006-05-07 10:20:43 +00:00
|
|
|
|
int const sel = availableLW->currentItem();
|
2006-03-25 21:26:09 +00:00
|
|
|
|
if (sel >= 0 && sel <= int(bibkeys.size()-1))
|
2006-03-05 17:24:44 +00:00
|
|
|
|
start += sel;
|
|
|
|
|
|
|
|
|
|
// Find the NEXT instance...
|
|
|
|
|
if (dir == biblio::FORWARD)
|
|
|
|
|
start += 1;
|
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
bool const casesens = searchCaseCB->isChecked();
|
|
|
|
|
string const str = fromqstr(searchED->text());
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
vector<string>::const_iterator cit =
|
2006-03-25 21:26:09 +00:00
|
|
|
|
biblio::searchKeys(theMap, bibkeys, str,
|
2006-03-05 17:24:44 +00:00
|
|
|
|
start, type, dir, casesens);
|
|
|
|
|
|
|
|
|
|
// not found. let's loop round
|
2006-03-25 21:26:09 +00:00
|
|
|
|
if (cit == bibkeys.end()) {
|
2006-03-05 17:24:44 +00:00
|
|
|
|
if (dir == biblio::FORWARD) {
|
2006-03-25 21:26:09 +00:00
|
|
|
|
start = bibkeys.begin();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
2006-03-25 21:26:09 +00:00
|
|
|
|
else start = bibkeys.end() - 1;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
cit = biblio::searchKeys(theMap, bibkeys, str,
|
2006-03-05 17:24:44 +00:00
|
|
|
|
start, type, dir, casesens);
|
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
if (cit == bibkeys.end())
|
2006-03-05 17:24:44 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2006-03-25 21:26:09 +00:00
|
|
|
|
int const found = int(cit - bibkeys.begin());
|
2006-03-05 17:24:44 +00:00
|
|
|
|
if (found == sel) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update the display
|
|
|
|
|
// note that we have multi selection mode!
|
2006-05-07 10:20:43 +00:00
|
|
|
|
availableLW->setSelected(sel, false);
|
|
|
|
|
availableLW->setSelected(found, true);
|
|
|
|
|
availableLW->setCurrentItem(found);
|
|
|
|
|
availableLW->ensureCurrentVisible();
|
2006-03-25 21:26:09 +00:00
|
|
|
|
*/
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
|
} // namespace lyx
|
2006-05-18 08:51:12 +00:00
|
|
|
|
|
|
|
|
|
#include "QCitationDialog_moc.cpp"
|