]> git.lyx.org Git - features.git/blob - src/frontends/qt2/QBibtexDialog.C
add external material dialog to Qt2
[features.git] / src / frontends / qt2 / QBibtexDialog.C
1 /**
2  * \file QBibtexDialog.C
3  * Copyright 2001 the LyX Team
4  * Read the file COPYING
5  *
6  * \author John Levon <moz@compsoc.man.ac.uk>
7  */
8
9 #include <qwidget.h>
10 #include <qpushbutton.h>
11 #include <qcombobox.h>
12 #include <qlistbox.h>
13 #include <qcheckbox.h>
14 #include <qfiledialog.h>
15  
16 #include "QBibtexDialog.h"
17 #include "QBibtex.h"
18 #include "Dialogs.h"
19 #include "ControlBibtex.h" 
20 #include "gettext.h" 
21 #include "debug.h"
22
23 #include "support/filetools.h"
24
25 QBibtexDialog::QBibtexDialog(QBibtex * form)
26         : QBibtexDialogBase(0, 0, false, 0),
27         form_(form)
28 {
29         connect(okPB, SIGNAL(clicked()),
30                 form, SLOT(slotOK()));
31         connect(closePB, SIGNAL(clicked()),
32                 form, SLOT(slotClose()));
33 }
34
35  
36 void QBibtexDialog::change_adaptor()
37 {
38         form_->changed();
39 }
40
41
42 void QBibtexDialog::browsePressed()
43 {
44         QString file = QFileDialog::getOpenFileName(QString::null, 
45                 _("BibTeX style files (*.bst)"), this, 0, _("Select a BibTeX style"));
46         lyxerr << "HELLO" << std::endl;
47         if (!file.isNull()) {
48                 lyxerr << "MONKEYS" << std::endl;
49                 styleED->setText(ChangeExtension(OnlyFilename(file.latin1()), "").c_str());
50                 form_->changed();
51         }
52 }
53
54  
55 void QBibtexDialog::addPressed()
56 {
57         string file(QFileDialog::getOpenFileName(QString::null, 
58                 _("BibTeX database files (*.bib)"), this, 0, _("Select a BibTeX database to add")).latin1()); 
59         if (!file.empty()) {
60                 // FIXME: check duplicates
61                 databaseLB->insertItem(ChangeExtension(file, "").c_str());
62                 form_->changed();
63         }
64 }
65
66  
67 void QBibtexDialog::styleChanged(const QString & sel)
68 {
69         if (string(_("Other ...")) == sel.latin1() && !form_->readOnly()) {
70                 styleED->setEnabled(true);
71                 stylePB->setEnabled(true);
72         } else {
73                 styleED->setEnabled(false);
74                 stylePB->setEnabled(false);
75                 styleED->setText("");
76         }
77 }
78
79  
80 void QBibtexDialog::closeEvent(QCloseEvent *e)
81 {
82         form_->slotWMHide();
83         e->accept();
84 }