mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-03 14:13:58 +00:00
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:
parent
ca4d221248
commit
990df4924a
@ -86,9 +86,9 @@ bool Dialog::isBufferReadonly() const
|
||||
}
|
||||
|
||||
|
||||
string const Dialog::bufferFilepath() const
|
||||
QString Dialog::bufferFilepath() const
|
||||
{
|
||||
return buffer().filePath();
|
||||
return toqstr(buffer().filePath());
|
||||
}
|
||||
|
||||
|
||||
|
@ -227,7 +227,7 @@ public:
|
||||
//@{
|
||||
bool isBufferAvailable() const;
|
||||
bool isBufferReadonly() const;
|
||||
std::string const bufferFilepath() const;
|
||||
QString bufferFilepath() const;
|
||||
//@}
|
||||
|
||||
/// The type of the current buffer.
|
||||
|
@ -128,51 +128,52 @@ void GuiBibtex::change_adaptor()
|
||||
|
||||
void GuiBibtex::browsePressed()
|
||||
{
|
||||
docstring const file = browseBst(docstring());
|
||||
QString const file = browseBst(QString());
|
||||
|
||||
if (!file.empty()) {
|
||||
// FIXME UNICODE
|
||||
docstring const filen = from_utf8(changeExtension(to_utf8(file), ""));
|
||||
bool present = false;
|
||||
unsigned int pres = 0;
|
||||
if (file.isEmpty())
|
||||
return;
|
||||
|
||||
for (int i = 0; i != styleCB->count(); ++i) {
|
||||
if (qstring_to_ucs4(styleCB->itemText(i)) == filen) {
|
||||
present = true;
|
||||
pres = i;
|
||||
}
|
||||
// FIXME UNICODE
|
||||
QString const filen = toqstr(changeExtension(fromqstr(file), ""));
|
||||
bool present = false;
|
||||
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()
|
||||
{
|
||||
docstring const file = trim(browseBib(docstring()));
|
||||
QString const file = browseBib(QString()).trimmed();
|
||||
|
||||
if (!file.empty()) {
|
||||
// FIXME UNICODE
|
||||
QString const f = toqstr(changeExtension(to_utf8(file), ""));
|
||||
bool present = false;
|
||||
if (file.isEmpty())
|
||||
return;
|
||||
|
||||
for (int i = 0; i < add_->bibLW->count(); ++i) {
|
||||
if (add_->bibLW->item(i)->text() == f)
|
||||
present = true;
|
||||
}
|
||||
QString const f = toqstr(changeExtension(fromqstr(file), ""));
|
||||
bool present = false;
|
||||
|
||||
if (!present) {
|
||||
add_->bibLW->addItem(f);
|
||||
changed();
|
||||
}
|
||||
|
||||
add_->bibED->setText(f);
|
||||
for (int i = 0; i < add_->bibLW->count(); ++i) {
|
||||
if (add_->bibLW->item(i)->text() == f)
|
||||
present = true;
|
||||
}
|
||||
|
||||
if (!present) {
|
||||
add_->bibLW->addItem(f);
|
||||
changed();
|
||||
}
|
||||
|
||||
add_->bibED->setText(f);
|
||||
}
|
||||
|
||||
|
||||
@ -186,9 +187,9 @@ void GuiBibtex::addPressed()
|
||||
void GuiBibtex::addDatabase()
|
||||
{
|
||||
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;
|
||||
|
||||
// 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();
|
||||
QString const f = toqstr(from_utf8(changeExtension(to_utf8(file), "")));
|
||||
QString const f = toqstr(changeExtension(fromqstr(file), ""));
|
||||
QList<QListWidgetItem *> matches =
|
||||
databaseLW->findItems(f, Qt::MatchExactly);
|
||||
if (matches.empty()) {
|
||||
@ -359,24 +360,24 @@ void GuiBibtex::updateContents()
|
||||
|
||||
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");
|
||||
|
||||
unsigned int maxCount = databaseLW->count();
|
||||
for (unsigned int i = 1; i < maxCount; i++) {
|
||||
dbs += ',';
|
||||
dbs += qstring_to_ucs4(databaseLW->item(i)->text());
|
||||
dbs += databaseLW->item(i)->text();
|
||||
emb += ',';
|
||||
emb += databaseLW->item(i)->checkState() == Qt::Checked ? _("true") : _("false");
|
||||
}
|
||||
|
||||
params_["bibfiles"] = dbs;
|
||||
params_["bibfiles"] = qstring_to_ucs4(dbs);
|
||||
params_["embed"] = emb;
|
||||
|
||||
docstring const bibstyle = qstring_to_ucs4(styleCB->currentText());
|
||||
bool const bibtotoc = bibtocCB->isChecked();
|
||||
|
||||
if (bibtotoc && (!bibstyle.empty())) {
|
||||
if (bibtotoc && !bibstyle.empty()) {
|
||||
// both bibtotoc and style
|
||||
params_["options"] = "bibtotoc," + bibstyle;
|
||||
} 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
|
||||
docstring const label1 = _("Documents|#o#O");
|
||||
docstring const dir1 = from_utf8(lyxrc.document_path);
|
||||
QString const label1 = qt_("Documents|#o#O");
|
||||
QString const dir1 = toqstr(lyxrc.document_path);
|
||||
FileFilterList const filter(_("BibTeX Databases (*.bib)"));
|
||||
return browseRelFile(in_name, from_utf8(bufferFilepath()),
|
||||
_("Select a BibTeX database to add"), filter, false, label1, dir1);
|
||||
return browseRelFile(in_name, bufferFilepath(),
|
||||
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
|
||||
docstring const label1 = _("Documents|#o#O");
|
||||
docstring const dir1 = from_utf8(lyxrc.document_path);
|
||||
QString const label1 = qt_("Documents|#o#O");
|
||||
QString const dir1 = toqstr(lyxrc.document_path);
|
||||
FileFilterList const filter(_("BibTeX Styles (*.bst)"));
|
||||
return browseRelFile(in_name, from_utf8(bufferFilepath()),
|
||||
_("Select a BibTeX style"), filter, false, label1, dir1);
|
||||
return browseRelFile(in_name, bufferFilepath(),
|
||||
qt_("Select a BibTeX style"), filter, false, label1, dir1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,8 +18,7 @@
|
||||
#include "ui_BibtexUi.h"
|
||||
#include "ui_BibtexAddUi.h"
|
||||
|
||||
#include "support/docstring.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace lyx {
|
||||
@ -68,10 +67,10 @@ private:
|
||||
void updateContents();
|
||||
|
||||
/// 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
|
||||
docstring const browseBst(docstring const & in_name) const;
|
||||
QString browseBst(QString const & in_name) const;
|
||||
|
||||
/// get the list of bst files
|
||||
void getBibStyles(std::vector<std::string> & data) const;
|
||||
|
@ -255,10 +255,10 @@ void GuiExternal::bbChanged()
|
||||
void GuiExternal::browseClicked()
|
||||
{
|
||||
int const choice = externalCO->currentIndex();
|
||||
docstring const template_name = from_utf8(getTemplate(choice).lyxName);
|
||||
docstring const str = browse(qstring_to_ucs4(fileED->text()), template_name);
|
||||
if (!str.empty()) {
|
||||
fileED->setText(toqstr(str));
|
||||
QString const template_name = toqstr(getTemplate(choice).lyxName);
|
||||
QString const str = browse(fileED->text(), template_name);
|
||||
if (!str.isEmpty()) {
|
||||
fileED->setText(str);
|
||||
changed();
|
||||
}
|
||||
}
|
||||
@ -548,7 +548,7 @@ void GuiExternal::updateContents()
|
||||
tab->setCurrentIndex(0);
|
||||
|
||||
string const name =
|
||||
params_.filename.outputFilename(bufferFilepath());
|
||||
params_.filename.outputFilename(fromqstr(bufferFilepath()));
|
||||
fileED->setText(toqstr(name));
|
||||
embedCB->setCheckState(params_.filename.embedded() ? Qt::Checked : Qt::Unchecked);
|
||||
|
||||
@ -632,7 +632,7 @@ void GuiExternal::updateTemplate()
|
||||
|
||||
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_.settemplate(getTemplate(externalCO->currentIndex()).lyxName);
|
||||
@ -769,17 +769,16 @@ GuiExternal::getTemplateFilters(string const & template_name) const
|
||||
}
|
||||
|
||||
|
||||
docstring const GuiExternal::browse(docstring const & input,
|
||||
docstring const & template_name) const
|
||||
QString GuiExternal::browse(QString const & input,
|
||||
QString const & template_name) const
|
||||
{
|
||||
docstring const title = _("Select external file");
|
||||
|
||||
docstring const bufpath = from_utf8(bufferFilepath());
|
||||
QString const title = qt_("Select external file");
|
||||
QString const bufpath = bufferFilepath();
|
||||
FileFilterList const filter =
|
||||
FileFilterList(from_utf8(getTemplateFilters(to_utf8(template_name))));
|
||||
FileFilterList(from_utf8(getTemplateFilters(fromqstr(template_name))));
|
||||
|
||||
docstring const label1 = _("Documents|#o#O");
|
||||
docstring const dir1 = from_utf8(lyxrc.document_path);
|
||||
QString const label1 = qt_("Documents|#o#O");
|
||||
QString const dir1 = toqstr(lyxrc.document_path);
|
||||
|
||||
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)
|
||||
{
|
||||
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
|
||||
// unzipped in the readBB_from_PSFile-Function
|
||||
|
@ -94,8 +94,8 @@ private:
|
||||
std::string const
|
||||
getTemplateFilters(std::string const & template_name) const;
|
||||
///
|
||||
docstring const browse(docstring const & input_file,
|
||||
docstring const & template_name) const;
|
||||
QString browse(QString const & input_file,
|
||||
QString const & template_name) const;
|
||||
|
||||
/// Read the Bounding Box from a eps or ps-file
|
||||
std::string const readBB(std::string const & file);
|
||||
|
@ -264,9 +264,9 @@ void GuiGraphics::change_bb()
|
||||
|
||||
void GuiGraphics::on_browsePB_clicked()
|
||||
{
|
||||
docstring const str = browse(qstring_to_ucs4(filename->text()));
|
||||
if (!str.empty()) {
|
||||
filename->setText(toqstr(str));
|
||||
QString const str = browse(filename->text());
|
||||
if (!str.isEmpty()) {
|
||||
filename->setText(str);
|
||||
changed();
|
||||
}
|
||||
}
|
||||
@ -287,7 +287,7 @@ void GuiGraphics::on_editPB_clicked()
|
||||
void GuiGraphics::on_filename_textChanged(const QString & filename)
|
||||
{
|
||||
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 =
|
||||
igp.filename.outputFilename(bufferFilepath());
|
||||
igp.filename.outputFilename(fromqstr(bufferFilepath()));
|
||||
filename->setText(toqstr(name));
|
||||
embedCB->setCheckState(igp.filename.embedded() ? Qt::Checked : Qt::Unchecked);
|
||||
|
||||
@ -578,7 +578,7 @@ void GuiGraphics::applyView()
|
||||
{
|
||||
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);
|
||||
|
||||
// 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?
|
||||
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()))
|
||||
clipdir = addName(package().system_support().absFilename(), "clipart");
|
||||
|
||||
return browseRelFile(in_name, from_utf8(bufferFilepath()),
|
||||
return browseRelFile(in_name, bufferFilepath(),
|
||||
title, FileFilterList(), false,
|
||||
_("Clipart|#C#c"), from_utf8(clipdir),
|
||||
_("Documents|#o#O"), from_utf8(lyxrc.document_path));
|
||||
qt_("Clipart|#C#c"), toqstr(clipdir),
|
||||
qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
// 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
|
||||
{
|
||||
// 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 {
|
||||
|
||||
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
|
||||
// correspond to the LaTeX identifiers shown in the comments at the
|
||||
|
@ -74,7 +74,7 @@ private:
|
||||
bool isBufferDependent() const { return true; }
|
||||
|
||||
/// 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
|
||||
std::string const readBB(std::string const & file);
|
||||
/// Control the bb
|
||||
|
@ -283,9 +283,9 @@ void GuiInclude::browse()
|
||||
else
|
||||
type = LISTINGS;
|
||||
|
||||
docstring const & name = browse(qstring_to_ucs4(filenameED->text()), type);
|
||||
if (!name.empty())
|
||||
filenameED->setText(toqstr(name));
|
||||
QString name = browse(filenameED->text(), type);
|
||||
if (!name.isEmpty())
|
||||
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 ?
|
||||
FileFilterList filters;
|
||||
@ -321,10 +321,10 @@ docstring GuiInclude::browse(docstring const & in_name, Type in_type) const
|
||||
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,
|
||||
_("Documents|#o#O"), from_utf8(lyxrc.document_path));
|
||||
qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
|
||||
}
|
||||
|
||||
|
||||
|
@ -74,7 +74,7 @@ private:
|
||||
///
|
||||
bool isBufferDependent() const { return true; }
|
||||
/// Browse for a file
|
||||
docstring browse(docstring const &, Type) const;
|
||||
QString browse(QString const &, Type) const;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
|
@ -185,6 +185,8 @@ QString browseDir(QString const & pathname,
|
||||
}
|
||||
|
||||
|
||||
} // namespace frontend
|
||||
|
||||
QString browseRelFile(QString const & filename, QString const & refpath,
|
||||
QString const & title, FileFilterList const & filters, bool save,
|
||||
QString const & label1, QString const & dir1,
|
||||
@ -194,7 +196,7 @@ QString browseRelFile(QString const & filename, QString const & refpath,
|
||||
fromqstr(filename), fromqstr(refpath)).absFilename());
|
||||
|
||||
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 =
|
||||
toqstr(makeRelPath(qstring_to_ucs4(outname), qstring_to_ucs4(refpath)));
|
||||
@ -205,20 +207,6 @@ QString browseRelFile(QString const & filename, QString const & refpath,
|
||||
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)));
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
@ -84,13 +84,10 @@ void GuiPrint::change_adaptor()
|
||||
|
||||
void GuiPrint::browseClicked()
|
||||
{
|
||||
docstring name =
|
||||
browseRelFile(docstring(), from_utf8(buffer().filePath()),
|
||||
_("Print to file"),
|
||||
FileFilterList(_("PostScript files (*.ps)")),
|
||||
true);
|
||||
QString file = toqstr(name);
|
||||
if (!file.isNull()) {
|
||||
QString file =
|
||||
browseRelFile(QString(), bufferFilepath(), qt_("Print to file"),
|
||||
FileFilterList(_("PostScript files (*.ps)")), true);
|
||||
if (!file.isEmpty()) {
|
||||
fileED->setText(file);
|
||||
changed();
|
||||
}
|
||||
|
@ -20,7 +20,6 @@
|
||||
|
||||
#include "Dialog.h"
|
||||
#include "PrinterParams.h"
|
||||
#include "support/docstring.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
@ -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
|
||||
intended to be useful for insets which encapsulate files/
|
||||
*/
|
||||
docstring browseRelFile(docstring const & filename,
|
||||
docstring const & refpath,
|
||||
docstring const & title,
|
||||
QString browseRelFile(QString const & filename,
|
||||
QString const & refpath,
|
||||
QString const & title,
|
||||
support::FileFilterList const & filters,
|
||||
bool save = false,
|
||||
docstring const & label1 = docstring(),
|
||||
docstring const & dir1 = docstring(),
|
||||
docstring const & label2 = docstring(),
|
||||
docstring const & dir2 = docstring());
|
||||
QString const & label1 = QString(),
|
||||
QString const & dir1 = QString(),
|
||||
QString const & label2 = QString(),
|
||||
QString const & dir2 = QString());
|
||||
|
||||
|
||||
/** Build filelists of all availabe bst/cls/sty-files. Done through
|
||||
|
Loading…
Reference in New Issue
Block a user