mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-03 08:28:25 +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,
|
void Buffer::getSourceCode(odocstream & os, string const format,
|
||||||
pit_type par_begin, pit_type par_end,
|
pit_type par_begin, pit_type par_end,
|
||||||
OutputWhat output) const
|
OutputWhat output, bool master) const
|
||||||
{
|
{
|
||||||
OutputParams runparams(¶ms().encoding());
|
OutputParams runparams(¶ms().encoding());
|
||||||
runparams.nice = true;
|
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,
|
// child of some other buffer, let's cut the link here,
|
||||||
// so that no concurring settings from the master
|
// so that no concurring settings from the master
|
||||||
// (e.g. branch state) interfere (see #8101).
|
// (e.g. branch state) interfere (see #8101).
|
||||||
// FIXME: Add an optional "from master" perspective.
|
if (!master)
|
||||||
d->ignore_parent = true;
|
d->ignore_parent = true;
|
||||||
// We need to validate the Buffer params' features here
|
// We need to validate the Buffer params' features here
|
||||||
// in order to know if we should output polyglossia
|
// in order to know if we should output polyglossia
|
||||||
// macros (instead of babel macros)
|
// macros (instead of babel macros)
|
||||||
@ -3369,7 +3369,8 @@ void Buffer::getSourceCode(odocstream & os, string const format,
|
|||||||
latexParagraphs(*this, text(), ots, runparams);
|
latexParagraphs(*this, text(), ots, runparams);
|
||||||
|
|
||||||
// Restore the parenthood
|
// Restore the parenthood
|
||||||
d->ignore_parent = false;
|
if (!master)
|
||||||
|
d->ignore_parent = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
os << "% ";
|
os << "% ";
|
||||||
@ -3404,6 +3405,8 @@ void Buffer::getSourceCode(odocstream & os, string const format,
|
|||||||
d->texrow.newline();
|
d->texrow.newline();
|
||||||
d->texrow.newline();
|
d->texrow.newline();
|
||||||
otexstream ots(os, d->texrow);
|
otexstream ots(os, d->texrow);
|
||||||
|
if (master)
|
||||||
|
runparams.is_child = true;
|
||||||
writeLaTeXSource(ots, string(), runparams, output);
|
writeLaTeXSource(ots, string(), runparams, output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -589,7 +589,8 @@ public:
|
|||||||
/// get source code (latex/docbook) for some paragraphs, or all paragraphs
|
/// get source code (latex/docbook) for some paragraphs, or all paragraphs
|
||||||
/// including preamble
|
/// including preamble
|
||||||
void getSourceCode(odocstream & os, std::string const format,
|
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.
|
/// Access to error list.
|
||||||
/// This method is used only for GUI visualisation of Buffer related
|
/// This method is used only for GUI visualisation of Buffer related
|
||||||
|
@ -55,6 +55,8 @@ ViewSourceWidget::ViewSourceWidget()
|
|||||||
updatePB, SLOT(setDisabled(bool)));
|
updatePB, SLOT(setDisabled(bool)));
|
||||||
connect(autoUpdateCB, SIGNAL(toggled(bool)),
|
connect(autoUpdateCB, SIGNAL(toggled(bool)),
|
||||||
this, SLOT(updateView()));
|
this, SLOT(updateView()));
|
||||||
|
connect(masterPerspectiveCB, SIGNAL(toggled(bool)),
|
||||||
|
this, SLOT(updateView()));
|
||||||
connect(updatePB, SIGNAL(clicked()),
|
connect(updatePB, SIGNAL(clicked()),
|
||||||
this, SLOT(updateView()));
|
this, SLOT(updateView()));
|
||||||
connect(outputFormatCO, SIGNAL(activated(int)),
|
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.
|
\return true if the content has changed since last call.
|
||||||
*/
|
*/
|
||||||
static bool getContent(BufferView const * view, Buffer::OutputWhat output,
|
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,
|
// get the *top* level paragraphs that contain the cursor,
|
||||||
// or the selected text
|
// or the selected text
|
||||||
@ -108,7 +111,8 @@ static bool getContent(BufferView const * view, Buffer::OutputWhat output,
|
|||||||
if (par_begin > par_end)
|
if (par_begin > par_end)
|
||||||
swap(par_begin, par_end);
|
swap(par_begin, par_end);
|
||||||
odocstringstream ostr;
|
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();
|
docstring s = ostr.str();
|
||||||
static size_t crc = 0;
|
static size_t crc = 0;
|
||||||
size_t newcrc = crcCheck(s);
|
size_t newcrc = crcCheck(s);
|
||||||
@ -165,7 +169,8 @@ void ViewSourceWidget::updateView()
|
|||||||
else if (contentsCO->currentIndex() == 3)
|
else if (contentsCO->currentIndex() == 3)
|
||||||
output = Buffer::OnlyBody;
|
output = Buffer::OnlyBody;
|
||||||
|
|
||||||
if (getContent(bv_, output, content, format, force_getcontent_))
|
if (getContent(bv_, output, content, format,
|
||||||
|
force_getcontent_, masterPerspectiveCB->isChecked()))
|
||||||
document_->setPlainText(content);
|
document_->setPlainText(content);
|
||||||
|
|
||||||
CursorSlice beg = bv_->cursor().selectionBegin().bottom();
|
CursorSlice beg = bv_->cursor().selectionBegin().bottom();
|
||||||
@ -243,6 +248,7 @@ void GuiViewSource::updateView()
|
|||||||
widget_->setBufferView(bufferview());
|
widget_->setBufferView(bufferview());
|
||||||
widget_->updateView();
|
widget_->updateView();
|
||||||
}
|
}
|
||||||
|
widget_->masterPerspectiveCB->setEnabled(buffer().parent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,17 +73,17 @@
|
|||||||
</item>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1" colspan="2" >
|
<item row="2" column="1" colspan="2" >
|
||||||
<widget class="QPushButton" name="updatePB" >
|
<widget class="QCheckBox" name="masterPerspectiveCB" >
|
||||||
<property name="enabled" >
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
<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>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1" colspan="2" >
|
<item row="3" column="1" colspan="2" >
|
||||||
<widget class="QCheckBox" name="autoUpdateCB" >
|
<widget class="QCheckBox" name="autoUpdateCB" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Automatic update</string>
|
<string>Automatic update</string>
|
||||||
@ -93,13 +93,17 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
<zorder>viewSourceTV</zorder>
|
|
||||||
<zorder>outputFormatLA</zorder>
|
|
||||||
<zorder>outputFormatCO</zorder>
|
|
||||||
<zorder>contentsCO</zorder>
|
|
||||||
<zorder>updatePB</zorder>
|
|
||||||
<zorder>autoUpdateCB</zorder>
|
|
||||||
</widget>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>viewSourceTV</tabstop>
|
<tabstop>viewSourceTV</tabstop>
|
||||||
|
Loading…
Reference in New Issue
Block a user