Hello,

the following patch for my personal branch decouples the tracking of changes from the output of changes, i.e., you can turn both on and off at any time. The patch will also enable (once the LyX core is fixed) accepting/rejecting changes even if ct is switched off.

I assume that technically there won't be a big difference whether ct is on or off. Therefore, a lot of code can go (and I promise the code reduction will continue!)

I will commit the patch instantly because it feels right. However, please have a look and give comments if you dislike anything.

Michael
Index: BufferView_pimpl.C
===================================================================
--- BufferView_pimpl.C	(Revision 13818)
+++ BufferView_pimpl.C	(Arbeitskopie)
@@ -940,36 +940,6 @@
 }
 
 
-void BufferView::Pimpl::trackChanges()
-{
-	bool const tracking = buffer_->params().tracking_changes;
-
-	if (!tracking) {
-		for_each(buffer_->par_iterator_begin(),
-			 buffer_->par_iterator_end(),
-			 bind(&Paragraph::trackChanges, _1, Change::UNCHANGED));
-		buffer_->params().tracking_changes = true;
-
-		// We cannot allow undos beyond the freeze point
-		buffer_->undostack().clear();
-	} else {
-		cursor_.setCursor(doc_iterator_begin(buffer_->inset()));
-		if (lyx::find::findNextChange(bv_)) {
-			owner_->getDialogs().show("changes");
-			return;
-		}
-
-		for_each(buffer_->par_iterator_begin(),
-			 buffer_->par_iterator_end(),
-			 mem_fun_ref(&Paragraph::untrackChanges));
-
-		buffer_->params().tracking_changes = false;
-	}
-
-	buffer_->redostack().clear();
-}
-
-
 bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0)
 {
 	//lyxerr << BOOST_CURRENT_FUNCTION << "[ cmd0 " << cmd0 << "]" << endl;
@@ -1111,8 +1081,7 @@
 	case LFUN_CHANGES_OUTPUT: {
 		OutputParams runparams;
 		LaTeXFeatures features(*buffer_, buffer_->params(), runparams);
-		flag.enabled(buffer_ && buffer_->params().tracking_changes
-			&& features.isAvailable("dvipost"));
+		flag.enabled(buffer_ && features.isAvailable("dvipost"));
 		flag.setOnOff(buffer_->params().output_changes);
 		break;
 	}
@@ -1122,7 +1091,7 @@
 	case LFUN_CHANGE_REJECT: // what about these two
 	case LFUN_ALL_CHANGES_ACCEPT:
 	case LFUN_ALL_CHANGES_REJECT:
-		flag.enabled(buffer_ && buffer_->params().tracking_changes);
+		flag.enabled(buffer_);
 		break;
 
 	case LFUN_BUFFER_TOGGLE_COMPRESSION: {
@@ -1276,12 +1245,11 @@
 	}
 
 	case LFUN_CHANGES_TRACK:
-		trackChanges();
+		buffer_->params().tracking_changes = !buffer_->params().tracking_changes;
 		break;
 
 	case LFUN_CHANGES_OUTPUT: {
-		bool const state = buffer_->params().output_changes;
-		buffer_->params().output_changes = !state;
+		buffer_->params().output_changes = !buffer_->params().output_changes;
 		break;
 	}
 
Index: buffer.C
===================================================================
--- buffer.C	(Revision 13818)
+++ buffer.C	(Arbeitskopie)
@@ -1154,8 +1154,7 @@
 {
 	LyXTextClass const & tclass = params().getLyXTextClass();
 
-	if (features.isAvailable("dvipost") && params().tracking_changes
-	    && params().output_changes)
+	if (features.isAvailable("dvipost") && params().output_changes)
 		features.require("dvipost");
 
 	// AMS Style is at document level
Index: BufferView_pimpl.h
===================================================================
--- BufferView_pimpl.h	(Revision 13818)
+++ BufferView_pimpl.h	(Arbeitskopie)
@@ -133,8 +133,6 @@
 	void connectBuffer(Buffer & buf);
 	/// disconnect from signals in the given buffer
 	void disconnectBuffer();
-	/// track changes for the document
-	void trackChanges();
 	/// notify readonly status
 	void showReadonly(bool);
 
Index: lyxfunc.C
===================================================================
--- lyxfunc.C	(Revision 13818)
+++ lyxfunc.C	(Arbeitskopie)
@@ -634,8 +634,7 @@
 	}
 
 	// Are we in a DELETED change-tracking region?
-	if (buf && buf->params().tracking_changes
-	    && lookupChangeType(cur, true) == Change::DELETED
+	if (buf && lookupChangeType(cur, true) == Change::DELETED
 	    && !lyxaction.funcHasFlag(cmd.action, LyXAction::ReadOnly)
 	    && !lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer)) {
 		flag.message(N_("This portion of the document is deleted."));
Index: bufferparams.C
===================================================================
--- bufferparams.C	(Revision 13818)
+++ bufferparams.C	(Arbeitskopie)
@@ -671,12 +671,10 @@
 	os << "\\tracking_changes " << convert<string>(tracking_changes) << "\n";
 	os << "\\output_changes " << convert<string>(output_changes) << "\n";
 
-	if (tracking_changes) {
-		AuthorList::Authors::const_iterator it = pimpl_->authorlist.begin();
-		AuthorList::Authors::const_iterator end = pimpl_->authorlist.end();
-		for (; it != end; ++it) {
-			os << "\\author " << it->second << "\n";
-		}
+	AuthorList::Authors::const_iterator a_it = pimpl_->authorlist.begin();
+	AuthorList::Authors::const_iterator a_end = pimpl_->authorlist.end();
+	for (; a_it != a_end; ++a_it) {
+		os << "\\author " << a_it->second << "\n";
 	}
 }
 
@@ -1052,7 +1050,7 @@
 	lyxpreamble += "\\makeatother\n";
 
 	// dvipost settings come after everything else
-	if (features.isAvailable("dvipost") && tracking_changes && output_changes) {
+	if (features.isAvailable("dvipost") && output_changes) {
 		lyxpreamble +=
 			"\\dvipostlayout\n"
 			"\\dvipost{osstart color push Red}\n"
Index: text.C
===================================================================
--- text.C	(Revision 13818)
+++ text.C	(Arbeitskopie)
@@ -2253,8 +2253,7 @@
 	Paragraph const & par = cur.paragraph();
 	std::ostringstream os;
 
-	bool const show_change = buf.params().tracking_changes
-		&& par.lookupChange(cur.pos()) != Change::UNCHANGED;
+	bool const show_change = par.lookupChange(cur.pos()) != Change::UNCHANGED;
 
 	if (buf.params().tracking_changes)
 		os << "[C] ";

Reply via email to