[Kst] extragear/graphics/kst/kst
George Staikos
staikos at kde.org
Wed Jul 13 22:42:15 CEST 2005
SVN commit 434372 by staikos:
add vector index parsing
M +20 -4 labelparser.cpp
M +2 -0 labelparser.h
--- trunk/extragear/graphics/kst/kst/labelparser.cpp #434371:434372
@@ -21,11 +21,12 @@
#include <qstring.h>
+#include <kdebug.h>
using namespace Label;
Chunk::Chunk(Chunk *parent, VOffset dir, bool group)
-: next(0L), prev(0L), up(0L), down(0L), symbol(false), scalar(false), group(group), linebreak(false), tab(false), vOffset(dir) {
+: next(0L), prev(0L), up(0L), down(0L), symbol(false), scalar(false), group(group), linebreak(false), tab(false), vector(false), vOffset(dir) {
assert(parent || vOffset == None);
if (parent) { // attach and inherit
switch (vOffset) {
@@ -70,7 +71,7 @@
bool Chunk::locked() const {
- return scalar || group || linebreak || tab;
+ return scalar || group || linebreak || tab || vector;
}
@@ -334,6 +335,9 @@
break;
case '[':
{
+ bool vector = false;
+ int vectorIndexStart = -1;
+ int vectorIndexEnd = -1;
int bracketStack = 1;
int pos = -1;
for (uint searchPt = i + 1; bracketStack != 0 && searchPt < cnt; ++searchPt) {
@@ -341,9 +345,15 @@
if (--bracketStack == 0) {
pos = searchPt;
break;
+ } else if (bracketStack == 1 && vector && vectorIndexEnd == -1) {
+ vectorIndexEnd = searchPt - 1;
}
} else if (txt[searchPt] == '[') {
++bracketStack;
+ if (!vector) {
+ vector = true;
+ vectorIndexStart = searchPt + 1;
+ }
}
}
@@ -359,8 +369,14 @@
}
}
- ctail->text = txt.mid(i + 1, pos - i - 1);
- ctail->scalar = true;
+ if (vector) {
+ ctail->text = txt.mid(i + 1, vectorIndexStart - i - 2).stripWhiteSpace();
+ ctail->expression = txt.mid(vectorIndexStart, vectorIndexEnd - vectorIndexStart + 1);
+ ctail->vector = true;
+ } else {
+ ctail->text = txt.mid(i + 1, pos - i - 1).stripWhiteSpace();
+ ctail->scalar = true;
+ }
i = uint(pos);
}
break;
--- trunk/extragear/graphics/kst/kst/labelparser.h #434371:434372
@@ -52,8 +52,10 @@
bool group : 1;
bool linebreak : 1;
bool tab : 1;
+ bool vector : 1;
VOffset vOffset : 2;
QString text;
+ QString expression;
};
More information about the Kst
mailing list