The View->Source pane resets the format every time you click into

a new paragraph, which is very annoying. This commit fixes this bug.

If anyone has a better idea, please let me know. I posted to devel
about it but got no response.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40456 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2011-12-09 19:48:50 +00:00
parent 2d8d85f47e
commit 264cc1139c
3 changed files with 26 additions and 6 deletions

View File

@ -58,7 +58,7 @@ ViewSourceWidget::ViewSourceWidget()
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:
@ -136,6 +136,13 @@ void ViewSourceWidget::contentsChanged()
}
void ViewSourceWidget::setViewFormat()
{
view_format_ = outputFormatCO->itemData(
outputFormatCO->currentIndex()).toString();
updateView();
}
void ViewSourceWidget::updateView()
{
if (!bv_) {
@ -146,8 +153,7 @@ void ViewSourceWidget::updateView()
setEnabled(true);
string const format = fromqstr(outputFormatCO->itemData(
outputFormatCO->currentIndex()).toString());
string const format = fromqstr(view_format_);
QString content;
Buffer::OutputWhat output = Buffer::CurrentParagraph;
@ -190,13 +196,20 @@ void ViewSourceWidget::updateDefaultFormat()
outputFormatCO->clear();
outputFormatCO->addItem(qt_("Default"),
QVariant(QString("default")));
int index = 0;
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)
for (; cit != end; ++cit) {
QString const fname = toqstr((*cit)->name());
outputFormatCO->addItem(qt_((*cit)->prettyname()),
QVariant(toqstr((*cit)->name())));
QVariant(fname));
if (fname == view_format_)
index = outputFormatCO->count() -1;
}
outputFormatCO->setCurrentIndex(index);
outputFormatCO->blockSignals(false);
}

View File

@ -42,9 +42,11 @@ public:
void setBufferView(BufferView const * bv);
public Q_SLOTS:
// update content
/// update content
void updateView();
///
void setViewFormat();
///
void updateDefaultFormat();
///
void contentsChanged();
@ -58,6 +60,8 @@ private:
LaTeXHighlighter * highlighter_;
///
bool force_getcontent_;
///
QString view_format_;
};

View File

@ -45,6 +45,9 @@
<property name="toolTip">
<string>Select the output format</string>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">