Merge lp:~hid-iwata/qbzr/curved-diff-handle into lp:qbzr

Proposed by IWATA Hidetaka on 2011-09-09
Status: Merged
Approved by: Jonathan Riddell on 2011-09-27
Approved revision: 1430
Merged at revision: 1434
Proposed branch: lp:~hid-iwata/qbzr/curved-diff-handle
Merge into: lp:qbzr
Diff against target: 91 lines (+39/-12) (has conflicts)
2 files modified
NEWS.txt (+5/-0)
lib/diffview.py (+34/-12)
Text conflict in NEWS.txt
To merge this branch: bzr merge lp:~hid-iwata/qbzr/curved-diff-handle
Reviewer Review Type Date Requested Status
Jonathan Riddell (community) 2011-09-09 Approve on 2011-09-27
Review via email: mp+74833@code.launchpad.net

Description of the change

Make configurable change marker style of qdiff(side by side view). Straight lines or curved lines.

Sample of curved line style is here.
http://dl.dropbox.com/u/16802579/qdiff-curved-change-marker.png

# This does nothing important, this is just matter of liking.
# Feel free to reject it.

To post a comment you must log in.
Jonathan Riddell (jr) wrote :

I think these curved lines are a nice improvement.

I don't see a need to keep the current straight lines around as an option, it's not something users are likely to care enough about and the curved lines are nicer.

So I'll approve if the config option is not added.

Also all non-private methods should have a doc string to explain what they do (my rule, not qbzr's) so "def create_line" should be documented.

review: Needs Fixing
1429. By IWATA Hidetaka on 2011-09-20

Revert qconfig, (Change marker style don't have to be configurable.)

1430. By IWATA Hidetaka on 2011-09-20

Update NEWS.

IWATA Hidetaka (hid-iwata) wrote :

Thank you for the review.
I've fixed my code by your suggestion now.

Jonathan Riddell (jr) wrote :

Approved, with the NEWS file updated

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NEWS.txt'
--- NEWS.txt 2011-09-06 21:53:08 +0000
+++ NEWS.txt 2011-09-20 18:38:23 +0000
@@ -11,10 +11,15 @@
11 (IWATA Hidetaka)11 (IWATA Hidetaka)
12 * Fixed ignore whitespace changes code.12 * Fixed ignore whitespace changes code.
13 (Alexander Belchenko, Bug #827391)13 (Alexander Belchenko, Bug #827391)
14<<<<<<< TREE
14 * In the case of file content has mixed encoding that cannot be safely15 * In the case of file content has mixed encoding that cannot be safely
15 decode to unicode qdiff don't fallback to use latin-1 encoding anymore,16 decode to unicode qdiff don't fallback to use latin-1 encoding anymore,
16 but try to decode such content in "replace" mode.17 but try to decode such content in "replace" mode.
17 (Alexander Belchenko, Bug #814117)18 (Alexander Belchenko, Bug #814117)
19=======
20 * Change appearance of change markers.
21 (IWATA Hidetaka)
22>>>>>>> MERGE-SOURCE
18 * qlog:23 * qlog:
19 * Do not crash on ghost revisions.24 * Do not crash on ghost revisions.
20 (Jonathan Riddell, Bug #785967)25 (Jonathan Riddell, Bug #785967)
2126
=== modified file 'lib/diffview.py'
--- lib/diffview.py 2011-07-23 03:02:27 +0000
+++ lib/diffview.py 2011-09-20 18:38:23 +0000
@@ -165,7 +165,23 @@
165 ry = self.view.browsers[1].verticalScrollBar().value() - frame165 ry = self.view.browsers[1].verticalScrollBar().value() - frame
166 w = self.width()166 w = self.width()
167 h = self.height()167 h = self.height()
168 168 painter.setRenderHints(QtGui.QPainter.Antialiasing, True)
169
170 C = 16 # Curve factor.
171
172 def create_line(ly, ry, right_to_left=False):
173 """
174 Create path which represents upper or lower line of change marker.
175 """
176 line = QtGui.QPainterPath()
177 if not right_to_left:
178 line.moveTo(0, ly)
179 line.cubicTo(C, ly, w - C, ry, w, ry)
180 else:
181 line.moveTo(w, ry)
182 line.cubicTo(w - C, ry, C, ly, 0, ly)
183 return line
184
169 pen = QtGui.QPen(QtCore.Qt.black)185 pen = QtGui.QPen(QtCore.Qt.black)
170 pen.setWidth(2)186 pen.setWidth(2)
171 painter.setPen(pen)187 painter.setPen(pen)
@@ -176,7 +192,8 @@
176 continue192 continue
177 if block_ly > h and block_ry > h:193 if block_ly > h and block_ry > h:
178 break194 break
179 painter.drawLine(0, block_ly, w, block_ry)195
196 painter.drawPath(create_line(block_ly, block_ry))
180197
181 for ly_top, ly_bot, ry_top, ry_bot, kind in self.changes:198 for ly_top, ly_bot, ry_top, ry_bot, kind in self.changes:
182 ly_top -= ly199 ly_top -= ly
@@ -189,17 +206,22 @@
189 if ly_top > h and ly_bot > h and ry_top > h and ry_bot > h:206 if ly_top > h and ly_bot > h and ry_top > h and ry_bot > h:
190 break207 break
191208
192 polygon = QtGui.QPolygon(4)209 upper_line = create_line(ly_top, ry_top)
193 polygon.setPoints(0, ly_top, w, ry_top, w, ry_bot, 0, ly_bot)210 lower_line = create_line(ly_bot, ry_bot, True)
194 painter.setPen(QtCore.Qt.NoPen)211
195 painter.setBrush(brushes[kind][0])212 region = QtGui.QPainterPath()
196 painter.drawConvexPolygon(polygon)213 region.moveTo(0, ly_top)
197214 region.connectPath(upper_line)
215 region.lineTo(w, ry_bot)
216 region.connectPath(lower_line)
217 region.closeSubpath()
218
219 painter.fillPath(region, brushes[kind][0])
198 painter.setPen(colors[kind][1])220 painter.setPen(colors[kind][1])
199 painter.setRenderHints(QtGui.QPainter.Antialiasing, ly_top != ry_top)221 for path, aa in zip((upper_line, lower_line),
200 painter.drawLine(0, ly_top, w, ry_top)222 (ly_top != ry_top, ly_bot != ry_bot)):
201 painter.setRenderHints(QtGui.QPainter.Antialiasing, ly_bot != ry_bot)223 painter.setRenderHints(QtGui.QPainter.Antialiasing, aa)
202 painter.drawLine(0, ly_bot, w, ry_bot)224 painter.drawPath(path)
203 del painter225 del painter
204226
205 def wheelEvent(self, event):227 def wheelEvent(self, event):

Subscribers

People subscribed via source and target branches