Qt frontend for Bazaar

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) 2 files modified (has conflicts)
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

1=== modified file 'NEWS.txt'
2--- NEWS.txt 2011-09-06 21:53:08 +0000
3+++ NEWS.txt 2011-09-20 18:38:23 +0000
4@@ -11,10 +11,15 @@
5 (IWATA Hidetaka)
6 * Fixed ignore whitespace changes code.
7 (Alexander Belchenko, Bug #827391)
8+<<<<<<< TREE
9 * In the case of file content has mixed encoding that cannot be safely
10 decode to unicode qdiff don't fallback to use latin-1 encoding anymore,
11 but try to decode such content in "replace" mode.
12 (Alexander Belchenko, Bug #814117)
13+=======
14+ * Change appearance of change markers.
15+ (IWATA Hidetaka)
16+>>>>>>> MERGE-SOURCE
17 * qlog:
18 * Do not crash on ghost revisions.
19 (Jonathan Riddell, Bug #785967)
20
21=== modified file 'lib/diffview.py'
22--- lib/diffview.py 2011-07-23 03:02:27 +0000
23+++ lib/diffview.py 2011-09-20 18:38:23 +0000
24@@ -165,7 +165,23 @@
25 ry = self.view.browsers[1].verticalScrollBar().value() - frame
26 w = self.width()
27 h = self.height()
28-
29+ painter.setRenderHints(QtGui.QPainter.Antialiasing, True)
30+
31+ C = 16 # Curve factor.
32+
33+ def create_line(ly, ry, right_to_left=False):
34+ """
35+ Create path which represents upper or lower line of change marker.
36+ """
37+ line = QtGui.QPainterPath()
38+ if not right_to_left:
39+ line.moveTo(0, ly)
40+ line.cubicTo(C, ly, w - C, ry, w, ry)
41+ else:
42+ line.moveTo(w, ry)
43+ line.cubicTo(w - C, ry, C, ly, 0, ly)
44+ return line
45+
46 pen = QtGui.QPen(QtCore.Qt.black)
47 pen.setWidth(2)
48 painter.setPen(pen)
49@@ -176,7 +192,8 @@
50 continue
51 if block_ly > h and block_ry > h:
52 break
53- painter.drawLine(0, block_ly, w, block_ry)
54+
55+ painter.drawPath(create_line(block_ly, block_ry))
56
57 for ly_top, ly_bot, ry_top, ry_bot, kind in self.changes:
58 ly_top -= ly
59@@ -189,17 +206,22 @@
60 if ly_top > h and ly_bot > h and ry_top > h and ry_bot > h:
61 break
62
63- polygon = QtGui.QPolygon(4)
64- polygon.setPoints(0, ly_top, w, ry_top, w, ry_bot, 0, ly_bot)
65- painter.setPen(QtCore.Qt.NoPen)
66- painter.setBrush(brushes[kind][0])
67- painter.drawConvexPolygon(polygon)
68-
69+ upper_line = create_line(ly_top, ry_top)
70+ lower_line = create_line(ly_bot, ry_bot, True)
71+
72+ region = QtGui.QPainterPath()
73+ region.moveTo(0, ly_top)
74+ region.connectPath(upper_line)
75+ region.lineTo(w, ry_bot)
76+ region.connectPath(lower_line)
77+ region.closeSubpath()
78+
79+ painter.fillPath(region, brushes[kind][0])
80 painter.setPen(colors[kind][1])
81- painter.setRenderHints(QtGui.QPainter.Antialiasing, ly_top != ry_top)
82- painter.drawLine(0, ly_top, w, ry_top)
83- painter.setRenderHints(QtGui.QPainter.Antialiasing, ly_bot != ry_bot)
84- painter.drawLine(0, ly_bot, w, ry_bot)
85+ for path, aa in zip((upper_line, lower_line),
86+ (ly_top != ry_top, ly_bot != ry_bot)):
87+ painter.setRenderHints(QtGui.QPainter.Antialiasing, aa)
88+ painter.drawPath(path)
89 del painter
90
91 def wheelEvent(self, event):

Subscribers

People subscribed via source and target branches