From 4d04d6fb9b2e88c025aac98b0a016abb4065b1de Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Tue, 10 Dec 2013 01:41:32 -0800 Subject: [PATCH] diff: remove `self.mode` state We already have a reference to the model so it's simpler to just check at runtime instead of storing state and using a callback to update it. Signed-off-by: David Aguilar --- cola/widgets/diff.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/cola/widgets/diff.py b/cola/widgets/diff.py index 57df3e0c..85386f2b 100644 --- a/cola/widgets/diff.py +++ b/cola/widgets/diff.py @@ -34,7 +34,6 @@ class DiffEditor(DiffTextEdit): def __init__(self, parent): DiffTextEdit.__init__(self, parent) self.model = model = main.model() - self.mode = self.model.mode_none self.action_process_section = qtutils.add_action(self, N_('Process Section'), @@ -76,8 +75,6 @@ class DiffEditor(DiffTextEdit): self.stage_selection) self.action_apply_selection.setIcon(qtutils.apply_icon()) - model.add_observer(model.message_mode_about_to_change, - self._mode_about_to_change) model.add_observer(model.message_diff_text_changed, self._emit_text) self.connect(self, SIGNAL('copyAvailable(bool)'), @@ -172,13 +169,11 @@ class DiffEditor(DiffTextEdit): return DiffTextEdit.mousePressEvent(self, event) - def _mode_about_to_change(self, mode): - self.mode = mode - def setPlainText(self, text): """setPlainText(str) while retaining scrollbar positions""" - highlight = (self.mode != self.model.mode_none and - self.mode != self.model.mode_untracked) + mode = self.model.mode + highlight = (mode != self.model.mode_none and + mode != self.model.mode_untracked) self.highlighter.set_enabled(highlight) scrollbar = self.verticalScrollBar() -- 2.11.4.GIT