]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlBibtex.C
do not use QFileDialog directly
[lyx.git] / src / frontends / controllers / ControlBibtex.C
1 /**
2  * \file ControlBibtex.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  * \author Angus Leeming
8  * \author Herbert Voß
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #include <config.h>
14
15 #include "ControlBibtex.h"
16
17 #include "buffer.h"
18 #include "bufferparams.h"
19
20 #include "lyxrc.h"
21 #include "helper_funcs.h"
22 #include "tex_helpers.h"
23 #include "gettext.h"
24
25 #include "support/filetools.h"
26 #include "support/globbing.h"
27
28 using std::pair;
29 using std::string;
30 using std::vector;
31
32
33 namespace lyx {
34
35 using support::FileFilterList;
36 using support::OnlyFilename;
37
38 namespace frontend {
39
40
41 ControlBibtex::ControlBibtex(Dialog & d)
42         : ControlCommand(d, "bibtex")
43 {}
44
45
46 string const ControlBibtex::browseBib(string const & in_name) const
47 {
48         pair<string, string> dir1(_("Documents|#o#O"),
49                                   string(lyxrc.document_path));
50         FileFilterList const filter(_("BibTeX Databases (*.bib)"));
51         return browseRelFile(in_name, kernel().bufferFilepath(),
52                              _("Select a BibTeX database to add"),
53                              filter, false, dir1);
54 }
55
56
57 string const ControlBibtex::browseBst(string const & in_name) const
58 {
59         pair<string, string> dir1(_("Documents|#o#O"),
60                                   string(lyxrc.document_path));
61         FileFilterList const filter(_("BibTeX Styles (*.bst)"));
62         return browseRelFile(in_name, kernel().bufferFilepath(),
63                              _("Select a BibTeX style"), filter, false, dir1);
64 }
65
66
67 void ControlBibtex::getBibStyles(vector<string> & data) const
68 {
69         data.clear();
70
71         getTexFileList("bstFiles.lst", data);
72         // test, if we have a valid list, otherwise run rescan
73         if (data.empty()) {
74                 rescanBibStyles();
75                 getTexFileList("bstFiles.lst", data);
76         }
77         vector<string>::iterator it  = data.begin();
78         vector<string>::iterator end = data.end();
79         for (; it != end; ++it) {
80                 *it = OnlyFilename(*it);
81         }
82 }
83
84
85 void ControlBibtex::getBibFiles(vector<string> & data) const
86 {
87         data.clear();
88
89         getTexFileList("bibFiles.lst", data);
90         // test, if we have a valid list, otherwise run rescan
91         if (data.empty()) {
92                 rescanBibStyles();
93                 getTexFileList("bibFiles.lst", data);
94         }
95         vector<string>::iterator it  = data.begin();
96         vector<string>::iterator end = data.end();
97         for (; it != end; ++it) {
98                 *it = OnlyFilename(*it);
99         }
100 }
101
102
103 void ControlBibtex::rescanBibStyles() const
104 {
105         rescanTexStyles();
106 }
107
108
109 bool ControlBibtex::usingBibtopic() const
110 {
111     return kernel().buffer().params().use_bibtopic;
112 }
113
114 } // namespace frontend
115 } // namespace lyx