diff options
author | deva <deva> | 2008-09-03 15:07:50 +0000 |
---|---|---|
committer | deva <deva> | 2008-09-03 15:07:50 +0000 |
commit | 4dd7add65ed2648e7c139df3138e489f8dbd8e43 (patch) | |
tree | b30eea7c4b49fce9fe329c7a3d955627167f26a1 /client/formatparser.cc | |
parent | 4549daa34926ca806daf6cbf4aea70bf24338f4a (diff) |
The dbwidget now work generally, controlled by the xml.
Diffstat (limited to 'client/formatparser.cc')
-rw-r--r-- | client/formatparser.cc | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/client/formatparser.cc b/client/formatparser.cc index 260a2bf..233a694 100644 --- a/client/formatparser.cc +++ b/client/formatparser.cc @@ -26,6 +26,8 @@ */ #include "formatparser.h" +#include <QSqlRecord> +#include <QVariant> #include <string.h> QString format_parser(QString format, QVector< Widget *> widgets) @@ -98,3 +100,80 @@ QString format_parser(QString format, QVector< Widget *> widgets) return resume; } + + +QString format_parser(QString format, QSqlQuery &query) +{ + QString resume; + QString var; + + QChar *p = format.data(); + QChar *theend = p + format.size(); + while(p < theend) { + switch((*p).toLatin1()) { + case '$': + p++; + switch((*p).toLatin1()) { + case '$': + resume.append(*p); + break; + + case '{': + p++; + var = ""; + // Parser + while(p < theend && *p != '}') { + var.append(*p); + p++; + } + { + int fieldNo = query.record().indexOf(var); + resume += query.value(fieldNo).toString(); + + /* + QVector< Widget* >::iterator i = widgets.begin(); + while (i != widgets.end()) { + Widget* w = *i; + if(w->getName() == var) resume += w->getValue(); + i++; + } + */ + } + break; + + default: + resume.append(*p); + break; + } + p++; + break; + + case '\\': + p++; + switch((*p).toLatin1()) { + case 't': + resume.append('\t'); + break; + case 'n': + resume.append('\n'); + break; + case 'r': + resume.append('\r'); + break; + case '\\': + default: + resume.append(*p); + break; + } + p++; + break; + + default: + resume.append(QChar(*p)); + p++; + break; + } + } + + return resume; +} |