Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce renamed methods of QHeaderView in PyQt4 and PySide #65

Merged
merged 5 commits into from Aug 25, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions qtpy/QtWidgets.py
Expand Up @@ -15,6 +15,7 @@

from qtpy import PYQT5, PYQT4, PYSIDE, PythonQtError
from qtpy._patch.qcombobox import patch_qcombobox
from qtpy._patch.qheaderview import introduce_renamed_methods_qheaderview


if PYQT5:
Expand Down Expand Up @@ -65,6 +66,9 @@
# Patch QComboBox to allow Python objects to be passed to userData
patch_qcombobox(QComboBox)

# QHeaderView: renamed methods
introduce_renamed_methods_qheaderview(QHeaderView)

elif PYSIDE:
from PySide.QtGui import *
QStyleOptionViewItem = QStyleOptionViewItemV4
Expand Down Expand Up @@ -111,5 +115,8 @@
# Patch QComboBox to allow Python objects to be passed to userData
patch_qcombobox(QComboBox)

# QHeaderView: renamed methods
introduce_renamed_methods_qheaderview(QHeaderView)

else:
raise PythonQtError('No Qt bindings could be found')
48 changes: 48 additions & 0 deletions qtpy/_patch/qheaderview.py
@@ -0,0 +1,48 @@
def introduce_renamed_methods_qheaderview(QHeaderView):

def sectionsClickable(self):
"""
QHeaderView.sectionsClickable() -> bool
"""
return QHeaderView.isClickable(self)
QHeaderView.sectionsClickable = sectionsClickable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why define a new method each time ? This code should be equivalent:

QHeaderView.sectionsClickable = QHeaderView.isClickable

I think there a re some differences, like the __name__ attribute would still be the one from the initial method. On the other hand the help should be more complete (instead of just the signature in the current state of this PR).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Nodd the signatures of pyqt are no better than what Tobias did


def sectionsMovable(self):
"""
QHeaderView.sectionsMovable() -> bool
"""
return QHeaderView.isMovable(self)
QHeaderView.sectionsMovable = sectionsMovable

def sectionResizeMode(self, logicalIndex):
"""
QHeaderView.sectionResizeMode(int) -> QHeaderView.ResizeMode
"""
return QHeaderView.resizeMode(self, logicalIndex)
QHeaderView.sectionResizeMode = sectionResizeMode

def setSectionsClickable(self, clickable):
"""
QHeaderView.setSectionsClickable(bool)
"""
return QHeaderView.setClickable(self, clickable)
QHeaderView.setSectionsClickable = setSectionsClickable

def setSectionsMovable(self, movable):
"""
QHeaderView.setSectionsMovable(bool)
"""
return QHeaderView.setMovable(self, movable)
QHeaderView.setSectionsMovable = setSectionsMovable

def setSectionResizeMode(self, *args):
"""
QHeaderView.setSectionResizeMode(QHeaderView.ResizeMode)
QHeaderView.setSectionResizeMode(int, QHeaderView.ResizeMode)
"""
QHeaderView.setResizeMode(self, *args)
QHeaderView.setSectionResizeMode = setSectionResizeMode