more of that

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23497 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2008-03-06 00:07:19 +00:00
parent ca4d221248
commit 990df4924a
14 changed files with 110 additions and 129 deletions

View File

@ -86,9 +86,9 @@ bool Dialog::isBufferReadonly() const
} }
string const Dialog::bufferFilepath() const QString Dialog::bufferFilepath() const
{ {
return buffer().filePath(); return toqstr(buffer().filePath());
} }

View File

@ -227,7 +227,7 @@ public:
//@{ //@{
bool isBufferAvailable() const; bool isBufferAvailable() const;
bool isBufferReadonly() const; bool isBufferReadonly() const;
std::string const bufferFilepath() const; QString bufferFilepath() const;
//@} //@}
/// The type of the current buffer. /// The type of the current buffer.

View File

@ -128,51 +128,52 @@ void GuiBibtex::change_adaptor()
void GuiBibtex::browsePressed() void GuiBibtex::browsePressed()
{ {
docstring const file = browseBst(docstring()); QString const file = browseBst(QString());
if (!file.empty()) { if (file.isEmpty())
// FIXME UNICODE return;
docstring const filen = from_utf8(changeExtension(to_utf8(file), ""));
bool present = false;
unsigned int pres = 0;
for (int i = 0; i != styleCB->count(); ++i) { // FIXME UNICODE
if (qstring_to_ucs4(styleCB->itemText(i)) == filen) { QString const filen = toqstr(changeExtension(fromqstr(file), ""));
present = true; bool present = false;
pres = i; unsigned int pres = 0;
}
for (int i = 0; i != styleCB->count(); ++i) {
if (styleCB->itemText(i) == filen) {
present = true;
pres = i;
} }
if (!present)
styleCB->insertItem(0, toqstr(filen));
styleCB->setCurrentIndex(pres);
changed();
} }
if (!present)
styleCB->insertItem(0, filen);
styleCB->setCurrentIndex(pres);
changed();
} }
void GuiBibtex::browseBibPressed() void GuiBibtex::browseBibPressed()
{ {
docstring const file = trim(browseBib(docstring())); QString const file = browseBib(QString()).trimmed();
if (!file.empty()) { if (file.isEmpty())
// FIXME UNICODE return;
QString const f = toqstr(changeExtension(to_utf8(file), ""));
bool present = false;
for (int i = 0; i < add_->bibLW->count(); ++i) { QString const f = toqstr(changeExtension(fromqstr(file), ""));
if (add_->bibLW->item(i)->text() == f) bool present = false;
present = true;
}
if (!present) { for (int i = 0; i < add_->bibLW->count(); ++i) {
add_->bibLW->addItem(f); if (add_->bibLW->item(i)->text() == f)
changed(); present = true;
}
add_->bibED->setText(f);
} }
if (!present) {
add_->bibLW->addItem(f);
changed();
}
add_->bibED->setText(f);
} }
@ -186,9 +187,9 @@ void GuiBibtex::addPressed()
void GuiBibtex::addDatabase() void GuiBibtex::addDatabase()
{ {
int const sel = add_->bibLW->currentRow(); int const sel = add_->bibLW->currentRow();
docstring const file = trim(qstring_to_ucs4(add_->bibED->text())); QString const file = add_->bibED->text().trimmed();
if (sel < 0 && file.empty()) if (sel < 0 && file.isEmpty())
return; return;
// Add the selected browser_bib keys to browser_database // Add the selected browser_bib keys to browser_database
@ -210,9 +211,9 @@ void GuiBibtex::addDatabase()
} }
} }
if (!file.empty()) { if (!file.isEmpty()) {
add_->bibED->clear(); add_->bibED->clear();
QString const f = toqstr(from_utf8(changeExtension(to_utf8(file), ""))); QString const f = toqstr(changeExtension(fromqstr(file), ""));
QList<QListWidgetItem *> matches = QList<QListWidgetItem *> matches =
databaseLW->findItems(f, Qt::MatchExactly); databaseLW->findItems(f, Qt::MatchExactly);
if (matches.empty()) { if (matches.empty()) {
@ -359,24 +360,24 @@ void GuiBibtex::updateContents()
void GuiBibtex::applyView() void GuiBibtex::applyView()
{ {
docstring dbs = qstring_to_ucs4(databaseLW->item(0)->text()); QString dbs = databaseLW->item(0)->text();
docstring emb = databaseLW->item(0)->checkState() == Qt::Checked ? _("true") : _("false"); docstring emb = databaseLW->item(0)->checkState() == Qt::Checked ? _("true") : _("false");
unsigned int maxCount = databaseLW->count(); unsigned int maxCount = databaseLW->count();
for (unsigned int i = 1; i < maxCount; i++) { for (unsigned int i = 1; i < maxCount; i++) {
dbs += ','; dbs += ',';
dbs += qstring_to_ucs4(databaseLW->item(i)->text()); dbs += databaseLW->item(i)->text();
emb += ','; emb += ',';
emb += databaseLW->item(i)->checkState() == Qt::Checked ? _("true") : _("false"); emb += databaseLW->item(i)->checkState() == Qt::Checked ? _("true") : _("false");
} }
params_["bibfiles"] = dbs; params_["bibfiles"] = qstring_to_ucs4(dbs);
params_["embed"] = emb; params_["embed"] = emb;
docstring const bibstyle = qstring_to_ucs4(styleCB->currentText()); docstring const bibstyle = qstring_to_ucs4(styleCB->currentText());
bool const bibtotoc = bibtocCB->isChecked(); bool const bibtotoc = bibtocCB->isChecked();
if (bibtotoc && (!bibstyle.empty())) { if (bibtotoc && !bibstyle.empty()) {
// both bibtotoc and style // both bibtotoc and style
params_["options"] = "bibtotoc," + bibstyle; params_["options"] = "bibtotoc," + bibstyle;
} else if (bibtotoc) { } else if (bibtotoc) {
@ -427,25 +428,23 @@ bool GuiBibtex::isValid()
} }
docstring const GuiBibtex::browseBib(docstring const & in_name) const QString GuiBibtex::browseBib(QString const & in_name) const
{ {
// FIXME UNICODE QString const label1 = qt_("Documents|#o#O");
docstring const label1 = _("Documents|#o#O"); QString const dir1 = toqstr(lyxrc.document_path);
docstring const dir1 = from_utf8(lyxrc.document_path);
FileFilterList const filter(_("BibTeX Databases (*.bib)")); FileFilterList const filter(_("BibTeX Databases (*.bib)"));
return browseRelFile(in_name, from_utf8(bufferFilepath()), return browseRelFile(in_name, bufferFilepath(),
_("Select a BibTeX database to add"), filter, false, label1, dir1); qt_("Select a BibTeX database to add"), filter, false, label1, dir1);
} }
docstring const GuiBibtex::browseBst(docstring const & in_name) const QString GuiBibtex::browseBst(QString const & in_name) const
{ {
// FIXME UNICODE QString const label1 = qt_("Documents|#o#O");
docstring const label1 = _("Documents|#o#O"); QString const dir1 = toqstr(lyxrc.document_path);
docstring const dir1 = from_utf8(lyxrc.document_path);
FileFilterList const filter(_("BibTeX Styles (*.bst)")); FileFilterList const filter(_("BibTeX Styles (*.bst)"));
return browseRelFile(in_name, from_utf8(bufferFilepath()), return browseRelFile(in_name, bufferFilepath(),
_("Select a BibTeX style"), filter, false, label1, dir1); qt_("Select a BibTeX style"), filter, false, label1, dir1);
} }

View File

@ -18,8 +18,7 @@
#include "ui_BibtexUi.h" #include "ui_BibtexUi.h"
#include "ui_BibtexAddUi.h" #include "ui_BibtexAddUi.h"
#include "support/docstring.h" #include <string>
#include <vector> #include <vector>
namespace lyx { namespace lyx {
@ -68,10 +67,10 @@ private:
void updateContents(); void updateContents();
/// Browse for a .bib file /// Browse for a .bib file
docstring const browseBib(docstring const & in_name) const; QString browseBib(QString const & in_name) const;
/// Browse for a .bst file /// Browse for a .bst file
docstring const browseBst(docstring const & in_name) const; QString browseBst(QString 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;

View File

@ -255,10 +255,10 @@ void GuiExternal::bbChanged()
void GuiExternal::browseClicked() void GuiExternal::browseClicked()
{ {
int const choice = externalCO->currentIndex(); int const choice = externalCO->currentIndex();
docstring const template_name = from_utf8(getTemplate(choice).lyxName); QString const template_name = toqstr(getTemplate(choice).lyxName);
docstring const str = browse(qstring_to_ucs4(fileED->text()), template_name); QString const str = browse(fileED->text(), template_name);
if (!str.empty()) { if (!str.isEmpty()) {
fileED->setText(toqstr(str)); fileED->setText(str);
changed(); changed();
} }
} }
@ -548,7 +548,7 @@ void GuiExternal::updateContents()
tab->setCurrentIndex(0); tab->setCurrentIndex(0);
string const name = string const name =
params_.filename.outputFilename(bufferFilepath()); params_.filename.outputFilename(fromqstr(bufferFilepath()));
fileED->setText(toqstr(name)); fileED->setText(toqstr(name));
embedCB->setCheckState(params_.filename.embedded() ? Qt::Checked : Qt::Unchecked); embedCB->setCheckState(params_.filename.embedded() ? Qt::Checked : Qt::Unchecked);
@ -632,7 +632,7 @@ void GuiExternal::updateTemplate()
void GuiExternal::applyView() void GuiExternal::applyView()
{ {
params_.filename.set(fromqstr(fileED->text()), bufferFilepath()); params_.filename.set(fromqstr(fileED->text()), fromqstr(bufferFilepath()));
params_.filename.setEmbed(embedCB->checkState() == Qt::Checked); params_.filename.setEmbed(embedCB->checkState() == Qt::Checked);
params_.settemplate(getTemplate(externalCO->currentIndex()).lyxName); params_.settemplate(getTemplate(externalCO->currentIndex()).lyxName);
@ -769,17 +769,16 @@ GuiExternal::getTemplateFilters(string const & template_name) const
} }
docstring const GuiExternal::browse(docstring const & input, QString GuiExternal::browse(QString const & input,
docstring const & template_name) const QString const & template_name) const
{ {
docstring const title = _("Select external file"); QString const title = qt_("Select external file");
QString const bufpath = bufferFilepath();
docstring const bufpath = from_utf8(bufferFilepath());
FileFilterList const filter = FileFilterList const filter =
FileFilterList(from_utf8(getTemplateFilters(to_utf8(template_name)))); FileFilterList(from_utf8(getTemplateFilters(fromqstr(template_name))));
docstring const label1 = _("Documents|#o#O"); QString const label1 = qt_("Documents|#o#O");
docstring const dir1 = from_utf8(lyxrc.document_path); QString const dir1 = toqstr(lyxrc.document_path);
return browseRelFile(input, bufpath, title, filter, false, label1, dir1); return browseRelFile(input, bufpath, title, filter, false, label1, dir1);
} }
@ -787,7 +786,7 @@ docstring const GuiExternal::browse(docstring const & input,
string const GuiExternal::readBB(string const & file) string const GuiExternal::readBB(string const & file)
{ {
FileName const abs_file(makeAbsPath(file, bufferFilepath())); FileName const abs_file(makeAbsPath(file, fromqstr(bufferFilepath())));
// try to get it from the file, if possible. Zipped files are // try to get it from the file, if possible. Zipped files are
// unzipped in the readBB_from_PSFile-Function // unzipped in the readBB_from_PSFile-Function

View File

@ -94,8 +94,8 @@ private:
std::string const std::string const
getTemplateFilters(std::string const & template_name) const; getTemplateFilters(std::string const & template_name) const;
/// ///
docstring const browse(docstring const & input_file, QString browse(QString const & input_file,
docstring const & template_name) const; QString const & template_name) const;
/// Read the Bounding Box from a eps or ps-file /// Read the Bounding Box from a eps or ps-file
std::string const readBB(std::string const & file); std::string const readBB(std::string const & file);

View File

@ -264,9 +264,9 @@ void GuiGraphics::change_bb()
void GuiGraphics::on_browsePB_clicked() void GuiGraphics::on_browsePB_clicked()
{ {
docstring const str = browse(qstring_to_ucs4(filename->text())); QString const str = browse(filename->text());
if (!str.empty()) { if (!str.isEmpty()) {
filename->setText(toqstr(str)); filename->setText(str);
changed(); changed();
} }
} }
@ -287,7 +287,7 @@ void GuiGraphics::on_editPB_clicked()
void GuiGraphics::on_filename_textChanged(const QString & filename) void GuiGraphics::on_filename_textChanged(const QString & filename)
{ {
editPB->setDisabled(filename.isEmpty()); editPB->setDisabled(filename.isEmpty());
EmbeddedFile file = EmbeddedFile(fromqstr(filename), bufferFilepath()); EmbeddedFile file = EmbeddedFile(fromqstr(filename), fromqstr(bufferFilepath()));
} }
@ -435,7 +435,7 @@ void GuiGraphics::updateContents()
} }
string const name = string const name =
igp.filename.outputFilename(bufferFilepath()); igp.filename.outputFilename(fromqstr(bufferFilepath()));
filename->setText(toqstr(name)); filename->setText(toqstr(name));
embedCB->setCheckState(igp.filename.embedded() ? Qt::Checked : Qt::Unchecked); embedCB->setCheckState(igp.filename.embedded() ? Qt::Checked : Qt::Unchecked);
@ -578,7 +578,7 @@ void GuiGraphics::applyView()
{ {
InsetGraphicsParams & igp = params_; InsetGraphicsParams & igp = params_;
igp.filename.set(fromqstr(filename->text()), bufferFilepath()); igp.filename.set(fromqstr(filename->text()), fromqstr(bufferFilepath()));
igp.filename.setEmbed(embedCB->checkState() == Qt::Checked); igp.filename.setEmbed(embedCB->checkState() == Qt::Checked);
// the bb section // the bb section
@ -718,9 +718,9 @@ void GuiGraphics::dispatchParams()
} }
docstring const GuiGraphics::browse(docstring const & in_name) const QString GuiGraphics::browse(QString const & in_name) const
{ {
docstring const title = _("Select graphics file"); QString const title = qt_("Select graphics file");
// Does user clipart directory exist? // Does user clipart directory exist?
string clipdir = addName(package().user_support().absFilename(), "clipart"); string clipdir = addName(package().user_support().absFilename(), "clipart");
@ -730,16 +730,16 @@ docstring const GuiGraphics::browse(docstring const & in_name) const
if (!(clip.exists() && clip.isDirectory())) if (!(clip.exists() && clip.isDirectory()))
clipdir = addName(package().system_support().absFilename(), "clipart"); clipdir = addName(package().system_support().absFilename(), "clipart");
return browseRelFile(in_name, from_utf8(bufferFilepath()), return browseRelFile(in_name, bufferFilepath(),
title, FileFilterList(), false, title, FileFilterList(), false,
_("Clipart|#C#c"), from_utf8(clipdir), qt_("Clipart|#C#c"), toqstr(clipdir),
_("Documents|#o#O"), from_utf8(lyxrc.document_path)); qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
} }
string const GuiGraphics::readBB(string const & file) string const GuiGraphics::readBB(string const & file)
{ {
FileName const abs_file = makeAbsPath(file, bufferFilepath()); FileName const abs_file = makeAbsPath(file, fromqstr(bufferFilepath()));
// try to get it from the file, if possible. Zipped files are // try to get it from the file, if possible. Zipped files are
// unzipped in the readBB_from_PSFile-Function // unzipped in the readBB_from_PSFile-Function
@ -768,7 +768,7 @@ string const GuiGraphics::readBB(string const & file)
bool GuiGraphics::isFilenameValid(string const & fname) const bool GuiGraphics::isFilenameValid(string const & fname) const
{ {
// It may be that the filename is relative. // It may be that the filename is relative.
return makeAbsPath(fname, bufferFilepath()).isReadableFile(); return makeAbsPath(fname, fromqstr(bufferFilepath())).isReadableFile();
} }
@ -784,7 +784,7 @@ void GuiGraphics::editGraphics()
namespace { namespace {
char const * const bb_units[] = { "bp", "cm", "mm", "in" }; char const * const bb_units[] = { "bp", "cm", "mm", "in" };
size_t const bb_size = sizeof(bb_units) / sizeof(char *); size_t const bb_size = sizeof(bb_units) / sizeof(bb_units[0]);
// These are the strings that are stored in the LyX file and which // These are the strings that are stored in the LyX file and which
// correspond to the LaTeX identifiers shown in the comments at the // correspond to the LaTeX identifiers shown in the comments at the

View File

@ -74,7 +74,7 @@ private:
bool isBufferDependent() const { return true; } bool isBufferDependent() const { return true; }
/// Browse for a file /// Browse for a file
docstring const browse(docstring const &) const; QString browse(QString const &) const;
/// Read the Bounding Box from a eps or ps-file /// Read the Bounding Box from a eps or ps-file
std::string const readBB(std::string const & file); std::string const readBB(std::string const & file);
/// Control the bb /// Control the bb

View File

@ -283,9 +283,9 @@ void GuiInclude::browse()
else else
type = LISTINGS; type = LISTINGS;
docstring const & name = browse(qstring_to_ucs4(filenameED->text()), type); QString name = browse(filenameED->text(), type);
if (!name.empty()) if (!name.isEmpty())
filenameED->setText(toqstr(name)); filenameED->setText(name);
} }
@ -305,9 +305,9 @@ bool GuiInclude::isValid()
} }
docstring GuiInclude::browse(docstring const & in_name, Type in_type) const QString GuiInclude::browse(QString const & in_name, Type in_type) const
{ {
docstring const title = _("Select document to include"); QString const title = qt_("Select document to include");
// input TeX, verbatim, or LyX file ? // input TeX, verbatim, or LyX file ?
FileFilterList filters; FileFilterList filters;
@ -321,10 +321,10 @@ docstring GuiInclude::browse(docstring const & in_name, Type in_type) const
break; break;
} }
docstring const docpath = from_utf8(support::onlyPath(buffer().absFileName())); QString const docpath = toqstr(support::onlyPath(buffer().absFileName()));
return browseRelFile(in_name, docpath, title, filters, false, return browseRelFile(in_name, docpath, title, filters, false,
_("Documents|#o#O"), from_utf8(lyxrc.document_path)); qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
} }

View File

@ -74,7 +74,7 @@ private:
/// ///
bool isBufferDependent() const { return true; } bool isBufferDependent() const { return true; }
/// Browse for a file /// Browse for a file
docstring browse(docstring const &, Type) const; QString browse(QString const &, Type) const;
}; };
} // namespace frontend } // namespace frontend

View File

@ -185,6 +185,8 @@ QString browseDir(QString const & pathname,
} }
} // namespace frontend
QString browseRelFile(QString const & filename, QString const & refpath, QString browseRelFile(QString const & filename, QString const & refpath,
QString const & title, FileFilterList const & filters, bool save, QString const & title, FileFilterList const & filters, bool save,
QString const & label1, QString const & dir1, QString const & label1, QString const & dir1,
@ -194,7 +196,7 @@ QString browseRelFile(QString const & filename, QString const & refpath,
fromqstr(filename), fromqstr(refpath)).absFilename()); fromqstr(filename), fromqstr(refpath)).absFilename());
QString const outname = QString const outname =
browseFile(fname, title, filters, save, label1, dir1, label2, dir2); frontend::browseFile(fname, title, filters, save, label1, dir1, label2, dir2);
QString const reloutname = QString const reloutname =
toqstr(makeRelPath(qstring_to_ucs4(outname), qstring_to_ucs4(refpath))); toqstr(makeRelPath(qstring_to_ucs4(outname), qstring_to_ucs4(refpath)));
@ -205,20 +207,6 @@ QString browseRelFile(QString const & filename, QString const & refpath,
return reloutname; return reloutname;
} }
} // namespace frontend
docstring browseRelFile(docstring const & filename, docstring const & refpath,
docstring const & title, FileFilterList const & filters, bool save,
docstring const & label1, docstring const & dir1,
docstring const & label2, docstring const & dir2)
{
return qstring_to_ucs4(frontend::browseRelFile(
toqstr(filename), toqstr(refpath),
toqstr(title), filters, save,
toqstr(label1), toqstr(dir1),
toqstr(label2), toqstr(dir2)));
}
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
// //

View File

@ -84,13 +84,10 @@ void GuiPrint::change_adaptor()
void GuiPrint::browseClicked() void GuiPrint::browseClicked()
{ {
docstring name = QString file =
browseRelFile(docstring(), from_utf8(buffer().filePath()), browseRelFile(QString(), bufferFilepath(), qt_("Print to file"),
_("Print to file"), FileFilterList(_("PostScript files (*.ps)")), true);
FileFilterList(_("PostScript files (*.ps)")), if (!file.isEmpty()) {
true);
QString file = toqstr(name);
if (!file.isNull()) {
fileED->setText(file); fileED->setText(file);
changed(); changed();
} }

View File

@ -20,7 +20,6 @@
#include "Dialog.h" #include "Dialog.h"
#include "PrinterParams.h" #include "PrinterParams.h"
#include "support/docstring.h"
namespace lyx { namespace lyx {
namespace frontend { namespace frontend {

View File

@ -84,15 +84,15 @@ std::vector<LanguagePair> const getLanguageData(bool character_dlg);
of the form "../baz/foo.txt", an absolute path is returned. This is of the form "../baz/foo.txt", an absolute path is returned. This is
intended to be useful for insets which encapsulate files/ intended to be useful for insets which encapsulate files/
*/ */
docstring browseRelFile(docstring const & filename, QString browseRelFile(QString const & filename,
docstring const & refpath, QString const & refpath,
docstring const & title, QString const & title,
support::FileFilterList const & filters, support::FileFilterList const & filters,
bool save = false, bool save = false,
docstring const & label1 = docstring(), QString const & label1 = QString(),
docstring const & dir1 = docstring(), QString const & dir1 = QString(),
docstring const & label2 = docstring(), QString const & label2 = QString(),
docstring const & dir2 = docstring()); QString const & dir2 = QString());
/** Build filelists of all availabe bst/cls/sty-files. Done through /** Build filelists of all availabe bst/cls/sty-files. Done through