28
28
import os
29
29
30
30
from qgis .PyQt .QtGui import QIcon
31
- from qgis .PyQt .QtCore import QLocale , QDate
31
+ from qgis .PyQt .QtCore import QLocale , QDate , QVariant
32
32
33
33
from qgis .core import QgsFeatureRequest , QgsFeature , QgsGeometry
34
34
@@ -113,26 +113,26 @@ def processAlgorithm(self, progress):
113
113
selectType = processLayer .fields ()[selectindex ].type ()
114
114
selectionError = False
115
115
116
- if selectType == 2 or selectType == 4 :
116
+ if selectType == QVariant . Int or selectType == QVariant . LongLong :
117
117
try :
118
118
y = int (comparisonvalue )
119
119
except ValueError :
120
120
selectionError = True
121
121
msg = self .tr ('Cannot convert "%s" to integer' % unicode (comparisonvalue ))
122
- elif selectType == 6 :
122
+ elif selectType == QVariant . Double :
123
123
try :
124
124
y = float (comparisonvalue )
125
125
except ValueError :
126
126
selectionError = True
127
127
msg = self .tr ('Cannot convert "%s" to float' % unicode (comparisonvalue ))
128
- elif selectType == 10 :
128
+ elif selectType == QVariant . String :
129
129
# 10: string, boolean
130
130
try :
131
131
y = unicode (comparisonvalue )
132
132
except ValueError :
133
133
selectionError = True
134
134
msg = self .tr ('Cannot convert "%s" to unicode' % unicode (comparisonvalue ))
135
- elif selectType == 14 :
135
+ elif selectType == QVariant . Date :
136
136
# date
137
137
dateAndFormat = comparisonvalue .split (' ' )
138
138
@@ -157,7 +157,7 @@ def processAlgorithm(self, progress):
157
157
msg += self .tr ('Enter the date and the date format, e.g. "07.26.2011" "MM.dd.yyyy".' )
158
158
159
159
if (comparison == 'begins with' or comparison == 'contains' ) \
160
- and selectType != 10 :
160
+ and selectType != QVariant . String :
161
161
selectionError = True
162
162
msg = self .tr ('"%s" can only be used with string fields' % comparison )
163
163
@@ -173,14 +173,14 @@ def processAlgorithm(self, progress):
173
173
if aValue is None :
174
174
continue
175
175
176
- if selectType == 2 or selectType == 4 :
176
+ if selectType == QVariant . Int or selectType == QVariant . LongLong :
177
177
x = int (aValue )
178
- elif selectType == 6 :
178
+ elif selectType == QVariant . Double :
179
179
x = float (aValue )
180
- elif selectType == 10 :
180
+ elif selectType == QVariant . String :
181
181
# 10: string, boolean
182
182
x = unicode (aValue )
183
- elif selectType == 14 :
183
+ elif selectType == QVariant . Date :
184
184
# date
185
185
x = aValue # should be date
186
186
0 commit comments