Factor out some common code.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31655 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2009-10-17 22:58:44 +00:00
parent 973b0e25fb
commit 5f8f8dd947

View File

@ -1835,14 +1835,13 @@ void PrefFileformats::updatePrettyname()
}
void PrefFileformats::updateViewers()
namespace {
void updateComboBox(LyXRC::Alternatives const & alts,
string const & fmt, QComboBox * combo)
{
Format const f = currentFormat();
viewerCO->clear();
viewerCO->addItem(qt_("None"), QString());
LyXRC::Alternatives::const_iterator it =
viewer_alternatives.find(f.name());
if (it != viewer_alternatives.end()) {
alts.find(fmt);
if (it != alts.end()) {
LyXRC::CommandSet const & cmds = it->second;
LyXRC::CommandSet::const_iterator sit =
cmds.begin();
@ -1850,9 +1849,19 @@ void PrefFileformats::updateViewers()
cmds.end();
for (; sit != sen; ++sit) {
QString const qcmd = toqstr(*sit);
viewerCO->addItem(qcmd, qcmd);
combo->addItem(qcmd, qcmd);
}
}
}
}
void PrefFileformats::updateViewers()
{
Format const f = currentFormat();
viewerCO->clear();
viewerCO->addItem(qt_("None"), QString());
updateComboBox(viewer_alternatives, f.name(), viewerCO);
viewerCO->addItem(qt_("Custom"), QString("custom viewer"));
int pos = viewerCO->findData(toqstr(f.viewer()));
@ -1873,19 +1882,7 @@ void PrefFileformats::updateEditors()
Format const f = currentFormat();
editorCO->clear();
editorCO->addItem(qt_("None"), QString());
LyXRC::Alternatives::const_iterator it =
editor_alternatives.find(f.name());
if (it != editor_alternatives.end()) {
LyXRC::CommandSet const & cmds = it->second;
LyXRC::CommandSet::const_iterator sit =
cmds.begin();
LyXRC::CommandSet::const_iterator const sen =
cmds.end();
for (; sit != sen; ++sit) {
QString const qcmd = toqstr(*sit);
editorCO->addItem(qcmd, qcmd);
}
}
updateComboBox(editor_alternatives, f.name(), editorCO);
editorCO->addItem(qt_("Custom"), QString("custom editor"));
int pos = editorCO->findData(toqstr(f.editor()));