[LyX/master] Revert "Automatically show the review toolbar if the document has tracked changes"

Jean-Marc Lasgouttes lasgouttes at lyx.org
Sun Jan 12 20:05:12 UTC 2020


commit dba1e40b520f67faeb49759b7cec9ec4f981f9a1
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date:   Sun Jan 12 18:33:01 2020 +0100

    Revert "Automatically show the review toolbar if the document has tracked changes"
    
    We will replace this with a better solution
    
    For now, only keep
    - Changes::isChanged()
    - Buffer::areChangesPresent(), replaced by a dummy function
    
    Next step will be to provide a working areChangesPresent() and to
    compute Inset::isChanged in updateBuffer.
    
    This reverts commit 6d4e6aad24edb7bcfbc49f03d2432fc9fa06954d.
---
 lib/ui/default.ui                   |    3 +-
 src/Buffer.cpp                      |   37 +----------------------------------
 src/Buffer.h                        |    8 ++----
 src/Changes.cpp                     |    8 -------
 src/Changes.h                       |   11 ----------
 src/Cursor.cpp                      |    6 -----
 src/DispatchResult.h                |   18 +---------------
 src/Paragraph.cpp                   |   12 -----------
 src/Paragraph.h                     |    4 ---
 src/frontends/qt/GuiApplication.cpp |    3 --
 10 files changed, 7 insertions(+), 103 deletions(-)

diff --git a/lib/ui/default.ui b/lib/ui/default.ui
index 607d00a..d9f57a3 100644
--- a/lib/ui/default.ui
+++ b/lib/ui/default.ui
@@ -34,8 +34,7 @@ Include "stdtoolbars.inc"
 # math: the toolbar is visible only when in math
 # mathmacrotemplate: the toolbar is visible only when in a macro definition
 # table: the toolbar is visible only when in a table
-# review: the toolbar is visible only when tracked changes are present or
-#         change tracking is enabled
+# review: the toolbar is visible only when inside a tracked change
 # ipa: the toolbar is only visible when inside an ipa inset
 #
 # top: the toolbar should be at the top of the window
diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 2d3160e..ea04b34 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -391,10 +391,6 @@ public:
 		+ (with_blanks ? blank_count_ : 0);
 	}
 
-	// does the buffer contain tracked changes? (if so, we automatically
-	// display the review toolbar, for instance)
-	mutable bool tracked_changes_present_;
-
 	// Make sure the file monitor monitors the good file.
 	void refreshFileMonitor();
 
