Skip to content

Commit

Permalink
updated Qt.py module 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jchanvfx committed Jun 8, 2019
1 parent e50a60f commit d36393e
Showing 1 changed file with 57 additions and 4 deletions.
61 changes: 57 additions & 4 deletions NodeGraphQt/vendor/Qt.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import importlib


__version__ = "1.2.0.b3"
__version__ = "1.2.0"

# Enable support for `from Qt import *`
__all__ = []
Expand Down Expand Up @@ -778,6 +778,32 @@ def _wrapinstance(ptr, base=None):
return func(long(ptr), base)


def _isvalid(object):
"""Check if the object is valid to use in Python runtime.
Usage:
See :func:`QtCompat.isValid()`
Arguments:
object (QObject): QObject to check the validity of.
"""

assert isinstance(object, Qt.QtCore.QObject)

if hasattr(Qt, "_shiboken2"):
return getattr(Qt, "_shiboken2").isValid(object)

elif hasattr(Qt, "_shiboken"):
return getattr(Qt, "_shiboken").isValid(object)

elif hasattr(Qt, "_sip"):
return not getattr(Qt, "_sip").isdeleted(object)

else:
raise AttributeError("'module' has no attribute isValid")


def _translate(context, sourceText, *args):
# In Qt4 bindings, translate can be passed 2 or 3 arguments
# In Qt5 bindings, translate can be passed 2 arguments
Expand Down Expand Up @@ -968,6 +994,7 @@ def createWidget(self, class_name, parent=None, name=""):
"QtUiTools.QUiLoader": ["QtCompat.loadUi", _loadUi],
"shiboken2.wrapInstance": ["QtCompat.wrapInstance", _wrapinstance],
"shiboken2.getCppPointer": ["QtCompat.getCppPointer", _getcpppointer],
"shiboken2.isValid": ["QtCompat.isValid", _isvalid],
"QtWidgets.qApp": "QtWidgets.QApplication.instance()",
"QtCore.QCoreApplication.translate": [
"QtCompat.translate", _translate
Expand All @@ -992,6 +1019,7 @@ def createWidget(self, class_name, parent=None, name=""):
"uic.loadUi": ["QtCompat.loadUi", _loadUi],
"sip.wrapinstance": ["QtCompat.wrapInstance", _wrapinstance],
"sip.unwrapinstance": ["QtCompat.getCppPointer", _getcpppointer],
"sip.isdeleted": ["QtCompat.isValid", _isvalid],
"QtWidgets.qApp": "QtWidgets.QApplication.instance()",
"QtCore.QCoreApplication.translate": [
"QtCompat.translate", _translate
Expand Down Expand Up @@ -1024,6 +1052,7 @@ def createWidget(self, class_name, parent=None, name=""):
"QtUiTools.QUiLoader": ["QtCompat.loadUi", _loadUi],
"shiboken.wrapInstance": ["QtCompat.wrapInstance", _wrapinstance],
"shiboken.unwrapInstance": ["QtCompat.getCppPointer", _getcpppointer],
"shiboken.isValid": ["QtCompat.isValid", _isvalid],
"QtGui.qApp": "QtWidgets.QApplication.instance()",
"QtCore.QCoreApplication.translate": [
"QtCompat.translate", _translate
Expand Down Expand Up @@ -1057,6 +1086,7 @@ def createWidget(self, class_name, parent=None, name=""):
"uic.loadUi": ["QtCompat.loadUi", _loadUi],
"sip.wrapinstance": ["QtCompat.wrapInstance", _wrapinstance],
"sip.unwrapinstance": ["QtCompat.getCppPointer", _getcpppointer],
"sip.isdeleted": ["QtCompat.isValid", _isvalid],
"QtCore.QString": "str",
"QtGui.qApp": "QtWidgets.QApplication.instance()",
"QtCore.QCoreApplication.translate": [
Expand Down Expand Up @@ -1391,6 +1421,10 @@ def _pyside2():

if hasattr(Qt, "_QtCore"):
Qt.__qt_version__ = Qt._QtCore.qVersion()
Qt.QtCompat.dataChanged = (
lambda self, topleft, bottomright, roles=None:
self.dataChanged.emit(topleft, bottomright, roles or [])
)

if hasattr(Qt, "_QtWidgets"):
Qt.QtCompat.setSectionResizeMode = \
Expand Down Expand Up @@ -1438,6 +1472,10 @@ def _pyside():

if hasattr(Qt, "_QtCore"):
Qt.__qt_version__ = Qt._QtCore.qVersion()
Qt.QtCompat.dataChanged = (
lambda self, topleft, bottomright, roles=None:
self.dataChanged.emit(topleft, bottomright)
)

_reassign_misplaced_members("PySide")
_build_compatibility_members("PySide")
Expand All @@ -1448,11 +1486,18 @@ def _pyqt5():

import PyQt5 as module
extras = ["uic"]

try:
import sip
extras.append(sip.__name__)
extras += ["sip"]
except ImportError:
sip = None

# Relevant to PyQt5 5.11 and above
try:
from PyQt5 import sip
extras += ["sip"]
except ImportError:
sip = None

_setup(module, extras)
if hasattr(Qt, "_sip"):
Expand All @@ -1466,6 +1511,10 @@ def _pyqt5():
if hasattr(Qt, "_QtCore"):
Qt.__binding_version__ = Qt._QtCore.PYQT_VERSION_STR
Qt.__qt_version__ = Qt._QtCore.QT_VERSION_STR
Qt.QtCompat.dataChanged = (
lambda self, topleft, bottomright, roles=None:
self.dataChanged.emit(topleft, bottomright, roles or [])
)

if hasattr(Qt, "_QtWidgets"):
Qt.QtCompat.setSectionResizeMode = \
Expand Down Expand Up @@ -1542,6 +1591,10 @@ def _pyqt4():
if hasattr(Qt, "_QtCore"):
Qt.__binding_version__ = Qt._QtCore.PYQT_VERSION_STR
Qt.__qt_version__ = Qt._QtCore.QT_VERSION_STR
Qt.QtCompat.dataChanged = (
lambda self, topleft, bottomright, roles=None:
self.dataChanged.emit(topleft, bottomright)
)

_reassign_misplaced_members("PyQt4")

Expand Down Expand Up @@ -1867,4 +1920,4 @@ def _install():
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 comments on commit d36393e

Please sign in to comment.