The branch, master, has been updated. - Log -----------------------------------------------------------------
commit b6ecb3213bfa045618936c1a0905cbc562ec2bb0 Author: Juergen Spitzmueller <[email protected]> Date: Fri Oct 5 14:30:20 2012 +0200 Add master's perspective in children's source preview diff --git a/src/Buffer.cpp b/src/Buffer.cpp index b0db5c7..3561c45 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -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); } } diff --git a/src/Buffer.h b/src/Buffer.h index 8873471..246e1ce 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -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 diff --git a/src/frontends/qt4/GuiViewSource.cpp b/src/frontends/qt4/GuiViewSource.cpp index f4f197d..1fc259b 100644 --- a/src/frontends/qt4/GuiViewSource.cpp +++ b/src/frontends/qt4/GuiViewSource.cpp @@ -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()); } diff --git a/src/frontends/qt4/ui/ViewSourceUi.ui b/src/frontends/qt4/ui/ViewSourceUi.ui index d37ba1f..0691fd2 100644 --- a/src/frontends/qt4/ui/ViewSourceUi.ui +++ b/src/frontends/qt4/ui/ViewSourceUi.ui @@ -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> ----------------------------------------------------------------------- Summary of changes: src/Buffer.cpp | 11 +++++++---- src/Buffer.h | 3 ++- src/frontends/qt4/GuiViewSource.cpp | 12 +++++++++--- src/frontends/qt4/ui/ViewSourceUi.ui | 30 +++++++++++++++++------------- 4 files changed, 35 insertions(+), 21 deletions(-) hooks/post-receive -- The LyX Source Repository
