]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QBibtexDialog.C
qt2 ert dialog
[lyx.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
22 #include "support/filetools.h"
23
24 QBibtexDialog::QBibtexDialog(QBibtex * form)
25         : QBibtexDialogBase(0, 0, false, 0),
26         form_(form)
27 {
28         connect(okPB, SIGNAL(clicked()),
29                 form, SLOT(slotOK()));
30         connect(closePB, SIGNAL(clicked()),
31                 form, SLOT(slotClose()));
32 }
33
34  
35 void QBibtexDialog::change_adaptor()
36 {
37         form_->changed();
38 }
39
40
41 void QBibtexDialog::browsePressed()
42 {
43         string file(QFileDialog::getOpenFileName(QString::null, 
44                 _("BibTeX style files (*.bst)"), this, 0, _("Select a BibTeX style")).latin1()); 
45         if (!file.empty()) {
46                 styleED->setText(ChangeExtension(OnlyFilename(file), "").c_str());
47                 form_->changed();
48         }
49 }
50
51  
52 void QBibtexDialog::addPressed()
53 {
54         string file(QFileDialog::getOpenFileName(QString::null, 
55                 _("BibTeX database files (*.bib)"), this, 0, _("Select a BibTeX database to add")).latin1()); 
56         if (!file.empty()) {
57                 // FIXME: check duplicates
58                 databaseLB->insertItem(ChangeExtension(file, "").c_str());
59                 form_->changed();
60         }
61 }
62
63  
64 void QBibtexDialog::styleChanged(const QString & sel)
65 {
66         if (string(_("Other ...")) == sel.latin1() && !form_->readOnly()) {
67                 styleED->setEnabled(true);
68                 stylePB->setEnabled(true);
69         } else {
70                 styleED->setEnabled(false);
71                 stylePB->setEnabled(false);
72                 styleED->setText("");
73         }
74 }
75
76  
77 void QBibtexDialog::closeEvent(QCloseEvent *e)
78 {
79         form_->slotWMHide();
80         e->accept();
81 }