Skip to content

Commit 2c6ebf1

Browse files
gacarrilloralexbruy
authored andcommittedOct 20, 2016
Using QVariant.Type enum instead of numbers for readability.
(cherry picked from commit 6df926d)
1 parent e64a96f commit 2c6ebf1

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed
 

‎python/plugins/processing/algs/qgis/Eliminate.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import os
2929

3030
from qgis.PyQt.QtGui import QIcon
31-
from qgis.PyQt.QtCore import QLocale, QDate
31+
from qgis.PyQt.QtCore import QLocale, QDate, QVariant
3232

3333
from qgis.core import QgsFeatureRequest, QgsFeature, QgsGeometry
3434

@@ -113,26 +113,26 @@ def processAlgorithm(self, progress):
113113
selectType = processLayer.fields()[selectindex].type()
114114
selectionError = False
115115

116-
if selectType == 2 or selectType == 4:
116+
if selectType == QVariant.Int or selectType == QVariant.LongLong:
117117
try:
118118
y = int(comparisonvalue)
119119
except ValueError:
120120
selectionError = True
121121
msg = self.tr('Cannot convert "%s" to integer' % unicode(comparisonvalue))
122-
elif selectType == 6:
122+
elif selectType == QVariant.Double:
123123
try:
124124
y = float(comparisonvalue)
125125
except ValueError:
126126
selectionError = True
127127
msg = self.tr('Cannot convert "%s" to float' % unicode(comparisonvalue))
128-
elif selectType == 10:
128+
elif selectType == QVariant.String:
129129
# 10: string, boolean
130130
try:
131131
y = unicode(comparisonvalue)
132132
except ValueError:
133133
selectionError = True
134134
msg = self.tr('Cannot convert "%s" to unicode' % unicode(comparisonvalue))
135-
elif selectType == 14:
135+
elif selectType == QVariant.Date:
136136
# date
137137
dateAndFormat = comparisonvalue.split(' ')
138138

@@ -157,7 +157,7 @@ def processAlgorithm(self, progress):
157157
msg += self.tr('Enter the date and the date format, e.g. "07.26.2011" "MM.dd.yyyy".')
158158

159159
if (comparison == 'begins with' or comparison == 'contains') \
160-
and selectType != 10:
160+
and selectType != QVariant.String:
161161
selectionError = True
162162
msg = self.tr('"%s" can only be used with string fields' % comparison)
163163

@@ -173,14 +173,14 @@ def processAlgorithm(self, progress):
173173
if aValue is None:
174174
continue
175175

176-
if selectType == 2 or selectType == 4:
176+
if selectType == QVariant.Int or selectType == QVariant.LongLong:
177177
x = int(aValue)
178-
elif selectType == 6:
178+
elif selectType == QVariant.Double:
179179
x = float(aValue)
180-
elif selectType == 10:
180+
elif selectType == QVariant.String:
181181
# 10: string, boolean
182182
x = unicode(aValue)
183-
elif selectType == 14:
183+
elif selectType == QVariant.Date:
184184
# date
185185
x = aValue # should be date
186186

0 commit comments

Comments
 (0)
Please sign in to comment.