@@ -459,7 +455,7 @@ Buffer::Impl::Impl(Buffer * owner, FileName const & file, bool readonly_,
 	  cite_labels_valid_(false), have_bibitems_(false), require_fresh_start_(false),
 	  inset(0), preview_loader_(0), cloned_buffer_(cloned_buffer),
 	  clone_list_(0), doing_export(false),
-	  tracked_changes_present_(0), externally_modified_(false), parent_buffer(0),
+	  externally_modified_(false), parent_buffer(0),
 	  word_count_(0), char_count_(0), blank_count_(0)
 {
 	refreshFileMonitor();
@@ -490,7 +486,6 @@ Buffer::Impl::Impl(Buffer * owner, FileName const & file, bool readonly_,
 	preview_file_ = cloned_buffer_->d->preview_file_;
 	preview_format_ = cloned_buffer_->d->preview_format_;
 	require_fresh_start_ = cloned_buffer_->d->require_fresh_start_;
-	tracked_changes_present_ = cloned_buffer_->d->tracked_changes_present_;
 }
 
 
@@ -3033,8 +3028,6 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
 		if (params().save_transient_properties)
 			undo().recordUndoBufferParams(CursorData());
 		params().track_changes = !params().track_changes;
-		if (!params().track_changes)
-			dr.forceChangesUpdate();
 		break;
 
 	case LFUN_CHANGES_OUTPUT:
@@ -5032,7 +5025,6 @@ void Buffer::updateBuffer(UpdateScope scope, UpdateType utype) const
 	// update all caches
 	clearReferenceCache();
 	updateMacros();
-	setChangesPresent(false);
 
 	Buffer & cbuf = const_cast<Buffer &>(*this);
 	// if we are reloading, then we could have a dangling TOC,
@@ -5073,7 +5065,6 @@ void Buffer::updateBuffer(UpdateScope scope, UpdateType utype) const
 		clearReferenceCache();
 		// we should not need to do this again?
 		// updateMacros();
-		setChangesPresent(false);
 		updateBuffer(parit, utype);
 		// this will already have been done by reloadBibInfoCache();
 		// d->bibinfo_cache_valid_ = true;
@@ -5355,9 +5346,6 @@ void Buffer::updateBuffer(ParIterator & parit, UpdateType utype) const
 		// set the counter for this paragraph
 		d->setLabel(parit, utype);
 
-		// update change-tracking flag
-		parit->addChangesToBuffer(*this);
-
 		// now the insets
 		for (auto const & insit : parit->insetList()) {
 			parit.pos() = insit.pos;
@@ -5619,29 +5607,6 @@ string Buffer::includedFilePath(string const & name, string const & ext) const
 }
 
 
-void Buffer::setChangesPresent(bool b) const
-{
-	d->tracked_changes_present_ = b;
-}
-
-
-bool Buffer::areChangesPresent() const
-{
-	return d->tracked_changes_present_;
-}
-
-
-void Buffer::updateChangesPresent() const
-{
-	LYXERR(Debug::CHANGES, "Buffer::updateChangesPresent");
-	setChangesPresent(false);
-	ParConstIterator it = par_iterator_begin();
-	ParConstIterator const end = par_iterator_end();
-	for (; !areChangesPresent() && it != end; ++it)
-		it->addChangesToBuffer(*this);
-}
-
-
 void Buffer::Impl::refreshFileMonitor()
 {
 	if (file_monitor_ && file_monitor_->filename() == filename.absFileName()) {
diff --git a/src/Buffer.h b/src/Buffer.h
index 621c294..977d893 100644
--- a/src/Buffer.h
+++ b/src/Buffer.h
@@ -774,11 +774,9 @@ public:
 	int wordCount() const;
 	int charCount(bool with_blanks) const;
 
-	// this is const because it does not modify the buffer's real contents,
-	// only the mutable flag.
-	void setChangesPresent(bool) const;
-	bool areChangesPresent() const;
-	void updateChangesPresent() const;
+	/// FIXME: dummy function for now
+	bool areChangesPresent() const { return true; }
+
 	///
 	void registerBibfiles(docstring_list const & bf) const;
 	///
diff --git a/src/Changes.cpp b/src/Changes.cpp
index 64fb3c4..52e69da 100644
--- a/src/Changes.cpp
+++ b/src/Changes.cpp
@@ -561,14 +561,6 @@ void Changes::addToToc(DocIterator const & cdit, Buffer const & buffer,
 }
 
 
-void Changes::updateBuffer(Buffer const & buf)
-{
-	bool const changed = isChanged();
-	buf.setChangesPresent(buf.areChangesPresent() || changed);
-	previously_changed_ = changed;
-}
-
-
 void Change::paintCue(PainterInfo & pi, double const x1, double const y,
                       double const x2, FontInfo const & font) const
 {
diff --git a/src/Changes.h b/src/Changes.h
index 5bded17..6146b5a 100644
--- a/src/Changes.h
+++ b/src/Changes.h
@@ -95,8 +95,6 @@ class BufferParams;
 
 class Changes {
 public:
-	Changes() : previously_changed_(false) {}
-
 	/// set the pos to the given change
 	void set(Change const & change, pos_type pos);
 	/// set the range (excluding end) to the given change
@@ -140,11 +138,6 @@ public:
 	void addToToc(DocIterator const & cdit, Buffer const & buffer,
 	              bool output_active, TocBackend & backend) const;
 
-	///
-	void updateBuffer(Buffer const & buf);
-	///
-	bool isUpdateRequired() const { return previously_changed_ != isChanged(); }
-
 private:
 	class Range {
 	public:
@@ -187,10 +180,6 @@ private:
 
 	/// table of changes, every row a change and range descriptor
 	ChangeTable table_;
-
-	/// cache previous value of isChanged to be able to tell whether the
-	/// buffer's flag tracked_changes_present_ needs to be recomputed
-	bool previously_changed_;
 };
 
 
diff --git a/src/Cursor.cpp b/src/Cursor.cpp
index 97d4972..1a3ee3b 100644
--- a/src/Cursor.cpp
+++ b/src/Cursor.cpp
@@ -2474,12 +2474,6 @@ void Cursor::checkBufferStructure()
 		// In case the master has no gui associated with it,
 		// the TocItem is not updated (part of bug 5699).
 		buffer()->tocBackend().updateItem(*this);
-
-	// If the last tracked change of the paragraph has just been
-	// deleted, then we need to recompute the buffer flag
-	// tracked_changes_present_.
-	if (inTexted() && paragraph().isChangeUpdateRequired())
-		disp_.forceChangesUpdate();
 }
 
 
diff --git a/src/DispatchResult.h b/src/DispatchResult.h
index 4b9cbfe..d868989 100644
--- a/src/DispatchResult.h
+++ b/src/DispatchResult.h
@@ -29,8 +29,7 @@ public:
 			error_(false),
 			update_(Update::None),
 			need_buf_update_(false),
-			need_msg_update_(true),
-			need_changes_update_(false)
+			need_msg_update_(true)
 	{}
 	///
 	DispatchResult(bool dispatched, Update::flags f) :
@@ -38,8 +37,7 @@ public:
 			error_(false),
 			update_(f),
 			need_buf_update_(false),
-			need_msg_update_(true),
-			need_changes_update_(false)
+			need_msg_update_(true)
 	{}
 	///
 	bool dispatched() const { return dispatched_; }
@@ -59,14 +57,12 @@ public:
 	Update::flags screenUpdate() const { return update_; }
 	///
 	void screenUpdate(Update::flags f) { update_ = f; }
-
 	/// Does the buffer need updating?
 	bool needBufferUpdate() const { return need_buf_update_; }
 	/// Force the buffer to be updated
 	void forceBufferUpdate() { need_buf_update_ = true; }
 	/// Clear the flag indicating we need an update
 	void clearBufferUpdate() { need_buf_update_ = false; }
-
 	/// Do we need to display a message in the status bar?
 	bool needMessageUpdate() const { return need_msg_update_; }
 	/// Force the message to be displayed
@@ -74,14 +70,6 @@ public:
 	/// Clear the flag indicating we need to display the message
 	void clearMessageUpdate() { need_msg_update_ = false; }
 
-	/// Do we need to update the change tracking presence flag?
-	bool needChangesUpdate() { return need_changes_update_; }
-	/// Force the change tracking presence flag to be updated
-	void forceChangesUpdate() { need_changes_update_ = true; }
-	/// Clear the flag indicating that we need to update the change tracking
-	/// presence flag
-	void clearChangesUpdate() { need_changes_update_ = false; }
-
 private:
 	/// was the event fully dispatched?
 	bool dispatched_;
@@ -95,8 +83,6 @@ private:
 	bool need_buf_update_;
 	///
 	bool need_msg_update_;
-	///
-	bool need_changes_update_;
 };
 
 
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 10263d1..22aa744 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -581,18 +581,6 @@ void Paragraph::addChangesToToc(DocIterator const & cdit, Buffer const & buf,
 }
 
 
-void Paragraph::addChangesToBuffer(Buffer const & buf) const
-{
-	d->changes_.updateBuffer(buf);
-}
-
-
-bool Paragraph::isChangeUpdateRequired() const
-{
-	return d->changes_.isUpdateRequired();
-}
-
-
 bool Paragraph::isDeleted(pos_type start, pos_type end) const
 {
 	LASSERT(start >= 0 && start <= size(), return false);
diff --git a/src/Paragraph.h b/src/Paragraph.h
index 08d1bad..297bff3 100644
--- a/src/Paragraph.h
+++ b/src/Paragraph.h
@@ -153,10 +153,6 @@ public:
 	///
 	void addChangesToToc(DocIterator const & cdit, Buffer const & buf,
 	                     bool output_active, TocBackend & backend) const;
-	/// set the buffer flag if there are changes in the paragraph
-	void addChangesToBuffer(Buffer const & buf) const;
-	///
-	bool isChangeUpdateRequired() const;
 	///
 	Language const * getParLanguage(BufferParams const &) const;
 	///
diff --git a/src/frontends/qt/GuiApplication.cpp b/src/frontends/qt/GuiApplication.cpp
index 9c15d7a..8fdd9bf 100644
--- a/src/frontends/qt/GuiApplication.cpp
+++ b/src/frontends/qt/GuiApplication.cpp
@@ -1476,9 +1476,6 @@ void GuiApplication::updateCurrentView(FuncRequest const & cmd, DispatchResult &
 		if (dr.needBufferUpdate()) {
 			bv->cursor().clearBufferUpdate();
 			bv->buffer().updateBuffer();
-		} else if (dr.needChangesUpdate()) {
-			// updateBuffer() already updates the change-tracking presence flag
-			bv->buffer().updateChangesPresent();
 		}
 		// BufferView::update() updates the ViewMetricsInfo and
 		// also initializes the position cache for all insets in


More information about the lyx-cvs mailing list