Skip to content

Commit

Permalink
Copyright year update, PEP 8
Browse files Browse the repository at this point in the history
  • Loading branch information
rproepp committed Mar 24, 2014
1 parent 045504a commit 5f56810
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2012, Robert Pröpper and conbtributors.
Copyright (c) 2012-2014, Robert Pröpper and conbtributors.
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand All @@ -21,4 +21,4 @@ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 changes: 8 additions & 15 deletions spykeviewer/ui/checkable_item_delegate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from PyQt4.QtCore import Qt
from PyQt4.QtGui import QStyledItemDelegate, QStyle, QApplication


class CheckableItemDelegate(QStyledItemDelegate):
""" A StyledItemDelegate for checkable items with support for both
checkboxes and radio buttons.
Expand All @@ -21,8 +22,8 @@ def paint(self, painter, option, index):

if index.data(CheckableItemDelegate.CheckTypeRole):
# Size and spacing in current style
is_radio = index.data(CheckableItemDelegate.CheckTypeRole) ==\
CheckableItemDelegate.RadioCheckType
is_radio = index.data(CheckableItemDelegate.CheckTypeRole) == \
CheckableItemDelegate.RadioCheckType
if is_radio:
button_width = style.pixelMetric(
QStyle.PM_ExclusiveIndicatorWidth, option)
Expand All @@ -34,7 +35,6 @@ def paint(self, painter, option, index):
spacing = style.pixelMetric(
QStyle.PM_CheckBoxLabelSpacing, option)


# Draw default appearance shifted to right
myOption = option
left = myOption.rect.left()
Expand All @@ -51,26 +51,19 @@ def paint(self, painter, option, index):
myOption.state |= QStyle.State_Off

if is_radio:
style.drawPrimitive(QStyle.PE_IndicatorRadioButton, myOption, painter)
style.drawPrimitive(
QStyle.PE_IndicatorRadioButton, myOption, painter)
else:
style.drawPrimitive(QStyle.PE_IndicatorCheckBox, myOption, painter)
style.drawPrimitive(
QStyle.PE_IndicatorCheckBox, myOption, painter)
else:
QStyledItemDelegate.paint(self, painter, option, index)

def sizeHint(self, option, index):
s = QStyledItemDelegate.sizeHint(self, option, index)
# sizeHint is for some reason only called once, so set
# size globally
#if index.data(CheckableItemDelegate.CheckTypeRole):
# # Determine size of check buttons in current style
# #noinspection PyArgumentList
# button_height = QApplication.style().pixelMetric(QStyle.PM_ExclusiveIndicatorHeight, option)
# # Ensure that row is tall enough to draw check button
# print button_height
# s.setHeight(max(s.height(), button_height))
radio_height = QApplication.style().pixelMetric(
QStyle.PM_ExclusiveIndicatorHeight, option)
check_height = QApplication.style().pixelMetric(
QStyle.PM_IndicatorHeight, option)
s.setHeight(max(s.height(), radio_height, check_height))
return s
return s

0 comments on commit 5f56810

Please sign in to comment.