]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt2/QCitationDialog.C
better selection and scrolling behaviour
[lyx.git] / src / frontends / qt2 / QCitationDialog.C
index 1aefb79d0db413ac371923ae506f48277b83c66d..282aa21f68900703a976a6e8d1eb14284ea53403 100644 (file)
@@ -1,18 +1,25 @@
 /**
  * \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 "gettext.h"
+#ifdef __GNUG__
+#pragma implementation
+#endif
 
-#include "QCitationDialog.h"
-#include "Dialogs.h"
+#include <algorithm>
+
+#include "gettext.h"
 #include "controllers/ControlCitation.h"
+#include "LyXView.h"
+#include "buffer.h"
 
 #include <qcheckbox.h>
 #include <qcombobox.h>
 #include <qmultilineedit.h>
 #include <qpushbutton.h>
 
-#include "QtLyXView.h"
-
-#include <algorithm>
-#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)
        : QCitationDialogBase(0, 0, false, 0),
        form_(form)
@@ -61,14 +68,14 @@ QCitationDialog::~QCitationDialog()
 void QCitationDialog::slotBibSelected(int sel)
 {
        slotBibHighlighted(sel);
-       if (form_->readOnly()) 
+
+       if (form_->readOnly())
                return;
+
        slotAddClicked();
 }
 
+
 void QCitationDialog::slotBibHighlighted(int sel)
 {
        biblio::InfoMap const & theMap = form_->controller().bibkeysInfo();
@@ -137,7 +144,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(biblio::getInfo(theMap, form_->citekeys[sel]).c_str());
        }
 }
 
@@ -158,6 +165,7 @@ void QCitationDialog::slotAddClicked()
        int const n = int(form_->citekeys.size());
        citeLB->setSelected(n - 1, true);
 
+       slotBibHighlighted(sel);
        form_->setBibButtons(QCitation::OFF);
        form_->setCiteButtons(QCitation::ON);
        form_->changed();
@@ -243,7 +251,13 @@ 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();
@@ -264,22 +278,21 @@ void QCitationDialog::doFind(biblio::Direction const dir)
                start -= 1;
 
        bool const caseSensitive = searchCaseCB->isChecked();
-       
+
        vector<string>::const_iterator cit =
                biblio::searchKeys(theMap, form_->bibkeys, str,
-                       start, type, dir, caseSensitive);
+                                  start, type, dir, caseSensitive);
 
-       // FIXME: should work ... 
+       // not found. let's loop round
        if (cit == form_->bibkeys.end()) {
-               // not found. let's loop round
-               if (dir == biblio::FORWARD)
+               if (dir == biblio::FORWARD) {
                        start = form_->bibkeys.begin();
-               else
-                       start = form_->bibkeys.end();
-               
+               }
+               else start = form_->bibkeys.end() - 1;
+
                cit = biblio::searchKeys(theMap, form_->bibkeys, str,
-                       start, type, dir, caseSensitive);
+                                        start, type, dir, caseSensitive);
+
                if (cit == form_->bibkeys.end())
                        return;
        }