connect(updatePB, SIGNAL(clicked()),
this, SLOT(updateView()));
connect(outputFormatCO, SIGNAL(activated(int)),
- this, SLOT(updateView()));
+ this, SLOT(setViewFormat()));
// setting a document at this point trigger an assertion in Qt
// so we disable the signals here:
}
+void ViewSourceWidget::setViewFormat()
+{
+ view_format_ = outputFormatCO->itemData(
+ outputFormatCO->currentIndex()).toString();
+ updateView();
+}
+
+
void ViewSourceWidget::updateView()
{
if (!bv_) {
setEnabled(true);
- string const format = fromqstr(outputFormatCO->itemData(
- outputFormatCO->currentIndex()).toString());
+ string const format = fromqstr(view_format_);
QString content;
Buffer::OutputWhat output = Buffer::CurrentParagraph;
outputFormatCO->clear();
outputFormatCO->addItem(qt_("Default"),
QVariant(QString("default")));
- typedef vector<Format const *> Formats;
- Formats formats = bv_->buffer().params().exportableFormats(true);
- Formats::const_iterator cit = formats.begin();
- Formats::const_iterator end = formats.end();
- for (; cit != end; ++cit)
- outputFormatCO->addItem(qt_((*cit)->prettyname()),
- QVariant(toqstr((*cit)->name())));
+
+ int index = 0;
+ vector<string> tmp = bv_->buffer().params().backends();
+ vector<string>::const_iterator it = tmp.begin();
+ vector<string>::const_iterator en = tmp.end();
+ for (; it != en; ++it) {
+ string const format = *it;
+ Format const * fmt = formats.getFormat(format);
+ if (!fmt) {
+ LYXERR0("Can't find format for backend " << format << "!");
+ continue;
+ }
+
+ QString const pretty = qt_(fmt->prettyname());
+ QString const qformat = toqstr(format);
+ outputFormatCO->addItem(pretty, QVariant(qformat));
+ if (qformat == view_format_)
+ index = outputFormatCO->count() -1;
+ }
+ outputFormatCO->setCurrentIndex(index);
+
outputFormatCO->blockSignals(false);
}