gSAFE  1.3.8
hfactory.cpp
1 /* gSAFE - LIB
2  general Sql dAtabase FrontEnd
3  http://hyperprog.com/gsafe/
4 
5  (C) 2005-2013 Peter Deak (hyper80@gmail.com)
6 
7  License: GPLv2 http://www.gnu.org/licenses/gpl-2.0.html
8 
9  hfactory.cpp
10 */
11 
12 #include "datalib.h"
13 #include "hfactory.h"
14 #include "dconsole.h"
15 
16 //#define PARSER_DEBUG
17 
18 Hff_node::Hff_node(QString namep,HDataField *fp)
19 {
20  f=fp;
21  name=namep;
22 }
23 
24 Hff_node::~Hff_node(void)
25 {
26  if(f != NULL)
27  delete f;
28 }
29 
30 HFactory::HFactory(QString rdata)
31 {
32  errstr = "";
33  rawdata = rdata;
34  fieldlist = new QList<Hff_node *>();
35  fields_readed = false;
36 
37  default_readonly=false;
38  default_hide=false;
39  default_logging=false;
40  default_color=false;
41  default_color_r=0;
42  default_color_g=0;
43  default_color_b=0;
44 }
45 
47 {
48  Hff_node *n;
49  while(!fieldlist->isEmpty())
50  {
51  n = *fieldlist->begin();
52  fieldlist->removeAll(n);
53  delete n;
54  }
55  delete fieldlist;
56  fieldlist = NULL;
57  fields_readed = false;
58 
59  fpar_att = "";
60  fpar_def = "";
61  fpar_sql = "";
62 }
63 
64 HTable* HFactory::genHTable(QString part,QString inRole)
65 {
66  HTable *t;
67  t = (HTable *)genTable(part,TABLE);
68  if(!inRole.isEmpty())
69  t->useRole(inRole);
70  return t;
71 }
72 
73 HList* HFactory::genHList (QString part,QString inRole)
74 {
75  HList *l;
76  l = (HList *)genTable(part,LIST);
77  if(!inRole.isEmpty())
78  l->useRole(inRole);
79  return l;
80 }
81 
82 QString HFactory::sqlCreateString(QString part)
83 {
84  QString cs="";
85  HTable *t=NULL;
86 
87  t = genHTable(part);
88  if(t != NULL)
89  cs = t->sqlCreateString();
90  delete t;
91  return cs;
92 }
93 
95 {
96  sdebug("==Reading from file==");
97  if (!f->open(QIODevice::ReadOnly | QIODevice::Text))
98  return 1;
99  QTextStream in(f);
100  rawdata = in.readAll();
101  sdebug("==Done==");
102  return 0;
103 }
104 
105 int HFactory::readFromFile(QString fn)
106 {
107  QFile f(fn);
108  return readFromFile(&f);
109 }
110 
111 void HFactory::appendTemplateData(QString rdata)
112 {
113  rawdata.append(rdata);
114 
115 }
116 
118 {
119  rawdata = "";
120 }
121 
123 {
124  return errstr;
125 }
126 
127 bool HFactory::warning(const QXmlParseException& exception)
128 {
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())
136  .arg(perror);
137  return false;
138 }
139 
140 bool HFactory::error(const QXmlParseException& exception)
141 {
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())
149  .arg(perror);
150  return false;
151 }
152 
153 bool HFactory::fatalError(const QXmlParseException& exception)
154 {
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())
162  .arg(perror);
163  return false;
164 }
165 
166 HTableBase *HFactory::genTable(QString part,int mode)
167 {
168  sdebug("*** HFactory::genTable ***");
169  t = NULL;
170  ttype = mode;
171  level = 0;
172 
173  if(ttype != FIELDS)
174  {
175  sdebug("== Begin reading fields ==");
176  if(!fields_readed)
177  {
178  sdebug("Parsing...");
179  genTable("",FIELDS);
180  }
181  fields_readed = true;
182  ttype = mode;
183  sdebug("== End reading fields ==");
184  }
185 
186  mainblock=false;
187  read_on=false;
188  fieldread_on=false;
189  pname=part;
190 
191  emptyBuffer();
192 
193  QXmlInputSource *source =new QXmlInputSource();
194  source->setData(rawdata);
195 
196  QXmlSimpleReader reader;
197  reader.setContentHandler( this );
198  reader.setErrorHandler( this );
199  if(!reader.parse( *source ))
200  {
201  emit errorSignal("Error during the XML parsing! \n: " + errorString());
202  sdebug("!!!!!!!!!!!!! THE XML PARSER FOUND ERROR:");
203  sdebug("--begin error string--------------------");
204  sdebug(errorString());
205  sdebug("--end error string----------------------");
206  delete source;
207  sdebug("*** HFactory::genTable *** END");
208  return NULL;
209  }
210  if(t==NULL && mode != FIELDS)
211  {
212  emit errorSignal(QString("XML Warinig: The requested element not found! (%1)").arg(part));
213  }
214  delete source;
215  source = NULL;
216  sdebug("*** HFactory::genTable *** END");
217  return t;
218 }
219 
221 {
222  sdebug("///HFactory///-> start-document");
223  return true;
224 }
225 
227 {
228  sdebug("///HFactory///-> end-document");
229  return true;
230 }
231 
232 bool HFactory::startElement( const QString& ls, const QString& ln, const QString& name,
233  const QXmlAttributes& atts)
234 {
235  Q_UNUSED(ls);
236  Q_UNUSED(ln);
237 #ifdef PARSER_DEBUG
238  sdebug("XML-PARSER start-element: "+name);
239 #endif
240 
242  // Main containers /////////////////////////////////////////////////////////////////////////
244 
245  if(name == "templates")
246  {
247  mainblock = true;
248  return true;
249  }
250 
251  if(!mainblock) return true;
252 
253  if(ttype != FIELDS && name == "element" && atts.value("name") == pname)
254  {
255  read_on = true;
256  return true;
257  }
258 
259  if(ttype == FIELDS && !read_on && name == "field") //we are'nt in the required section or there is a field definition
260  {
261  fieldread_on = true;
262  f = NULL;
263  fname = atts.value("name");
264  if(fname.isEmpty())
265  {
266  errstr="The name of the field node is cannot empty!";
267  return false;
268  }
269  return true;
270  }
271 
272  if(!read_on && !fieldread_on)
273  return true;
274 
275  if(read_on && fieldread_on)
276  {
277  errstr = "Place the \"field\" nodes out of the element \"nodes\" !";
278  return false;
279  }
280 
282  // Main targets ////////////////////////////////////////////////////////////////////////////
284  if(name == "table")
285  {
286  if(!read_on && fieldread_on)
287  {
288  errstr = "Systax error: Cannot place \"table\" node in \"field\" node!";
289  return false;
290  }
291 
292  if(atts.value("sqln").isEmpty())
293  {
294  errstr = "Missig or empty \"sqln\" parameter of node \"table\" !";
295  return false;
296  }
297  if(ttype == TABLE)
298  t = new HTable(atts.value("sqln"));
299  else if(ttype == LIST)
300  t = new HList (atts.value("sqln"));
301 
302  default_readonly=false;
303  default_hide=false;
304  default_logging=false;
305  default_color=false;
306  default_color_r=0;
307  default_color_g=0;
308  default_color_b=0;
309 
310  level = 1;
311 
312  return true;
313  }
314 
316  if(read_on && t == NULL)
317  {
318  errstr = "Want to read table element to uninitialized Table !";
319  return false;
320  }
321 
322  if(read_on && name == "usefield")
323  {
324  if(!fields_readed)
325  {
326  errstr = "Internal error: Fields not readed yet!";
327  return false;
328  }
329  QString match;
330  HDataField *clone;
331  match = atts.value("name");
332 
333  fpar_att = "";
334  fpar_def = "";
335  fpar_sql = "";
336  fpar_att = atts.value("mode");
337  fpar_def = atts.value("default");
338  fpar_sql = atts.value("sqln");
339 
340  QList<Hff_node *>::iterator i = fieldlist->begin();
341  while(i != fieldlist->end())
342  {
343  if((*i)->name == match)
344  {
345  sdebug("==== Begin - INSERT a CLONE ====");
346  clone = (*i)->f->get_clone();
347 
348  if(!fpar_def.isEmpty())
349  {
350  sdebug("Set a NEW default VALUE!");
351  clone->setDefval(fpar_def);
352  }
353 
354  if(!fpar_sql.isEmpty())
355  {
356  sdebug("Set a NEW default SQLN!");
357  clone->setDefval(fpar_sql);
358  }
359 
360  if(fpar_att.contains("rw"))
361  clone->setEditable();
362  if(fpar_att.contains("ro"))
363  clone->setReadonly();
364  if(fpar_att.contains("hide"))
365  clone->setHide();
366  if(fpar_att.contains("show"))
367  clone->setShow();
368 
369  insertDF(clone);
370 
371  sdebug("==== End - INSERT a CLONE ====");
372  }
373  ++i;
374  }
375  return true;
376  }
377 
379  // Type modifier parts /////////////////////////////////////////////////////////////////////
381  if(name == "color")
382  {
383  if(level == 1 && !fieldread_on)
384  {
385  default_color=true;
386  default_color_r=atts.value("r").toUInt();
387  default_color_g=atts.value("g").toUInt();
388  default_color_b=atts.value("b").toUInt();
389  }
390  else if(level == 2 || fieldread_on)
391  {
392  color = true;
393  r = atts.value("r").toUInt();
394  g = atts.value("g").toUInt();
395  b = atts.value("b").toUInt();
396  }
397  return true;
398  }
400  if(name == "readonly")
401  {
402  if(level == 1 && !fieldread_on)
403  default_readonly=true;
404  else if(level == 2 || fieldread_on)
405  readonly=true;
406  return true;
407  }
408  if(name == "editable")
409  {
410  if(level == 1 && !fieldread_on)
411  ; //not necessary because the default is editable
412  else if(level == 2 || fieldread_on)
413  editable=true;
414  return true;
415  }
417  if(name == "logging")
418  {
419  if(level == 1 && !fieldread_on)
420  default_logging=true;
421  else if(level == 2 || fieldread_on)
422  logging=true;
423  return true;
424  }
425  if(name == "nologging")
426  {
427  if(level == 1 && !fieldread_on)
428  ; //not necessary because the default is nologging
429  else if(level == 2 || fieldread_on)
430  nologging=true;
431  return true;
432  }
434  if(name == "show")
435  {
436  if(level == 2 || fieldread_on)
437  show=true;
438  return true;
439  }
440  if(name == "hide")
441  {
442  if(level == 2 || fieldread_on)
443  hide=true;
444  return true;
445  }
446 
447  if(name == "role")
448  {
449  if(level == 1 && !fieldread_on)
450  {
451  errstr="Not allowed \"role\" tag here...";
452  return false;
453  }
454  else if(level == 2 || fieldread_on)
455  {
456  if(atts.value("name").isEmpty())
457  {
458  errstr="You must specify valid (not empty) role name!";
459  return false;
460  }
461 
462  rolename.push_back( atts.value("name") );
463  rolemod.push_back( atts.value("mod") );
464  roleval.push_back( atts.value("val") );
465  }
466  return true;
467  }
469  if(name == "meldwithnext")
470  {
471  if(level == 2 || fieldread_on)
472  meldwithnext=true;
473  return true;
474  }
475 
476  if(name == "nomiddlestretch")
477  {
478  if(level == 2 || fieldread_on)
479  nomiddlestretch=true;
480  return true;
481  }
482 
483  if(name == "displayformat")
484  {
485  bool ok;
486 
487  fmin = atts.value("minfrag").toInt(&ok);
488  if(!ok)
489  {
490  errstr = "Cannot parse minfrag attribute!";
491  return false;
492  }
493 
494  fmax = atts.value("maxfrag").toInt(&ok);
495  if(!ok)
496  {
497  errstr = "Cannot parse minfrag attribute!";
498  return false;
499  }
500  fgroup = atts.value("group").toInt(&ok);
501  if(!ok)
502  {
503  errstr = "Cannot parse minfrag attribute!";
504  return false;
505  }
506 
507  return true;
508  }
510  // in Filends //////////////////////////////////////////////////////////////////////////////
512  if(name == "hash")
513  {
514 
515  buffer_k.push_back(atts.value("key"));
516  buffer_v.push_back(atts.value("value"));
517 
518  return true;
519  }
521  // Fields //////////////////////////////////////////////////////////////////////////////////
523 
524  if(name == "key" ||
525  name == "smalltext" ||
526  name == "largetext" ||
527  name == "charhash" ||
528  name == "numhash" ||
529  name == "number" ||
530  name == "check" ||
531  name == "floating" ||
532  name == "static" ||
533  name == "date" ||
534  name == "dateu" ||
535  name == "timestamp" ||
536  name == "connect" ||
537  name == "sqlchoose" )
538  {
539  level++;
540  emptyBuffer();
541  buffer_sql = atts.value("sqln");
542  return true;
543  }
544 
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" ||
562  name == "valid" ||
563  name == "notvalid" ||
564  name == "function" ||
565  name == "sortc" ||
566  name == "extrafeatures" ||
567  name == "showtitle" ||
568  name == "orderby_part" ||
569  name == "popuptitle" ||
570  name == "specialsort" ||
571  name == "progress" ||
572  name == "depend" ||
573  name == "minimum" ||
574  name == "maximum" ||
575  name == "meldwithnext" ||
576  name == "nomiddlestretch" ||
577  name == "editmaxwidth" )
578  {
579  //action in endElement
580  return true;
581  }
582 
583  errstr = "Unknown (start)element found: \""+name+"\" !";
584  return false;
585 }
586 
587 void HFactory::emptyBuffer(void)
588 {
589  fpar_att = "";
590  fpar_def = "";
591  fpar_sql = "";
592 
593  buffer = "";
594  buffer_sql = "";
595  buffer_exp = "";
596  buffer_tit = "";
597  buffer_tail = "";
598  buffer_def = "";
599  buffer_valid= "";
600  buffer_func = "";
601  buffer_hashf= "";
602  buffer_specsort="";
603  buffer_popuptitle="";
604  buffer_minimum ="";
605  buffer_maximum ="";
606  buffer_1 = "";
607  buffer_2 = "";
608  buffer_3 = "";
609  buffer_4 = "";
610  buffer_5 = "";
611  buffer_6 = "";
612  buffer_7 = "";
613 
614  nomiddlestretch = false;
615  guieditmaxwidth = 0;
616 
617  editable = false;
618  readonly = false;
619 
620  logging = false;
621  nologging= false;
622 
623  show = false;
624  hide = false;
625 
626  color = false;
627 
628  easy = true;
629  meldwithnext = false;
630  showprogress = false;
631  sortc = -1; //no sort
632  r=0; g=0; b=0;
633  buffer_k.clear();
634  buffer_v.clear();
635  buffer_notvalid.clear();
636  fmin=0;
637  fmax=4;
638  fgroup=0;
639 
640  markers.clear();
641 
642  rolename.clear();
643  rolemod.clear();
644  roleval.clear();
645 }
646 
647 bool HFactory::characters(const QString& ch)
648 {
649  if(!mainblock) return true;
650  if(!read_on && !fieldread_on) return true;
651 
652  buffer.append(QString(ch).trimmed());
653  return true;
654 }
655 
656 void HFactory::setHDataFieldAttributes(HDataField * d)
657 {
658  if(default_color && !color) d->setColor(default_color_r,default_color_g,default_color_b);
659  if(color) d->setColor(r,g,b);
660 
661  if(readonly || default_readonly) d->setReadonly();
662  if(editable) d->setEditable();
663 
664  if(logging || default_logging) d->setLogging();
665  if(nologging) d->resetLogging();
666 
667  if(show) d->setShow();
668  if(hide) d->setHide();
669 
670  if(meldwithnext) d->meldWithNext();
671  if(nomiddlestretch) d->noMiddleStretch();
672  if(guieditmaxwidth != 0) d->setEditBoxMaxWidth(guieditmaxwidth);
673 
674  if(!buffer_specsort.isEmpty())
675  d->setSpecDisplaySortMode(buffer_specsort);
676  if(!buffer_func.isEmpty())
677  d->setFunction(buffer_func);
678  if(!markers.isEmpty())
679  d->addMark(markers);
680 
681  if(rolename.count() > 0)
682  {
683  int i,c=rolename.count();
684  for(i=0;i<c;++i)
685  d->addRole( HDataFieldRole(rolename[i],rolemod[i],roleval[i]) );
686  }
687 }
688 
689 
690 void HFactory::insertDF(HDataField *df)
691 {
692  if(read_on)
693  t->addField(df);
694  if(fieldread_on)
695  {
696  fieldlist->push_back(new Hff_node(fname,df));
697  fname = "";
698  }
699 }
700 
701 bool HFactory::endElement( const QString& ls, const QString&ln, const QString& name)
702 {
703  Q_UNUSED(ls);
704  Q_UNUSED(ln);
705 
706 #ifdef PARSER_DEBUG
707  sdebug("XML-PARSER end-element: "+name);
708 #endif
709 
710  if(name == "templates")
711  {
712  mainblock = false;
713  return true;
714  }
715 
716  if(!mainblock) return true;
717 
718  if(name == "element")
719  {
720  read_on = false;
721  return true;
722  }
723 
724  if(name == "field")
725  {
726  fieldread_on = false;
727  return true;
728  }
729 
730  if(!read_on && !fieldread_on) return true;
731 
734  if(read_on && t == NULL)
735  {
736  errstr = "Want to read table element to uninitialized Table (end)!";
737  return false;
738  }
739 
740  if(read_on && name == "tabletitle")
741  {
742  if(t != NULL)
743  {
744  t->setTableTitle(buffer);
745  }
746  buffer = "";
747  return true;
748  }
750  if(name == "explain" || name == "ex")
751  {
752  buffer_exp = buffer;
753  buffer = "";
754  return true;
755  }
756  if(name == "title" || name == "ti")
757  {
758  buffer_tit = buffer;
759  buffer = "";
760  return true;
761  }
762  if(name == "tail" || name == "ta")
763  {
764  buffer_tail = buffer;
765  buffer = "";
766  return true;
767  }
768  if(name == "default" || name == "de")
769  {
770  buffer_def = buffer;
771  buffer = "";
772  return true;
773  }
774  if(name == "true" || name == "tr")
775  {
776  buffer_1 = buffer;
777  buffer = "";
778  return true;
779  }
780  if(name == "false" || name == "fa")
781  {
782  buffer_2 = buffer;
783  buffer = "";
784  return true;
785  }
786 
787  if(name == "controll" || name == "co")
788  {
789  buffer_1 = "controll";
790  return true;
791  }
792 
793  if(name == "connected_table")
794  {
795  buffer_1 = buffer;
796  buffer = "";
797  return true;
798  }
799  if(name == "keyfield")
800  {
801  buffer_2 = buffer;
802  buffer = "";
803  return true;
804  }
805  if(name == "showfield")
806  {
807  buffer_3 = buffer;
808  buffer = "";
809  return true;
810  }
811  if(name == "showfieldeasy")
812  {
813  buffer_7 = buffer;
814  buffer = "";
815  return true;
816  }
817  if(name == "showfieldhead")
818  {
819  buffer_4 = buffer;
820  buffer = "";
821  return true;
822  }
823  if(name == "filter_part")
824  {
825  buffer_5 = buffer;
826  buffer = "";
827  return true;
828  }
829  if(name == "orderby_part")
830  {
831  buffer_6 = buffer;
832  buffer = "";
833  return true;
834  }
835  if(name == "popuptitle")
836  {
837  buffer_popuptitle = buffer;
838  buffer = "";
839  return true;
840  }
841  if(name == "sortc")
842  {
843  bool ok;
844  sortc = buffer.toInt(&ok) - 1;
845  if(!ok)
846  {
847  errstr = QString("Bad value in sortc!");
848  return false;
849  }
850  buffer = "";
851  return true;
852  }
853 
854  if(name == "extended")
855  {
856  easy = false;
857  return true;
858  }
859 
860  if(name == "progress")
861  {
862  showprogress = true;
863  return true;
864  }
865 
866  if(name == "extrafeatures")
867  {
868  t->extrafeatures = true;
869  return true;
870  }
871 
872  if(name == "showtitle")
873  {
874  t->gui_showtabletitle = true;
875  return true;
876  }
877 
878  if(name == "valid")
879  {
880  buffer_valid = buffer;
881  buffer = "";
882  return true;
883  }
884  if(name == "notvalid")
885  {
886  buffer_notvalid.push_back(buffer);
887  buffer = "";
888  return true;
889  }
890  if(name == "function")
891  {
892  buffer_func = buffer;
893  buffer = "";
894  return true;
895  }
896 
897  if(name == "mark" || name == "m")
898  {
899  markers.push_back(buffer);
900  buffer = "";
901  return true;
902  }
903 
904  if(name == "hashfunc")
905  {
906  buffer_hashf = buffer;
907  buffer = "";
908  return true;
909  }
910 
911  if(name == "specialsort")
912  {
913  buffer_specsort = buffer;
914  buffer = "";
915  return true;
916  }
917 
918  if(name == "minimum")
919  {
920  buffer_minimum = buffer;
921  buffer = "";
922  return true;
923  }
924  if(name == "maximum")
925  {
926  buffer_maximum = buffer;
927  buffer = "";
928  return true;
929  }
930  if(name == "editmaxwidth")
931  {
932  int i=0;
933  bool ok;
934  i = buffer.toInt(&ok);
935  if(ok)
936  guieditmaxwidth = i;
937  buffer = "";
938  return true;
939  }
940 
942  if(read_on && name == "depend")
943  {
944  if(!buffer.isEmpty())
945  t->addDependTableName(buffer);
946  buffer = "";
947  return true;
948  }
949 
950 
952  // Fields //////////////////////////////////////////////////////////////////////////////////
954  if(name == "key")
955  {
956  level--;
957 
958  if(buffer_sql.isEmpty())
959  {
960  errstr = QString("Missing parameter (%1) !").arg(name);
961  return false;
962  }
963 
964  HKey *d = new HKey(buffer_sql,buffer_exp,buffer_tit,buffer_def);
965  setHDataFieldAttributes(d);
966  insertDF(d);
967  emptyBuffer();
968  return true;
969  }
970 
971  if(name == "connect")
972  {
973  level--;
974 
975  if(buffer_sql.isEmpty() || buffer_1.isEmpty())
976  {
977  errstr = QString("Missing parameter (%1) !").arg(name);
978  return false;
979  }
980 
981  HConnect *d = new HConnect(buffer_sql,buffer_1);
982  setHDataFieldAttributes(d);
983  insertDF(d);
984  emptyBuffer();
985  return true;
986  }
987 
988  if(name == "smalltext")
989  {
990  level--;
991 
992  if(buffer_sql.isEmpty())
993  {
994  errstr = QString("Missing parameter (%1) !").arg(name);
995  return false;
996  }
997 
998  HSmallText *d = new HSmallText(buffer_sql,buffer_exp,buffer_tit,buffer_tail,buffer_def);
999  setHDataFieldAttributes(d);
1000  d->setValidator(buffer_valid);
1001  d->setNotValidValues(buffer_notvalid);
1002  insertDF(d);
1003  emptyBuffer();
1004  return true;
1005  }
1006 
1007  if(name == "largetext")
1008  {
1009  level--;
1010 
1011  if(buffer_sql.isEmpty())
1012  {
1013  errstr = QString("Missing parameter (%1) !").arg(name);
1014  return false;
1015  }
1016 
1017  HLargeText *d = new HLargeText(buffer_sql,buffer_exp,buffer_tit,buffer_def);
1018  setHDataFieldAttributes(d);
1019  d->setValidator(buffer_valid);
1020  d->setNotValidValues(buffer_notvalid);
1021  insertDF(d);
1022  emptyBuffer();
1023  return true;
1024  }
1025 
1026  if(name == "charhash")
1027  {
1028  level--;
1029 
1030  if(buffer_sql.isEmpty())
1031  {
1032  errstr = QString("Missing parameter (%1) !").arg(name);
1033  return false;
1034  }
1035  HCharHash *d = new HCharHash(buffer_sql,buffer_exp,buffer_tit,buffer_tail,
1036  buffer_def,buffer_k,buffer_v);
1037  setHDataFieldAttributes(d);
1038  d->setValidator(buffer_valid);
1039  d->setNotValidValues(buffer_notvalid);
1040  insertDF(d);
1041  emptyBuffer();
1042  return true;
1043  }
1044 
1045  if(name == "numhash")
1046  {
1047  level--;
1048 
1049  if(buffer_sql.isEmpty())
1050  {
1051  errstr = QString("Missing parameter (%1) !").arg(name);
1052  return false;
1053  }
1054  HNumHash *d = new HNumHash(buffer_sql,buffer_exp,buffer_tit,buffer_tail,
1055  buffer_def,buffer_k,buffer_v);
1056  setHDataFieldAttributes(d);
1057  d->setValidator(buffer_valid);
1058  d->setNotValidValues(buffer_notvalid);
1059  insertDF(d);
1060  emptyBuffer();
1061  return true;
1062  }
1063 
1064  if(name == "number")
1065  {
1066  bool ok=true;
1067  level--;
1068 
1069  if(buffer_sql.isEmpty())
1070  {
1071  errstr = QString("Missing parameter (%1) !").arg(name);
1072  return false;
1073  }
1074  HNumber *d = new HNumber(buffer_sql,buffer_exp,buffer_tit,buffer_tail,
1075  buffer_def);
1076  setHDataFieldAttributes(d);
1077  d->setValidator(buffer_valid);
1078  d->setNotValidValues(buffer_notvalid);
1079 
1080  if(!buffer_maximum.isEmpty())
1081  {
1082  d->setMaximum(buffer_maximum.toInt(&ok));
1083  if(!ok)
1084  sdebug(QString("Error conversion HNumber..maximum field data to int: \"%1\"").arg(buffer_maximum));
1085  }
1086  if(!buffer_minimum.isEmpty())
1087  {
1088  d->setMinimum(buffer_minimum.toInt(&ok));
1089  if(!ok)
1090  sdebug(QString("Error conversion HNumber..minimum field data to int: \"%1\"").arg(buffer_minimum));
1091  }
1092 
1093  insertDF(d);
1094  emptyBuffer();
1095  return true;
1096  }
1097 
1098  if(name == "static")
1099  {
1100  level--;
1101 
1102  HStatic *d = new HStatic(buffer_exp,buffer_tit,buffer_def);
1103  setHDataFieldAttributes(d);
1104  insertDF(d);
1105  emptyBuffer();
1106  return true;
1107  }
1108 
1109  if(name == "check")
1110  {
1111  level--;
1112 
1113  if(buffer_sql.isEmpty())
1114  {
1115  errstr = QString("Missing parameter (%1) !").arg(name);
1116  return false;
1117  }
1118  HCheck *d = new HCheck(buffer_sql,buffer_exp,buffer_tit,buffer_tail,
1119  buffer_def,buffer_1,buffer_2);
1120  setHDataFieldAttributes(d);
1121  insertDF(d);
1122  emptyBuffer();
1123  return true;
1124  }
1125 
1126  if(name == "floating")
1127  {
1128  bool ok=true;
1129  level--;
1130 
1131  if(buffer_sql.isEmpty())
1132  {
1133  errstr = QString("Missing parameter (%1) !").arg(name);
1134  return false;
1135  }
1136  HFloating *d = new HFloating(buffer_sql,buffer_exp,buffer_tit,buffer_tail,
1137  buffer_def);
1138  setHDataFieldAttributes(d);
1139  d->setValidator(buffer_valid);
1140  d->setNotValidValues(buffer_notvalid);
1141  d->setDisplayMode(fmin,fmax,fgroup);
1142 
1143  if(!buffer_maximum.isEmpty())
1144  {
1145  d->setMaximum(buffer_maximum.toDouble(&ok));
1146  if(!ok)
1147  sdebug(QString("Error conversion HFloating..maximum field data to double: \"%1\"").arg(buffer_maximum));
1148  }
1149  if(!buffer_minimum.isEmpty())
1150  {
1151  d->setMinimum(buffer_minimum.toDouble(&ok));
1152  if(!ok)
1153  sdebug(QString("Error conversion HFloating..minimum field data to double: \"%1\"").arg(buffer_minimum));
1154  }
1155 
1156  insertDF(d);
1157  emptyBuffer();
1158  return true;
1159  }
1160 
1161  if(name == "date")
1162  {
1163  level--;
1164 
1165  if(buffer_sql.isEmpty())
1166  {
1167  errstr = QString("Missing parameter (%1) !").arg(name);
1168  return false;
1169  }
1170 
1171  HDate *d = new HDate(buffer_sql,buffer_exp,buffer_tit,buffer_def,
1172  false,false);
1173  setHDataFieldAttributes(d);
1174  insertDF(d);
1175  emptyBuffer();
1176  return true;
1177  }
1178 
1179  if(name == "dateu")
1180  {
1181  level--;
1182 
1183  if(buffer_sql.isEmpty())
1184  {
1185  errstr = QString("Missing parameter (%1) !").arg(name);
1186  return false;
1187  }
1188 
1189  HDate *d = new HDate(buffer_sql,buffer_exp,buffer_tit,buffer_def,
1190  true);
1191  setHDataFieldAttributes(d);
1192  insertDF(d);
1193  emptyBuffer();
1194  return true;
1195  }
1196 
1197  if(name == "timestamp")
1198  {
1199  level--;
1200 
1201  if(buffer_sql.isEmpty())
1202  {
1203  errstr = QString("Missing parameter (%1) !").arg(name);
1204  return false;
1205  }
1206  HTimestamp *d = new HTimestamp(buffer_sql,buffer_exp,buffer_tit,buffer_def,
1207  buffer_1 == "controll" ? true : false);
1208  setHDataFieldAttributes(d);
1209  insertDF(d);
1210  emptyBuffer();
1211  return true;
1212  }
1213 
1214  if(name == "sqlchoose")
1215  {
1216  level--;
1217 
1218  if(buffer_sql.isEmpty())
1219  {
1220  errstr = QString("Missing parameter (%1) !").arg(name);
1221  return false;
1222  }
1223 
1224  if(buffer_3.isEmpty() && buffer_7.isEmpty())
1225  {
1226  errstr = QString("SqlChoose: Have to define showfield or showfieldeasy attribute!");
1227  return false;
1228  }
1229  if(!buffer_3.isEmpty() && !buffer_7.isEmpty())
1230  {
1231  errstr = QString("SqlChoose: You have to define showfield OR showfieldeasy attribute but only one! (not both)");
1232  return false;
1233  }
1234  if(buffer_3.isEmpty() && !buffer_7.isEmpty())
1235  {
1236  buffer_7.replace("|","||\'|\'||");
1237  buffer_3 = buffer_7;
1238  }
1239 
1240  HSqlChoose *d = new HSqlChoose(buffer_sql,buffer_exp,buffer_tit,buffer_def,
1241  buffer_1,buffer_2,buffer_3,buffer_4,buffer_5,buffer_6,buffer_hashf,easy);
1242 
1243  if(easy)
1244  d->progress_on_read = false;
1245  else
1246  d->progress_on_read = showprogress;
1247 
1248 
1249  if(!buffer_popuptitle.isEmpty())
1250  d->setPopupDialogTitle(buffer_popuptitle);
1251 
1252  d->setGuiSortIndicator(sortc);
1253  setHDataFieldAttributes(d);
1254 
1255  d->setValidator(buffer_valid);
1256  d->setNotValidValues(buffer_notvalid);
1257 
1258  insertDF(d);
1259  emptyBuffer();
1260  return true;
1261  }
1262 
1264  // Not affected elements ///////////////////////////////////////////////////////////////////
1266  if(name == "table" ||
1267  name == "usefield" ||
1268  name == "color" ||
1269  name == "role" ||
1270  name == "readonly" ||
1271  name == "editable" ||
1272  name == "show" ||
1273  name == "hide" ||
1274  name == "logging" ||
1275  name == "nologging" ||
1276  name == "meldwithnext" ||
1277  name == "nomiddlestretch"||
1278  name == "displayformat" ||
1279  name == "hash" )
1280  {
1281  buffer = "";
1282  return true;
1283  }
1284 
1285 
1286  sdebug("end-element: "+name);
1287 
1288  errstr = "Unknown (end)element found: \""+name+"\" !";
1289  return false;
1290 }
1291 
1292 //end code
void setFunction(QString func)
Definition: datalib.cpp:5214
void setMaximum(long int m)
Definition: datalib.h:2950
HList * genHList(QString part, QString inRole="")
Definition: hfactory.cpp:73
bool progress_on_read
Definition: datalib.h:3363
QString sqlCreateString(QString switches="")
Definition: datalib.cpp:2871
void setShow(void)
Definition: datalib.h:2296
void addRole(HDataFieldRole role)
Definition: datalib.cpp:5489
QString errorString(void)
Definition: hfactory.cpp:122
void setMinimum(double m)
Definition: datalib.h:3103
bool characters(const QString &ch)
Definition: hfactory.cpp:647
void addMark(QString mark)
Definition: datalib.cpp:5460
void noMiddleStretch(void)
Definition: datalib.h:2368
bool startDocument(void)
Definition: hfactory.cpp:220
void setMaximum(double m)
Definition: datalib.h:3105
void setMinimum(long int m)
Definition: datalib.h:2948
void setPopupDialogTitle(QString title)
Definition: datalib.h:3479
void addDependTableName(QString n)
Definition: datalib.cpp:2408
void meldWithNext(void)
Definition: datalib.h:2354
~HFactory(void)
Definition: hfactory.cpp:46
int readFromFile(QFile *f)
Definition: hfactory.cpp:94
void setGuiSortIndicator(int i)
Definition: datalib.h:3439
bool endDocument(void)
Definition: hfactory.cpp:226
void setLogging(void)
Definition: datalib.h:2314
bool endElement(const QString &ns, const QString &ln, const QString &name)
Definition: hfactory.cpp:701
void appendTemplateData(QString rdata)
Definition: hfactory.cpp:111
HFactory(QString rdata="")
Definition: hfactory.cpp:30
void setDisplayMode(int minDf, int maxDf, int groupDf)
Definition: datalib.h:3117
bool fatalError(const QXmlParseException &exception)
Definition: hfactory.cpp:153
void setTableTitle(QString s)
Definition: datalib.h:1129
void addField(HDataField *i)
Definition: datalib.cpp:2560
bool error(const QXmlParseException &exception)
Definition: hfactory.cpp:140
HTableBase * genTable(QString part, int mode=TABLE)
Definition: hfactory.cpp:166
void setEditable(void)
Definition: datalib.cpp:5443
bool warning(const QXmlParseException &exception)
Definition: hfactory.cpp:127
QString sqlCreateString(QString part)
Definition: hfactory.cpp:82
void setNotValidValues(QStringList nvl)
Definition: datalib.cpp:5190
void resetLogging(void)
Definition: datalib.h:2317
void sdebug(QString s)
Definition: dconsole.cpp:48
bool extrafeatures
Definition: datalib.h:948
bool gui_showtabletitle
Definition: datalib.h:952
virtual int setDefval(QVariant v)
Definition: datalib.cpp:5401
void setColor(int r, int g, int b)
Definition: datalib.cpp:5383
void setSpecDisplaySortMode(QString m)
Definition: datalib.h:2205
void setValidator(QString v="")
Definition: datalib.cpp:5185
Definition: datalib.h:2591
void setEditBoxMaxWidth(int max)
Definition: datalib.h:2379
void useRole(QString name)
Definition: datalib.cpp:3008
virtual HDataField * get_clone(void)
Definition: datalib.cpp:5175
void setReadonly(void)
Definition: datalib.cpp:5448
void clearTemplateData(void)
Definition: hfactory.cpp:117
void setHide(void)
Definition: datalib.h:2299
HTable * genHTable(QString part, QString inRole="")
Definition: hfactory.cpp:64
bool startElement(const QString &ns, const QString &ln, const QString &name, const QXmlAttributes &atts)
Definition: hfactory.cpp:232