masterPerspectiveCB->isChecked());
QString old = document_->toPlainText();
QString qcontent = toqstr(content);
-#ifdef DEVEL_VERSION
- // output tex<->row correspondences in the source panel if the "-dbg latex"
- // option is given.
- if (texrow_ && lyx::lyxerr.debugging(Debug::LATEX)) {
- QStringList list = qcontent.split(QChar('\n'));
- docstring_list dlist;
- for (QStringList::const_iterator it = list.begin(); it != list.end(); ++it)
- dlist.push_back(from_utf8(fromqstr(*it)));
- texrow_->prepend(dlist);
- qcontent.clear();
- for (docstring_list::iterator it = dlist.begin(); it != dlist.end(); ++it)
- qcontent += toqstr(*it) + '\n';
+ if (guiApp->currentView()->develMode()) {
+ // output tex<->row correspondences in the source panel if the "-dbg latex"
+ // option is given.
+ if (texrow_ && lyx::lyxerr.debugging(Debug::LATEX)) {
+ QStringList list = qcontent.split(QChar('\n'));
+ docstring_list dlist;
+ for (QStringList::const_iterator it = list.begin(); it != list.end(); ++it)
+ dlist.push_back(from_utf8(fromqstr(*it)));
+ texrow_->prepend(dlist);
+ qcontent.clear();
+ for (docstring_list::iterator it = dlist.begin(); it != dlist.end(); ++it)
+ qcontent += toqstr(*it) + '\n';
+ }
}
-#endif
+
// prevent gotoCursor()
QSignalBlocker blocker(viewSourceTV);
bool const changed = setText(qcontent);
if (changed && !texrow_) {
// position-to-row is unavailable
// we jump to the first modification
- const QChar * oc = old.constData();
- const QChar * nc = qcontent.constData();
+ int length = min(old.length(), qcontent.length());
int pos = 0;
- while (*oc != '\0' && *nc != '\0' && *oc == *nc) {
- ++oc;
- ++nc;
- ++pos;
- }
+ for (; pos < length && old.at(pos) == qcontent.at(pos); ++pos) {}
QTextCursor c = QTextCursor(viewSourceTV->document());
//get some space below the cursor
c.setPosition(pos);
// Compute the actual format used
string const format = !bv ? ""
: flavor2format(bv->buffer().params().getOutputFlavor(view_format_));
- Format const * f = formats.getFormat(format.empty() ? view_format_ : format);
+ Format const * f = theFormats().getFormat(format.empty() ? view_format_ : format);
return f ? f->prettyname() : from_utf8(view_format_);
}
QSignalBlocker blocker(outputFormatCO);
outputFormatCO->clear();
outputFormatCO->addItem(qt_("Default"),
- QVariant(QString("default")));
+ QVariant(QString("default")));
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);
+ for (string const & fmt_name : bv.buffer().params().backends()) {
+ Format const * fmt = theFormats().getFormat(fmt_name);
if (!fmt) {
- LYXERR0("Can't find format for backend " << format << "!");
+ LYXERR0("Can't find format for backend " << fmt_name << "!");
continue;
- }
-
+ }
QString const pretty = toqstr(translateIfPossible(fmt->prettyname()));
- outputFormatCO->addItem(pretty, QVariant(toqstr(format)));
- if (format == view_format_)
- index = outputFormatCO->count() -1;
+ outputFormatCO->addItem(pretty, QVariant(toqstr(fmt_name)));
+ if (fmt_name == view_format_)
+ index = outputFormatCO->count() - 1;
}
setViewFormat(index);
}
QWidget::resizeEvent(event);
}
-void ViewSourceWidget::saveSession(QString const & session_key) const
+
+void ViewSourceWidget::saveSession(QSettings & settings, QString const & session_key) const
{
- QSettings settings;
settings.setValue(session_key + "/output", toqstr(view_format_));
settings.setValue(session_key + "/contents", contentsCO->currentIndex());
settings.setValue(session_key + "/autoupdate", autoUpdateCB->isChecked());
}
-void GuiViewSource::on_bufferViewChanged()
+void GuiViewSource::onBufferViewChanged()
{
widget_->setText();
widget_->setEnabled((bool)bufferview());
}
-void GuiViewSource::saveSession() const
+void GuiViewSource::saveSession(QSettings & settings) const
{
- Dialog::saveSession();
- widget_->saveSession(sessionKey());
+ Dialog::saveSession(settings);
+ widget_->saveSession(settings, sessionKey());
}