do not use QFileDialog directly

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8871 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2004-08-08 13:17:22 +00:00
parent f8146681da
commit 9e25f077c3
8 changed files with 51 additions and 37 deletions

View File

@ -1,3 +1,10 @@
2004-08-07 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* ControlBibtex.C (browseBst): new method, specialized to lookup
bibtex style files
(browseBib): new method, specialized to lookup bibtex database files
(browse): removed
2004-07-25 Lars Gullik Bjonnes <larsbj@gullik.net> 2004-07-25 Lars Gullik Bjonnes <larsbj@gullik.net>
* ControlErrorList.C (goTo): shuffle code to avoid compiler warning. * ControlErrorList.C (goTo): shuffle code to avoid compiler warning.

View File

@ -43,14 +43,24 @@ ControlBibtex::ControlBibtex(Dialog & d)
{} {}
string const ControlBibtex::browse(string const & in_name, string const ControlBibtex::browseBib(string const & in_name) const
string const & title,
FileFilterList const & filters) const
{ {
pair<string, string> dir1(_("Documents|#o#O"), pair<string, string> dir1(_("Documents|#o#O"),
string(lyxrc.document_path)); string(lyxrc.document_path));
FileFilterList const filter(_("BibTeX Databases (*.bib)"));
return browseRelFile(in_name, kernel().bufferFilepath(), return browseRelFile(in_name, kernel().bufferFilepath(),
title, filters, false, dir1); _("Select a BibTeX database to add"),
filter, false, dir1);
}
string const ControlBibtex::browseBst(string const & in_name) const
{
pair<string, string> dir1(_("Documents|#o#O"),
string(lyxrc.document_path));
FileFilterList const filter(_("BibTeX Styles (*.bst)"));
return browseRelFile(in_name, kernel().bufferFilepath(),
_("Select a BibTeX style"), filter, false, dir1);
} }

View File

@ -33,10 +33,12 @@ public:
/// ///
ControlBibtex(Dialog &); ControlBibtex(Dialog &);
/// Browse for a file /// Browse for a .bib file
std::string const browse(std::string const & in_name, std::string const browseBib(std::string const & in_name) const;
std::string const & title,
support::FileFilterList const & filters) const; /// Browse for a .bst file
std::string const browseBst(std::string const & in_name) const;
/// get the list of bst files /// get the list of bst files
void getBibStyles(std::vector<std::string> & data) const; void getBibStyles(std::vector<std::string> & data) const;
/// get the list of bib files /// get the list of bib files

View File

@ -1,3 +1,10 @@
2004-08-07 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* QBibtexDialog.C (browsePressed): use ControlBibtex::browseBst
(browseBibPressed): use ControlBibtex::browseBib
* QLPrintDialog.C (browseClicked): use ControlPrint::browse
2004-08-01 Lars Gullik Bjonnes <larsbj@gullik.net> 2004-08-01 Lars Gullik Bjonnes <larsbj@gullik.net>
* QContentPane.C (keyPressEvent): make sure to use the smart * QContentPane.C (keyPressEvent): make sure to use the smart

View File

