]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt2/QCitationDialog.C
Strip trailing whitespace.
[lyx.git] / src / frontends / qt2 / QCitationDialog.C
index 6f9f32c1dd63574229823e268f07a36238e95ce1..8b6588309de6c3fecce57faa879b7a9d2dcda181 100644 (file)
@@ -1,16 +1,19 @@
 /**
  * \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 <kalle@klaralvdalens-datakonsult.se>
+ * \author Kalle Dalheimer
+ *
+ * Full author contact details are available in file CREDITS
  */
 
 #include <config.h>
+
+
 #include <algorithm>
 
-#include "gettext.h"
+#include "qt_helpers.h"
 #include "controllers/ControlCitation.h"
 #include "LyXView.h"
 #include "buffer.h"
 #include <qpushbutton.h>
 
 #include "QCitationDialog.h"
+#include "QCitation.h"
+#include "support/lstrings.h"
+
 using std::vector;
 using std::find;
 using std::max;
 
+
 QCitationDialog::QCitationDialog(QCitation * form)
        : QCitationDialogBase(0, 0, false, 0),
        form_(form)
@@ -43,7 +49,7 @@ QCitationDialog::QCitationDialog(QCitation * form)
        connect(searchED, SIGNAL(returnPressed()),
                this, SLOT(slotNextClicked()));
 
-       textBeforeED->setText(_("Not yet supported"));
+       textBeforeED->setText(qt_("Not yet supported"));
        textBeforeED->setReadOnly(true);
        textBeforeED->setFocusPolicy(QWidget::NoFocus);
        citationStyleCO->setEnabled(false);
@@ -82,7 +88,7 @@ void QCitationDialog::slotBibHighlighted(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
@@ -135,7 +141,7 @@ void QCitationDialog::slotCiteHighlighted(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])));
        }
 }
 
@@ -150,7 +156,7 @@ 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());
@@ -160,6 +166,7 @@ void QCitationDialog::slotAddClicked()
        form_->setBibButtons(QCitation::OFF);
        form_->setCiteButtons(QCitation::ON);
        form_->changed();
+       form_->fillStyles();
 }
 
 
@@ -179,6 +186,8 @@ void QCitationDialog::slotDelClicked()
        form_->setBibButtons(QCitation::ON);
        form_->setCiteButtons(QCitation::OFF);
        form_->changed();
+       form_->fillStyles();
+       form_->updateStyle();
 }
 
 
@@ -198,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();
 }
 
 
@@ -222,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();
 }
 
 
@@ -242,10 +253,16 @@ void QCitationDialog::slotNextClicked()
 }
 
 
+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() ?
@@ -281,7 +298,7 @@ void QCitationDialog::doFind(biblio::Direction dir)
                if (cit == form_->bibkeys.end())
                        return;
        }
-       
+
        int const found = int(cit - form_->bibkeys.begin());
        if (found == sel) {
                return;
@@ -291,5 +308,5 @@ void QCitationDialog::doFind(biblio::Direction dir)
        int const top = max(found - 5, 1);
        bibLB->setTopItem(top);
        bibLB->setSelected(found, true);
-       slotBibHighlighted(0);
+       slotBibHighlighted(found);
 }