X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt2%2FQCitationDialog.C;h=8b6588309de6c3fecce57faa879b7a9d2dcda181;hb=1fcedd4b635807e7046342f324d054c04c37f054;hp=aeaaae23c4ec8685676896df8c98da9689750bc6;hpb=6dac02d3bbbb3327ea2f92c37cd6ce8fd91f3462;p=lyx.git diff --git a/src/frontends/qt2/QCitationDialog.C b/src/frontends/qt2/QCitationDialog.C index aeaaae23c4..8b6588309d 100644 --- a/src/frontends/qt2/QCitationDialog.C +++ b/src/frontends/qt2/QCitationDialog.C @@ -1,56 +1,79 @@ /** * \file QCitationDialog.C - * Copyright 2001 the LyX Team - * Read the file COPYING + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. * - * \author Kalle Dalheimer + * \author Kalle Dalheimer + * + * Full author contact details are available in file CREDITS */ #include - -#include "QCitationDialog.h" -#include "Dialogs.h" -#include "QCitation.h" + + +#include + +#include "qt_helpers.h" #include "controllers/ControlCitation.h" +#include "LyXView.h" +#include "buffer.h" #include +#include #include #include #include #include - -#include "QtLyXView.h" -#include -#include "buffer.h" +#include "QCitationDialog.h" +#include "QCitation.h" +#include "support/lstrings.h" using std::vector; using std::find; using std::max; -QCitationDialog::QCitationDialog(QCitation * form, QWidget * parent, const char * name, bool modal, WFlags fl) - : QCitationDialogBase(parent, name, modal, fl), + +QCitationDialog::QCitationDialog(QCitation * form) + : QCitationDialogBase(0, 0, false, 0), form_(form) { - connect(okPB, SIGNAL(clicked()), - form, SLOT(slotOK())); - connect(cancelPB, SIGNAL(clicked()), - form, SLOT(slotCancel())); connect(restorePB, SIGNAL(clicked()), form, SLOT(slotRestore())); + connect(okPB, SIGNAL(clicked()), + form, SLOT(slotOK())); connect(applyPB, SIGNAL(clicked()), form, SLOT(slotApply())); + connect(closePB, SIGNAL(clicked()), + form, SLOT(slotClose())); connect(searchED, SIGNAL(returnPressed()), - form, SLOT(slotNextClicked())); + this, SLOT(slotNextClicked())); + + textBeforeED->setText(qt_("Not yet supported")); + textBeforeED->setReadOnly(true); + textBeforeED->setFocusPolicy(QWidget::NoFocus); + citationStyleCO->setEnabled(false); + citationStyleCO->setFocusPolicy(QWidget::NoFocus); } - + QCitationDialog::~QCitationDialog() { } -void QCitationDialog::slotBibSelected( int sel ) +void QCitationDialog::slotBibSelected(int sel) +{ + slotBibHighlighted(sel); + + if (form_->readOnly()) + return; + + slotAddClicked(); +} + + +void QCitationDialog::slotBibHighlighted(int sel) { biblio::InfoMap const & theMap = form_->controller().bibkeysInfo(); @@ -65,7 +88,7 @@ void QCitationDialog::slotBibSelected( int sel ) // the selected browser_bib key infoML->clear(); - infoML->setText(biblio::getInfo(theMap, form_->bibkeys[sel]).c_str()); + infoML->setText(toqstr(biblio::getInfo(theMap, form_->bibkeys[sel]))); // Highlight the selected browser_bib key in browser_cite if // present @@ -79,7 +102,7 @@ void QCitationDialog::slotBibSelected( int sel ) citeLB->setTopItem(n); } - if (!form_->controller().isReadonly()) { + if (!form_->readOnly()) { if (cit != form_->citekeys.end()) { form_->setBibButtons(QCitation::OFF); form_->setCiteButtons(QCitation::ON); @@ -91,7 +114,7 @@ void QCitationDialog::slotBibSelected( int sel ) } -void QCitationDialog::slotCiteSelected(int sel) +void QCitationDialog::slotCiteHighlighted(int sel) { biblio::InfoMap const & theMap = form_->controller().bibkeysInfo(); @@ -100,14 +123,14 @@ void QCitationDialog::slotCiteSelected(int sel) return; } - if (!form_->controller().isReadonly()) { + if (!form_->readOnly()) { form_->setBibButtons(QCitation::OFF); form_->setCiteButtons(QCitation::ON); } // Highlight the selected browser_cite key in browser_bib vector::const_iterator cit = - std::find(form_->bibkeys.begin(), + std::find(form_->bibkeys.begin(), form_->bibkeys.end(), form_->citekeys[sel]); if (cit != form_->bibkeys.end()) { @@ -118,7 +141,7 @@ void QCitationDialog::slotCiteSelected(int sel) // Put into browser_info the additional info associated // with the selected browser_cite key infoML->clear(); - infoML->setText(biblio::getInfo(theMap, form_->bibkeys[sel]).c_str()); + infoML->setText(toqstr(biblio::getInfo(theMap, form_->citekeys[sel]))); } } @@ -133,15 +156,17 @@ void QCitationDialog::slotAddClicked() } // Add the selected browser_bib key to browser_cite - citeLB->insertItem(form_->bibkeys[sel].c_str()); + citeLB->insertItem(toqstr(form_->bibkeys[sel])); form_->citekeys.push_back(form_->bibkeys[sel]); int const n = int(form_->citekeys.size()); citeLB->setSelected(n - 1, true); + slotBibHighlighted(sel); form_->setBibButtons(QCitation::OFF); form_->setCiteButtons(QCitation::ON); form_->changed(); + form_->fillStyles(); } @@ -149,7 +174,7 @@ void QCitationDialog::slotDelClicked() { int const sel = citeLB->currentItem(); - // FIXME: why ? + // FIXME: why ? if (sel < 0 || sel >= (int)form_->citekeys.size()) { return; } @@ -161,6 +186,8 @@ void QCitationDialog::slotDelClicked() form_->setBibButtons(QCitation::ON); form_->setCiteButtons(QCitation::OFF); form_->changed(); + form_->fillStyles(); + form_->updateStyle(); } @@ -180,11 +207,12 @@ void QCitationDialog::slotUpClicked() citeLB->removeItem(sel); form_->citekeys.erase(it); - citeLB->insertItem(tmp.c_str(), sel - 1); + citeLB->insertItem(toqstr(tmp), sel - 1); citeLB->setSelected(sel - 1, true); form_->citekeys.insert(it - 1, tmp); form_->setCiteButtons(QCitation::ON); form_->changed(); + form_->fillStyles(); } @@ -192,7 +220,7 @@ void QCitationDialog::slotDownClicked() { int const sel = citeLB->currentItem(); - // FIXME: ? + // FIXME: ? if (sel < 0 || sel >= (int)form_->citekeys.size() - 1) { return; } @@ -204,11 +232,12 @@ void QCitationDialog::slotDownClicked() citeLB->removeItem(sel); form_->citekeys.erase(it); - citeLB->insertItem(tmp.c_str(), sel + 1); + citeLB->insertItem(toqstr(tmp), sel + 1); citeLB->setSelected(sel + 1, true); form_->citekeys.insert(it + 1, tmp); form_->setCiteButtons(QCitation::ON); form_->changed(); + form_->fillStyles(); } @@ -224,10 +253,16 @@ void QCitationDialog::slotNextClicked() } -void QCitationDialog::doFind(biblio::Direction const dir) +void QCitationDialog::changed_adaptor() +{ + form_->changed(); +} + + +void QCitationDialog::doFind(biblio::Direction dir) { biblio::InfoMap const & theMap = form_->controller().bibkeysInfo(); - string const str = searchED->text().latin1(); + string const str = fromqstr(searchED->text()); biblio::Search const type = searchTypeCB->isChecked() ? @@ -245,13 +280,23 @@ void QCitationDialog::doFind(biblio::Direction const dir) start -= 1; bool const caseSensitive = searchCaseCB->isChecked(); - - vector::const_iterator const cit = + + vector::const_iterator cit = biblio::searchKeys(theMap, form_->bibkeys, str, - start, type, dir, caseSensitive); + start, type, dir, caseSensitive); + // not found. let's loop round if (cit == form_->bibkeys.end()) { - return; + if (dir == biblio::FORWARD) { + start = form_->bibkeys.begin(); + } + else start = form_->bibkeys.end() - 1; + + cit = biblio::searchKeys(theMap, form_->bibkeys, str, + start, type, dir, caseSensitive); + + if (cit == form_->bibkeys.end()) + return; } int const found = int(cit - form_->bibkeys.begin()); @@ -263,23 +308,5 @@ void QCitationDialog::doFind(biblio::Direction const dir) int const top = max(found - 5, 1); bibLB->setTopItem(top); bibLB->setSelected(found, true); - slotBibSelected(0); -} - - -void QCitationDialog::slotCitationStyleSelected( int ) -{ - form_->changed(); -} - - -void QCitationDialog::slotTextBeforeReturn() -{ - form_->changed(); -} - - -void QCitationDialog::slotTextAfterReturn() -{ - form_->changed(); + slotBibHighlighted(found); }