QGIS/python/PyQt/PyQt5/QtCore.py

74 lines
2.0 KiB
Python
Raw Normal View History

2018-02-18 20:53:40 +01:00
# -*- coding: utf-8 -*-
"""
***************************************************************************
QtCore.py
---------------------
Date : November 2015
Copyright : (C) 2015 by Matthias Kuhn
Email : matthias at opengis dot ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = 'Matthias Kuhn'
__date__ = 'November 2015'
__copyright__ = '(C) 2015, Matthias Kuhn'
from PyQt5.QtCore import *
2016-05-11 21:18:54 +02:00
from types import MethodType
2017-03-04 19:41:23 +01:00
2016-05-11 21:36:30 +02:00
_QVariant__repr__ = QVariant.__repr__
_QVariant__eq__ = QVariant.__eq__
_QVariant__ne__ = QVariant.__ne__
_QVariant__hash__ = QVariant.__hash__
2016-05-11 21:18:54 +02:00
def __bool__(self):
return not self.isNull()
2016-05-11 21:18:54 +02:00
def __repr__(self):
if self.isNull():
return 'NULL'
else:
2016-05-11 21:36:30 +02:00
return _QVariant__repr__(self)
2016-05-11 21:18:54 +02:00
def __eq__(self, other):
if self.isNull():
2020-11-27 08:59:48 +01:00
return (isinstance(other, QVariant) and other.isNull()) or other is None
2016-05-11 21:18:54 +02:00
else:
2016-05-11 21:36:30 +02:00
return _QVariant__eq__(self, other)
2016-05-11 21:18:54 +02:00
def __ne__(self, other):
if self.isNull():
return not (isinstance(other, QVariant) and other.isNull()) and other is not None
else:
2016-05-11 21:36:30 +02:00
return _QVariant__ne__(self, other)
2016-05-11 21:18:54 +02:00
def __hash__(self):
if self.isNull():
return 2178309
else:
2016-05-11 21:36:30 +02:00
return _QVariant__hash__(self)
2016-05-11 21:18:54 +02:00
2017-03-04 19:41:23 +01:00
QVariant.__bool__ = __bool__
2016-05-11 21:18:54 +02:00
QVariant.__repr__ = __repr__
QVariant.__eq__ = __eq__
QVariant.__ne__ = __ne__
QVariant.__hash__ = __hash__
NULL = QVariant(QVariant.Int)