Add master's perspective in children's source preview

This commit is contained in:
Juergen Spitzmueller 2012-10-05 14:30:20 +02:00
parent 0c76f9c430
commit b6ecb3213b
4 changed files with 35 additions and 21 deletions

View File

@ -3303,7 +3303,7 @@ void Buffer::changeRefsIfUnique(docstring const & from, docstring const & to,
void Buffer::getSourceCode(odocstream & os, string const format,
pit_type par_begin, pit_type par_end,
OutputWhat output) const
OutputWhat output, bool master) const
{
OutputParams runparams(&params().encoding());
runparams.nice = true;
@ -3350,8 +3350,8 @@ void Buffer::getSourceCode(odocstream & os, string const format,
// child of some other buffer, let's cut the link here,
// so that no concurring settings from the master
// (e.g. branch state) interfere (see #8101).
// FIXME: Add an optional "from master" perspective.
d->ignore_parent = true;
if (!master)
d->ignore_parent = true;
// We need to validate the Buffer params' features here
// in order to know if we should output polyglossia
// macros (instead of babel macros)
@ -3369,7 +3369,8 @@ void Buffer::getSourceCode(odocstream & os, string const format,
latexParagraphs(*this, text(), ots, runparams);
// Restore the parenthood
d->ignore_parent = false;
if (!master)
d->ignore_parent = false;
}
} else {
os << "% ";
@ -3404,6 +3405,8 @@ void Buffer::getSourceCode(odocstream & os, string const format,
d->texrow.newline();
d->texrow.newline();
otexstream ots(os, d->texrow);
if (master)
runparams.is_child = true;
writeLaTeXSource(ots, string(), runparams, output);
}
}

View File

@ -589,7 +589,8 @@ public:
/// get source code (latex/docbook) for some paragraphs, or all paragraphs
/// including preamble
void getSourceCode(odocstream & os, std::string const format,
pit_type par_begin, pit_type par_end, OutputWhat output) const;
pit_type par_begin, pit_type par_end, OutputWhat output,
bool master) const;
/// Access to error list.
/// This method is used only for GUI visualisation of Buffer related

View File

@ -55,6 +55,8 @@ ViewSourceWidget::ViewSourceWidget()
updatePB, SLOT(setDisabled(bool)));
connect(autoUpdateCB, SIGNAL(toggled(bool)),
this, SLOT(updateView()));
connect(masterPerspectiveCB, SIGNAL(toggled(bool)),
this, SLOT(updateView()));
connect(updatePB, SIGNAL(clicked()),
this, SLOT(updateView()));
connect(outputFormatCO, SIGNAL(activated(int)),
@ -91,7 +93,8 @@ static size_t crcCheck(docstring const & s)
\return true if the content has changed since last call.
*/
static bool getContent(BufferView const * view, Buffer::OutputWhat output,
QString & qstr, string const format, bool force_getcontent)
QString & qstr, string const format, bool force_getcontent,
bool master)
{
// get the *top* level paragraphs that contain the cursor,
// or the selected text
@ -108,7 +111,8 @@ static bool getContent(BufferView const * view, Buffer::OutputWhat output,
if (par_begin > par_end)
swap(par_begin, par_end);
odocstringstream ostr;
view->buffer().getSourceCode(ostr, format, par_begin, par_end + 1, output);
view->buffer().getSourceCode(ostr, format, par_begin, par_end + 1,
output, master);
docstring s = ostr.str();
static size_t crc = 0;
size_t newcrc = crcCheck(s);
@ -165,7 +169,8 @@ void ViewSourceWidget::updateView()
else if (contentsCO->currentIndex() == 3)
output = Buffer::OnlyBody;
if (getContent(bv_, output, content, format, force_getcontent_))
if (getContent(bv_, output, content, format,
force_getcontent_, masterPerspectiveCB->isChecked()))
document_->setPlainText(content);
CursorSlice beg = bv_->cursor().selectionBegin().bottom();
@ -243,6 +248,7 @@ void GuiViewSource::updateView()
widget_->setBufferView(bufferview());
widget_->updateView();
}
widget_->masterPerspectiveCB->setEnabled(buffer().parent());
}

View File

@ -73,17 +73,17 @@
</item>
</widget>
</item>
<item row="3" column="1" colspan="2" >
<widget class="QPushButton" name="updatePB" >
<property name="enabled" >
<bool>false</bool>
</property>
<item row="2" column="1" colspan="2" >
<widget class="QCheckBox" name="masterPerspectiveCB" >
<property name="text" >
<string>&amp;Update</string>
<string>&amp;Master's perspective</string>
</property>
<property name="toolTip" >
<string>Show the source as the master document gets it</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2" >
<item row="3" column="1" colspan="2" >
<widget class="QCheckBox" name="autoUpdateCB" >
<property name="text" >
<string>Automatic update</string>
@ -93,13 +93,17 @@
</property>
</widget>
</item>
<item row="4" column="1" colspan="2" >
<widget class="QPushButton" name="updatePB" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>&amp;Update</string>
</property>
</widget>
</item>
</layout>
<zorder>viewSourceTV</zorder>
<zorder>outputFormatLA</zorder>
<zorder>outputFormatCO</zorder>
<zorder>contentsCO</zorder>
<zorder>updatePB</zorder>
<zorder>autoUpdateCB</zorder>
</widget>
<tabstops>
<tabstop>viewSourceTV</tabstop>