@ -15,14 +15,13 @@
#include "QBibtex.h" #include "QBibtex.h"
#include "qt_helpers.h" #include "qt_helpers.h"
#include "controllers/ControlBibtex.h"
#include "support/filetools.h" #include "support/filetools.h"
#include <qpushbutton.h> #include <qpushbutton.h>
#include <qcombobox.h> #include <qcombobox.h>
#include <qlineedit.h> #include <qlineedit.h>
#include <qlistbox.h> #include <qlistbox.h>
#include <qfiledialog.h>
using lyx::support::ChangeExtension; using lyx::support::ChangeExtension;
@ -58,14 +57,10 @@ void QBibtexDialog::change_adaptor()
void QBibtexDialog::browsePressed() void QBibtexDialog::browsePressed()
{ {
QString const file = string const file = form_->controller().browseBst("");
QFileDialog::getOpenFileName(QString::null,
qt_("BibTeX style files (*.bst)"), if (!file.empty()) {
this, string const filen = ChangeExtension(file, "");
0,
qt_("Select a BibTeX style"));
if (!file.isNull()) {
string const filen = ChangeExtension(fromqstr(file), "");
bool present = false; bool present = false;
unsigned int pres = 0; unsigned int pres = 0;
@ -87,11 +82,10 @@ void QBibtexDialog::browsePressed()
void QBibtexDialog::browseBibPressed() void QBibtexDialog::browseBibPressed()
{ {
QString const file = QFileDialog::getOpenFileName(QString::null, string const file = form_->controller().browseBib("");
qt_("BibTeX database files (*.bib)"), add_, 0, qt_("Select a BibTeX database to add"));
if (!file.isNull()) { if (!file.empty()) {
string const f = ChangeExtension(fromqstr(file), ""); string const f = ChangeExtension(file, "");
bool present = false; bool present = false;
for (unsigned int i = 0; i != add_->bibLB->count(); i++) { for (unsigned int i = 0; i != add_->bibLB->count(); i++) {

View File

@ -11,11 +11,11 @@
#include <config.h> #include <config.h>
#include "controllers/ControlPrint.h"
#include "QLPrintDialog.h" #include "QLPrintDialog.h"
#include "QPrint.h" #include "QPrint.h"
#include "qt_helpers.h" #include "qt_helpers.h"
#include <qfiledialog.h>
#include <qcheckbox.h> #include <qcheckbox.h>
#include <qlineedit.h> #include <qlineedit.h>
#include <qpushbutton.h> #include <qpushbutton.h>
@ -43,11 +43,7 @@ void QLPrintDialog::change_adaptor()
void QLPrintDialog::browseClicked() void QLPrintDialog::browseClicked()
{ {
QString file = QString file = toqstr(form_->controller().browse(""));
QFileDialog::getOpenFileName(QString::null,
qt_("PostScript files (*.ps)"),
this, 0,
qt_("Select a file to print to"));
if (!file.isNull()) { if (!file.isNull()) {
fileED->setText(file); fileED->setText(file);
form_->changed(); form_->changed();

View File

@ -1,3 +1,8 @@
2004-08-08 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* FormBibtex.C (input): use ControlBibtex::browseBst and
ControlBibtex::browseBib
2004-08-01 Lars Gullik Bjonnes <larsbj@gullik.net> 2004-08-01 Lars Gullik Bjonnes <larsbj@gullik.net>
* XWorkArea.C (work_area_handler): handle wheel events more * XWorkArea.C (work_area_handler): handle wheel events more

View File

@ -128,11 +128,7 @@ ButtonPolicy::SMInput FormBibtex::input(FL_OBJECT * ob, long ob_value)
if (ob == dialog_->button_database_browse) { if (ob == dialog_->button_database_browse) {
// When browsing, take the first file only // When browsing, take the first file only
string const in_name = getString(dialog_->input_database); string const in_name = getString(dialog_->input_database);
FileFilterList const string out_name = controller().browseBib("");
filter(_("*.bib| BibTeX Databases (*.bib)"));
string out_name =
controller().browse("", _("Select Database"),
filter);
if (!out_name.empty()) { if (!out_name.empty()) {
// add the database to any existing ones // add the database to any existing ones
if (!in_name.empty()) if (!in_name.empty())
@ -143,10 +139,7 @@ ButtonPolicy::SMInput FormBibtex::input(FL_OBJECT * ob, long ob_value)
} else if (ob == dialog_->button_style_browse) { } else if (ob == dialog_->button_style_browse) {
string const in_name = getString(dialog_->input_style); string const in_name = getString(dialog_->input_style);
FileFilterList const string const style = controller().browseBst(in_name);
filter(_("*.bst| BibTeX Styles (*.bst)"));
string const style = controller()
.browse(in_name, _("Select BibTeX-Style"), filter);
if (!style.empty()) { if (!style.empty()) {
fl_set_input(dialog_->input_style, style.c_str()); fl_set_input(dialog_->input_style, style.c_str());
} }