Commit 7f3472a3 authored by Steve Borho's avatar Steve Borho
Browse files

hgqt: remove utf-8 markers on source files, remove trailing white-space

parent 7b2980a423b1
# -*- coding: utf-8 -*-
# Copyright (c) 2003-2010 LOGILAB S.A. (Paris, FRANCE).
# http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
......@@ -16,7 +15,7 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
"""
Qt4 widgets to display diffs as blocks
Qt4 widgets to display diffs as blocks
"""
import sys, os
......@@ -56,7 +55,7 @@ class BlockList(QWidget):
def clear(self):
self._blocks = set()
def addBlock(self, typ, alo, ahi):
self._blocks.add((typ, alo, ahi))
......@@ -77,7 +76,7 @@ class BlockList(QWidget):
self._maximum = maximum
self.update()
self.rangeChanged.emit(self._minimum, self._maximum)
def setValue(self, val):
if val != self._value:
self._value = val
......@@ -99,7 +98,7 @@ class BlockList(QWidget):
self.setMaximum(sbar.maximum())
self.setMinimum(sbar.minimum())
self.setPageStep(sbar.pageStep())
self.setValue(sbar.value())
self.setValue(sbar.value())
self.setUpdatesEnabled(True)
sbar.valueChanged.connect(self.setValue)
......@@ -111,7 +110,7 @@ class BlockList(QWidget):
def syncPageStep(self):
self.setPageStep(self._sbar.pageStep())
def paintEvent(self, event):
w = self.width() - 1
h = self.height()
......@@ -129,7 +128,7 @@ class BlockList(QWidget):
p.setBrush(self._vrectcolor)
p.drawRect(0, self._value, w, self._pagestep)
p.restore()
class BlockMatch(BlockList):
"""
A simpe widget to be linked to 2 file views (text areas),
......@@ -193,26 +192,26 @@ class BlockMatch(BlockList):
if i == len(blocks)-1:
return 1
return 0
def nextDiff(self):
return self.showDiff(+1)
def prevDiff(self):
return self.showDiff(-1)
return self.showDiff(-1)
def addBlock(self, typ, alo, ahi, blo=None, bhi=None):
if bhi is None:
bhi = ahi
if blo is None:
blo = alo
self._blocks.add((typ, alo, ahi, blo, bhi))
def paintEvent(self, event):
w = self.width()
h = self.height()
p = QPainter(self)
p.setRenderHint(p.Antialiasing)
ps_l = float(self._pagestep['left'])
ps_r = float(self._pagestep['right'])
v_l = self._value['left']
......@@ -222,12 +221,12 @@ class BlockMatch(BlockList):
# integer number of fully displayed text lines
scalel = self._sbar['left'].height()//ps_l
scaler = self._sbar['right'].height()//ps_r
ml = v_l
Ml = v_l + ps_l
mr = v_r
Mr = v_r + ps_r
p.setPen(Qt.NoPen)
for typ, alo, ahi, blo, bhi in self._blocks:
if not (ml<=alo<=Ml or ml<=ahi<=Ml or mr<=blo<=Mr or mr<=bhi<=Mr):
......@@ -269,7 +268,7 @@ class BlockMatch(BlockList):
self._maximum[side] = maximum
self.update()
self.rangeChanged.emit(self._minimum[side], self._maximum[side], side)
def setValue(self, val, side=None):
if side is None:
if self.sender() == self._sbar['left']:
......@@ -293,7 +292,7 @@ class BlockMatch(BlockList):
def resizeEvent(self, event):
self.syncPageStep()
def linkScrollBar(self, sb, side):
"""
Make the block list displayer be linked to the scrollbar
......@@ -315,7 +314,7 @@ class BlockMatch(BlockList):
lambda v1, v2, s: side==s and sb.setRange(v1, v2))
self.pageStepChanged.connect(
lambda v, s: side==s and sb.setPageStep(v))
if __name__ == '__main__':
a = QApplication([])
f = QFrame()
......@@ -323,7 +322,7 @@ if __name__ == '__main__':
sb1 = QScrollBar()
sb2 = QScrollBar()
w0 = BlockList()
w0.addBlock('-', 200, 300)
w0.addBlock('-', 450, 460)
......@@ -362,7 +361,7 @@ if __name__ == '__main__':
print "sb1=", sb1.minimum(), sb1.maximum(), sb1.pageStep()
print "sb2=", sb2.minimum(), sb2.maximum(), sb2.pageStep()
f.show()
a.exec_()
# -*- coding: utf-8 -*-
"""
Some useful decorator functions
"""
......
# -*- coding: utf-8 -*-
# Copyright (c) 2003-2010 LOGILAB S.A. (Paris, FRANCE).
# http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment