Skip to content

Commit 819d7e6

Browse files
committed
Manually patch in Qgis.FeatureCountState on qt 6 builds
it's not referenced anywhere in the sip bindings and we need it to have negative values, which aren't supported by sip
1 parent 167e487 commit 819d7e6

File tree

5 files changed

+28
-16
lines changed

5 files changed

+28
-16
lines changed

python/PyQt6/core/__init__.py.in

+23
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ __copyright__ = '(C) 2014, Nathan Woodrow'
2424
from qgis.PyQt.QtCore import NULL
2525
from qgis._core import *
2626

27+
from enum import IntEnum
28+
2729
@MONKEYPATCH_INJECTIONS@
2830

2931
from .additions.edit import edit, QgsEditError
@@ -159,3 +161,24 @@ PROJECT_SCALES = Qgis.defaultProjectScales()
159161
GEOPROJ4 = geoProj4()
160162
GEO_EPSG_CRS_AUTHID = geoEpsgCrsAuthId()
161163
GEO_NONE = geoNone()
164+
165+
# manually patch this in -- it's not referenced anywhere in the sip bindings
166+
# and we need it to have negative values, which aren't supported by sip
167+
class _FeatureCountState(IntEnum):
168+
Uncounted = -2
169+
UnknownCount = -1
170+
171+
172+
Qgis.FeatureCountState = _FeatureCountState
173+
Qgis.FeatureCountState.Uncounted.__doc__ = "Feature count not yet computed"
174+
Qgis.FeatureCountState.UnknownCount.__doc__ = "Provider returned an unknown feature count"
175+
QgsVectorDataProvider.FeatureCountState = Qgis.FeatureCountState
176+
QgsVectorDataProvider.Uncounted = Qgis.FeatureCountState.Uncounted
177+
QgsVectorDataProvider.Uncounted.is_monkey_patched = True
178+
QgsVectorDataProvider.Uncounted.__doc__ = "Feature count not yet computed"
179+
QgsVectorDataProvider.UnknownCount = Qgis.FeatureCountState.UnknownCount
180+
QgsVectorDataProvider.UnknownCount.is_monkey_patched = True
181+
QgsVectorDataProvider.UnknownCount.__doc__ = "Provider returned an unknown feature count"
182+
Qgis.FeatureCountState.__doc__ = "Enumeration of feature count states\n\n.. versionadded:: 3.20\n\n" + '* ``Uncounted``: ' + Qgis.FeatureCountState.Uncounted.__doc__ + '\n' + '* ``UnknownCount``: ' + Qgis.FeatureCountState.UnknownCount.__doc__
183+
Qgis.FeatureCountState.baseClass = Qgis
184+

python/PyQt6/core/auto_additions/qgis.py

-11
Original file line numberDiff line numberDiff line change
@@ -394,17 +394,6 @@
394394
Qgis.PythonMacroMode.__doc__ = "Authorisation to run Python Macros\n\n.. versionadded:: 3.10\n\n" + '* ``Never``: ' + Qgis.PythonMacroMode.Never.__doc__ + '\n' + '* ``Ask``: ' + Qgis.PythonMacroMode.Ask.__doc__ + '\n' + '* ``SessionOnly``: ' + Qgis.PythonMacroMode.SessionOnly.__doc__ + '\n' + '* ``Always``: ' + Qgis.PythonMacroMode.Always.__doc__ + '\n' + '* ``NotForThisSession``: ' + Qgis.PythonMacroMode.NotForThisSession.__doc__
395395
# --
396396
Qgis.PythonMacroMode.baseClass = Qgis
397-
QgsVectorDataProvider.FeatureCountState = Qgis.FeatureCountState
398-
# monkey patching scoped based enum
399-
QgsVectorDataProvider.Uncounted = Qgis.FeatureCountState.Uncounted
400-
QgsVectorDataProvider.Uncounted.is_monkey_patched = True
401-
QgsVectorDataProvider.Uncounted.__doc__ = "Feature count not yet computed"
402-
QgsVectorDataProvider.UnknownCount = Qgis.FeatureCountState.UnknownCount
403-
QgsVectorDataProvider.UnknownCount.is_monkey_patched = True
404-
QgsVectorDataProvider.UnknownCount.__doc__ = "Provider returned an unknown feature count"
405-
Qgis.FeatureCountState.__doc__ = "Enumeration of feature count states\n\n.. versionadded:: 3.20\n\n" + '* ``Uncounted``: ' + Qgis.FeatureCountState.Uncounted.__doc__ + '\n' + '* ``UnknownCount``: ' + Qgis.FeatureCountState.UnknownCount.__doc__
406-
# --
407-
Qgis.FeatureCountState.baseClass = Qgis
408397
# monkey patching scoped based enum
409398
Qgis.VectorDataProviderAttributeEditCapability.EditAlias.__doc__ = "Allows editing aliases"
410399
Qgis.VectorDataProviderAttributeEditCapability.EditComment.__doc__ = "Allows editing comments"

python/PyQt6/core/auto_generated/qgis.sip.in

-5
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,6 @@ The development version
225225
NotForThisSession,
226226
};
227227

228-
enum class FeatureCountState /BaseType=IntFlag/
229-
{
230-
Uncounted,
231-
UnknownCount,
232-
};
233228

234229
enum class VectorDataProviderAttributeEditCapability /BaseType=IntFlag/
235230
{

python/core/auto_generated/qgis.sip.in

+1
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ The development version
225225
NotForThisSession,
226226
};
227227

228+
228229
enum class FeatureCountState
229230
{
230231
Uncounted,

src/core/qgis.h

+4
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,9 @@ class CORE_EXPORT Qgis
327327
};
328328
Q_ENUM( PythonMacroMode )
329329

330+
// this is manually patched in Qt6 builds to allow for negative values
331+
#ifdef SIP_PYQT5_RUN
332+
330333
/**
331334
* \ingroup core
332335
* \brief Enumeration of feature count states
@@ -338,6 +341,7 @@ class CORE_EXPORT Qgis
338341
UnknownCount = -1, //!< Provider returned an unknown feature count
339342
};
340343
Q_ENUM( FeatureCountState )
344+
#endif
341345

342346
/**
343347
* Attribute editing capabilities which may be supported by vector data providers.

0 commit comments

Comments
 (0)