mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 21:21:32 +00:00
Reimplement computation of change tracking status
This is a reimplementation of 6d4e6aad
that is both simpler and more
complete.
This uses the updateBuffer mechanism to implement a fully working
version of Inset::isChanged(). Now the function returns true for an
inset that contains an inset that contains a change, for example.
Moverover Buffer::areChangesPresent() is merely a proxy for
Buffer::inset().isChanged().
This commit is contained in:
parent
dba1e40b52
commit
4a4ded2297
@ -5320,6 +5320,7 @@ void Buffer::updateBuffer(ParIterator & parit, UpdateType utype) const
|
|||||||
|
|
||||||
depth_type maxdepth = 0;
|
depth_type maxdepth = 0;
|
||||||
pit_type const lastpit = parit.lastpit();
|
pit_type const lastpit = parit.lastpit();
|
||||||
|
bool changed = false;
|
||||||
for ( ; parit.pit() <= lastpit ; ++parit.pit()) {
|
for ( ; parit.pit() <= lastpit ; ++parit.pit()) {
|
||||||
// reduce depth if necessary
|
// reduce depth if necessary
|
||||||
if (parit->params().depth() > maxdepth) {
|
if (parit->params().depth() > maxdepth) {
|
||||||
@ -5350,8 +5351,15 @@ void Buffer::updateBuffer(ParIterator & parit, UpdateType utype) const
|
|||||||
for (auto const & insit : parit->insetList()) {
|
for (auto const & insit : parit->insetList()) {
|
||||||
parit.pos() = insit.pos;
|
parit.pos() = insit.pos;
|
||||||
insit.inset->updateBuffer(parit, utype);
|
insit.inset->updateBuffer(parit, utype);
|
||||||
|
changed |= insit.inset->isChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// are there changes in this paragraph?
|
||||||
|
changed |= parit->isChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set change indicator for the inset
|
||||||
|
parit.inset().asInsetText()->isChanged(changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -5464,6 +5472,12 @@ int Buffer::charCount(bool with_blanks) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Buffer::areChangesPresent() const
|
||||||
|
{
|
||||||
|
return inset().isChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Buffer::ReadStatus Buffer::reload()
|
Buffer::ReadStatus Buffer::reload()
|
||||||
{
|
{
|
||||||
setBusy(true);
|
setBusy(true);
|
||||||
|
@ -775,7 +775,7 @@ public:
|
|||||||
int charCount(bool with_blanks) const;
|
int charCount(bool with_blanks) const;
|
||||||
|
|
||||||
/// FIXME: dummy function for now
|
/// FIXME: dummy function for now
|
||||||
bool areChangesPresent() const { return true; }
|
bool areChangesPresent() const;
|
||||||
|
|
||||||
///
|
///
|
||||||
void registerBibfiles(docstring_list const & bf) const;
|
void registerBibfiles(docstring_list const & bf) const;
|
||||||
|
@ -79,14 +79,15 @@ using graphics::PreviewLoader;
|
|||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
InsetText::InsetText(Buffer * buf, UsePlain type)
|
InsetText::InsetText(Buffer * buf, UsePlain type)
|
||||||
: Inset(buf), drawFrame_(false), frame_color_(Color_insetframe),
|
: Inset(buf), drawFrame_(false), is_changed_(false), frame_color_(Color_insetframe),
|
||||||
text_(this, type == DefaultLayout)
|
text_(this, type == DefaultLayout)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InsetText::InsetText(InsetText const & in)
|
InsetText::InsetText(InsetText const & in)
|
||||||
: Inset(in), drawFrame_(in.drawFrame_), frame_color_(in.frame_color_),
|
: Inset(in), drawFrame_(in.drawFrame_), is_changed_(in.is_changed_),
|
||||||
|
frame_color_(in.frame_color_),
|
||||||
text_(this, in.text_)
|
text_(this, in.text_)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -410,16 +411,16 @@ void InsetText::fixParagraphsFont()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool InsetText::isChanged() const
|
// bool InsetText::isChanged() const
|
||||||
{
|
// {
|
||||||
ParagraphList::const_iterator pit = paragraphs().begin();
|
// ParagraphList::const_iterator pit = paragraphs().begin();
|
||||||
ParagraphList::const_iterator end = paragraphs().end();
|
// ParagraphList::const_iterator end = paragraphs().end();
|
||||||
for (; pit != end; ++pit) {
|
// for (; pit != end; ++pit) {
|
||||||
if (pit->isChanged())
|
// if (pit->isChanged())
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
void InsetText::setChange(Change const & change)
|
void InsetText::setChange(Change const & change)
|
||||||
|
@ -125,7 +125,9 @@ public:
|
|||||||
void fixParagraphsFont();
|
void fixParagraphsFont();
|
||||||
|
|
||||||
/// does the inset contain changes ?
|
/// does the inset contain changes ?
|
||||||
bool isChanged() const;
|
bool isChanged() const { return is_changed_; }
|
||||||
|
/// this is const because value is mutable
|
||||||
|
void isChanged(bool ic) const { is_changed_ = ic; }
|
||||||
/// set the change for the entire inset
|
/// set the change for the entire inset
|
||||||
void setChange(Change const & change);
|
void setChange(Change const & change);
|
||||||
/// accept the changes within the inset
|
/// accept the changes within the inset
|
||||||
@ -247,6 +249,8 @@ private:
|
|||||||
TocBackend & backend) const;
|
TocBackend & backend) const;
|
||||||
///
|
///
|
||||||
bool drawFrame_;
|
bool drawFrame_;
|
||||||
|
/// true if the inset contains change
|
||||||
|
mutable bool is_changed_;
|
||||||
///
|
///
|
||||||
ColorCode frame_color_;
|
ColorCode frame_color_;
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user