From 990df4924a00309f49f89466179fc46ad1b382c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Thu, 6 Mar 2008 00:07:19 +0000 Subject: [PATCH] more of that git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23497 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/Dialog.cpp | 4 +- src/frontends/qt4/Dialog.h | 2 +- src/frontends/qt4/GuiBibtex.cpp | 103 +++++++++++++++--------------- src/frontends/qt4/GuiBibtex.h | 7 +- src/frontends/qt4/GuiExternal.cpp | 29 ++++----- src/frontends/qt4/GuiExternal.h | 4 +- src/frontends/qt4/GuiGraphics.cpp | 28 ++++---- src/frontends/qt4/GuiGraphics.h | 2 +- src/frontends/qt4/GuiInclude.cpp | 14 ++-- src/frontends/qt4/GuiInclude.h | 2 +- src/frontends/qt4/GuiPrefs.cpp | 18 +----- src/frontends/qt4/GuiPrint.cpp | 11 ++-- src/frontends/qt4/GuiPrint.h | 1 - src/frontends/qt4/qt_helpers.h | 14 ++-- 14 files changed, 110 insertions(+), 129 deletions(-) diff --git a/src/frontends/qt4/Dialog.cpp b/src/frontends/qt4/Dialog.cpp index 7df839d56c..5c37b23241 100644 --- a/src/frontends/qt4/Dialog.cpp +++ b/src/frontends/qt4/Dialog.cpp @@ -86,9 +86,9 @@ bool Dialog::isBufferReadonly() const } -string const Dialog::bufferFilepath() const +QString Dialog::bufferFilepath() const { - return buffer().filePath(); + return toqstr(buffer().filePath()); } diff --git a/src/frontends/qt4/Dialog.h b/src/frontends/qt4/Dialog.h index 7b96d65390..45570893bc 100644 --- a/src/frontends/qt4/Dialog.h +++ b/src/frontends/qt4/Dialog.h @@ -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. diff --git a/src/frontends/qt4/GuiBibtex.cpp b/src/frontends/qt4/GuiBibtex.cpp index 69aebc4961..15d84ea45c 100644 --- a/src/frontends/qt4/GuiBibtex.cpp +++ b/src/frontends/qt4/GuiBibtex.cpp @@ -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 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); } diff --git a/src/frontends/qt4/GuiBibtex.h b/src/frontends/qt4/GuiBibtex.h index 9bac17bc45..e9d5b0b4fe 100644 --- a/src/frontends/qt4/GuiBibtex.h +++ b/src/frontends/qt4/GuiBibtex.h @@ -18,8 +18,7 @@ #include "ui_BibtexUi.h" #include "ui_BibtexAddUi.h" -#include "support/docstring.h" - +#include #include 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 & data) const; diff --git a/src/frontends/qt4/GuiExternal.cpp b/src/frontends/qt4/GuiExternal.cpp index cd17d2d2f6..8f6d54f2bd 100644 --- a/src/frontends/qt4/GuiExternal.cpp +++ b/src/frontends/qt4/GuiExternal.cpp @@ -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 diff --git a/src/frontends/qt4/GuiExternal.h b/src/frontends/qt4/GuiExternal.h index dd591e3f14..3baa7a08d6 100644 --- a/src/frontends/qt4/GuiExternal.h +++ b/src/frontends/qt4/GuiExternal.h @@ -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); diff --git a/src/frontends/qt4/GuiGraphics.cpp b/src/frontends/qt4/GuiGraphics.cpp index b7286edbce..f9bd9e5d5b 100644 --- a/src/frontends/qt4/GuiGraphics.cpp +++ b/src/frontends/qt4/GuiGraphics.cpp @@ -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 diff --git a/src/frontends/qt4/GuiGraphics.h b/src/frontends/qt4/GuiGraphics.h index b544c5308c..2e8e2235e0 100644 --- a/src/frontends/qt4/GuiGraphics.h +++ b/src/frontends/qt4/GuiGraphics.h @@ -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 diff --git a/src/frontends/qt4/GuiInclude.cpp b/src/frontends/qt4/GuiInclude.cpp index 2b25fea23f..b728efcafe 100644 --- a/src/frontends/qt4/GuiInclude.cpp +++ b/src/frontends/qt4/GuiInclude.cpp @@ -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)); } diff --git a/src/frontends/qt4/GuiInclude.h b/src/frontends/qt4/GuiInclude.h index df33c26ee2..0d66d92e92 100644 --- a/src/frontends/qt4/GuiInclude.h +++ b/src/frontends/qt4/GuiInclude.h @@ -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 diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index ff90e69ca2..ff288c34da 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -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))); -} - ///////////////////////////////////////////////////////////////////// // diff --git a/src/frontends/qt4/GuiPrint.cpp b/src/frontends/qt4/GuiPrint.cpp index 80e2152a99..ed8898126c 100644 --- a/src/frontends/qt4/GuiPrint.cpp +++ b/src/frontends/qt4/GuiPrint.cpp @@ -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(); } diff --git a/src/frontends/qt4/GuiPrint.h b/src/frontends/qt4/GuiPrint.h index 3d793500fc..332ede8021 100644 --- a/src/frontends/qt4/GuiPrint.h +++ b/src/frontends/qt4/GuiPrint.h @@ -20,7 +20,6 @@ #include "Dialog.h" #include "PrinterParams.h" -#include "support/docstring.h" namespace lyx { namespace frontend { diff --git a/src/frontends/qt4/qt_helpers.h b/src/frontends/qt4/qt_helpers.h index 216e876fa2..920cc9c8a4 100644 --- a/src/frontends/qt4/qt_helpers.h +++ b/src/frontends/qt4/qt_helpers.h @@ -84,15 +84,15 @@ std::vector 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