From 5f56810d04c6d28701fa44a3cc2c527bf704c589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Pr=C3=B6pper?= Date: Mon, 24 Mar 2014 16:37:06 +0100 Subject: [PATCH] Copyright year update, PEP 8 --- LICENSE | 4 ++-- spykeviewer/ui/checkable_item_delegate.py | 23 ++++++++--------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/LICENSE b/LICENSE index 4c6d824..f7a2f8f 100644 --- a/LICENSE +++ b/LICENSE @@ -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 @@ -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. \ No newline at end of file +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/spykeviewer/ui/checkable_item_delegate.py b/spykeviewer/ui/checkable_item_delegate.py index 0c05309..94d5636 100644 --- a/spykeviewer/ui/checkable_item_delegate.py +++ b/spykeviewer/ui/checkable_item_delegate.py @@ -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. @@ -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) @@ -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() @@ -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 \ No newline at end of file + return s