commit 4a4ded2297ece7548aa6cbf731e9a90253cdeb63
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Sun Jan 12 20:09:41 2020 +0100
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().
---
src/Buffer.cpp | 14 ++++++++++++++
src/Buffer.h | 2 +-
src/insets/InsetText.cpp | 25 +++++++++++++------------
src/insets/InsetText.h | 6 +++++-
4 files changed, 33 insertions(+), 14 deletions(-)
diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index ea04b34..bd3d63e 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -5320,6 +5320,7 @@ void Buffer::updateBuffer(ParIterator & parit, UpdateType
utype) const
depth_type maxdepth = 0;
pit_type const lastpit = parit.lastpit();
+ bool changed = false;
for ( ; parit.pit() <= lastpit ; ++parit.pit()) {
// reduce depth if necessary
if (parit->params().depth() > maxdepth) {
@@ -5350,8 +5351,15 @@ void Buffer::updateBuffer(ParIterator & parit,
UpdateType utype) const
for (auto const & insit : parit->insetList()) {
parit.pos() = insit.pos;
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()
{
setBusy(true);
diff --git a/src/Buffer.h b/src/Buffer.h
index 977d893..0e1ec6b 100644
--- a/src/Buffer.h
+++ b/src/Buffer.h
@@ -775,7 +775,7 @@ public:
int charCount(bool with_blanks) const;
/// FIXME: dummy function for now
- bool areChangesPresent() const { return true; }
+ bool areChangesPresent() const;
///
void registerBibfiles(docstring_list const & bf) const;
diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp
index eca69df..f3e33f0 100644
--- a/src/insets/InsetText.cpp
+++ b/src/insets/InsetText.cpp
@@ -79,14 +79,15 @@ using graphics::PreviewLoader;
/////////////////////////////////////////////////////////////////////
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)
{
}
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_)
{
}
@@ -410,16 +411,16 @@ void InsetText::fixParagraphsFont()
}
-bool InsetText::isChanged() const
-{
- ParagraphList::const_iterator pit = paragraphs().begin();
- ParagraphList::const_iterator end = paragraphs().end();
- for (; pit != end; ++pit) {
- if (pit->isChanged())
- return true;
- }
- return false;
-}
+// bool InsetText::isChanged() const
+// {
+// ParagraphList::const_iterator pit = paragraphs().begin();
+// ParagraphList::const_iterator end = paragraphs().end();
+// for (; pit != end; ++pit) {
+// if (pit->isChanged())
+// return true;
+// }
+// return false;
+// }
void InsetText::setChange(Change const & change)
diff --git a/src/insets/InsetText.h b/src/insets/InsetText.h
index fc43ccb..3e535cb 100644
--- a/src/insets/InsetText.h
+++ b/src/insets/InsetText.h
@@ -125,7 +125,9 @@ public:
void fixParagraphsFont();
/// 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
void setChange(Change const & change);
/// accept the changes within the inset
@@ -247,6 +249,8 @@ private:
TocBackend & backend) const;
///
bool drawFrame_;
+ /// true if the inset contains change
+ mutable bool is_changed_;
///
ColorCode frame_color_;
///
--
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs