18 Hff_node::Hff_node(QString namep,
HDataField *fp)
24 Hff_node::~Hff_node(
void)
34 fieldlist =
new QList<Hff_node *>();
35 fields_readed =
false;
37 default_readonly=
false;
39 default_logging=
false;
49 while(!fieldlist->isEmpty())
51 n = *fieldlist->begin();
52 fieldlist->removeAll(n);
57 fields_readed =
false;
96 sdebug(
"==Reading from file==");
97 if (!f->open(QIODevice::ReadOnly | QIODevice::Text))
100 rawdata = in.readAll();
113 rawdata.append(rdata);
129 QString perror = errstr;
130 errstr = QString(
"XML parse error!\nLine:%1 Col:%2\n(pubID:%3 sysID:%4)\n\nHFactory message:%6\nSorry :-(")
131 .arg(exception.lineNumber())
132 .arg(exception.columnNumber())
133 .arg(exception.publicId())
134 .arg(exception.systemId())
135 .arg(exception.message())
142 QString perror = errstr;
143 errstr = QString(
"XML parse error!\nLine:%1 Col:%2\n(pubID:%3 sysID:%4)\n\nHFactory message:%6\nSorry :-(")
144 .arg(exception.lineNumber())
145 .arg(exception.columnNumber())
146 .arg(exception.publicId())
147 .arg(exception.systemId())
148 .arg(exception.message())
155 QString perror = errstr;
156 errstr = QString(
"XML parse error!\nLine:%1 Col:%2\n(pubID:%3 sysID:%4)\nMessage:%5\n\nHFactory message:%6\nSorry :-(")
157 .arg(exception.lineNumber())
158 .arg(exception.columnNumber())
159 .arg(exception.publicId())
160 .arg(exception.systemId())
161 .arg(exception.message())
168 sdebug(
"*** HFactory::genTable ***");
175 sdebug(
"== Begin reading fields ==");
181 fields_readed =
true;
183 sdebug(
"== End reading fields ==");
193 QXmlInputSource *source =
new QXmlInputSource();
194 source->setData(rawdata);
196 QXmlSimpleReader reader;
197 reader.setContentHandler(
this );
198 reader.setErrorHandler(
this );
199 if(!reader.parse( *source ))
201 emit errorSignal(
"Error during the XML parsing! \n: " +
errorString());
202 sdebug(
"!!!!!!!!!!!!! THE XML PARSER FOUND ERROR:");
203 sdebug(
"--begin error string--------------------");
205 sdebug(
"--end error string----------------------");
207 sdebug(
"*** HFactory::genTable *** END");
210 if(t==NULL && mode != FIELDS)
212 emit errorSignal(QString(
"XML Warinig: The requested element not found! (%1)").arg(part));
216 sdebug(
"*** HFactory::genTable *** END");
222 sdebug(
"///HFactory///-> start-document");
228 sdebug(
"///HFactory///-> end-document");
233 const QXmlAttributes& atts)
238 sdebug(
"XML-PARSER start-element: "+name);
245 if(name ==
"templates")
251 if(!mainblock)
return true;
253 if(ttype != FIELDS && name ==
"element" && atts.value(
"name") == pname)
259 if(ttype == FIELDS && !read_on && name ==
"field")
263 fname = atts.value(
"name");
266 errstr=
"The name of the field node is cannot empty!";
272 if(!read_on && !fieldread_on)
275 if(read_on && fieldread_on)
277 errstr =
"Place the \"field\" nodes out of the element \"nodes\" !";
286 if(!read_on && fieldread_on)
288 errstr =
"Systax error: Cannot place \"table\" node in \"field\" node!";
292 if(atts.value(
"sqln").isEmpty())
294 errstr =
"Missig or empty \"sqln\" parameter of node \"table\" !";
298 t =
new HTable(atts.value(
"sqln"));
299 else if(ttype == LIST)
300 t =
new HList (atts.value(
"sqln"));
302 default_readonly=
false;
304 default_logging=
false;
316 if(read_on && t == NULL)
318 errstr =
"Want to read table element to uninitialized Table !";
322 if(read_on && name ==
"usefield")
326 errstr =
"Internal error: Fields not readed yet!";
331 match = atts.value(
"name");
336 fpar_att = atts.value(
"mode");
337 fpar_def = atts.value(
"default");
338 fpar_sql = atts.value(
"sqln");
340 QList<Hff_node *>::iterator i = fieldlist->begin();
341 while(i != fieldlist->end())
343 if((*i)->name == match)
345 sdebug(
"==== Begin - INSERT a CLONE ====");
348 if(!fpar_def.isEmpty())
350 sdebug(
"Set a NEW default VALUE!");
354 if(!fpar_sql.isEmpty())
356 sdebug(
"Set a NEW default SQLN!");
360 if(fpar_att.contains(
"rw"))
362 if(fpar_att.contains(
"ro"))
364 if(fpar_att.contains(
"hide"))
366 if(fpar_att.contains(
"show"))
371 sdebug(
"==== End - INSERT a CLONE ====");
383 if(level == 1 && !fieldread_on)
386 default_color_r=atts.value(
"r").toUInt();
387 default_color_g=atts.value(
"g").toUInt();
388 default_color_b=atts.value(
"b").toUInt();
390 else if(level == 2 || fieldread_on)
393 r = atts.value(
"r").toUInt();
394 g = atts.value(
"g").toUInt();
395 b = atts.value(
"b").toUInt();
400 if(name ==
"readonly")
402 if(level == 1 && !fieldread_on)
403 default_readonly=
true;
404 else if(level == 2 || fieldread_on)
408 if(name ==
"editable")
410 if(level == 1 && !fieldread_on)
412 else if(level == 2 || fieldread_on)
417 if(name ==
"logging")
419 if(level == 1 && !fieldread_on)
420 default_logging=
true;
421 else if(level == 2 || fieldread_on)
425 if(name ==
"nologging")
427 if(level == 1 && !fieldread_on)
429 else if(level == 2 || fieldread_on)
436 if(level == 2 || fieldread_on)
442 if(level == 2 || fieldread_on)
449 if(level == 1 && !fieldread_on)
451 errstr=
"Not allowed \"role\" tag here...";
454 else if(level == 2 || fieldread_on)
456 if(atts.value(
"name").isEmpty())
458 errstr=
"You must specify valid (not empty) role name!";
462 rolename.push_back( atts.value(
"name") );
463 rolemod.push_back( atts.value(
"mod") );
464 roleval.push_back( atts.value(
"val") );
469 if(name ==
"meldwithnext")
471 if(level == 2 || fieldread_on)
476 if(name ==
"nomiddlestretch")
478 if(level == 2 || fieldread_on)
479 nomiddlestretch=
true;
483 if(name ==
"displayformat")
487 fmin = atts.value(
"minfrag").toInt(&ok);
490 errstr =
"Cannot parse minfrag attribute!";
494 fmax = atts.value(
"maxfrag").toInt(&ok);
497 errstr =
"Cannot parse minfrag attribute!";
500 fgroup = atts.value(
"group").toInt(&ok);
503 errstr =
"Cannot parse minfrag attribute!";
515 buffer_k.push_back(atts.value(
"key"));
516 buffer_v.push_back(atts.value(
"value"));
525 name ==
"smalltext" ||
526 name ==
"largetext" ||
527 name ==
"charhash" ||
531 name ==
"floating" ||
535 name ==
"timestamp" ||
537 name ==
"sqlchoose" )
541 buffer_sql = atts.value(
"sqln");
545 if(name ==
"explain" || name ==
"ex" ||
546 name ==
"title" || name ==
"ti" ||
547 name ==
"tail" || name ==
"ta" ||
548 name ==
"default" || name ==
"de" ||
549 name ==
"true" || name ==
"tr" ||
550 name ==
"false" || name ==
"fa" ||
551 name ==
"controll"|| name ==
"co" ||
552 name ==
"mark" || name ==
"m" ||
553 name ==
"connected_table" ||
554 name ==
"keyfield" ||
555 name ==
"showfield" ||
556 name ==
"showfieldeasy" ||
557 name ==
"showfieldhead" ||
558 name ==
"filter_part" ||
559 name ==
"tabletitle" ||
560 name ==
"hashfunc" ||
561 name ==
"extended" ||
563 name ==
"notvalid" ||
564 name ==
"function" ||
566 name ==
"extrafeatures" ||
567 name ==
"showtitle" ||
568 name ==
"orderby_part" ||
569 name ==
"popuptitle" ||
570 name ==
"specialsort" ||
571 name ==
"progress" ||
575 name ==
"meldwithnext" ||
576 name ==
"nomiddlestretch" ||
577 name ==
"editmaxwidth" )
583 errstr =
"Unknown (start)element found: \""+name+
"\" !";
587 void HFactory::emptyBuffer(
void)
603 buffer_popuptitle=
"";
614 nomiddlestretch =
false;
629 meldwithnext =
false;
630 showprogress =
false;
635 buffer_notvalid.clear();
649 if(!mainblock)
return true;
650 if(!read_on && !fieldread_on)
return true;
652 buffer.append(QString(ch).trimmed());
656 void HFactory::setHDataFieldAttributes(
HDataField * d)
658 if(default_color && !color) d->
setColor(default_color_r,default_color_g,default_color_b);
664 if(logging || default_logging) d->
setLogging();
674 if(!buffer_specsort.isEmpty())
676 if(!buffer_func.isEmpty())
678 if(!markers.isEmpty())
681 if(rolename.count() > 0)
683 int i,c=rolename.count();
696 fieldlist->push_back(
new Hff_node(fname,df));
707 sdebug(
"XML-PARSER end-element: "+name);
710 if(name ==
"templates")
716 if(!mainblock)
return true;
718 if(name ==
"element")
726 fieldread_on =
false;
730 if(!read_on && !fieldread_on)
return true;
734 if(read_on && t == NULL)
736 errstr =
"Want to read table element to uninitialized Table (end)!";
740 if(read_on && name ==
"tabletitle")
750 if(name ==
"explain" || name ==
"ex")
756 if(name ==
"title" || name ==
"ti")
762 if(name ==
"tail" || name ==
"ta")
764 buffer_tail = buffer;
768 if(name ==
"default" || name ==
"de")
774 if(name ==
"true" || name ==
"tr")
780 if(name ==
"false" || name ==
"fa")
787 if(name ==
"controll" || name ==
"co")
789 buffer_1 =
"controll";
793 if(name ==
"connected_table")
799 if(name ==
"keyfield")
805 if(name ==
"showfield")
811 if(name ==
"showfieldeasy")
817 if(name ==
"showfieldhead")
823 if(name ==
"filter_part")
829 if(name ==
"orderby_part")
835 if(name ==
"popuptitle")
837 buffer_popuptitle = buffer;
844 sortc = buffer.toInt(&ok) - 1;
847 errstr = QString(
"Bad value in sortc!");
854 if(name ==
"extended")
860 if(name ==
"progress")
866 if(name ==
"extrafeatures")
872 if(name ==
"showtitle")
880 buffer_valid = buffer;
884 if(name ==
"notvalid")
886 buffer_notvalid.push_back(buffer);
890 if(name ==
"function")
892 buffer_func = buffer;
897 if(name ==
"mark" || name ==
"m")
899 markers.push_back(buffer);
904 if(name ==
"hashfunc")
906 buffer_hashf = buffer;
911 if(name ==
"specialsort")
913 buffer_specsort = buffer;
918 if(name ==
"minimum")
920 buffer_minimum = buffer;
924 if(name ==
"maximum")
926 buffer_maximum = buffer;
930 if(name ==
"editmaxwidth")
934 i = buffer.toInt(&ok);
942 if(read_on && name ==
"depend")
944 if(!buffer.isEmpty())
958 if(buffer_sql.isEmpty())
960 errstr = QString(
"Missing parameter (%1) !").arg(name);
964 HKey *d =
new HKey(buffer_sql,buffer_exp,buffer_tit,buffer_def);
965 setHDataFieldAttributes(d);
971 if(name ==
"connect")
975 if(buffer_sql.isEmpty() || buffer_1.isEmpty())
977 errstr = QString(
"Missing parameter (%1) !").arg(name);
982 setHDataFieldAttributes(d);
988 if(name ==
"smalltext")
992 if(buffer_sql.isEmpty())
994 errstr = QString(
"Missing parameter (%1) !").arg(name);
999 setHDataFieldAttributes(d);
1007 if(name ==
"largetext")
1011 if(buffer_sql.isEmpty())
1013 errstr = QString(
"Missing parameter (%1) !").arg(name);
1018 setHDataFieldAttributes(d);
1026 if(name ==
"charhash")
1030 if(buffer_sql.isEmpty())
1032 errstr = QString(
"Missing parameter (%1) !").arg(name);
1036 buffer_def,buffer_k,buffer_v);
1037 setHDataFieldAttributes(d);
1045 if(name ==
"numhash")
1049 if(buffer_sql.isEmpty())
1051 errstr = QString(
"Missing parameter (%1) !").arg(name);
1055 buffer_def,buffer_k,buffer_v);
1056 setHDataFieldAttributes(d);
1064 if(name ==
"number")
1069 if(buffer_sql.isEmpty())
1071 errstr = QString(
"Missing parameter (%1) !").arg(name);
1074 HNumber *d =
new HNumber(buffer_sql,buffer_exp,buffer_tit,buffer_tail,
1076 setHDataFieldAttributes(d);
1080 if(!buffer_maximum.isEmpty())
1084 sdebug(QString(
"Error conversion HNumber..maximum field data to int: \"%1\"").arg(buffer_maximum));
1086 if(!buffer_minimum.isEmpty())
1090 sdebug(QString(
"Error conversion HNumber..minimum field data to int: \"%1\"").arg(buffer_minimum));
1098 if(name ==
"static")
1103 setHDataFieldAttributes(d);
1113 if(buffer_sql.isEmpty())
1115 errstr = QString(
"Missing parameter (%1) !").arg(name);
1118 HCheck *d =
new HCheck(buffer_sql,buffer_exp,buffer_tit,buffer_tail,
1119 buffer_def,buffer_1,buffer_2);
1120 setHDataFieldAttributes(d);
1126 if(name ==
"floating")
1131 if(buffer_sql.isEmpty())
1133 errstr = QString(
"Missing parameter (%1) !").arg(name);
1138 setHDataFieldAttributes(d);
1143 if(!buffer_maximum.isEmpty())
1147 sdebug(QString(
"Error conversion HFloating..maximum field data to double: \"%1\"").arg(buffer_maximum));
1149 if(!buffer_minimum.isEmpty())
1153 sdebug(QString(
"Error conversion HFloating..minimum field data to double: \"%1\"").arg(buffer_minimum));
1165 if(buffer_sql.isEmpty())
1167 errstr = QString(
"Missing parameter (%1) !").arg(name);
1171 HDate *d =
new HDate(buffer_sql,buffer_exp,buffer_tit,buffer_def,
1173 setHDataFieldAttributes(d);
1183 if(buffer_sql.isEmpty())
1185 errstr = QString(
"Missing parameter (%1) !").arg(name);
1189 HDate *d =
new HDate(buffer_sql,buffer_exp,buffer_tit,buffer_def,
1191 setHDataFieldAttributes(d);
1197 if(name ==
"timestamp")
1201 if(buffer_sql.isEmpty())
1203 errstr = QString(
"Missing parameter (%1) !").arg(name);
1207 buffer_1 ==
"controll" ?
true :
false);
1208 setHDataFieldAttributes(d);
1214 if(name ==
"sqlchoose")
1218 if(buffer_sql.isEmpty())
1220 errstr = QString(
"Missing parameter (%1) !").arg(name);
1224 if(buffer_3.isEmpty() && buffer_7.isEmpty())
1226 errstr = QString(
"SqlChoose: Have to define showfield or showfieldeasy attribute!");
1229 if(!buffer_3.isEmpty() && !buffer_7.isEmpty())
1231 errstr = QString(
"SqlChoose: You have to define showfield OR showfieldeasy attribute but only one! (not both)");
1234 if(buffer_3.isEmpty() && !buffer_7.isEmpty())
1236 buffer_7.replace(
"|",
"||\'|\'||");
1237 buffer_3 = buffer_7;
1241 buffer_1,buffer_2,buffer_3,buffer_4,buffer_5,buffer_6,buffer_hashf,easy);
1249 if(!buffer_popuptitle.isEmpty())
1253 setHDataFieldAttributes(d);
1266 if(name ==
"table" ||
1267 name ==
"usefield" ||
1270 name ==
"readonly" ||
1271 name ==
"editable" ||
1274 name ==
"logging" ||
1275 name ==
"nologging" ||
1276 name ==
"meldwithnext" ||
1277 name ==
"nomiddlestretch"||
1278 name ==
"displayformat" ||
1286 sdebug(
"end-element: "+name);
1288 errstr =
"Unknown (end)element found: \""+name+
"\" !";
void setFunction(QString func)
void setMaximum(long int m)
HList * genHList(QString part, QString inRole="")
QString sqlCreateString(QString switches="")
void addRole(HDataFieldRole role)
QString errorString(void)
void setMinimum(double m)
bool characters(const QString &ch)
void addMark(QString mark)
void noMiddleStretch(void)
void setMaximum(double m)
void setMinimum(long int m)
void setPopupDialogTitle(QString title)
void addDependTableName(QString n)
int readFromFile(QFile *f)
void setGuiSortIndicator(int i)
bool endElement(const QString &ns, const QString &ln, const QString &name)
void appendTemplateData(QString rdata)
HFactory(QString rdata="")
void setDisplayMode(int minDf, int maxDf, int groupDf)
bool fatalError(const QXmlParseException &exception)
void setTableTitle(QString s)
void addField(HDataField *i)
bool error(const QXmlParseException &exception)
HTableBase * genTable(QString part, int mode=TABLE)
bool warning(const QXmlParseException &exception)
QString sqlCreateString(QString part)
void setNotValidValues(QStringList nvl)
virtual int setDefval(QVariant v)
void setColor(int r, int g, int b)
void setSpecDisplaySortMode(QString m)
void setValidator(QString v="")
void setEditBoxMaxWidth(int max)
void useRole(QString name)
virtual HDataField * get_clone(void)
void clearTemplateData(void)
HTable * genHTable(QString part, QString inRole="")
bool startElement(const QString &ns, const QString &ln, const QString &name, const QXmlAttributes &atts)