mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-29 21:05:12 +00:00
This commit is converting everything related to browsing to unicode (qt4 only).
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15293 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
41d7e4c394
commit
f5f4b31f4a
@ -1369,6 +1369,7 @@ void BufferView::menuInsertLyXFile(string const & filenm)
|
||||
|
||||
if (filename.empty()) {
|
||||
// Launch a file browser
|
||||
// FIXME UNICODE
|
||||
string initpath = lyxrc.document_path;
|
||||
|
||||
if (buffer_) {
|
||||
@ -1378,22 +1379,22 @@ void BufferView::menuInsertLyXFile(string const & filenm)
|
||||
initpath = trypath;
|
||||
}
|
||||
|
||||
FileDialog fileDlg(lyx::to_utf8(_("Select LyX document to insert")),
|
||||
// FIXME UNICODE
|
||||
FileDialog fileDlg(_("Select LyX document to insert"),
|
||||
LFUN_FILE_INSERT,
|
||||
make_pair(string(lyx::to_utf8(_("Documents|#o#O"))),
|
||||
string(lyxrc.document_path)),
|
||||
make_pair(string(lyx::to_utf8(_("Examples|#E#e"))),
|
||||
string(addPath(package().system_support(), "examples"))));
|
||||
make_pair(_("Documents|#o#O"), lyx::from_utf8(lyxrc.document_path)),
|
||||
make_pair(_("Examples|#E#e"), lyx::from_utf8(addPath(package().system_support(), "examples"))));
|
||||
|
||||
FileDialog::Result result =
|
||||
fileDlg.open(initpath,
|
||||
FileFilterList(lyx::to_utf8(_("LyX Documents (*.lyx)"))),
|
||||
string());
|
||||
fileDlg.open(lyx::from_utf8(initpath),
|
||||
FileFilterList(_("LyX Documents (*.lyx)")),
|
||||
docstring());
|
||||
|
||||
if (result.first == FileDialog::Later)
|
||||
return;
|
||||
|
||||
filename = result.second;
|
||||
// FIXME UNICODE
|
||||
filename = lyx::to_utf8(result.second);
|
||||
|
||||
// check selected filename
|
||||
if (filename.empty()) {
|
||||
|
@ -15,6 +15,8 @@
|
||||
|
||||
#include "lfuns.h"
|
||||
|
||||
#include "support/docstring.h"
|
||||
|
||||
#include <utility>
|
||||
#include <string>
|
||||
|
||||
@ -37,7 +39,7 @@ class FileDialog
|
||||
{
|
||||
public:
|
||||
/// label, directory path button
|
||||
typedef std::pair<std::string, std::string> Button;
|
||||
typedef std::pair<lyx::docstring, lyx::docstring> Button;
|
||||
|
||||
/// result type
|
||||
enum ResultType {
|
||||
@ -46,7 +48,7 @@ public:
|
||||
};
|
||||
|
||||
/// result return
|
||||
typedef std::pair<FileDialog::ResultType, std::string> Result;
|
||||
typedef std::pair<FileDialog::ResultType, lyx::docstring> Result;
|
||||
|
||||
/**
|
||||
* Constructs a file dialog with title \param title.
|
||||
@ -59,27 +61,27 @@ public:
|
||||
* additional directories in the navigation (an empty
|
||||
* directory is interpreted as getcwd())
|
||||
*/
|
||||
FileDialog(std::string const & title,
|
||||
FileDialog(lyx::docstring const & title,
|
||||
kb_action a = LFUN_SELECT_FILE_SYNC,
|
||||
Button b1 = Button(std::string(), std::string()),
|
||||
Button b2 = Button(std::string(), std::string()));
|
||||
Button b1 = Button(lyx::docstring(), lyx::docstring()),
|
||||
Button b2 = Button(lyx::docstring(), lyx::docstring()));
|
||||
|
||||
|
||||
~FileDialog();
|
||||
|
||||
/// Choose a file for opening, starting in directory \c path.
|
||||
Result const open(std::string const & path,
|
||||
Result const open(lyx::docstring const & path,
|
||||
lyx::support::FileFilterList const & filters,
|
||||
std::string const & suggested);
|
||||
lyx::docstring const & suggested);
|
||||
|
||||
/// Choose a directory, starting in directory \c path.
|
||||
Result const opendir(std::string const & path = std::string(),
|
||||
std::string const & suggested = std::string());
|
||||
Result const opendir(lyx::docstring const & path = lyx::docstring(),
|
||||
lyx::docstring const & suggested = lyx::docstring());
|
||||
|
||||
/// Choose a file for saving, starting in directory \c path.
|
||||
Result const save(std::string const & path,
|
||||
Result const save(lyx::docstring const & path,
|
||||
lyx::support::FileFilterList const & filters,
|
||||
std::string const & suggested);
|
||||
lyx::docstring const & suggested);
|
||||
|
||||
private:
|
||||
class Private;
|
||||
@ -87,7 +89,7 @@ private:
|
||||
Private * private_;
|
||||
|
||||
/// the dialog title
|
||||
std::string title_;
|
||||
lyx::docstring title_;
|
||||
|
||||
/// success action to perform if not synchronous
|
||||
kb_action success_;
|
||||
|
@ -48,26 +48,26 @@ ControlBibtex::ControlBibtex(Dialog & d)
|
||||
{}
|
||||
|
||||
|
||||
string const ControlBibtex::browseBib(string const & in_name) const
|
||||
docstring const ControlBibtex::browseBib(docstring const & in_name) const
|
||||
{
|
||||
// FIXME UNICODE
|
||||
pair<string, string> dir1(lyx::to_utf8(_("Documents|#o#O")),
|
||||
string(lyxrc.document_path));
|
||||
FileFilterList const filter(lyx::to_utf8(_("BibTeX Databases (*.bib)")));
|
||||
return browseRelFile(in_name, kernel().bufferFilepath(),
|
||||
lyx::to_utf8(_("Select a BibTeX database to add")),
|
||||
pair<docstring, docstring> dir1(_("Documents|#o#O"),
|
||||
lyx::from_utf8(lyxrc.document_path));
|
||||
FileFilterList const filter(_("BibTeX Databases (*.bib)"));
|
||||
return browseRelFile(in_name, lyx::from_utf8(kernel().bufferFilepath()),
|
||||
_("Select a BibTeX database to add"),
|
||||
filter, false, dir1);
|
||||
}
|
||||
|
||||
|
||||
string const ControlBibtex::browseBst(string const & in_name) const
|
||||
docstring const ControlBibtex::browseBst(docstring const & in_name) const
|
||||
{
|
||||
// FIXME UNICODE
|
||||
pair<string, string> dir1(lyx::to_utf8(_("Documents|#o#O")),
|
||||
string(lyxrc.document_path));
|
||||
FileFilterList const filter(lyx::to_utf8(_("BibTeX Styles (*.bst)")));
|
||||
return browseRelFile(in_name, kernel().bufferFilepath(),
|
||||
lyx::to_utf8(_("Select a BibTeX style")), filter, false, dir1);
|
||||
pair<docstring, docstring> dir1(_("Documents|#o#O"),
|
||||
lyx::from_utf8(lyxrc.document_path));
|
||||
FileFilterList const filter(_("BibTeX Styles (*.bst)"));
|
||||
return browseRelFile(in_name, lyx::from_utf8(kernel().bufferFilepath()),
|
||||
_("Select a BibTeX style"), filter, false, dir1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,6 +14,9 @@
|
||||
#define CONTROLBIBTEX_H
|
||||
|
||||
#include "ControlCommand.h"
|
||||
|
||||
#include "support/docstring.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace lyx {
|
||||
@ -34,10 +37,10 @@ public:
|
||||
ControlBibtex(Dialog &);
|
||||
|
||||
/// Browse for a .bib file
|
||||
std::string const browseBib(std::string const & in_name) const;
|
||||
lyx::docstring const browseBib(lyx::docstring const & in_name) const;
|
||||
|
||||
/// Browse for a .bst file
|
||||
std::string const browseBst(std::string const & in_name) const;
|
||||
lyx::docstring const browseBst(lyx::docstring const & in_name) const;
|
||||
|
||||
/// get the list of bst files
|
||||
void getBibStyles(std::vector<std::string> & data) const;
|
||||
|
@ -156,17 +156,17 @@ ControlExternal::getTemplateFilters(string const & template_name) const
|
||||
}
|
||||
|
||||
|
||||
string const ControlExternal::browse(string const & input,
|
||||
string const & template_name) const
|
||||
docstring const ControlExternal::browse(docstring const & input,
|
||||
docstring const & template_name) const
|
||||
{
|
||||
string const title = lyx::to_utf8(_("Select external file"));
|
||||
docstring const title = _("Select external file");
|
||||
|
||||
string const bufpath = kernel().bufferFilepath();
|
||||
docstring const bufpath = lyx::from_utf8(kernel().bufferFilepath());
|
||||
FileFilterList const filter =
|
||||
FileFilterList(getTemplateFilters(template_name));
|
||||
FileFilterList(lyx::from_utf8(getTemplateFilters(lyx::to_utf8(template_name))));
|
||||
|
||||
std::pair<string, string> dir1(N_("Documents|#o#O"),
|
||||
string(lyxrc.document_path));
|
||||
std::pair<docstring, docstring> dir1(_("Documents|#o#O"),
|
||||
lyx::from_utf8(lyxrc.document_path));
|
||||
|
||||
return browseRelFile(input, bufpath, title, filter, false, dir1);
|
||||
}
|
||||
|
@ -68,8 +68,8 @@ public:
|
||||
std::string const
|
||||
getTemplateFilters(std::string const & template_name) const;
|
||||
///
|
||||
std::string const browse(std::string const & input_file,
|
||||
std::string const & template_name) const;
|
||||
lyx::docstring const browse(lyx::docstring const & input_file,
|
||||
lyx::docstring const & template_name) const;
|
||||
|
||||
/// Read the Bounding Box from a eps or ps-file
|
||||
std::string const readBB(std::string const & file);
|
||||
|
@ -81,20 +81,20 @@ void ControlGraphics::dispatchParams()
|
||||
}
|
||||
|
||||
|
||||
string const ControlGraphics::browse(string const & in_name) const
|
||||
docstring const ControlGraphics::browse(docstring const & in_name) const
|
||||
{
|
||||
// FIXME UNICODE
|
||||
string const title = lyx::to_utf8(_("Select graphics file"));
|
||||
docstring const title = _("Select graphics file");
|
||||
|
||||
// Does user clipart directory exist?
|
||||
string clipdir = addName(package().user_support(), "clipart");
|
||||
if (!(fs::exists(clipdir) && fs::is_directory(clipdir)))
|
||||
// No - bail out to system clipart directory
|
||||
clipdir = addName(package().system_support(), "clipart");
|
||||
pair<string, string> dir1(lyx::to_utf8(_("Clipart|#C#c")), clipdir);
|
||||
pair<string, string> dir2(lyx::to_utf8(_("Documents|#o#O")), string(lyxrc.document_path));
|
||||
pair<docstring, docstring> dir1(_("Clipart|#C#c"), lyx::from_utf8(clipdir));
|
||||
pair<docstring, docstring> dir2(_("Documents|#o#O"), lyx::from_utf8(lyxrc.document_path));
|
||||
// Show the file browser dialog
|
||||
return browseRelFile(in_name, kernel().bufferFilepath(),
|
||||
return browseRelFile(in_name, lyx::from_utf8(kernel().bufferFilepath()),
|
||||
title,
|
||||
FileFilterList(),
|
||||
false, dir1, dir2);
|
||||
|
@ -16,6 +16,9 @@
|
||||
|
||||
|
||||
#include "Dialog.h"
|
||||
|
||||
#include "support/docstring.h"
|
||||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@ -46,7 +49,7 @@ public:
|
||||
InsetGraphicsParams const & params() const { return *params_.get(); }
|
||||
|
||||
/// Browse for a file
|
||||
std::string const browse(std::string const &) const;
|
||||
lyx::docstring const browse(lyx::docstring const &) const;
|
||||
/// Read the Bounding Box from a eps or ps-file
|
||||
std::string const readBB(std::string const & file);
|
||||
/// Control the bb
|
||||
|
@ -72,27 +72,25 @@ void ControlInclude::setParams(InsetCommandParams const & params)
|
||||
}
|
||||
|
||||
|
||||
string const ControlInclude::browse(string const & in_name, Type in_type) const
|
||||
docstring const ControlInclude::browse(docstring const & in_name, Type in_type) const
|
||||
{
|
||||
// FIXME UNICODE
|
||||
string const title = lyx::to_utf8(_("Select document to include"));
|
||||
docstring const title = _("Select document to include");
|
||||
|
||||
// input TeX, verbatim, or LyX file ?
|
||||
FileFilterList filters;
|
||||
switch (in_type) {
|
||||
case INCLUDE:
|
||||
case INPUT:
|
||||
// FIXME UNICODE
|
||||
filters = FileFilterList(lyx::to_utf8(_("LaTeX/LyX Documents (*.tex *.lyx)")));
|
||||
filters = FileFilterList(_("LaTeX/LyX Documents (*.tex *.lyx)"));
|
||||
break;
|
||||
case VERBATIM:
|
||||
break;
|
||||
}
|
||||
|
||||
pair<string, string> dir1(N_("Documents|#o#O"),
|
||||
string(lyxrc.document_path));
|
||||
pair<docstring, docstring> dir1(_("Documents|#o#O"),
|
||||
lyx::from_utf8(lyxrc.document_path));
|
||||
|
||||
string const docpath = onlyPath(kernel().buffer().fileName());
|
||||
docstring const docpath = lyx::from_utf8(onlyPath(kernel().buffer().fileName()));
|
||||
|
||||
return browseRelFile(in_name, docpath, title,
|
||||
filters, false, dir1);
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "Dialog.h"
|
||||
#include "insets/insetcommandparams.h"
|
||||
|
||||
#include "support/docstring.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
@ -52,7 +54,7 @@ public:
|
||||
void setParams(InsetCommandParams const &);
|
||||
|
||||
/// Browse for a file
|
||||
std::string const browse(std::string const &, Type) const;
|
||||
lyx::docstring const browse(lyx::docstring const &, Type) const;
|
||||
|
||||
/// load a file
|
||||
void load(std::string const & file);
|
||||
|
@ -27,6 +27,8 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
using lyx::docstring;
|
||||
|
||||
using std::ostringstream;
|
||||
using std::pair;
|
||||
using std::string;
|
||||
@ -107,51 +109,47 @@ void ControlPrefs::updateScreenFonts()
|
||||
}
|
||||
|
||||
|
||||
string const ControlPrefs::browsebind(string const & file) const
|
||||
docstring const ControlPrefs::browsebind(docstring const & file) const
|
||||
{
|
||||
// FIXME UNICODE
|
||||
return browseLibFile("bind", file, "bind",
|
||||
lyx::to_utf8(_("Choose bind file")),
|
||||
FileFilterList(lyx::to_utf8(_("LyX bind files (*.bind)"))));
|
||||
return browseLibFile(lyx::from_ascii("bind"), file, lyx::from_ascii("bind"),
|
||||
_("Choose bind file"),
|
||||
FileFilterList(_("LyX bind files (*.bind)")));
|
||||
}
|
||||
|
||||
|
||||
string const ControlPrefs::browseUI(string const & file) const
|
||||
docstring const ControlPrefs::browseUI(docstring const & file) const
|
||||
{
|
||||
// FIXME UNICODE
|
||||
return browseLibFile("ui", file, "ui",
|
||||
lyx::to_utf8(_("Choose UI file")),
|
||||
FileFilterList(lyx::to_utf8(_("LyX UI files (*.ui)"))));
|
||||
return browseLibFile(lyx::from_ascii("ui"), file, lyx::from_ascii("ui"),
|
||||
_("Choose UI file"),
|
||||
FileFilterList(_("LyX UI files (*.ui)")));
|
||||
}
|
||||
|
||||
|
||||
string const ControlPrefs::browsekbmap(string const & file) const
|
||||
docstring const ControlPrefs::browsekbmap(docstring const & file) const
|
||||
{
|
||||
// FIXME UNICODE
|
||||
return browseLibFile("kbd", file, "kmap",
|
||||
lyx::to_utf8(_("Choose keyboard map")),
|
||||
FileFilterList(lyx::to_utf8(_("LyX keyboard maps (*.kmap)"))));
|
||||
return browseLibFile(lyx::from_ascii("kbd"), file, lyx::from_ascii("kmap"),
|
||||
_("Choose keyboard map"),
|
||||
FileFilterList(_("LyX keyboard maps (*.kmap)")));
|
||||
}
|
||||
|
||||
|
||||
string const ControlPrefs::browsedict(string const & file) const
|
||||
docstring const ControlPrefs::browsedict(docstring const & file) const
|
||||
{
|
||||
// FIXME UNICODE
|
||||
return browseFile(file,
|
||||
lyx::to_utf8(_("Choose personal dictionary")),
|
||||
FileFilterList(lyx::to_utf8(_("*.ispell"))));
|
||||
_("Choose personal dictionary"),
|
||||
FileFilterList(_("*.ispell")));
|
||||
}
|
||||
|
||||
|
||||
string const ControlPrefs::browse(string const & file,
|
||||
string const & title) const
|
||||
docstring const ControlPrefs::browse(docstring const & file,
|
||||
docstring const & title) const
|
||||
{
|
||||
return browseFile(file, title, FileFilterList(), true);
|
||||
}
|
||||
|
||||
|
||||
string const ControlPrefs::browsedir(string const & path,
|
||||
string const & title) const
|
||||
docstring const ControlPrefs::browsedir(docstring const & path,
|
||||
docstring const & title) const
|
||||
{
|
||||
return browseDir(path, title);
|
||||
}
|
||||
|
@ -51,18 +51,18 @@ public:
|
||||
Movers const & movers() const { return movers_; }
|
||||
|
||||
/// various file pickers
|
||||
std::string const browsebind(std::string const & file) const;
|
||||
std::string const browseUI(std::string const & file) const;
|
||||
std::string const browsekbmap(std::string const & file) const;
|
||||
std::string const browsedict(std::string const & file) const;
|
||||
lyx::docstring const browsebind(lyx::docstring const & file) const;
|
||||
lyx::docstring const browseUI(lyx::docstring const & file) const;
|
||||
lyx::docstring const browsekbmap(lyx::docstring const & file) const;
|
||||
lyx::docstring const browsedict(lyx::docstring const & file) const;
|
||||
|
||||
/// general browse
|
||||
std::string const browse(std::string const & file,
|
||||
std::string const & title) const;
|
||||
lyx::docstring const browse(lyx::docstring const & file,
|
||||
lyx::docstring const & title) const;
|
||||
|
||||
/// browse directory
|
||||
std::string const browsedir(std::string const & path,
|
||||
std::string const & title) const;
|
||||
lyx::docstring const browsedir(lyx::docstring const & path,
|
||||
lyx::docstring const & title) const;
|
||||
|
||||
/// set a color
|
||||
void setColor(LColor_color col, std::string const & hex);
|
||||
|
@ -67,12 +67,11 @@ PrinterParams & ControlPrint::params() const
|
||||
}
|
||||
|
||||
|
||||
string const ControlPrint::browse(string const & in_name) const
|
||||
docstring const ControlPrint::browse(docstring const & in_name) const
|
||||
{
|
||||
// FIXME UNICODE
|
||||
return browseRelFile(in_name, kernel().buffer().filePath(),
|
||||
lyx::to_utf8(_("Print to file")),
|
||||
FileFilterList(lyx::to_utf8(_("PostScript files (*.ps)"))),
|
||||
return browseRelFile(in_name, lyx::from_utf8(kernel().buffer().filePath()),
|
||||
_("Print to file"),
|
||||
FileFilterList(_("PostScript files (*.ps)")),
|
||||
true);
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,9 @@
|
||||
#define CONTROLPRINT_H
|
||||
|
||||
#include "Dialog.h"
|
||||
|
||||
#include "support/docstring.h"
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
class PrinterParams;
|
||||
@ -39,7 +42,7 @@ public:
|
||||
virtual kb_action getLfun() const { return LFUN_BUFFER_PRINT; }
|
||||
|
||||
/// Browse for a file
|
||||
std::string const browse(std::string const &) const;
|
||||
lyx::docstring const browse(lyx::docstring const &) const;
|
||||
///
|
||||
PrinterParams & params() const;
|
||||
private:
|
||||
|
@ -23,9 +23,11 @@
|
||||
#include "support/lstrings.h"
|
||||
#include "support/package.h"
|
||||
|
||||
using lyx::docstring;
|
||||
|
||||
using std::pair;
|
||||
using std::vector;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
@ -44,16 +46,16 @@ using support::prefixIs;
|
||||
namespace frontend {
|
||||
|
||||
|
||||
string const browseFile(string const & filename,
|
||||
string const & title,
|
||||
docstring const browseFile(docstring const & filename,
|
||||
docstring const & title,
|
||||
FileFilterList const & filters,
|
||||
bool save,
|
||||
pair<string,string> const & dir1,
|
||||
pair<string,string> const & dir2)
|
||||
pair<docstring,docstring> const & dir1,
|
||||
pair<docstring,docstring> const & dir2)
|
||||
{
|
||||
string lastPath(".");
|
||||
docstring lastPath = from_ascii(".");
|
||||
if (!filename.empty())
|
||||
lastPath = onlyPath(filename);
|
||||
lastPath = lyx::from_utf8(onlyPath(lyx::to_utf8(filename)));
|
||||
|
||||
FileDialog fileDlg(title, LFUN_SELECT_FILE_SYNC, dir1, dir2);
|
||||
|
||||
@ -61,29 +63,31 @@ string const browseFile(string const & filename,
|
||||
|
||||
if (save)
|
||||
result = fileDlg.save(lastPath, filters,
|
||||
onlyFilename(filename));
|
||||
lyx::from_utf8(onlyFilename(lyx::to_utf8(filename))));
|
||||
else
|
||||
result = fileDlg.open(lastPath, filters,
|
||||
onlyFilename(filename));
|
||||
lyx::from_utf8(onlyFilename(lyx::to_utf8(filename))));
|
||||
|
||||
return result.second;
|
||||
}
|
||||
|
||||
|
||||
string const browseRelFile(string const & filename,
|
||||
string const & refpath,
|
||||
string const & title,
|
||||
docstring const browseRelFile(docstring const & filename,
|
||||
docstring const & refpath,
|
||||
docstring const & title,
|
||||
FileFilterList const & filters,
|
||||
bool save,
|
||||
pair<string,string> const & dir1,
|
||||
pair<string,string> const & dir2)
|
||||
pair<docstring,docstring> const & dir1,
|
||||
pair<docstring,docstring> const & dir2)
|
||||
{
|
||||
string const fname = makeAbsPath(filename, refpath);
|
||||
docstring const fname = lyx::from_utf8(
|
||||
makeAbsPath(lyx::to_utf8(filename), lyx::to_utf8(refpath)));
|
||||
|
||||
string const outname = browseFile(fname, title, filters, save,
|
||||
docstring const outname = browseFile(fname, title, filters, save,
|
||||
dir1, dir2);
|
||||
string const reloutname = makeRelPath(outname, refpath);
|
||||
if (prefixIs(reloutname, "../"))
|
||||
docstring const reloutname = lyx::from_utf8(
|
||||
makeRelPath(lyx::to_utf8(outname), lyx::to_utf8(refpath)));
|
||||
if (prefixIs(lyx::to_utf8(reloutname), "../"))
|
||||
return outname;
|
||||
else
|
||||
return reloutname;
|
||||
@ -91,63 +95,64 @@ string const browseRelFile(string const & filename,
|
||||
|
||||
|
||||
|
||||
string const browseLibFile(string const & dir,
|
||||
string const & name,
|
||||
string const & ext,
|
||||
string const & title,
|
||||
docstring const browseLibFile(docstring const & dir,
|
||||
docstring const & name,
|
||||
docstring const & ext,
|
||||
docstring const & title,
|
||||
FileFilterList const & filters)
|
||||
{
|
||||
// FIXME UNICODE
|
||||
pair<string,string> const dir1(lyx::to_utf8(_("System files|#S#s")),
|
||||
addName(package().system_support(), dir));
|
||||
pair<docstring, docstring> const dir1(_("System files|#S#s"),
|
||||
lyx::from_utf8(addName(package().system_support(), lyx::to_utf8(dir))));
|
||||
|
||||
pair<string,string> const dir2(lyx::to_utf8(_("User files|#U#u")),
|
||||
addName(package().user_support(), dir));
|
||||
pair<docstring, docstring> const dir2(_("User files|#U#u"),
|
||||
lyx::from_utf8(addName(package().user_support(), lyx::to_utf8(dir))));
|
||||
|
||||
string const result = browseFile(libFileSearch(dir, name, ext), title,
|
||||
filters, false, dir1, dir2);
|
||||
docstring const result = browseFile(lyx::from_utf8(
|
||||
libFileSearch(lyx::to_utf8(dir), lyx::to_utf8(name), lyx::to_utf8(ext))),
|
||||
title, filters, false, dir1, dir2);
|
||||
|
||||
// remove the extension if it is the default one
|
||||
string noextresult;
|
||||
if (getExtension(result) == ext)
|
||||
noextresult = changeExtension(result, string());
|
||||
docstring noextresult;
|
||||
if (lyx::from_utf8(getExtension(lyx::to_utf8(result))) == ext)
|
||||
noextresult = lyx::from_utf8(changeExtension(lyx::to_utf8(result), string()));
|
||||
else
|
||||
noextresult = result;
|
||||
|
||||
// remove the directory, if it is the default one
|
||||
string const file = onlyFilename(noextresult);
|
||||
if (libFileSearch(dir, file, ext) == result)
|
||||
docstring const file = lyx::from_utf8(onlyFilename(lyx::to_utf8(noextresult)));
|
||||
if (lyx::from_utf8(libFileSearch(lyx::to_utf8(dir), lyx::to_utf8(file), lyx::to_utf8(ext))) == result)
|
||||
return file;
|
||||
else
|
||||
return noextresult;
|
||||
}
|
||||
|
||||
|
||||
string const browseDir(string const & pathname,
|
||||
string const & title,
|
||||
pair<string,string> const & dir1,
|
||||
pair<string,string> const & dir2)
|
||||
docstring const browseDir(docstring const & pathname,
|
||||
docstring const & title,
|
||||
pair<docstring,docstring> const & dir1,
|
||||
pair<docstring,docstring> const & dir2)
|
||||
{
|
||||
string lastPath(".");
|
||||
docstring lastPath = lyx::from_ascii(".");
|
||||
if (!pathname.empty())
|
||||
lastPath = onlyPath(pathname);
|
||||
lastPath = lyx::from_utf8(onlyPath(lyx::to_utf8(pathname)));
|
||||
|
||||
FileDialog fileDlg(title, LFUN_SELECT_FILE_SYNC, dir1, dir2);
|
||||
|
||||
FileDialog::Result const result =
|
||||
fileDlg.opendir(lastPath, onlyFilename(pathname));
|
||||
fileDlg.opendir(lastPath, lyx::from_utf8(onlyFilename(lyx::to_utf8(pathname))));
|
||||
|
||||
return result.second;
|
||||
}
|
||||
|
||||
|
||||
vector<string> const getLatexUnits()
|
||||
vector<docstring> const getLatexUnits()
|
||||
{
|
||||
vector<string> units;
|
||||
vector<docstring> units;
|
||||
int i = 0;
|
||||
char const * str = stringFromUnit(i);
|
||||
for (; str != 0; ++i, str = stringFromUnit(i))
|
||||
units.push_back(str);
|
||||
units.push_back(lyx::from_ascii(str));
|
||||
|
||||
return units;
|
||||
}
|
||||
|
@ -12,6 +12,8 @@
|
||||
#ifndef HELPERFUNCS_H
|
||||
#define HELPERFUNCS_H
|
||||
|
||||
#include "support/docstring.h"
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
@ -34,15 +36,15 @@ namespace frontend {
|
||||
pattern: *.ps etc.
|
||||
dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
|
||||
*/
|
||||
std::string const
|
||||
browseFile(std::string const & filename,
|
||||
std::string const & title,
|
||||
lyx::docstring const
|
||||
browseFile(lyx::docstring const & filename,
|
||||
lyx::docstring const & title,
|
||||
support::FileFilterList const & filters,
|
||||
bool save = false,
|
||||
std::pair<std::string,std::string> const & dir1 =
|
||||
std::make_pair(std::string(), std::string()),
|
||||
std::pair<std::string,std::string> const & dir2 =
|
||||
std::make_pair(std::string(), std::string()));
|
||||
std::pair<lyx::docstring,lyx::docstring> const & dir1 =
|
||||
std::make_pair(lyx::docstring(), lyx::docstring()),
|
||||
std::pair<lyx::docstring,lyx::docstring> const & dir2 =
|
||||
std::make_pair(lyx::docstring(), lyx::docstring()));
|
||||
|
||||
|
||||
/** Wrapper around browseFile which tries to provide a filename
|
||||
@ -51,16 +53,16 @@ browseFile(std::string const & filename,
|
||||
of the form "../baz/foo.txt", an absolute path is returned. This is
|
||||
intended to be useful for insets which encapsulate files/
|
||||
*/
|
||||
std::string const
|
||||
browseRelFile(std::string const & filename,
|
||||
std::string const & refpath,
|
||||
std::string const & title,
|
||||
lyx::docstring const
|
||||
browseRelFile(lyx::docstring const & filename,
|
||||
lyx::docstring const & refpath,
|
||||
lyx::docstring const & title,
|
||||
support::FileFilterList const & filters,
|
||||
bool save = false,
|
||||
std::pair<std::string,std::string> const & dir1 =
|
||||
std::make_pair(std::string(), std::string()),
|
||||
std::pair<std::string,std::string> const & dir2 =
|
||||
std::make_pair(std::string(), std::string()));
|
||||
std::pair<lyx::docstring,lyx::docstring> const & dir1 =
|
||||
std::make_pair(lyx::docstring(), lyx::docstring()),
|
||||
std::pair<lyx::docstring,lyx::docstring> const & dir2 =
|
||||
std::make_pair(lyx::docstring(), lyx::docstring()));
|
||||
|
||||
|
||||
/** Wrapper around browseFile which tries to provide a filename
|
||||
@ -68,11 +70,11 @@ browseRelFile(std::string const & filename,
|
||||
* parameters have the same meaning as in the
|
||||
* lyx::support::LibFileSearch function.
|
||||
*/
|
||||
std::string const
|
||||
browseLibFile(std::string const & dir,
|
||||
std::string const & name,
|
||||
std::string const & ext,
|
||||
std::string const & title,
|
||||
lyx::docstring const
|
||||
browseLibFile(lyx::docstring const & dir,
|
||||
lyx::docstring const & name,
|
||||
lyx::docstring const & ext,
|
||||
lyx::docstring const & title,
|
||||
support::FileFilterList const & filters);
|
||||
|
||||
|
||||
@ -81,17 +83,17 @@ browseLibFile(std::string const & dir,
|
||||
title: the title of the dialog.
|
||||
dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
|
||||
*/
|
||||
std::string const
|
||||
browseDir(std::string const & pathname,
|
||||
std::string const & title,
|
||||
std::pair<std::string,std::string> const & dir1 =
|
||||
std::make_pair(std::string(), std::string()),
|
||||
std::pair<std::string,std::string> const & dir2 =
|
||||
std::make_pair(std::string(), std::string()));
|
||||
lyx::docstring const
|
||||
browseDir(lyx::docstring const & pathname,
|
||||
lyx::docstring const & title,
|
||||
std::pair<lyx::docstring,lyx::docstring> const & dir1 =
|
||||
std::make_pair(lyx::docstring(), lyx::docstring()),
|
||||
std::pair<lyx::docstring,lyx::docstring> const & dir2 =
|
||||
std::make_pair(lyx::docstring(), lyx::docstring()));
|
||||
|
||||
|
||||
/// Returns a vector of units that can be used to create a valid LaTeX length.
|
||||
std::vector<std::string> const getLatexUnits();
|
||||
std::vector<lyx::docstring> const getLatexUnits();
|
||||
|
||||
|
||||
/** Functions to extract vectors of the first and second elems from a
|
||||
|
@ -41,9 +41,9 @@ using lyx::support::makeAbsPath;
|
||||
#endif
|
||||
|
||||
using lyx::support::FileFilterList;
|
||||
using lyx::docstring;
|
||||
|
||||
using std::endl;
|
||||
using std::string;
|
||||
|
||||
|
||||
class FileDialog::Private {
|
||||
@ -53,7 +53,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
FileDialog::FileDialog(string const & t,
|
||||
FileDialog::FileDialog(docstring const & t,
|
||||
kb_action s, Button b1, Button b2)
|
||||
: private_(new FileDialog::Private), title_(t), success_(s)
|
||||
{
|
||||
@ -68,19 +68,19 @@ FileDialog::~FileDialog()
|
||||
}
|
||||
|
||||
|
||||
FileDialog::Result const FileDialog::save(string const & path,
|
||||
FileDialog::Result const FileDialog::save(docstring const & path,
|
||||
FileFilterList const & filters,
|
||||
string const & suggested)
|
||||
docstring const & suggested)
|
||||
{
|
||||
lyxerr[Debug::GUI] << "Select with path \"" << path
|
||||
<< "\", mask \"" << filters.as_string()
|
||||
<< "\", suggested \"" << suggested << '"' << endl;
|
||||
lyxerr[Debug::GUI] << "Select with path \"" << lyx::to_utf8(path)
|
||||
<< "\", mask \"" << lyx::to_utf8(filters.as_string())
|
||||
<< "\", suggested \"" << lyx::to_utf8(suggested) << '"' << endl;
|
||||
FileDialog::Result result;
|
||||
result.first = FileDialog::Chosen;
|
||||
|
||||
#ifdef USE_NATIVE_FILEDIALOG
|
||||
string const startsWith = makeAbsPath(suggested, path);
|
||||
result.second = fromqstr(QFileDialog::getSaveFileName(
|
||||
docstring const startsWith = makeAbsPath(suggested, path);
|
||||
result.second = qstring_to_ucs4(QFileDialog::getSaveFileName(
|
||||
qApp->focusWidget(),
|
||||
title_.c_str(), toqstr(startsWith), toqstr(filters.as_string()) ));
|
||||
#else
|
||||
@ -95,26 +95,26 @@ FileDialog::Result const FileDialog::save(string const & path,
|
||||
int res = dlg.exec();
|
||||
lyxerr[Debug::GUI] << "result " << res << endl;
|
||||
if (res == QDialog::Accepted)
|
||||
result.second = fromqstr(dlg.selectedFiles()[0]);
|
||||
result.second = qstring_to_ucs4(dlg.selectedFiles()[0]);
|
||||
dlg.hide();
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
FileDialog::Result const FileDialog::open(string const & path,
|
||||
FileDialog::Result const FileDialog::open(docstring const & path,
|
||||
FileFilterList const & filters,
|
||||
string const & suggested)
|
||||
docstring const & suggested)
|
||||
{
|
||||
lyxerr[Debug::GUI] << "Select with path \"" << path
|
||||
<< "\", mask \"" << filters.as_string()
|
||||
<< "\", suggested \"" << suggested << '"' << endl;
|
||||
lyxerr[Debug::GUI] << "Select with path \"" << lyx::to_utf8(path)
|
||||
<< "\", mask \"" << lyx::to_utf8(filters.as_string())
|
||||
<< "\", suggested \"" << lyx::to_utf8(suggested) << '"' << endl;
|
||||
FileDialog::Result result;
|
||||
result.first = FileDialog::Chosen;
|
||||
|
||||
#ifdef USE_NATIVE_FILEDIALOG
|
||||
string const startsWith = makeAbsPath(suggested, path);
|
||||
result.second = fromqstr(QFileDialog::getOpenFileName(
|
||||
docstring const startsWith = makeAbsPath(suggested, path);
|
||||
result.second = qstring_to_ucs4(QFileDialog::getOpenFileName(
|
||||
qApp->focusWidget(),
|
||||
title_.c_str(), toqstr(startsWith), toqstr(filters.as_string()) ));
|
||||
#else
|
||||
@ -127,28 +127,28 @@ FileDialog::Result const FileDialog::open(string const & path,
|
||||
int res = dlg.exec();
|
||||
lyxerr[Debug::GUI] << "result " << res << endl;
|
||||
if (res == QDialog::Accepted)
|
||||
result.second = fromqstr(dlg.selectedFiles()[0]);
|
||||
result.second = qstring_to_ucs4(dlg.selectedFiles()[0]);
|
||||
dlg.hide();
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
FileDialog::Result const FileDialog::opendir(string const & path,
|
||||
string const & suggested)
|
||||
FileDialog::Result const FileDialog::opendir(docstring const & path,
|
||||
docstring const & suggested)
|
||||
{
|
||||
lyxerr[Debug::GUI] << "Select with path \"" << path
|
||||
<< "\", suggested \"" << suggested << '"' << endl;
|
||||
lyxerr[Debug::GUI] << "Select with path \"" << lyx::to_utf8(path)
|
||||
<< "\", suggested \"" << lyx::to_utf8(suggested) << '"' << endl;
|
||||
FileDialog::Result result;
|
||||
result.first = FileDialog::Chosen;
|
||||
|
||||
#ifdef USE_NATIVE_FILEDIALOG
|
||||
string const startsWith = makeAbsPath(suggested, path);
|
||||
result.second = fromqstr(QFileDialog::getExistingDirectory(
|
||||
docstring const startsWith = makeAbsPath(suggested, path);
|
||||
result.second = qstring_to_ucs4(QFileDialog::getExistingDirectory(
|
||||
qApp->focusWidget(),
|
||||
title_.c_str(),toqstr(startsWith) ));
|
||||
#else
|
||||
FileFilterList const filter(lyx::to_utf8(_("Directories")));
|
||||
FileFilterList const filter(_("Directories"));
|
||||
|
||||
LyXFileDialog dlg(title_, path, filter, private_->b1, private_->b2);
|
||||
|
||||
@ -161,7 +161,7 @@ FileDialog::Result const FileDialog::opendir(string const & path,
|
||||
int res = dlg.exec();
|
||||
lyxerr[Debug::GUI] << "result " << res << endl;
|
||||
if (res == QDialog::Accepted)
|
||||
result.second = fromqstr(dlg.selectedFiles()[0]);
|
||||
result.second = qstring_to_ucs4(dlg.selectedFiles()[0]);
|
||||
dlg.hide();
|
||||
#endif
|
||||
return result;
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <QHBoxLayout>
|
||||
|
||||
using lyx::support::split;
|
||||
using lyx::docstring;
|
||||
|
||||
using std::string;
|
||||
|
||||
@ -29,23 +30,25 @@ using std::string;
|
||||
namespace {
|
||||
|
||||
/// return the Qt form of the label
|
||||
string const getLabel(string const & str) {
|
||||
docstring const getLabel(docstring const & ucs4str) {
|
||||
// FIXME UNICOE
|
||||
string str = lyx::to_utf8(ucs4str);
|
||||
string label;
|
||||
string sc(split(str, label, '|'));
|
||||
if (sc.length() < 2)
|
||||
return label;
|
||||
return lyx::from_utf8(label);
|
||||
string::size_type pos = label.find(sc[1]);
|
||||
if (pos == string::npos)
|
||||
return label;
|
||||
return lyx::from_utf8(label);
|
||||
label.insert(pos, 1, '&');
|
||||
return label;
|
||||
return lyx::from_utf8(label);
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
LyXFileDialog::LyXFileDialog(string const & t,
|
||||
string const & p,
|
||||
LyXFileDialog::LyXFileDialog(docstring const & t,
|
||||
docstring const & p,
|
||||
lyx::support::FileFilterList const & filters,
|
||||
FileDialog::Button const & b1,
|
||||
FileDialog::Button const & b2)
|
||||
|
@ -31,8 +31,8 @@ class LyXFileDialog : public QFileDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
LyXFileDialog(std::string const & title,
|
||||
std::string const & path,
|
||||
LyXFileDialog(lyx::docstring const & title,
|
||||
lyx::docstring const & path,
|
||||
lyx::support::FileFilterList const & filters,
|
||||
FileDialog::Button const & b1,
|
||||
FileDialog::Button const & b2);
|
||||
@ -40,10 +40,10 @@ public Q_SLOTS:
|
||||
void buttonClicked();
|
||||
private:
|
||||
QToolButton * b1_;
|
||||
std::string b1_dir_;
|
||||
lyx::docstring b1_dir_;
|
||||
|
||||
QToolButton * b2_;
|
||||
std::string b2_dir_;
|
||||
lyx::docstring b2_dir_;
|
||||
};
|
||||
|
||||
#endif // FILEDIALOG_PRIVATE_H
|
||||
|
@ -117,15 +117,16 @@ void QBibtexDialog::change_adaptor()
|
||||
|
||||
void QBibtexDialog::browsePressed()
|
||||
{
|
||||
string const file = form_->controller().browseBst("");
|
||||
docstring const file = form_->controller().browseBst(docstring());
|
||||
|
||||
if (!file.empty()) {
|
||||
string const filen = changeExtension(file, "");
|
||||
// FIXME UNICODE
|
||||
docstring const filen = lyx::from_utf8(changeExtension(lyx::to_utf8(file), ""));
|
||||
bool present = false;
|
||||
unsigned int pres = 0;
|
||||
|
||||
for (int i = 0; i != styleCB->count(); ++i) {
|
||||
if (fromqstr(styleCB->itemText(i)) == filen) {
|
||||
if (qstring_to_ucs4(styleCB->itemText(i)) == filen) {
|
||||
present = true;
|
||||
pres = i;
|
||||
}
|
||||
@ -142,10 +143,11 @@ void QBibtexDialog::browsePressed()
|
||||
|
||||
void QBibtexDialog::browseBibPressed()
|
||||
{
|
||||
string const file = trim(form_->controller().browseBib(""));
|
||||
docstring const file = trim(form_->controller().browseBib(docstring()));
|
||||
|
||||
if (!file.empty()) {
|
||||
QString const f = toqstr(changeExtension(file, ""));
|
||||
// FIXME UNICODE
|
||||
QString const f = toqstr(lyx::from_utf8(changeExtension(lyx::to_utf8(file), "")));
|
||||
bool present = false;
|
||||
|
||||
for (int i = 0; i < add_->bibLW->count(); ++i) {
|
||||
@ -173,7 +175,7 @@ void QBibtexDialog::addPressed()
|
||||
void QBibtexDialog::addDatabase()
|
||||
{
|
||||
int const sel = add_->bibLW->currentRow();
|
||||
string const file = trim(fromqstr(add_->bibED->text()));
|
||||
docstring const file = trim(qstring_to_ucs4(add_->bibED->text()));
|
||||
|
||||
if (sel < 0 && file.empty())
|
||||
return;
|
||||
@ -193,7 +195,7 @@ void QBibtexDialog::addDatabase()
|
||||
|
||||
if (!file.empty()) {
|
||||
add_->bibED->clear();
|
||||
QString const f = toqstr(changeExtension(file, ""));
|
||||
QString const f = toqstr(lyx::from_utf8(changeExtension(lyx::to_utf8(file), "")));
|
||||
QList<QListWidgetItem *> matches =
|
||||
databaseLW->findItems(f, Qt::MatchExactly);
|
||||
if (matches.empty())
|
||||
|
@ -144,10 +144,10 @@ void QExternalDialog::bbChanged()
|
||||
void QExternalDialog::browseClicked()
|
||||
{
|
||||
int const choice = externalCO->currentIndex();
|
||||
string const template_name =
|
||||
form_->controller().getTemplate(choice).lyxName;
|
||||
string const str =
|
||||
form_->controller().browse(fromqstr(fileED->text()),
|
||||
docstring const template_name =
|
||||
lyx::from_utf8(form_->controller().getTemplate(choice).lyxName);
|
||||
docstring const str =
|
||||
form_->controller().browse(qstring_to_ucs4(fileED->text()),
|
||||
template_name);
|
||||
fileED->setText(toqstr(str));
|
||||
form_->changed();
|
||||
|
@ -140,8 +140,8 @@ void QGraphicsDialog::closeEvent(QCloseEvent * e)
|
||||
|
||||
void QGraphicsDialog::browse_clicked()
|
||||
{
|
||||
string const str =
|
||||
form_->controller().browse(fromqstr(filename->text()));
|
||||
docstring const str =
|
||||
form_->controller().browse(qstring_to_ucs4(filename->text()));
|
||||
filename->setText(toqstr(str));
|
||||
form_->changed();
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ void QInclude::browse()
|
||||
else
|
||||
type = ControlInclude::VERBATIM;
|
||||
|
||||
string const & name = controller().browse(fromqstr(dialog_->filenameED->text()), type);
|
||||
docstring const & name = controller().browse(qstring_to_ucs4(dialog_->filenameED->text()), type);
|
||||
if (!name.empty())
|
||||
dialog_->filenameED->setText(toqstr(name));
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ void QLPrintDialog::change_adaptor()
|
||||
|
||||
void QLPrintDialog::browseClicked()
|
||||
{
|
||||
QString file = toqstr(form_->controller().browse(""));
|
||||
QString file = toqstr(form_->controller().browse(docstring()));
|
||||
if (!file.isNull()) {
|
||||
fileED->setText(file);
|
||||
form_->changed();
|
||||
|
@ -277,7 +277,7 @@ void PrefKeyboard::update(LyXRC const & rc)
|
||||
|
||||
QString PrefKeyboard::testKeymap(QString keymap)
|
||||
{
|
||||
return toqstr(form_->controller().browsekbmap(fromqstr(keymap)));
|
||||
return toqstr(form_->controller().browsekbmap(qstring_to_ucs4(keymap)));
|
||||
}
|
||||
|
||||
|
||||
@ -700,11 +700,11 @@ void PrefPaths::update(LyXRC const & rc)
|
||||
lyxserverDirED->setText(external_path(rc.lyxpipes));
|
||||
}
|
||||
|
||||
// NB: the lyx::to_utf8(_() is OK here because it gets passed back and we toqstr()) them
|
||||
|
||||
void PrefPaths::select_templatedir()
|
||||
{
|
||||
string file(form_->controller().browsedir(fromqstr(templateDirED->text()), lyx::to_utf8(_("Select a document templates directory"))));
|
||||
docstring file(form_->controller().browsedir(
|
||||
qstring_to_ucs4(templateDirED->text()),
|
||||
_("Select a document templates directory")));
|
||||
if (!file.empty())
|
||||
templateDirED->setText(toqstr(file));
|
||||
}
|
||||
@ -712,7 +712,9 @@ void PrefPaths::select_templatedir()
|
||||
|
||||
void PrefPaths::select_tempdir()
|
||||
{
|
||||
string file(form_->controller().browsedir(fromqstr(tempDirED->text()), lyx::to_utf8(_("Select a temporary directory"))));
|
||||
docstring file(form_->controller().browsedir(
|
||||
qstring_to_ucs4(tempDirED->text()),
|
||||
_("Select a temporary directory")));
|
||||
if (!file.empty())
|
||||
tempDirED->setText(toqstr(file));
|
||||
}
|
||||
@ -720,7 +722,9 @@ void PrefPaths::select_tempdir()
|
||||
|
||||
void PrefPaths::select_backupdir()
|
||||
{
|
||||
string file(form_->controller().browsedir(fromqstr(backupDirED->text()), lyx::to_utf8(_("Select a backups directory"))));
|
||||
docstring file(form_->controller().browsedir(
|
||||
qstring_to_ucs4(backupDirED->text()),
|
||||
_("Select a backups directory")));
|
||||
if (!file.empty())
|
||||
backupDirED->setText(toqstr(file));
|
||||
}
|
||||
@ -728,7 +732,9 @@ void PrefPaths::select_backupdir()
|
||||
|
||||
void PrefPaths::select_workingdir()
|
||||
{
|
||||
string file(form_->controller().browsedir(fromqstr(workingDirED->text()), lyx::to_utf8(_("Select a document directory"))));
|
||||
docstring file(form_->controller().browsedir(
|
||||
qstring_to_ucs4(workingDirED->text()),
|
||||
_("Select a document directory")));
|
||||
if (!file.empty())
|
||||
workingDirED->setText(toqstr(file));
|
||||
}
|
||||
@ -736,7 +742,9 @@ void PrefPaths::select_workingdir()
|
||||
|
||||
void PrefPaths::select_lyxpipe()
|
||||
{
|
||||
string file(form_->controller().browse(fromqstr(lyxserverDirED->text()), lyx::to_utf8(_("Give a filename for the LyX server pipe"))));
|
||||
docstring file(form_->controller().browse(
|
||||
qstring_to_ucs4(lyxserverDirED->text()),
|
||||
_("Give a filename for the LyX server pipe")));
|
||||
if (!file.empty())
|
||||
lyxserverDirED->setText(toqstr(file));
|
||||
}
|
||||
@ -837,7 +845,7 @@ void PrefSpellchecker::update(LyXRC const & rc)
|
||||
|
||||
void PrefSpellchecker::select_dict()
|
||||
{
|
||||
string file(form_->controller().browsedict(fromqstr(persDictionaryED->text())));
|
||||
docstring file(form_->controller().browsedict(qstring_to_ucs4(persDictionaryED->text())));
|
||||
if (!file.empty())
|
||||
persDictionaryED->setText(toqstr(file));
|
||||
}
|
||||
@ -1136,6 +1144,7 @@ void PrefCopiers::switch_copierLB(int row)
|
||||
if (row<0)
|
||||
return;
|
||||
|
||||
// FIXME UNICODE?
|
||||
std::string const browser_text =
|
||||
fromqstr(AllCopiersLW->currentItem()->text());
|
||||
Format const * fmt = getFormat(browser_text);
|
||||
@ -1786,7 +1795,7 @@ void PrefUserInterface::update(LyXRC const & rc)
|
||||
|
||||
void PrefUserInterface::select_ui()
|
||||
{
|
||||
string file(form_->controller().browseUI(fromqstr(uiFileED->text())));
|
||||
docstring file(form_->controller().browseUI(qstring_to_ucs4(uiFileED->text())));
|
||||
if (!file.empty())
|
||||
uiFileED->setText(toqstr(file));
|
||||
}
|
||||
@ -1794,7 +1803,7 @@ void PrefUserInterface::select_ui()
|
||||
|
||||
void PrefUserInterface::select_bind()
|
||||
{
|
||||
string file(form_->controller().browsebind(fromqstr(bindFileED->text())));
|
||||
docstring file(form_->controller().browsebind(qstring_to_ucs4(bindFileED->text())));
|
||||
if (!file.empty())
|
||||
bindFileED->setText(toqstr(file));
|
||||
}
|
||||
|
25
src/lyx_cb.C
25
src/lyx_cb.C
@ -129,27 +129,26 @@ bool writeAs(Buffer * buffer, string const & filename)
|
||||
|
||||
if (filename.empty()) {
|
||||
|
||||
FileDialog fileDlg(lyx::to_utf8(_("Choose a filename to save document as")),
|
||||
// FIXME UNICODE
|
||||
FileDialog fileDlg(_("Choose a filename to save document as"),
|
||||
LFUN_BUFFER_WRITE_AS,
|
||||
make_pair(string(lyx::to_utf8(_("Documents|#o#O"))),
|
||||
string(lyxrc.document_path)),
|
||||
make_pair(string(lyx::to_utf8(_("Templates|#T#t"))),
|
||||
string(lyxrc.template_path)));
|
||||
make_pair(_("Documents|#o#O"), lyx::from_utf8(lyxrc.document_path)),
|
||||
make_pair(_("Templates|#T#t"), lyx::from_utf8(lyxrc.template_path)));
|
||||
|
||||
if (!isLyXFilename(fname))
|
||||
fname += ".lyx";
|
||||
|
||||
FileFilterList const filter (lyx::to_utf8(_("LyX Documents (*.lyx)")));
|
||||
FileFilterList const filter (_("LyX Documents (*.lyx)"));
|
||||
|
||||
FileDialog::Result result =
|
||||
fileDlg.save(onlyPath(fname),
|
||||
fileDlg.save(lyx::from_utf8(onlyPath(fname)),
|
||||
filter,
|
||||
onlyFilename(fname));
|
||||
lyx::from_utf8(onlyFilename(fname)));
|
||||
|
||||
if (result.first == FileDialog::Later)
|
||||
return false;
|
||||
|
||||
fname = result.second;
|
||||
fname = lyx::to_utf8(result.second);
|
||||
|
||||
if (fname.empty())
|
||||
return false;
|
||||
@ -382,17 +381,17 @@ string getContentsOfAsciiFile(BufferView * bv, string const & f, bool asParagrap
|
||||
string fname = f;
|
||||
|
||||
if (fname.empty()) {
|
||||
FileDialog fileDlg(lyx::to_utf8(_("Select file to insert")),
|
||||
FileDialog fileDlg(_("Select file to insert"),
|
||||
(asParagraph) ? LFUN_FILE_INSERT_ASCII_PARA : LFUN_FILE_INSERT_ASCII);
|
||||
|
||||
FileDialog::Result result =
|
||||
fileDlg.open(bv->buffer()->filePath(),
|
||||
FileFilterList(), string());
|
||||
fileDlg.open(lyx::from_utf8(bv->buffer()->filePath()),
|
||||
FileFilterList(), docstring());
|
||||
|
||||
if (result.first == FileDialog::Later)
|
||||
return string();
|
||||
|
||||
fname = result.second;
|
||||
fname = lyx::to_utf8(result.second);
|
||||
|
||||
if (fname.empty())
|
||||
return string();
|
||||
|
@ -1707,23 +1707,21 @@ void LyXFunc::menuNew(string const & name, bool fromTemplate)
|
||||
// The template stuff
|
||||
string templname;
|
||||
if (fromTemplate) {
|
||||
FileDialog fileDlg(lyx::to_utf8(_("Select template file")),
|
||||
FileDialog fileDlg(_("Select template file"),
|
||||
LFUN_SELECT_FILE_SYNC,
|
||||
make_pair(string(lyx::to_utf8(_("Documents|#o#O"))),
|
||||
string(lyxrc.document_path)),
|
||||
make_pair(string(lyx::to_utf8(_("Templates|#T#t"))),
|
||||
string(lyxrc.template_path)));
|
||||
make_pair(_("Documents|#o#O"), lyx::from_utf8(lyxrc.document_path)),
|
||||
make_pair(_("Templates|#T#t"), lyx::from_utf8(lyxrc.template_path)));
|
||||
|
||||
FileDialog::Result result =
|
||||
fileDlg.open(lyxrc.template_path,
|
||||
FileFilterList(lyx::to_utf8(_("LyX Documents (*.lyx)"))),
|
||||
string());
|
||||
fileDlg.open(lyx::from_utf8(lyxrc.template_path),
|
||||
FileFilterList(_("LyX Documents (*.lyx)")),
|
||||
docstring());
|
||||
|
||||
if (result.first == FileDialog::Later)
|
||||
return;
|
||||
if (result.second.empty())
|
||||
return;
|
||||
templname = result.second;
|
||||
templname = lyx::to_utf8(result.second);
|
||||
}
|
||||
|
||||
Buffer * const b = newFile(filename, templname, !name.empty());
|
||||
@ -1746,22 +1744,20 @@ void LyXFunc::open(string const & fname)
|
||||
string filename;
|
||||
|
||||
if (fname.empty()) {
|
||||
FileDialog fileDlg(lyx::to_utf8(_("Select document to open")),
|
||||
FileDialog fileDlg(_("Select document to open"),
|
||||
LFUN_FILE_OPEN,
|
||||
make_pair(string(lyx::to_utf8(_("Documents|#o#O"))),
|
||||
string(lyxrc.document_path)),
|
||||
make_pair(string(lyx::to_utf8(_("Examples|#E#e"))),
|
||||
string(addPath(package().system_support(), "examples"))));
|
||||
make_pair(_("Documents|#o#O"), lyx::from_utf8(lyxrc.document_path)),
|
||||
make_pair(_("Examples|#E#e"), lyx::from_utf8(addPath(package().system_support(), "examples"))));
|
||||
|
||||
FileDialog::Result result =
|
||||
fileDlg.open(initpath,
|
||||
FileFilterList(lyx::to_utf8(_("LyX Documents (*.lyx)"))),
|
||||
string());
|
||||
fileDlg.open(lyx::from_utf8(initpath),
|
||||
FileFilterList(_("LyX Documents (*.lyx)")),
|
||||
docstring());
|
||||
|
||||
if (result.first == FileDialog::Later)
|
||||
return;
|
||||
|
||||
filename = result.second;
|
||||
filename = lyx::to_utf8(result.second);
|
||||
|
||||
// check selected filename
|
||||
if (filename.empty()) {
|
||||
@ -1823,25 +1819,27 @@ void LyXFunc::doImport(string const & argument)
|
||||
docstring const text = bformat(_("Select %1$s file to import"),
|
||||
formats.prettyName(format));
|
||||
|
||||
FileDialog fileDlg(lyx::to_utf8(text),
|
||||
FileDialog fileDlg(text,
|
||||
LFUN_BUFFER_IMPORT,
|
||||
make_pair(string(lyx::to_utf8(_("Documents|#o#O"))),
|
||||
string(lyxrc.document_path)),
|
||||
make_pair(string(lyx::to_utf8(_("Examples|#E#e"))),
|
||||
string(addPath(package().system_support(), "examples"))));
|
||||
make_pair(_("Documents|#o#O"), lyx::from_utf8(lyxrc.document_path)),
|
||||
make_pair(_("Examples|#E#e"),
|
||||
lyx::from_utf8(addPath(package().system_support(), "examples"))));
|
||||
|
||||
string const filter = lyx::to_utf8(formats.prettyName(format))
|
||||
+ " (*." + formats.extension(format) + ')';
|
||||
docstring filter = formats.prettyName(format);
|
||||
filter += " (*.";
|
||||
// FIXME UNICODE
|
||||
filter += lyx::from_utf8(formats.extension(format));
|
||||
filter += ')';
|
||||
|
||||
FileDialog::Result result =
|
||||
fileDlg.open(initpath,
|
||||
fileDlg.open(lyx::from_utf8(initpath),
|
||||
FileFilterList(filter),
|
||||
string());
|
||||
docstring());
|
||||
|
||||
if (result.first == FileDialog::Later)
|
||||
return;
|
||||
|
||||
filename = result.second;
|
||||
filename = lyx::to_utf8(result.second);
|
||||
|
||||
// check selected filename
|
||||
if (filename.empty())
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
using lyx::docstring;
|
||||
|
||||
using std::distance;
|
||||
using std::ostringstream;
|
||||
using std::string;
|
||||
@ -81,7 +83,7 @@ string const convert_brace_glob(string const & glob)
|
||||
namespace lyx {
|
||||
namespace support {
|
||||
|
||||
FileFilterList::Filter::Filter(std::string const & description,
|
||||
FileFilterList::Filter::Filter(lyx::docstring const & description,
|
||||
std::string const & globs)
|
||||
: desc_(description)
|
||||
{
|
||||
@ -99,10 +101,10 @@ FileFilterList::Filter::Filter(std::string const & description,
|
||||
}
|
||||
|
||||
|
||||
FileFilterList::FileFilterList(string const & qt_style_filter)
|
||||
FileFilterList::FileFilterList(docstring const & qt_style_filter)
|
||||
{
|
||||
// FIXME UNICODE
|
||||
string const filter = qt_style_filter
|
||||
string const filter = lyx::to_utf8(qt_style_filter)
|
||||
+ (qt_style_filter.empty() ? string() : ";;")
|
||||
+ lyx::to_utf8(_("All files (*)"));
|
||||
|
||||
@ -139,17 +141,19 @@ void FileFilterList::parse_filter(string const & filter)
|
||||
boost::match_results<string::const_iterator> what;
|
||||
if (!boost::regex_search(filter, what, filter_re)) {
|
||||
// Just a glob, no description.
|
||||
filters_.push_back(Filter(string(), trim(filter)));
|
||||
filters_.push_back(Filter(docstring(), trim(filter)));
|
||||
} else {
|
||||
string const desc = string(what[1].first, what[1].second);
|
||||
// FIXME UNICODE
|
||||
docstring const desc = lyx::from_utf8(string(what[1].first, what[1].second));
|
||||
string const globs = string(what[2].first, what[2].second);
|
||||
filters_.push_back(Filter(trim(desc), trim(globs)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string const FileFilterList::as_string() const
|
||||
docstring const FileFilterList::as_string() const
|
||||
{
|
||||
// FIXME UNICODE
|
||||
ostringstream ss;
|
||||
|
||||
vector<Filter>::const_iterator fit = filters_.begin();
|
||||
@ -165,7 +169,7 @@ string const FileFilterList::as_string() const
|
||||
|
||||
bool const has_description = !fit->description().empty();
|
||||
if (has_description)
|
||||
ss << fit->description() << " (";
|
||||
ss << lyx::to_utf8(fit->description()) << " (";
|
||||
|
||||
for (Filter::glob_iterator git = gbegin; git != gend; ++git) {
|
||||
if (git != gbegin)
|
||||
@ -177,7 +181,7 @@ string const FileFilterList::as_string() const
|
||||
ss << ')';
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
return lyx::from_utf8(ss.str());
|
||||
}
|
||||
|
||||
} // namespace support
|
||||
|
@ -12,6 +12,8 @@
|
||||
#ifndef FILE_FILTER_LIST_H
|
||||
#define FILE_FILTER_LIST_H
|
||||
|
||||
#include "support/docstring.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -26,18 +28,19 @@ namespace support {
|
||||
*/
|
||||
class FileFilterList {
|
||||
public:
|
||||
// FIXME UNICODE: globs_ should be unicode...
|
||||
class Filter {
|
||||
std::string desc_;
|
||||
lyx::docstring desc_;
|
||||
std::vector<std::string> globs_;
|
||||
public:
|
||||
/* \param description text describing the filters.
|
||||
* \param one or more wildcard patterns, separated by
|
||||
* whitespace.
|
||||
*/
|
||||
Filter(std::string const & description,
|
||||
Filter(lyx::docstring const & description,
|
||||
std::string const & globs);
|
||||
|
||||
std::string const & description() const { return desc_; }
|
||||
lyx::docstring const & description() const { return desc_; }
|
||||
|
||||
typedef std::vector<std::string>::const_iterator glob_iterator;
|
||||
glob_iterator begin() const { return globs_.begin(); }
|
||||
@ -48,8 +51,8 @@ public:
|
||||
* Eg. "TeX documents (*.tex);;LyX Documents (*.lyx)".
|
||||
* The "All files (*)" filter is always added to the list.
|
||||
*/
|
||||
explicit FileFilterList(std::string const & qt_style_filter =
|
||||
std::string());
|
||||
explicit FileFilterList(lyx::docstring const & qt_style_filter =
|
||||
lyx::docstring());
|
||||
|
||||
typedef std::vector<Filter>::size_type size_type;
|
||||
|
||||
@ -62,7 +65,7 @@ public:
|
||||
* although any brace expressions are expanded.
|
||||
* (E.g. "*.{png,jpg}" -> "*.png *.jpg")
|
||||
*/
|
||||
std::string const as_string() const;
|
||||
lyx::docstring const as_string() const;
|
||||
|
||||
private:
|
||||
void parse_filter(std::string const & filter);
|
||||
|
Loading…
Reference in New Issue
Block a user