1# -*- coding: utf-8 -*-

2

3"""

4***************************************************************************

5 QtCore.py

6 ---------------------

7 Date : November 2015

8 Copyright : (C) 2015 by Matthias Kuhn

9 Email : matthias at opengis dot ch

10***************************************************************************

11* *

12* This program is free software; you can redistribute it and/or modify *

13* it under the terms of the GNU General Public License as published by *

14* the Free Software Foundation; either version 2 of the License, or *

15* (at your option) any later version. *

16* *

17***************************************************************************

18"""

19

20__author__ = 'Matthias Kuhn'

21__date__ = 'November 2015'

22__copyright__ = '(C) 2015, Matthias Kuhn'

23

24 from PyQt5.QtCore import *

25

26 from types import MethodType

27

28

29_QVariant__repr__ = QVariant.__repr__

30_QVariant__eq__ = QVariant.__eq__

31_QVariant__ne__ = QVariant.__ne__

32_QVariant__hash__ = QVariant.__hash__

33

34

35 def __bool__(self):

36 return not self.isNull()

37

38

39 def __repr__(self):

40 if self.isNull():

41 return 'NULL'

42 else:

43 return _QVariant__repr__(self)

44

45

46 def __eq__(self, other):

47 if self.isNull():

48 return (isinstance(other, QVariant) and other.isNull())or other is None

49 else:

50 return _QVariant__eq__(self, other)

51

52

53 def __ne__(self, other):

54 if self.isNull():

55 return not (isinstance(other, QVariant) and other.isNull()) and other is not None

56 else:

57 return _QVariant__ne__(self, other)

58

59

60 def __hash__(self):

61 if self.isNull():

62 return 2178309

63 else:

64 return _QVariant__hash__(self)

65

66

67 QVariant.__bool__ = __bool__

68 QVariant.__repr__ = __repr__

69 QVariant.__eq__ = __eq__

70 QVariant.__ne__ = __ne__

71 QVariant.__hash__ = __hash__

72

73 NULL = QVariant(QVariant.Int)