Encapsulate Converter class

Now members are not directly accessible anymore.
This commit is contained in:
Georg Baum 2014-12-07 18:35:28 +01:00
parent 25344de51d
commit c86f299a50
7 changed files with 168 additions and 131 deletions

View File

@ -3988,7 +3988,7 @@ Buffer::ExportStatus Buffer::doExport(string const & target, bool put_in_tempdir
Graph::EdgePath::const_iterator it = path.begin(); Graph::EdgePath::const_iterator it = path.begin();
Graph::EdgePath::const_iterator en = path.end(); Graph::EdgePath::const_iterator en = path.end();
for (; it != en; ++it) for (; it != en; ++it)
if (theConverters().get(*it).nice) { if (theConverters().get(*it).nice()) {
need_nice_file = true; need_nice_file = true;
break; break;
} }

View File

@ -85,7 +85,7 @@ public:
ConverterEqual(string const & from, string const & to) ConverterEqual(string const & from, string const & to)
: from_(from), to_(to) {} : from_(from), to_(to) {}
bool operator()(Converter const & c) const { bool operator()(Converter const & c) const {
return c.from == from_ && c.to == to_; return c.from() == from_ && c.to() == to_;
} }
private: private:
string const from_; string const from_;
@ -97,39 +97,39 @@ private:
Converter::Converter(string const & f, string const & t, Converter::Converter(string const & f, string const & t,
string const & c, string const & l) string const & c, string const & l)
: from(f), to(t), command(c), flags(l), : from_(f), to_(t), command_(c), flags_(l),
From(0), To(0), latex(false), xml(false), From_(0), To_(0), latex_(false), xml_(false),
need_aux(false), nice(false) need_aux_(false), nice_(false)
{} {}
void Converter::readFlags() void Converter::readFlags()
{ {
string flag_list(flags); string flag_list(flags_);
while (!flag_list.empty()) { while (!flag_list.empty()) {
string flag_name, flag_value; string flag_name, flag_value;
flag_list = split(flag_list, flag_value, ','); flag_list = split(flag_list, flag_value, ',');
flag_value = split(flag_value, flag_name, '='); flag_value = split(flag_value, flag_name, '=');
if (flag_name == "latex") { if (flag_name == "latex") {
latex = true; latex_ = true;
latex_flavor = flag_value.empty() ? latex_flavor_ = flag_value.empty() ?
"latex" : flag_value; "latex" : flag_value;
} else if (flag_name == "xml") } else if (flag_name == "xml")
xml = true; xml_ = true;
else if (flag_name == "needaux") else if (flag_name == "needaux")
need_aux = true; need_aux_ = true;
else if (flag_name == "resultdir") else if (flag_name == "resultdir")
result_dir = (flag_value.empty()) result_dir_ = (flag_value.empty())
? token_base : flag_value; ? token_base : flag_value;
else if (flag_name == "resultfile") else if (flag_name == "resultfile")
result_file = flag_value; result_file_ = flag_value;
else if (flag_name == "parselog") else if (flag_name == "parselog")
parselog = flag_value; parselog_ = flag_value;
else if (flag_name == "nice") else if (flag_name == "nice")
nice = true; nice_ = true;
} }
if (!result_dir.empty() && result_file.empty()) if (!result_dir_.empty() && result_file_.empty())
result_file = "index." + formats.extension(to); result_file_ = "index." + formats.extension(to_);
//if (!contains(command, token_from)) //if (!contains(command, token_from))
// latex = true; // latex = true;
} }
@ -172,36 +172,36 @@ void Converters::add(string const & from, string const & to,
Converter converter(from, to, command, flags); Converter converter(from, to, command, flags);
if (it != converterlist_.end() && !flags.empty() && flags[0] == '*') { if (it != converterlist_.end() && !flags.empty() && flags[0] == '*') {
converter = *it; converter = *it;
converter.command = command; converter.setCommand(command);
converter.flags = flags; converter.setFlags(flags);
} }
converter.readFlags(); converter.readFlags();
// The latex_command is used to update the .aux file when running // The latex_command is used to update the .aux file when running
// a converter that uses it. // a converter that uses it.
if (converter.latex) { if (converter.latex()) {
if (latex_command_.empty() || if (latex_command_.empty() ||
converter.latex_flavor == "latex") converter.latex_flavor() == "latex")
latex_command_ = subst(command, token_from, ""); latex_command_ = subst(command, token_from, "");
if (dvilualatex_command_.empty() || if (dvilualatex_command_.empty() ||
converter.latex_flavor == "dvilualatex") converter.latex_flavor() == "dvilualatex")
dvilualatex_command_ = subst(command, token_from, ""); dvilualatex_command_ = subst(command, token_from, "");
if (lualatex_command_.empty() || if (lualatex_command_.empty() ||
converter.latex_flavor == "lualatex") converter.latex_flavor() == "lualatex")
lualatex_command_ = subst(command, token_from, ""); lualatex_command_ = subst(command, token_from, "");
if (pdflatex_command_.empty() || if (pdflatex_command_.empty() ||
converter.latex_flavor == "pdflatex") converter.latex_flavor() == "pdflatex")
pdflatex_command_ = subst(command, token_from, ""); pdflatex_command_ = subst(command, token_from, "");
if (xelatex_command_.empty() || if (xelatex_command_.empty() ||
converter.latex_flavor == "xelatex") converter.latex_flavor() == "xelatex")
xelatex_command_ = subst(command, token_from, ""); xelatex_command_ = subst(command, token_from, "");
} }
if (it == converterlist_.end()) { if (it == converterlist_.end()) {
converterlist_.push_back(converter); converterlist_.push_back(converter);
} else { } else {
converter.From = it->From; converter.setFrom(it->From());
converter.To = it->To; converter.setTo(it->To());
*it = converter; *it = converter;
} }
} }
@ -230,8 +230,8 @@ void Converters::update(Formats const & formats)
ConverterList::iterator it = converterlist_.begin(); ConverterList::iterator it = converterlist_.begin();
ConverterList::iterator end = converterlist_.end(); ConverterList::iterator end = converterlist_.end();
for (; it != end; ++it) { for (; it != end; ++it) {
it->From = formats.getFormat(it->from); it->setFrom(formats.getFormat(it->from()));
it->To = formats.getFormat(it->to); it->setTo(formats.getFormat(it->to()));
} }
} }
@ -242,8 +242,8 @@ void Converters::updateLast(Formats const & formats)
{ {
if (converterlist_.begin() != converterlist_.end()) { if (converterlist_.begin() != converterlist_.end()) {
ConverterList::iterator it = converterlist_.end() - 1; ConverterList::iterator it = converterlist_.end() - 1;
it->From = formats.getFormat(it->from); it->setFrom(formats.getFormat(it->from()));
it->To = formats.getFormat(it->to); it->setTo(formats.getFormat(it->to()));
} }
} }
@ -254,19 +254,19 @@ OutputParams::FLAVOR Converters::getFlavor(Graph::EdgePath const & path,
for (Graph::EdgePath::const_iterator cit = path.begin(); for (Graph::EdgePath::const_iterator cit = path.begin();
cit != path.end(); ++cit) { cit != path.end(); ++cit) {
Converter const & conv = converterlist_[*cit]; Converter const & conv = converterlist_[*cit];
if (conv.latex) { if (conv.latex()) {
if (conv.latex_flavor == "latex") if (conv.latex_flavor() == "latex")
return OutputParams::LATEX; return OutputParams::LATEX;
if (conv.latex_flavor == "xelatex") if (conv.latex_flavor() == "xelatex")
return OutputParams::XETEX; return OutputParams::XETEX;
if (conv.latex_flavor == "lualatex") if (conv.latex_flavor() == "lualatex")
return OutputParams::LUATEX; return OutputParams::LUATEX;
if (conv.latex_flavor == "dvilualatex") if (conv.latex_flavor() == "dvilualatex")
return OutputParams::DVILUATEX; return OutputParams::DVILUATEX;
if (conv.latex_flavor == "pdflatex") if (conv.latex_flavor() == "pdflatex")
return OutputParams::PDFLATEX; return OutputParams::PDFLATEX;
} }
if (conv.xml) if (conv.xml())
return OutputParams::XML; return OutputParams::XML;
} }
return buffer ? buffer->params().getOutputFlavor() return buffer ? buffer->params().getOutputFlavor()
@ -369,25 +369,25 @@ bool Converters::convert(Buffer const * buffer,
for (Graph::EdgePath::const_iterator cit = edgepath.begin(); for (Graph::EdgePath::const_iterator cit = edgepath.begin();
cit != edgepath.end(); ++cit) { cit != edgepath.end(); ++cit) {
Converter const & conv = converterlist_[*cit]; Converter const & conv = converterlist_[*cit];
bool dummy = conv.To->dummy() && conv.to != "program"; bool dummy = conv.To()->dummy() && conv.to() != "program";
if (!dummy) { if (!dummy) {
LYXERR(Debug::FILES, "Converting from " LYXERR(Debug::FILES, "Converting from "
<< conv.from << " to " << conv.to); << conv.from() << " to " << conv.to());
} }
infile = outfile; infile = outfile;
outfile = FileName(conv.result_file.empty() outfile = FileName(conv.result_file().empty()
? changeExtension(from_file.absFileName(), conv.To->extension()) ? changeExtension(from_file.absFileName(), conv.To()->extension())
: addName(subst(conv.result_dir, : addName(subst(conv.result_dir(),
token_base, from_base), token_base, from_base),
subst(conv.result_file, subst(conv.result_file(),
token_base, onlyFileName(from_base)))); token_base, onlyFileName(from_base))));
// if input and output files are equal, we use a // if input and output files are equal, we use a
// temporary file as intermediary (JMarc) // temporary file as intermediary (JMarc)
FileName real_outfile; FileName real_outfile;
if (!conv.result_file.empty()) if (!conv.result_file().empty())
real_outfile = FileName(changeExtension(from_file.absFileName(), real_outfile = FileName(changeExtension(from_file.absFileName(),
conv.To->extension())); conv.To()->extension()));
if (outfile == infile) { if (outfile == infile) {
real_outfile = infile; real_outfile = infile;
// when importing, a buffer does not necessarily exist // when importing, a buffer does not necessarily exist
@ -398,9 +398,9 @@ bool Converters::convert(Buffer const * buffer,
"tmpfile.out")); "tmpfile.out"));
} }
if (conv.latex) { if (conv.latex()) {
run_latex = true; run_latex = true;
string command = conv.command; string command = conv.command();
command = subst(command, token_from, ""); command = subst(command, token_from, "");
command = subst(command, token_latex_encoding, buffer ? command = subst(command, token_latex_encoding, buffer ?
buffer->params().encoding().latexName() : string()); buffer->params().encoding().latexName() : string());
@ -408,7 +408,7 @@ bool Converters::convert(Buffer const * buffer,
if (!runLaTeX(*buffer, command, runparams, errorList)) if (!runLaTeX(*buffer, command, runparams, errorList))
return false; return false;
} else { } else {
if (conv.need_aux && !run_latex) { if (conv.need_aux() && !run_latex) {
string command; string command;
switch (runparams.flavor) { switch (runparams.flavor) {
case OutputParams::DVILUATEX: case OutputParams::DVILUATEX:
@ -443,7 +443,7 @@ bool Converters::convert(Buffer const * buffer,
string const outfile2 = string const outfile2 =
to_utf8(makeRelPath(from_utf8(outfile.absFileName()), from_utf8(path))); to_utf8(makeRelPath(from_utf8(outfile.absFileName()), from_utf8(path)));
string command = conv.command; string command = conv.command();
command = subst(command, token_from, quoteName(infile2)); command = subst(command, token_from, quoteName(infile2));
command = subst(command, token_base, quoteName(from_base)); command = subst(command, token_base, quoteName(from_base));
command = subst(command, token_to, quoteName(outfile2)); command = subst(command, token_to, quoteName(outfile2));
@ -452,13 +452,13 @@ bool Converters::convert(Buffer const * buffer,
command = subst(command, token_orig_from, quoteName(onlyFileName(orig_from.absFileName()))); command = subst(command, token_orig_from, quoteName(onlyFileName(orig_from.absFileName())));
command = subst(command, token_encoding, buffer ? buffer->params().encoding().iconvName() : string()); command = subst(command, token_encoding, buffer ? buffer->params().encoding().iconvName() : string());
if (!conv.parselog.empty()) if (!conv.parselog().empty())
command += " 2> " + quoteName(infile2 + ".out"); command += " 2> " + quoteName(infile2 + ".out");
if (conv.from == "dvi" && conv.to == "ps") if (conv.from() == "dvi" && conv.to() == "ps")
command = add_options(command, command = add_options(command,
buffer->params().dvips_options()); buffer->params().dvips_options());
else if (conv.from == "dvi" && prefixIs(conv.to, "pdf")) else if (conv.from() == "dvi" && prefixIs(conv.to(), "pdf"))
command = add_options(command, command = add_options(command,
dvipdfm_options(buffer->params())); dvipdfm_options(buffer->params()));
@ -481,7 +481,7 @@ bool Converters::convert(Buffer const * buffer,
buffer ? buffer->filePath() buffer ? buffer->filePath()
: string()); : string());
if (!real_outfile.empty()) { if (!real_outfile.empty()) {
Mover const & mover = getMover(conv.to); Mover const & mover = getMover(conv.to());
if (!mover.rename(outfile, real_outfile)) if (!mover.rename(outfile, real_outfile))
res = -1; res = -1;
else else
@ -491,10 +491,10 @@ bool Converters::convert(Buffer const * buffer,
// converters to use the renamed file... // converters to use the renamed file...
outfile = real_outfile; outfile = real_outfile;
} }
if (!conv.parselog.empty()) { if (!conv.parselog().empty()) {
string const logfile = infile2 + ".log"; string const logfile = infile2 + ".log";
string const command2 = conv.parselog + string const command2 = conv.parselog() +
" < " + quoteName(infile2 + ".out") + " < " + quoteName(infile2 + ".out") +
" > " + quoteName(logfile); " > " + quoteName(logfile);
one.startscript(Systemcall::Wait, one.startscript(Systemcall::Wait,
@ -506,7 +506,7 @@ bool Converters::convert(Buffer const * buffer,
} }
if (res) { if (res) {
if (conv.to == "program") { if (conv.to() == "program") {
Alert::error(_("Build errors"), Alert::error(_("Build errors"),
_("There were errors during the build process.")); _("There were errors during the build process."));
} else { } else {
@ -522,18 +522,18 @@ bool Converters::convert(Buffer const * buffer,
} }
Converter const & conv = converterlist_[edgepath.back()]; Converter const & conv = converterlist_[edgepath.back()];
if (conv.To->dummy()) if (conv.To()->dummy())
return true; return true;
if (!conv.result_dir.empty()) { if (!conv.result_dir().empty()) {
// The converter has put the file(s) in a directory. // The converter has put the file(s) in a directory.
// In this case we ignore the given to_file. // In this case we ignore the given to_file.
if (from_base != to_base) { if (from_base != to_base) {
string const from = subst(conv.result_dir, string const from = subst(conv.result_dir(),
token_base, from_base); token_base, from_base);
string const to = subst(conv.result_dir, string const to = subst(conv.result_dir(),
token_base, to_base); token_base, to_base);
Mover const & mover = getMover(conv.from); Mover const & mover = getMover(conv.from());
if (!mover.rename(FileName(from), FileName(to))) { if (!mover.rename(FileName(from), FileName(to))) {
Alert::error(_("Cannot convert file"), Alert::error(_("Cannot convert file"),
bformat(_("Could not move a temporary directory from %1$s to %2$s."), bformat(_("Could not move a temporary directory from %1$s to %2$s."),
@ -545,7 +545,7 @@ bool Converters::convert(Buffer const * buffer,
} else { } else {
if (conversionflags & try_cache) if (conversionflags & try_cache)
ConverterCache::get().add(orig_from, to_format, outfile); ConverterCache::get().add(orig_from, to_format, outfile);
return move(conv.to, outfile, to_file, conv.latex); return move(conv.to(), outfile, to_file, conv.latex());
} }
} }
@ -596,7 +596,7 @@ bool Converters::formatIsUsed(string const & format)
ConverterList::const_iterator cit = converterlist_.begin(); ConverterList::const_iterator cit = converterlist_.begin();
ConverterList::const_iterator end = converterlist_.end(); ConverterList::const_iterator end = converterlist_.end();
for (; cit != end; ++cit) { for (; cit != end; ++cit) {
if (cit->from == format || cit->to == format) if (cit->from() == format || cit->to() == format)
return true; return true;
} }
return false; return false;
@ -682,13 +682,13 @@ void Converters::buildGraph()
// clear graph's data structures // clear graph's data structures
G_.init(formats.size()); G_.init(formats.size());
// each of the converters knows how to convert one format to another // each of the converters knows how to convert one format to another
// so, for each of them, we create an arrow on the graph, going from // so, for each of them, we create an arrow on the graph, going from
// the one to the other // the one to the other
ConverterList::iterator it = converterlist_.begin(); ConverterList::iterator it = converterlist_.begin();
ConverterList::iterator const end = converterlist_.end(); ConverterList::iterator const end = converterlist_.end();
for (; it != end ; ++it) { for (; it != end ; ++it) {
int const from = formats.getNumber(it->from); int const from = formats.getNumber(it->from());
int const to = formats.getNumber(it->to); int const to = formats.getNumber(it->to());
G_.addEdge(from, to); G_.addEdge(from, to);
} }
} }

View File

@ -40,36 +40,73 @@ public:
/// ///
void readFlags(); void readFlags();
/// ///
std::string from; std::string const & from() const { return from_; }
/// ///
std::string to; std::string const & to() const { return to_; }
/// ///
std::string command; std::string const & command() const { return command_; }
/// ///
std::string flags; void setCommand(std::string const & command) { command_ = command; }
/// ///
Format const * From; std::string const & flags() const { return flags_; }
/// ///
Format const * To; void setFlags(std::string const & flags) { flags_ = flags; }
///
Format const * From() const { return From_; }
///
void setFrom(Format const * From) { From_ = From; }
///
void setTo(Format const * To) { To_ = To; }
///
Format const * To() const { return To_; }
///
bool latex() const { return latex_; }
///
std::string const & latex_flavor() const { return latex_flavor_; }
///
bool xml() const { return xml_; }
///
bool need_aux() const { return need_aux_; }
///
bool nice() const { return nice_; }
///
std::string const & result_dir() const { return result_dir_; }
///
std::string const & result_file() const { return result_file_; }
///
std::string const & parselog() const { return parselog_; }
private:
///
std::string from_;
///
std::string to_;
///
std::string command_;
///
std::string flags_;
///
Format const * From_;
///
Format const * To_;
/// The converter is latex or its derivatives /// The converter is latex or its derivatives
bool latex; bool latex_;
/// The latex derivate /// The latex derivate
std::string latex_flavor; std::string latex_flavor_;
/// The converter is xml /// The converter is xml
bool xml; bool xml_;
/// This converter needs the .aux files /// This converter needs the .aux files
bool need_aux; bool need_aux_;
/// we need a "nice" file from the backend, c.f. OutputParams.nice. /// we need a "nice" file from the backend, c.f. OutputParams.nice.
bool nice; bool nice_;
/// If the converter put the result in a directory, then result_dir /// If the converter put the result in a directory, then result_dir
/// is the name of the directory /// is the name of the directory
std::string result_dir; std::string result_dir_;
/// If the converter put the result in a directory, then result_file /// If the converter put the result in a directory, then result_file
/// is the name of the main file in that directory /// is the name of the main file in that directory
std::string result_file; std::string result_file_;
/// Command to convert the program output to a LaTeX log file format /// Command to convert the program output to a LaTeX log file format
std::string parselog; std::string parselog_;
}; };

View File

@ -2330,7 +2330,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
} }
if (tag != RC_LAST) if (tag != RC_LAST)
break; break;
case RC_NUMLASTFILES: case RC_NUMLASTFILES:
if (ignore_system_lyxrc || if (ignore_system_lyxrc ||
num_lastfiles != system_lyxrc.num_lastfiles) { num_lastfiles != system_lyxrc.num_lastfiles) {
@ -2830,23 +2830,23 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
for (Converters::const_iterator cit = theConverters().begin(); for (Converters::const_iterator cit = theConverters().begin();
cit != theConverters().end(); ++cit) { cit != theConverters().end(); ++cit) {
Converter const * converter = Converter const * converter =
theSystemConverters().getConverter(cit->from, theSystemConverters().getConverter(cit->from(),
cit->to); cit->to());
if (!converter || if (!converter ||
converter->command != cit->command || converter->command() != cit->command() ||
converter->flags != cit->flags) converter->flags() != cit->flags())
os << "\\converter \"" << cit->from << "\" \"" os << "\\converter \"" << cit->from() << "\" \""
<< cit->to << "\" \"" << cit->to() << "\" \""
<< escapeCommand(cit->command) << "\" \"" << escapeCommand(cit->command()) << "\" \""
<< cit->flags << "\"\n"; << cit->flags() << "\"\n";
} }
// New/modifed converters // New/modifed converters
for (Converters::const_iterator cit = theSystemConverters().begin(); for (Converters::const_iterator cit = theSystemConverters().begin();
cit != theSystemConverters().end(); ++cit) cit != theSystemConverters().end(); ++cit)
if (!theConverters().getConverter(cit->from, cit->to)) if (!theConverters().getConverter(cit->from(), cit->to()))
os << "\\converter \"" << cit->from os << "\\converter \"" << cit->from()
<< "\" \"" << cit->to << "\" \"\" \"\"\n"; << "\" \"" << cit->to() << "\" \"\" \"\"\n";
if (tag != RC_LAST) if (tag != RC_LAST)
break; break;

View File

@ -232,7 +232,7 @@ QString browseRelToSub(QString const & filename, QString const & relpath,
QString testname = reloutname; QString testname = reloutname;
testname.remove(QRegExp("^(\\.\\./)+")); testname.remove(QRegExp("^(\\.\\./)+"));
if (testname.contains("/")) if (testname.contains("/"))
return outname; return outname;
else else
@ -600,8 +600,8 @@ void PrefInput::on_scrollzoomEnableCB_toggled(bool enabled)
{ {
scrollzoomValueCO->setEnabled(enabled); scrollzoomValueCO->setEnabled(enabled);
} }
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
// //
// PrefCompletion // PrefCompletion
@ -1097,7 +1097,7 @@ namespace {
struct ColorSorter struct ColorSorter
{ {
bool operator()(ColorCode lhs, ColorCode rhs) const { bool operator()(ColorCode lhs, ColorCode rhs) const {
return return
compare_no_case(lcolor.getGUIName(lhs), lcolor.getGUIName(rhs)) < 0; compare_no_case(lcolor.getGUIName(lhs), lcolor.getGUIName(rhs)) < 0;
} }
}; };
@ -1541,12 +1541,12 @@ void PrefSpellchecker::update(LyXRC const & rc)
void PrefSpellchecker::on_spellcheckerCB_currentIndexChanged(int index) void PrefSpellchecker::on_spellcheckerCB_currentIndexChanged(int index)
{ {
QString spellchecker = spellcheckerCB->itemData(index).toString(); QString spellchecker = spellcheckerCB->itemData(index).toString();
compoundWordCB->setEnabled(spellchecker == QString("aspell")); compoundWordCB->setEnabled(spellchecker == QString("aspell"));
} }
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
// //
// PrefConverters // PrefConverters
@ -1634,8 +1634,8 @@ void PrefConverters::updateGui()
Converters::const_iterator cend = form_->converters().end(); Converters::const_iterator cend = form_->converters().end();
for (; ccit != cend; ++ccit) { for (; ccit != cend; ++ccit) {
QString const name = QString const name =
qt_(ccit->From->prettyname()) + " -> " + qt_(ccit->To->prettyname()); qt_(ccit->From()->prettyname()) + " -> " + qt_(ccit->To()->prettyname());
int type = form_->converters().getNumber(ccit->From->name(), ccit->To->name()); int type = form_->converters().getNumber(ccit->From()->name(), ccit->To()->name());
new QListWidgetItem(name, convertersLW, type); new QListWidgetItem(name, convertersLW, type);
} }
convertersLW->sortItems(Qt::AscendingOrder); convertersLW->sortItems(Qt::AscendingOrder);
@ -1661,10 +1661,10 @@ void PrefConverters::switchConverter()
{ {
int const cnr = convertersLW->currentItem()->type(); int const cnr = convertersLW->currentItem()->type();
Converter const & c(form_->converters().get(cnr)); Converter const & c(form_->converters().get(cnr));
converterFromCO->setCurrentIndex(form_->formats().getNumber(c.from)); converterFromCO->setCurrentIndex(form_->formats().getNumber(c.from()));
converterToCO->setCurrentIndex(form_->formats().getNumber(c.to)); converterToCO->setCurrentIndex(form_->formats().getNumber(c.to()));
converterED->setText(toqstr(c.command)); converterED->setText(toqstr(c.command()));
converterFlagED->setText(toqstr(c.flags)); converterFlagED->setText(toqstr(c.flags()));
updateButtons(); updateButtons();
} }
@ -1693,8 +1693,8 @@ void PrefConverters::updateButtons()
if (convertersLW->count() > 0) { if (convertersLW->count() > 0) {
int const cnr = convertersLW->currentItem()->type(); int const cnr = convertersLW->currentItem()->type();
Converter const & c = form_->converters().get(cnr); Converter const & c = form_->converters().get(cnr);
old_command = c.command; old_command = c.command();
old_flag = c.flags; old_flag = c.flags();
} }
string const new_command = fromqstr(converterED->text()); string const new_command = fromqstr(converterED->text());
@ -2133,13 +2133,13 @@ namespace {
void updateComboBox(LyXRC::Alternatives const & alts, void updateComboBox(LyXRC::Alternatives const & alts,
string const & fmt, QComboBox * combo) string const & fmt, QComboBox * combo)
{ {
LyXRC::Alternatives::const_iterator it = LyXRC::Alternatives::const_iterator it =
alts.find(fmt); alts.find(fmt);
if (it != alts.end()) { if (it != alts.end()) {
LyXRC::CommandSet const & cmds = it->second; LyXRC::CommandSet const & cmds = it->second;
LyXRC::CommandSet::const_iterator sit = LyXRC::CommandSet::const_iterator sit =
cmds.begin(); cmds.begin();
LyXRC::CommandSet::const_iterator const sen = LyXRC::CommandSet::const_iterator const sen =
cmds.end(); cmds.end();
for (; sit != sen; ++sit) { for (; sit != sen; ++sit) {
QString const qcmd = toqstr(*sit); QString const qcmd = toqstr(*sit);
@ -2316,7 +2316,7 @@ PrefLanguage::PrefLanguage(GuiPreferences * form)
if (!lang) if (!lang)
continue; continue;
// never remove the currently selected language // never remove the currently selected language
if (name != form->rc().gui_language if (name != form->rc().gui_language
&& name != lyxrc.gui_language && name != lyxrc.gui_language
&& (!Messages::available(lang->code()) && (!Messages::available(lang->code())
|| added.find(lang->code()) != added.end())) || added.find(lang->code()) != added.end()))
@ -3004,7 +3004,7 @@ void PrefShortcuts::on_shortcutsTW_itemSelectionChanged()
if (items.isEmpty()) if (items.isEmpty())
return; return;
KeyMap::ItemType tag = KeyMap::ItemType tag =
static_cast<KeyMap::ItemType>(items[0]->data(0, Qt::UserRole).toInt()); static_cast<KeyMap::ItemType>(items[0]->data(0, Qt::UserRole).toInt());
if (tag == KeyMap::UserUnbind) if (tag == KeyMap::UserUnbind)
removePB->setText(qt_("Res&tore")); removePB->setText(qt_("Res&tore"));
@ -3044,7 +3044,7 @@ void PrefShortcuts::removeShortcut()
string shortcut = fromqstr(items[i]->data(1, Qt::UserRole).toString()); string shortcut = fromqstr(items[i]->data(1, Qt::UserRole).toString());
string lfun = fromqstr(items[i]->text(0)); string lfun = fromqstr(items[i]->text(0));
FuncRequest func = lyxaction.lookupFunc(lfun); FuncRequest func = lyxaction.lookupFunc(lfun);
KeyMap::ItemType tag = KeyMap::ItemType tag =
static_cast<KeyMap::ItemType>(items[i]->data(0, Qt::UserRole).toInt()); static_cast<KeyMap::ItemType>(items[i]->data(0, Qt::UserRole).toInt());
switch (tag) { switch (tag) {
@ -3183,7 +3183,7 @@ void PrefShortcuts::shortcutOkPressed()
if (oldBinding == func) if (oldBinding == func)
// nothing has changed // nothing has changed
return; return;
// make sure this key isn't already bound---and, if so, prompt user // make sure this key isn't already bound---and, if so, prompt user
FuncCode const unbind = user_unbind_.getBinding(k).action(); FuncCode const unbind = user_unbind_.getBinding(k).action();
docstring const action_string = makeCmdString(oldBinding); docstring const action_string = makeCmdString(oldBinding);
@ -3330,7 +3330,7 @@ GuiPreferences::GuiPreferences(GuiView & lv)
addModule(new PrefSpellchecker(this)); addModule(new PrefSpellchecker(this));
//for strftime validator //for strftime validator
PrefOutput * output = new PrefOutput(this); PrefOutput * output = new PrefOutput(this);
addModule(output); addModule(output);
addModule(new PrefPrinter(this)); addModule(new PrefPrinter(this));
addModule(new PrefLatex(this)); addModule(new PrefLatex(this));
@ -3409,11 +3409,11 @@ bool GuiPreferences::initialiseParams(string const &)
movers_ = theMovers(); movers_ = theMovers();
colors_.clear(); colors_.clear();
update_screen_font_ = false; update_screen_font_ = false;
updateRc(rc_); updateRc(rc_);
// Make sure that the bc is in the INITIAL state // Make sure that the bc is in the INITIAL state
if (bc().policy().buttonStatus(ButtonPolicy::RESTORE)) if (bc().policy().buttonStatus(ButtonPolicy::RESTORE))
bc().restore(); bc().restore();
return true; return true;
} }
@ -3429,7 +3429,7 @@ void GuiPreferences::dispatchParams()
prefsApplied(rc_); prefsApplied(rc_);
// FIXME: these need lfuns // FIXME: these need lfuns
// FIXME UNICODE // FIXME UNICODE
Author const & author = Author const & author =
Author(from_utf8(rc_.user_name), from_utf8(rc_.user_email)); Author(from_utf8(rc_.user_name), from_utf8(rc_.user_email));
theBufferList().recordCurrentAuthor(author); theBufferList().recordCurrentAuthor(author);

View File

@ -356,16 +356,16 @@ static void build_script(string const & from_file,
// Build the conversion command // Build the conversion command
string const infile = outfile; string const infile = outfile;
string const infile_base = changeExtension(infile, string()); string const infile_base = changeExtension(infile, string());
outfile = conv.result_file.empty() outfile = conv.result_file().empty()
? addExtension(to_base, conv.To->extension()) ? addExtension(to_base, conv.To()->extension())
: addName(subst(conv.result_dir, : addName(subst(conv.result_dir(),
token_base, infile_base), token_base, infile_base),
subst(conv.result_file, subst(conv.result_file(),
token_base, onlyFileName(infile_base))); token_base, onlyFileName(infile_base)));
// If two formats share the same extension we may get identical names // If two formats share the same extension we may get identical names
if (outfile == infile && conv.result_file.empty()) { if (outfile == infile && conv.result_file().empty()) {
TempFile tempfile(addExtension("gconvertXXXXXX", conv.To->extension())); TempFile tempfile(addExtension("gconvertXXXXXX", conv.To()->extension()));
tempfile.setAutoRemove(false); tempfile.setAutoRemove(false);
outfile = tempfile.name().toFilesystemEncoding(); outfile = tempfile.name().toFilesystemEncoding();
} }
@ -381,7 +381,7 @@ static void build_script(string const & from_file,
// See comment about extra " quotes above (although that // See comment about extra " quotes above (although that
// applies only for the first loop run here). // applies only for the first loop run here).
string command = conv.command; string command = conv.command();
command = subst(command, token_from, "' + '\"' + infile + '\"' + '"); command = subst(command, token_from, "' + '\"' + infile + '\"' + '");
command = subst(command, token_base, "' + '\"' + infile_base + '\"' + '"); command = subst(command, token_base, "' + '\"' + infile_base + '\"' + '");
command = subst(command, token_to, "' + '\"' + outfile + '\"' + '"); command = subst(command, token_to, "' + '\"' + outfile + '\"' + '");

View File

@ -538,7 +538,7 @@ void PreviewLoader::Impl::startLoading(bool wait)
// Create an InProgress instance to place in the map of all // Create an InProgress instance to place in the map of all
// such processes if it starts correctly. // such processes if it starts correctly.
InProgress inprogress(filename_base, pending_, pconverter_->to); InProgress inprogress(filename_base, pending_, pconverter_->to());
// clear pending_, so we're ready to start afresh. // clear pending_, so we're ready to start afresh.
pending_.clear(); pending_.clear();
@ -585,7 +585,7 @@ void PreviewLoader::Impl::startLoading(bool wait)
// The conversion command. // The conversion command.
ostringstream cs; ostringstream cs;
cs << pconverter_->command cs << pconverter_->command()
<< " " << quoteName(latexfile.toFilesystemEncoding()) << " " << quoteName(latexfile.toFilesystemEncoding())
<< " --dpi " << int(font_scaling_factor); << " --dpi " << int(font_scaling_factor);