Skip to content

Commit eceb4e8

Browse files
author
wonder
committedOct 12, 2006
Fix for ticket #323 (diacritics in column name).
Use QgsLogger in QgsSearchTreeNode instead of std::cout. git-svn-id: http://svn.osgeo.org/qgis/trunk@5939 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent adb5b48 commit eceb4e8

File tree

3 files changed

+20
-30
lines changed

3 files changed

+20
-30
lines changed
 

‎src/core/qgssearchstringlexer.ll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@
3434

3535
white [ \t\r\n]+
3636

37-
col_first [A-Za-z_]
38-
col_next [A-Za-z0-9_]
37+
non_ascii [\x80-\xFF]
38+
39+
col_first [A-Za-z_]|{non_ascii}
40+
col_next [A-Za-z0-9_]|{non_ascii}
3941
column_ref {col_first}{col_next}*
4042

4143
dig [0-9]

‎src/core/qgssearchtreenode.cpp

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,15 @@
1616
* *
1717
***************************************************************************/
1818
/* $Id$ */
19-
19+
20+
#include "qgslogger.h"
2021
#include "qgssearchtreenode.h"
2122
#include <qregexp.h>
2223
#include <qobject.h>
2324
#include <iostream>
2425

25-
// turn on/off debugging of search tree evaulation
26-
#undef DEBUG_TREE_EVAL
2726

28-
#ifdef DEBUG_TREE_EVAL
29-
#define TREE_EVAL(x) std::cout << x;
30-
#define TREE_EVAL2(x,y) std::cout << x << y << std::endl;
31-
#define TREE_EVAL3(x,y,z) std::cout << x << y << z << std::endl;
32-
#define TREE_EVAL4(x,y,z,zz) std::cout << x << y << z << zz << std::endl;
3327
#define EVAL_STR(x) (x.length() ? x : "(empty)")
34-
#else
35-
#define TREE_EVAL(x)
36-
#define TREE_EVAL2(x,y)
37-
#define TREE_EVAL3(x,y,z)
38-
#define TREE_EVAL4(x,y,z,zz)
39-
#endif
4028

