@@ -60,14 +60,16 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider(QString uri)
60
60
// get the individual parameters and assign values
61
61
QStringList temp = parameters.grep (" delimiter=" );
62
62
mDelimiter = temp.size ()? temp[0 ].mid (temp[0 ].find (" =" ) + 1 ) : " " ;
63
+ temp = parameters.grep (" delimiterType=" );
64
+ mDelimiterType = temp.size ()? temp[0 ].mid (temp[0 ].find (" =" ) + 1 ) : " " ;
63
65
temp = parameters.grep (" xField=" );
64
66
QString xField = temp.size ()? temp[0 ].mid (temp[0 ].find (" =" ) + 1 ) : " " ;
65
67
temp = parameters.grep (" yField=" );
66
68
QString yField = temp.size ()? temp[0 ].mid (temp[0 ].find (" =" ) + 1 ) : " " ;
67
69
// Decode the parts of the uri. Good if someone entered '=' as a delimiter, for instance.
68
70
mFileName = QUrl::fromPercentEncoding (mFileName .toUtf8 ());
69
71
mDelimiter = QUrl::fromPercentEncoding (mDelimiter .toUtf8 ());
70
- mDelimiterType = QUrl::fromPercentEncoding (mDelimiter .toUtf8 ());
72
+ mDelimiterType = QUrl::fromPercentEncoding (mDelimiterType .toUtf8 ());
71
73
xField = QUrl::fromPercentEncoding (xField.toUtf8 ());
72
74
yField = QUrl::fromPercentEncoding (yField.toUtf8 ());
73
75
@@ -79,10 +81,10 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider(QString uri)
79
81
QgsDebugMsg (" yField is: " + yField);
80
82
81
83
// if delimiter contains some special characters, convert them
82
- if (mDelimiterType == " plain" )
83
- mDelimiter .replace (" \\ t" , " \t " ); // replace "\t" with a real tabulator
84
- else
84
+ if (mDelimiterType == " regexp" )
85
85
mDelimiterRegexp = QRegExp (mDelimiter );
86
+ else
87
+ mDelimiter .replace (" \\ t" , " \t " ); // replace "\t" with a real tabulator
86
88
87
89
// Set the selection rectangle to null
88
90
mSelectionRectangle = QgsRect ();
@@ -138,10 +140,10 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider(QString uri)
138
140
QgsDebugMsg (" Attempting to split the input line: " + line + " using delimiter " + mDelimiter );
139
141
140
142
QStringList fieldList;
141
- if (mDelimiterType == " plain" )
142
- fieldList = QStringList::split (mDelimiter , line, true );
143
- else
143
+ if (mDelimiterType == " regexp" )
144
144
fieldList = line.split (mDelimiterRegexp );
145
+ else
146
+ fieldList = line.split (mDelimiter );
145
147
QgsDebugMsg (" Split line into " + QString::number (fieldList.size ()) + " parts" );
146
148
147
149
// We don't know anything about a text based field other
@@ -184,10 +186,10 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider(QString uri)
184
186
185
187
// split the line on the delimiter
186
188
QStringList parts;
187
- if (mDelimiterType == " plain" )
188
- parts = QStringList::split (mDelimiter , line, true );
189
- else
189
+ if (mDelimiterType == " regexp" )
190
190
parts = line.split (mDelimiterRegexp );
191
+ else
192
+ parts = line.split (mDelimiter );
191
193
192
194
// Skip malformed lines silently. Report line number with getNextFeature()
193
195
if (attributeFields.size () != parts.size ())
@@ -292,10 +294,10 @@ bool QgsDelimitedTextProvider::getNextFeature(QgsFeature& feature)
292
294
293
295
// lex the tokens from the current data line
294
296
QStringList tokens;
295
- if (mDelimiterType == " plain" )
296
- tokens = QStringList::split (mDelimiter , line, true );
297
- else
297
+ if (mDelimiterType == " regexp" )
298
298
tokens = line.split (mDelimiterRegexp );
299
+ else
300
+ tokens = line.split (mDelimiter );
299
301
300
302
bool xOk = false ;
301
303
bool yOk = false ;
0 commit comments