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

Revert "raise exception if old methods are called" #120

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 6 additions & 40 deletions qtpy/_patch/qheaderview.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,82 +7,48 @@

def introduce_renamed_methods_qheaderview(QHeaderView):

_isClickable = QHeaderView.isClickable
def sectionsClickable(self):
"""
QHeaderView.sectionsClickable() -> bool
"""
return _isClickable(self)
return QHeaderView.isClickable(self)
QHeaderView.sectionsClickable = sectionsClickable
def isClickable(self):
raise Exception('isClickable is only available in Qt4. Use '
'sectionsClickable instead.')
QHeaderView.isClickable = isClickable


_isMovable = QHeaderView.isMovable
def sectionsMovable(self):
"""
QHeaderView.sectionsMovable() -> bool
"""
return _isMovable(self)
return QHeaderView.isMovable(self)
QHeaderView.sectionsMovable = sectionsMovable
def isMovable(self):
raise Exception('isMovable is only available in Qt4. Use '
'sectionsMovable instead.')
QHeaderView.isMovable = isMovable


_resizeMode = QHeaderView.resizeMode
def sectionResizeMode(self, logicalIndex):
"""
QHeaderView.sectionResizeMode(int) -> QHeaderView.ResizeMode
"""
return _resizeMode(self, logicalIndex)
return QHeaderView.resizeMode(self, logicalIndex)
QHeaderView.sectionResizeMode = sectionResizeMode
def resizeMode(self, logicalIndex):
raise Exception('resizeMode is only available in Qt4. Use '
'sectionResizeMode instead.')
QHeaderView.resizeMode = resizeMode

_setClickable = QHeaderView.setClickable
def setSectionsClickable(self, clickable):
"""
QHeaderView.setSectionsClickable(bool)
"""
return _setClickable(self, clickable)
return QHeaderView.setClickable(self, clickable)
QHeaderView.setSectionsClickable = setSectionsClickable
def setClickable(self, clickable):
raise Exception('setClickable is only available in Qt4. Use '
'setSectionsClickable instead.')
QHeaderView.setClickable = setClickable


_setMovable = QHeaderView.setMovable
def setSectionsMovable(self, movable):
"""
QHeaderView.setSectionsMovable(bool)
"""
return _setMovable(self, movable)
return QHeaderView.setMovable(self, movable)
QHeaderView.setSectionsMovable = setSectionsMovable
def setMovable(self, movable):
raise Exception('setMovable is only available in Qt4. Use '
'setSectionsMovable instead.')
QHeaderView.setMovable = setMovable


_setResizeMode = QHeaderView.setResizeMode
def setSectionResizeMode(self, *args):
"""
QHeaderView.setSectionResizeMode(QHeaderView.ResizeMode)
QHeaderView.setSectionResizeMode(int, QHeaderView.ResizeMode)
"""
_setResizeMode(self, *args)
QHeaderView.setResizeMode(self, *args)
QHeaderView.setSectionResizeMode = setSectionResizeMode
def setResizeMode(self, *args):
raise Exception('setResizeMode is only available in Qt4. Use '
'setSectionResizeMode instead.')
QHeaderView.setResizeMode = setResizeMode



Expand Down
16 changes: 0 additions & 16 deletions qtpy/tests/test_patch_qheaderview.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,3 @@ class Model(QAbstractListModel):
headerview.setSectionResizeMode(0, QHeaderView.ResizeToContents)
assert headerview.sectionResizeMode(0) == QHeaderView.ResizeToContents

# test that the old methods in Qt4 raise exceptions
if PYQT4 or PYSIDE:
with pytest.raises(Exception):
headerview.isClickable()
with pytest.raises(Exception):
headerview.isMovable()
with pytest.raises(Exception):
headerview.resizeMode(0)
with pytest.raises(Exception):
headerview.setClickable(True)
with pytest.raises(Exception):
headerview.setMovableClickable(True)
with pytest.raises(Exception):
headerview.setResizeMode(0, QHeaderView.Interactive)