mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Add master's perspective in children's source preview
This commit is contained in:
parent
0c76f9c430
commit
b6ecb3213b
@ -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(¶ms().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);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
@ -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>&Update</string>
|
||||
<string>&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>&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>
|
||||
|
Loading…
Reference in New Issue
Block a user