4129
QgsSearchTreeNode::QgsSearchTreeNode(double number)
4230
{
@@ -194,7 +182,7 @@ QString QgsSearchTreeNode::makeSearchString()
194182

195183
bool QgsSearchTreeNode::checkAgainst(const std::vector<QgsFeatureAttribute>& attributes)
196184
{
197-
TREE_EVAL2("checkAgainst: ", makeSearchString());
185+
QgsDebugMsgLevel("checkAgainst: " + makeSearchString(), 2);
198186

199187
mError = "";
200188

@@ -275,8 +263,8 @@ bool QgsSearchTreeNode::checkAgainst(const std::vector<QgsFeatureAttribute>& att
275263

276264
QRegExp re(str);
277265
res = re.search(value1.string());
278-
TREE_EVAL4("REGEXP: ", str, " ~ ", value2.string());
279-
TREE_EVAL2(" res: ", res);
266+
QgsDebugMsgLevel("REGEXP: " + str + " ~ " + value2.string(), 2);
267+
QgsDebugMsgLevel(" res: " + res, 2);
280268
return (res != -1);
281269
}
282270

@@ -324,22 +312,22 @@ bool QgsSearchTreeNode::getValue(QgsSearchTreeValue& value, QgsSearchTreeNode* n
324312

325313
QgsSearchTreeValue QgsSearchTreeNode::valueAgainst(const std::vector<QgsFeatureAttribute>& attributes)
326314
{
327-
TREE_EVAL2("valueAgainst: ", makeSearchString());
315+
QgsDebugMsgLevel("valueAgainst: " + makeSearchString(), 2);
328316

329317
switch (mType)
330318
{
331319

332320
case tNumber:
333-
TREE_EVAL2("number: ", mNumber);
321+
QgsDebugMsgLevel("number: " + QString::number(mNumber), 2);
334322
return QgsSearchTreeValue(mNumber);
335323

336324
case tString:
337-
TREE_EVAL2("text: ", EVAL_STR(mText));
325+
QgsDebugMsgLevel("text: " + EVAL_STR(mText), 2);
338326
return QgsSearchTreeValue(mText);
339327

340328
case tColumnRef:
341329
{
342-
TREE_EVAL3("column (", mText, "): ");;
330+
QgsDebugMsgLevel("column (" + mText.lower() + "): ", 2);
343331
// find value for the column
344332
std::vector<QgsFeatureAttribute>::const_iterator it;
345333
for (it = attributes.begin(); it != attributes.end(); it++)
@@ -349,19 +337,19 @@ QgsSearchTreeValue QgsSearchTreeNode::valueAgainst(const std::vector<QgsFeatureA
349337
QString value = (*it).fieldValue();
350338
if ((*it).isNumeric())
351339
{
352-
TREE_EVAL2(" number: ", value.toDouble());
340+
QgsDebugMsgLevel(" number: " + QString::number(value.toDouble()), 2);
353341
return QgsSearchTreeValue(value.toDouble());
354342
}
355343
else
356344
{
357-
TREE_EVAL2(" text: ", EVAL_STR(value));
345+
QgsDebugMsgLevel(" text: " + EVAL_STR(value), 2);
358346
return QgsSearchTreeValue(value);
359347
}
360348
}
361349
}
362350

363351
// else report missing column
364-
TREE_EVAL("ERROR");
352+
QgsDebugMsgLevel("ERROR!", 2);
365353
return QgsSearchTreeValue(1, mText);
366354
}
367355

@@ -424,7 +412,7 @@ int QgsSearchTreeValue::compare(QgsSearchTreeValue& value1, QgsSearchTreeValue&
424412
else
425413
val2 = value2.string().toDouble();
426414

427-
TREE_EVAL4("NUM_COMP: ", val1, " ~ ", val2);
415+
QgsDebugMsgLevel("NUM_COMP: " + QString::number(val1) + " ~ " + QString::number(val2), 2);
428416

429417
if (val1 < val2)
430418
return -1;

‎src/providers/ogr/qgsogrprovider.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ void QgsOgrProvider::getFeatureAttribute(OGRFeature * ogrFet, QgsFeature * f, in
715715
return;
716716
}
717717

718-
QString fld = fldDef->GetNameRef();
718+
QString fld = mEncoding->toUnicode(fldDef->GetNameRef());
719719
QByteArray cstr(ogrFet->GetFieldAsString(attindex));
720720
bool numeric = attributeFields[attindex].isNumeric();
721721

@@ -730,7 +730,7 @@ void QgsOgrProvider::getFeatureAttributes(OGRFeature *ogrFet, QgsFeature *f){
730730
getFeatureAttribute(ogrFet,f,i);
731731
// add the feature attributes to the tree
732732
/*OGRFieldDefn *fldDef = ogrFet->GetFieldDefnRef(i);
733-
QString fld = fldDef->GetNameRef();
733+
QString fld = mEncoding->toUnicode(fldDef->GetNameRef());
734734
// OGRFieldType fldType = fldDef->GetType();
735735
QString val;
736736
@@ -1149,7 +1149,7 @@ bool QgsOgrProvider::changeAttributeValues(std::map<int,std::map<QString,QString
11491149
for ( int f = 0; f < fc; f++ ) {
11501150
OGRFieldDefn *fd = of->GetFieldDefnRef ( f );
11511151

1152-
if ( name.compare( fd->GetNameRef() ) == 0 ) {
1152+
if ( name.compare( mEncoding->toUnicode(fd->GetNameRef()) ) == 0 ) {
11531153
OGRFieldType type = fd->GetType();
11541154
switch ( type ) {
11551155
case OFTInteger:

0 commit comments

Comments
 (0)
Please sign in to comment.