gSAFE  1.3.8
guilib.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  guilib.cpp
10 */
11 
12 #include "guilib.h"
13 #include "dconsole.h"
14 #include "printlib.h"
15 #include "xmlolib.h"
16 
17 
18 static const char* const image_Y[] = {
19 "22 22 5 1",
20 ". c None",
21 "# c #000000",
22 "a c #848200",
23 "b c #c1c1c1",
24 "c c #cab5d1",
25 "......................",
26 ".####################.",
27 ".#aa#bbbbbbbbbbbb#bb#.",
28 ".#aa#bbbbbbbbbbbb#bb#.",
29 ".#aa#bbbbbbbbbcbb####.",
30 ".#aa#bbbccbbbbbbb#aa#.",
31 ".#aa#bbbccbbbbbbb#aa#.",
32 ".#aa#bbbbbbbbbbbb#aa#.",
33 ".#aa#bbbbbbbbbbbb#aa#.",
34 ".#aa#bbbbbbbbbbbb#aa#.",
35 ".#aa#bbbbbbbbbbbb#aa#.",
36 ".#aaa############aaa#.",
37 ".#aaaaaaaaaaaaaaaaaa#.",
38 ".#aaaaaaaaaaaaaaaaaa#.",
39 ".#aaa#############aa#.",
40 ".#aaa#########bbb#aa#.",
41 ".#aaa#########bbb#aa#.",
42 ".#aaa#########bbb#aa#.",
43 ".#aaa#########bbb#aa#.",
44 ".#aaa#########bbb#aa#.",
45 "..##################..",
46 "......................"};
47 
48 static const char* const image_F[] = {
49 "20 20 9 1",
50 "b c None",
51 "e c #ffffff",
52 "d c #ffffff",
53 "c c #ffffff",
54 "a c #ffffff",
55 "f c #0000f3",
56 ". c #030303",
57 "g c #4e1c0f",
58 "# c #eef11a",
59 ".##################.",
60 ".#################..",
61 "a..##############.bb",
62 "bc..###########...bb",
63 "dbe..##########...bb",
64 "bbbb..bbbbbbbb.bbbbb",
65 "bbbbbbffggfffbbbbbbb",
66 "bbbbbfffgfggggbbbbbb",
67 "bbbbffgffgfggggbbbbb",
68 "bbbffffgggggggggbbbb",
69 "bbbfffgfggggggggbbbb",
70 "bbbfffffffgfggggbbbb",
71 "bbbffffgggggffffbbbb",
72 "bbbffffggggfffffbbbb",
73 "bbbffgfffggfffffbbbb",
74 "bbbffffffggfffggbbbb",
75 "bbbbfffffggfffgbbbbb",
76 "bbbbbfffffffffbbbbbb",
77 "bbbbbbfffffffbbbbbbb",
78 "bbbbbbbbbbbbbbbbbbbb"};
79 
80 
81 static const char* const image_P[] = {
82 "16 16 6 1",
83 "# c #4d4d4d",
84 "c c #a6a6a6",
85 "b c #d3d3d3",
86 ". c #dbd8d1",
87 "d c #ffff4d",
88 "a c #ffffff",
89 "................",
90 ".....#########..",
91 "....#aaaaaaaa#..",
92 "....#a#####a#...",
93 "...#aaaaaaaa#...",
94 "...#a#####a####.",
95 "..#aaaaaaaa#b##.",
96 ".##########b#b#.",
97 "#bbbbbbbbbb#b##.",
98 "#############b#.",
99 "#bbbbbbcccbb#b#.",
100 "#bbbbbbdddbb###.",
101 "#############b#.",
102 ".#bbbbbbbbb#b#..",
103 "..###########...",
104 "................"};
105 
106 static const char* const image_X[] = {
107 "14 14 3 1",
108 "# c #006600",
109 ". c #dbd8d1",
110 "a c #ffffff",
111 "..............",
112 "..............",
113 "..####...###..",
114 "..#####.####..",
115 "..#a########..",
116 "...#a######...",
117 "....#a####....",
118 "...###a#####..",
119 "..#####a####..",
120 "..######a###..",
121 "..#######a###.",
122 "........#####.",
123 "..............",
124 ".............."};
125 
126 static const char* const image_E[] = {
127 "20 20 9 1",
128 "d c None",
129 "f c None",
130 ". c None",
131 "g c None",
132 "# c None",
133 "b c None",
134 "e c #000000",
135 "a c #f64421",
136 "c c #ffffff",
137 ".##########aaaaaaaaa",
138 ".##########aaaaaaaaa",
139 "b..########aacccccaa",
140 "bb..#######aacccccaa",
141 "bbb..######aacccccaa",
142 "dddd..dddddaacccccaa",
143 "dddddeeeeeeaaaaaaaaa",
144 "dddddeeeeeeaaaaaaaaa",
145 "ddddfeeeeeeeeegddddd",
146 "dddffffgeeeeeeggdddd",
147 "dddfffgeeeeeeeggdddd",
148 "dddffffeeegeeeggdddd",
149 "dddfffeeeggeeeffdddd",
150 "dddffeeegggeeeffdddd",
151 "dddfeeeffggfffffdddd",
152 "dddeeefffggfffggdddd",
153 "ddeeeffffggfffgddddd",
154 "deeedfffffffffdddddd",
155 "eeedddfffffffddddddd",
156 "dddddddddddddddddddd"};
157 
158 static const char* const refreshbutton_data[] = {
159 "16 16 105 2",
160 "#a c #008f00",
161 ".z c #009000",
162 ".A c #009200",
163 "#b c #009300",
164 ".B c #009400",
165 ".D c #009500",
166 ".L c #009600",
167 ".C c #009700",
168 ".y c #009800",
169 "#c c #009900",
170 ".R c #009b00",
171 "#y c #009c07",
172 "#i c #019901",
173 "#s c #029d0d",
174 "#x c #039c03",
175 "#p c #059a07",
176 "#r c #059d0b",
177 ".t c #0a9b0b",
178 ".G c #0aa40a",
179 ".q c #0ea110",
180 ".r c #0fa211",
181 "#g c #14a421",
182 "#C c #1d9e1d",
183 "#d c #229e20",
184 "#q c #24a831",
185 ".p c #2ca62d",
186 "#m c #2ea431",
187 ".K c #35b13e",
188 "#n c #3bb562",
189 ".H c #3dad41",
190 ".s c #48b04e",
191 ".N c #4eb855",
192 "#j c #4eb865",
193 "#w c #58be6f",
194 ".U c #6fc778",
195 ".1 c #70af70",
196 ".Z c #73b073",
197 ".Y c #75b075",
198 ".0 c #78b178",
199 "#F c #79c39c",
200 ".Q c #81b280",
201 "#z c #89bb9a",
202 ".o c #8dc490",
203 ".l c #91b691",
204 ".i c #94bd95",
205 "#G c #94ccc3",
206 ".j c #95bd98",
207 "#l c #98bba0",
208 "#t c #9dc3b7",
209 ".u c #a0b9a0",
210 ".S c #a5baa5",
211 ".E c #a8baa8",
212 ".M c #b0c4b2",
213 ".m c #b3bdb3",
214 ".3 c #b5c0b7",
215 ".2 c #b7beb7",
216 ".x c #b8beb7",
217 ".h c #b9c4ba",
218 "#E c #becfd8",
219 ".W c #c0bec0",
220 ".f c #c0bfc0",
221 "Qt c #c0c0c0",
222 "#k c #c0c7cc",
223 "#M c #c1bebe",
224 ".c c #c1bfc1",
225 ".e c #c1c0c1",
226 "#J c #c2bfc0",
227 ".# c #c2bfc2",
228 ".I c #c2cac7",
229 ".w c #c3c0c3",
230 ".v c #c4c1c4",
231 ".k c #c4c8c8",
232 "#H c #c4d1ec",
233 "#u c #c5c0c3",
234 ".b c #c5c0c5",
235 ".d c #c5c1c5",
236 "#f c #c5c1c6",
237 ".n c #c5c5c4",
238 "#L c #c6bfc1",
239 ".a c #c6c0c5",
240 ".T c #c7bfc6",
241 "#A c #c7c0c4",
242 ".X c #c7c1c7",
243 "#K c #c8c0c5",
244 "#I c #c9bfc4",
245 ".g c #c9c0c9",
246 ".8 c #c9c1c9",
247 ".P c #cac1ca",
248 ".9 c #cbc2cb",
249 ".V c #cbced0",
250 "#o c #cec1ca",
251 "#h c #cfc2ce",
252 "#B c #cfc3cf",
253 "#. c #d1c2d0",
254 ".F c #d4c2d4",
255 "#v c #d5c3d5",
256 ".5 c #d7c4d7",
257 "#e c #d8c4d7",
258 ".7 c #d8c5d8",
259 ".O c #d9c2d8",
260 ".4 c #d9c3d9",
261 "## c #d9c4d9",
262 ".6 c #ddc5dc",
263 "#D c #e0c3db",
264 ".J c #f3c8f2",
265 "QtQtQtQtQtQt.#.a.b.c.d.eQtQtQtQt",
266 "QtQtQtQt.f.g.h.i.j.k.l.m.eQtQtQt",
267 "QtQtQt.f.n.o.p.q.r.s.t.u.vQtQtQt",
268 "QtQtQt.w.x.y.z.A.B.C.D.E.vQtQtQt",
269 "QtQtQt.F.G.H.I.J.K.L.D.E.vQtQtQt",
270 "QtQt.#.M.N.O.P.Q.R.D.A.S.vQtQtQt",
271 "QtQt.T.U.V.W.X.Y.Z.0.1.2.eQtQtQt",
272 "QtQt.c.3.4.5.5.6.7.8.9#.QtQtQtQt",
273 "QtQtQt###a.B#b#c#d#e#f#g#hQtQtQt",
274 "QtQtQt.5.B#i.D#j#k#l#m#n#oQtQtQt",
275 "QtQtQt.5#b.D.C#p#q#r#s#t#uQtQtQt",
276 "QtQtQt#v#c#w#x.A.z#y#z#AQtQtQtQt",
277 "QtQtQt#B#C#D#E#F#G#H#IQtQtQtQtQt",
278 "QtQtQtQt#BQt#J#K#L#MQtQtQtQtQtQt",
279 "QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt",
280 "QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt"};
281 
282 static const char* const image_descend[] = {
283 "12 17 2 1",
284 ". c #f4b4c8",
285 "# c #ff0000",
286 "............",
287 "............",
288 ".....##.....",
289 "....####....",
290 "...######...",
291 "..########..",
292 ".##########.",
293 "############",
294 "############",
295 "...######...",
296 "...######...",
297 "...######...",
298 "...######...",
299 "...######...",
300 "............",
301 "............",
302 "............"};
303 
304 
305 static const char* const image_ascend[] = {
306 "12 17 2 1",
307 ". c #f4b4c8",
308 "# c #ff0000",
309 "............",
310 "............",
311 "............",
312 "...######...",
313 "...######...",
314 "...######...",
315 "...######...",
316 "...######...",
317 "############",
318 "############",
319 ".##########.",
320 "..########..",
321 "...######...",
322 "....####....",
323 ".....##.....",
324 "............",
325 "............"};
326 
327 static const char* const image_descend2[] = {
328 "12 17 2 1",
329 ". c #f4b4c8",
330 "# c #ff0000",
331 "............",
332 "............",
333 "............",
334 ".....##.....",
335 "....####....",
336 "...######...",
337 "..########..",
338 ".##########.",
339 "....####....",
340 "....####....",
341 "....####....",
342 "....####....",
343 "....####....",
344 "............",
345 "............",
346 "............",
347 "............"};
348 
349 static const char* const image_ascend2[] = {
350 "12 17 2 1",
351 ". c #f4b4c8",
352 "# c #ff0000",
353 "............",
354 "............",
355 "............",
356 "............",
357 "....####....",
358 "....####....",
359 "....####....",
360 "....####....",
361 "....####....",
362 ".##########.",
363 "..########..",
364 "...######...",
365 "....####....",
366 ".....##.....",
367 "............",
368 "............",
369 "............"};
370 
371 static const char* const image_up[] = {
372 "12 18 2 1",
373 "# c #0000ff",
374 ". c #ffffff",
375 "............",
376 ".....##.....",
377 ".....##.....",
378 "....####....",
379 "....####....",
380 "....####....",
381 "....####....",
382 "...######...",
383 "...######...",
384 "...######...",
385 "..########..",
386 "..########..",
387 "..########..",
388 "..########..",
389 ".##########.",
390 ".##########.",
391 "............",
392 "............"};
393 
394 static const char* const image_down[] = {
395 "12 18 2 1",
396 "# c #0000ff",
397 ". c #ffffff",
398 "............",
399 "............",
400 ".##########.",
401 ".##########.",
402 "..########..",
403 "..########..",
404 "..########..",
405 "..########..",
406 "...######...",
407 "...######...",
408 "...######...",
409 "....####....",
410 "....####....",
411 "....####....",
412 "....####....",
413 ".....##.....",
414 ".....##.....",
415 "............"};
416 
417 static const char* const image_hsdown[] = {
418 "9 6 2 1",
419 "# c #000000",
420 ". c #d0d0d0",
421 "#########",
422 ".#######.",
423 "..#####..",
424 "...###...",
425 "....#....",
426 "........."};
427 
428 static const char* const image_hsup[] = {
429 "9 6 2 1",
430 "# c #000000",
431 ". c #d0d0d0",
432 ".........",
433 "....#....",
434 "...###...",
435 "..#####..",
436 ".#######.",
437 "#########"};
438 
439 
441 int HArrayButton::defaultSizeY = 0;
442 
443 HArrayButton::HArrayButton(QString text,QWidget *parent)
444 :QPushButton(text,parent)
445 {
446  connect(this,SIGNAL(clicked()),this,SLOT(clickHandler()));
447  if(defaultSizeX != 0 && defaultSizeY != 0)
448  {
449  setMaximumSize(defaultSizeX,defaultSizeY);
450  setMinimumSize(defaultSizeX,defaultSizeY);
451  }
452 }
453 
454 int HArrayButton::clickHandler(void)
455 {
456  emit clickedValue(text());
457  return 0;
458 }
459 
460 QLayout * HArrayButton::abc_filt(QWidget *parent,const QObject *receiver,const char *member)
461 {
462 #define MAKE_A_BUTTON(a,b) {\
463  tmp = new HArrayButton(b,parent); \
464  connect(tmp,SIGNAL(clickedValue(QString)),receiver,member); \
465  (a)->addWidget(tmp); (a)->addSpacing(2); \
466  }
467 
468  HArrayButton *tmp;
469 
470  QVBoxLayout *ml = new QVBoxLayout(0);
471 
472  QHBoxLayout *ll2 = new QHBoxLayout(0);
473  ll2->setMargin(0);
474  ll2->setSpacing(0);
475  QHBoxLayout *ll3 = new QHBoxLayout(0);
476  ll3->setMargin(0);
477  ll3->setSpacing(0);
478 
479  ll2->addStretch();
480  ll3->addStretch();
481  MAKE_A_BUTTON(ll2,".");
482 
483 #ifdef GSAFETEXT_LANG_HU
484  MAKE_A_BUTTON(ll2,"A"); MAKE_A_BUTTON(ll2,"Á"); MAKE_A_BUTTON(ll2,"B");
485  MAKE_A_BUTTON(ll2,"C"); MAKE_A_BUTTON(ll2,"D"); MAKE_A_BUTTON(ll2,"E");
486  MAKE_A_BUTTON(ll2,"É"); MAKE_A_BUTTON(ll2,"F"); MAKE_A_BUTTON(ll2,"G");
487  MAKE_A_BUTTON(ll2,"H"); MAKE_A_BUTTON(ll2,"I"); MAKE_A_BUTTON(ll2,"Í");
488  MAKE_A_BUTTON(ll2,"J"); MAKE_A_BUTTON(ll2,"K"); MAKE_A_BUTTON(ll2,"L");
489  MAKE_A_BUTTON(ll2,"M");
490 
491  MAKE_A_BUTTON(ll2,"N"); MAKE_A_BUTTON(ll3,"O"); MAKE_A_BUTTON(ll3,"Ó");
492  MAKE_A_BUTTON(ll3,"Ö"); MAKE_A_BUTTON(ll3,"P");
493  MAKE_A_BUTTON(ll3,"Q"); MAKE_A_BUTTON(ll3,"R"); MAKE_A_BUTTON(ll3,"S");
494  MAKE_A_BUTTON(ll3,"T"); MAKE_A_BUTTON(ll3,"U"); MAKE_A_BUTTON(ll3,"Ú");
495  MAKE_A_BUTTON(ll3,"Ü"); MAKE_A_BUTTON(ll3,"X");
496  MAKE_A_BUTTON(ll3,"Y"); MAKE_A_BUTTON(ll3,"V"); MAKE_A_BUTTON(ll3,"W");
497  MAKE_A_BUTTON(ll3,"Z");
498 #else
499  MAKE_A_BUTTON(ll2,"A"); MAKE_A_BUTTON(ll2,"B"); MAKE_A_BUTTON(ll2,"C");
500  MAKE_A_BUTTON(ll2,"D"); MAKE_A_BUTTON(ll2,"E"); MAKE_A_BUTTON(ll2,"F");
501  MAKE_A_BUTTON(ll2,"G"); MAKE_A_BUTTON(ll2,"H"); MAKE_A_BUTTON(ll2,"I");
502  MAKE_A_BUTTON(ll2,"J"); MAKE_A_BUTTON(ll2,"K"); MAKE_A_BUTTON(ll2,"L");
503  MAKE_A_BUTTON(ll2,"M");
504 
505  MAKE_A_BUTTON(ll3,"N"); MAKE_A_BUTTON(ll3,"O"); MAKE_A_BUTTON(ll3,"P");
506  MAKE_A_BUTTON(ll3,"Q"); MAKE_A_BUTTON(ll3,"R"); MAKE_A_BUTTON(ll3,"S");
507  MAKE_A_BUTTON(ll3,"T"); MAKE_A_BUTTON(ll3,"U"); MAKE_A_BUTTON(ll3,"X");
508  MAKE_A_BUTTON(ll3,"Y"); MAKE_A_BUTTON(ll3,"V"); MAKE_A_BUTTON(ll3,"W");
509  MAKE_A_BUTTON(ll3,"Z");
510 #endif
511 
512  ll2->addStretch();
513  ll3->addStretch();
514 
515  ml->addLayout(ll2);
516  ml->addSpacing(2);
517  ml->addLayout(ll3);
518 
519 #undef MAKE_A_BUTTON
520  return ml;
521 }
522 
523 HArrayButton::~HArrayButton(void)
524 {
525 
526 }
527 
531 HSpinBox::HSpinBox(QWidget *parent)
532 :QFrame(parent)
533 {
534  int h;
535 
536  min = 0;
537  max = 1000000;
538  setFocusPolicy(Qt::StrongFocus);
539 
540  setMaximumWidth(100);
541 
542  /*
543  QFontMetrics *fm =
544  new QFontMetrics( QApplication::font() );
545  */
546 
547  QHBoxLayout *lay = new QHBoxLayout(this);
548  lay->setMargin(2);
549  lay->setSpacing(1);
550  QVBoxLayout *swl = new QVBoxLayout(0);
551  swl->setSpacing(0);
552  swl->setSpacing(0);
553 
554  le = new QLineEdit(this);
555 
556  h = height()/2-4;
557 
558 
559  QToolButton *bu = new QToolButton(this);
560  bu->setIcon(QPixmap(image_hsup));
561  bu->setMaximumHeight(h);
562  bu->setMinimumHeight(h);
563  bu->setMinimumWidth(14);
564  bu->setMaximumWidth(14);
565 
566  QToolButton *bd = new QToolButton(this);
567  bd->setIcon(QPixmap(image_hsdown));
568  bd->setMaximumHeight(h);
569  bu->setMinimumHeight(h);
570  bd->setMinimumWidth(14);
571  bd->setMaximumWidth(14);
572 
573  swl->addWidget(bu);
574  swl->addWidget(bd);
575 
576  lay->addLayout(swl);
577  lay->addWidget(le);
578  le->setAlignment(Qt::AlignRight);
579 
580  val = 0;
581 
582  connect(le,SIGNAL(textChanged(const QString&)),this,SLOT(leChanged(const QString&)));
583  connect(bu,SIGNAL(clicked()),this,SLOT(bUp()));
584  connect(bd,SIGNAL(clicked()),this,SLOT(bDown()));
585  oldtext = "";
586 }
587 
588 int HSpinBox::bUp(void)
589 {
590  val++;
591  check();
592  emit valueChanged(val);
593  return 0;
594 }
595 
596 int HSpinBox::bDown(void)
597 {
598  val--;
599  check();
600  emit valueChanged(val);
601  return 0;
602 }
603 
604 int HSpinBox::leChanged(const QString& t)
605 {
606  int v;
607  bool ok;
608 
609  if(t.isEmpty())
610  {
611  val = 0;
612  oldtext = t;
613  emit valueChanged(val);
614  return 0;
615  }
616 
617  v = t.toInt(&ok);
618  if(ok)
619  {
620  val = v;
621  oldtext = t;
622  emit valueChanged(val);
623  }
624  else
625  {
626  le->setText(oldtext);
627  }
628  return 0;
629 }
630 
632 {
633  if(val == v)
634  return v;
635 
636  val = v;
637  check();
638  emit valueChanged(val);
639  return v;
640 }
641 
642 void HSpinBox::check(void)
643 {
644  if(val > max)
645  val=max;
646  if(val < min)
647  val=min;
648  le->setText((oldtext = QString("%1").arg(val)));
649 }
650 
651 void HSpinBox::wheelEvent(QWheelEvent *e)
652 {
653  if(e->delta() > 0)
654  val++;
655  else
656  val--;
657  check();
658  emit valueChanged(val);
659 }
660 
662 {
663 
664 }
665 
669 
670 #define CELLHMARGIN 3
671 #define CELLVMARGIN 3
672 
673 #define TMARGIN 10
674 #define LMARGIN 10
675 
676 #define BARW 12
677 #define BUTTH 18
678 
679 #define DEFAULT_HEADCOLOR QColor(244,180,200)
680 #define DEFAULT_HEADCOLOR_CURSOR QColor(250,100,120)
681 #define DEFAULT_CURSORCOLOR QColor(140,140,230)
682 #define DEFAULT_BGCOLOR QColor(240,240,240)
683 
684 bool HTableBrowser::staticinit = false;
685 QPixmap *HTableBrowser::pix_up = NULL;
686 QPixmap *HTableBrowser::pix_down = NULL;
687 QPixmap *HTableBrowser::pix_asc = NULL;
688 QPixmap *HTableBrowser::pix_desc = NULL;
689 QPixmap *HTableBrowser::pix_asc2 = NULL;
690 QPixmap *HTableBrowser::pix_desc2 = NULL;
691 
693 :QFrame(parent)
694 {
695  start = NULL;
696  end = NULL;
697  top = NULL;
698  cur = NULL;
699 
700  curc = 0;
701  asc = true;
702  query_cursor = NULL;
703  col_scroll = 0;
704  lastkey="";
705  inscroll = false;
706  oldw = 0;
707  oldh = 0;
708  old_col_scroll = 0;
709 
710  precolor.clear();
711 
712  keycolumn = -1;
713  keycolumn2 = -1;
714 
715  cachedElements.clear();
716  cacheLimit = 20; //An initial size. It increased automatically if necessary
717 
718  if(!staticinit)
719  {
720  staticinit = true;
721  pix_up = new QPixmap(image_up);
722  pix_down = new QPixmap(image_down);
723  pix_asc = new QPixmap(image_ascend);
724  pix_desc = new QPixmap(image_descend);
725  pix_asc2 = new QPixmap(image_ascend2);
726  pix_desc2= new QPixmap(image_descend2);
727  }
728 
729  setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
730  setMidLineWidth(100);
731  setMinimumHeight(100);
732  setFocusPolicy(Qt::StrongFocus);
733  setFocus();
734 
735  color_cursor = DEFAULT_CURSORCOLOR;
736  color_header = DEFAULT_HEADCOLOR;
737  color_header_cursor = DEFAULT_HEADCOLOR_CURSOR;
738  color_background = DEFAULT_BGCOLOR;
739 
740  QPalette palette;
741  palette.setColor(QPalette::Window,color_background);
742  setPalette(palette);
743  setAutoFillBackground(true);
744 
745  fm = new QFontMetrics( QApplication::font() );
746  clear();
747 }
748 
750  {
751  color_background = c;
752  QPalette palette;
753  palette.setColor(QPalette::Window,color_background);
754  setPalette(palette);
755  setAutoFillBackground(true);
756  }
757 
758 int HTableBrowser::setHeadTexts(QStringList h)
759 {
760  head = h;
761  return 0;
762 };
763 
765 {
766  sdebug("*** HTableBrowser::~HTableBrowser ***\nDestory HTableBrowser, delete items...");
767  clear();
768  delete fm;
769  sdebug("*** HTableBrowser::~HTableBrowser ***END");
770 }
771 
773 {
774  if(cur == NULL)
775  return "";
776  return cur->key;
777 }
778 
780 {
781  if(top == NULL)
782  return "";
783  return top->key;
784 }
785 
787 {
789 
791 
792  number = 0;
793  seek = "";
794  head.clear();
795  colc.clear();
796  colw.clear();
797  spec_sort.clear();
798  asc = false;
799  rowh = fm->height();
800 
801  //Freeing list
802  cacheMutex.lock();
803  tmp = end;
804  while(tmp != NULL)
805  {
806  tmp = tmp->prev;
807  delete end;
808  end = tmp;
809  }
810  cacheMutex.unlock();
811 
812  start = NULL;
813  top = NULL;
814  end = NULL;
815  cur = NULL;
816  return 0;
817 }
818 
819 void HTableBrowser::setColumnColor(int col,QColor c)
820 {
821  if(col >= (int)colc.size())
822  {
823  precolor[col] = c;
824  return;
825  }
826  precolor[col] = c;
827  colc[col] = c;
828 }
829 
831 {
832  int i,l;
833 
834  e->index = number;
835  //add to list, graphical analysis...
836  if(start == NULL) //there is no element yet
837  {
838  if(head.size() > e->size())
839  {
840  QString errortxt="You try to add smaller record than previous. (Contains less cell. Why? Forget separate signals? \"|\"?) ";
841  sdebug(errortxt);
842  error(errortxt);
843  return 0;
844  }
845 
846  cur = top = start = end = e;
847 
848  for(i=0;i<e->size();++i)
849  {
850  colw.push_back( fm->width((*e)[i]) );
851  colc.push_back( precolor.contains(i) ? precolor[i] : QColor( (100+i*25)>255 ? 255 : (100+i*25) ,200-i*5,180 ));
852  spec_sort.push_back("");
853  }
854  rowh = fm->height();
855 
856  while(head.size() < colw.size())
857  head.push_back("");
858 
859  for(i=0;i<(int)head.size();++i)
860  {
861  l = fm->width(head[i]) + BARW; //because the sort indicator
862  if(l > colw[i])
863  colw[i] = l;
864  }
865 
866  }
867  else //insert to the end
868  {
869  end->next = e;
870  e->prev = end;
871  end = e;
872 
873  for(i=0;i<e->size();++i)
874  {
875  l = fm->width((*e)[i]) + BARW; //because the sort indicator
876  if(l > colw[i])
877  colw[i] = l;
878  }
879  }
880  ++number;
881  return 0;
882 }
883 
885 {
886  HTableBrowserElement *tmp = NULL;
887  int deleteditems;
888 
889  if(start == NULL)
890  return 0; // no element
891 
893 
894  deleteditems = 0;
895  // HTableBrowserElement *start,*end,*top,*cur,*query_cursor;
896  HTableBrowserElement *seek = start;
897  while(seek != NULL)
898  {
899  if(seek->key == key)
900  { //Found->erase
901  //================================//
902  if(seek->prev != NULL)
903  seek->prev->next = seek->next;
904  if(seek->next != NULL)
905  seek->next->prev = seek->prev;
906  if(start == seek)
907  start = seek->next;
908  if(end == seek)
909  end = seek->prev;
910  if(top == seek)
911  {
912  if (seek->prev != NULL) top = seek->prev;
913  else if(seek->next != NULL) top = seek->next;
914  else top = start;
915  }
916  if(cur == seek)
917  {
918  if (seek->prev != NULL) cur = seek->prev;
919  else if(seek->next != NULL) cur = seek->next;
920  else cur = start;
921  }
922  query_cursor = start;
923 
924  tmp = seek->next;
925  cacheMutex.lock();
926  delete seek;
927  cacheMutex.unlock();
928  seek = tmp;
929  number--;
930  deleteditems++;
931  //================================//
932  continue;
933  }
934  seek = seek->next;
935  }
936  update();
937  return deleteditems;
938 }
939 
940 void HTableBrowser::setSpecSort(int col,QString specsortname)
941 {
942  if(col >= (int)spec_sort.size())
943  {
944  sdebug("Warning: Less column exists than column index received in \"setSpecSort\"!!\n (Hint:Insert an element before you set the column colors!)");
945  return;
946  }
947 
948  spec_sort[col] = specsortname;
949 }
950 
951 int HTableBrowser::setCurrentElement(QString c,QString t)
952 {
953  HTableBrowserElement *topm=start,*step=start;
954  while(step != NULL)
955  {
956  if(step->key == t)
957  topm = step;
958  if(step->key == c)
959  {
960  cur = step;
961  if( height()-(rowh) > (cur->index - topm->index)*(rowh+2*CELLVMARGIN)+2*rowh) //this will be the top
962  top = topm;
963  else
964  top = cur;
965 
966  update();
967  return 1;
968  }
969  step = step->next;
970  }
971  return 0;
972 }
973 
975 {
976  HTableBrowserElement *step=start;
977  while(step != NULL)
978  {
979  if(step->index == index)
980  {
981  top = cur = step;
982  update();
983  return 1;
984  }
985  step = step->next;
986  }
987  return 0;
988 }
989 
991 {
992  HTableBrowserElement *step=start;
993  while(step != NULL)
994  {
995  if(step->index == index)
996  {
997  top = step;
998  update();
999  return 1;
1000  }
1001  step = step->next;
1002  }
1003  return 0;
1004 }
1005 
1007 {
1008  if(top == NULL)
1009  return NULL;
1010  return top;
1011 }
1012 
1014 {
1015  if(cur == NULL)
1016  return NULL;
1017  return cur;
1018 }
1019 
1021 {
1022  bool fresh;
1023 
1024  if(cur == NULL)
1025  return false;
1026 
1027  fresh = false;
1028  if(cur->prev != NULL)
1029  {
1030  cur = cur->prev;
1031  fresh = true;
1032  }
1033  //if we need scroll...
1034  if(top->prev == cur)
1035  {
1036  top = cur;
1037  fresh = true;
1038  }
1039  else if(abs(top->index - cur->index) > (showrow+2))
1040  {
1041  top = cur;
1042  fresh = true;
1043  }
1044  return fresh;
1045 }
1046 
1048 {
1049  bool fresh;
1050 
1051  if(cur == NULL)
1052  return false;
1053 
1054  fresh = false;
1055  if(cur->next != NULL)
1056  {
1057  cur = cur->next;
1058  fresh = true;
1059  }
1060 
1061  //if we need scroll...
1062  if(cur->index < top->index) //out on top
1063  {
1064  top = cur;
1065  fresh = true;
1066  }
1067  while(height()-(rowh+4*CELLVMARGIN+12) < (cur->index - top->index)*(rowh+2*CELLVMARGIN)+2*rowh)
1068  {
1069  if(top->next != NULL)
1070  {
1071  top = top->next;
1072  fresh = true;
1073  }
1074  else
1075  break;
1076  }
1077  return fresh;
1078 }
1079 
1080 void HTableBrowser::wheelEvent(QWheelEvent *e)
1081 {
1082  if(e->delta() < 0)
1083  {
1084  if(stepDown())
1085  update();
1086  return;
1087  }
1088  else
1089  {
1090  if(stepUp())
1091  update();
1092  return;
1093  }
1094 }
1095 
1097 {
1098  seek = "";
1099  top = cur = start;
1100  update();
1101  return 0;
1102 }
1103 
1105 {
1106  seek = "";
1107  top = cur = end;
1108  update();
1109  return 0;
1110 }
1111 
1112 void HTableBrowser::keyPressEvent(QKeyEvent *e)
1113 {
1114  int i;
1115  bool fresh;
1116 
1117  fresh = false;
1118 
1119  if(e->modifiers() == Qt::ControlModifier)
1120  {
1121  QFrame::keyPressEvent(e);
1122  return;
1123  }
1124 
1125  if(e->key() == Qt::Key_Down)
1126  {
1127  seek = "";
1128  if(stepDown())
1129  update();
1130  return;
1131  }
1132 
1133  if(e->key() == Qt::Key_Up)
1134  {
1135  seek = "";
1136  if(stepUp())
1137  update();
1138  return;
1139  }
1140 
1141  if(e->key() == Qt::Key_PageUp)
1142  {
1143  seek = "";
1144  for(i=0;i < showrow-2;++i)
1145  if(stepUp())
1146  fresh = true;
1147 
1148  if(fresh)
1149  update();
1150  return;
1151  }
1152 
1153  if(e->key() == Qt::Key_PageDown)
1154  {
1155  seek = "";
1156  for(i=0;i < showrow-2;++i)
1157  if(stepDown())
1158  fresh = true;
1159  if(fresh)
1160  update();
1161  return;
1162  }
1163 
1164  if(e->key() == Qt::Key_Home)
1165  {
1166  seek = "";
1167  top = cur = start;
1168  update();
1169  return;
1170  }
1171 
1172  if(e->key() == Qt::Key_End)
1173  {
1174  seek = "";
1175  top = cur = end;
1176  update();
1177  return;
1178  }
1179 
1180  if(e->key() == Qt::Key_Left)
1181  {
1182  seek = "";
1183  if(curc > 0)
1184  {
1185  --curc;
1186  //do horizontal scroll if necessary
1187  if(col_scroll > curc)
1188  col_scroll = curc;
1189  update();
1190  }
1191  return;
1192  }
1193 
1194  if(e->key() == Qt::Key_Right)
1195  {
1196  seek = "";
1197  if(curc+1 < (int)colw.size())
1198  {
1199  ++curc;
1200 
1201  //do horizontal scroll if necessary
1202  bool run;
1203  int sum;
1204  do
1205  {
1206  sum = 0;
1207  run = false;
1208  for(i=col_scroll;i<=curc;++i)
1209  sum += colw[i]+2*CELLHMARGIN;
1210  if(sum > (width()-(LMARGIN*2)))
1211  {
1212  ++col_scroll;
1213  run = true;
1214  }
1215  } while(run);
1216 
1217  update();
1218  }
1219  return;
1220  }
1221 
1222  if(e->key() == Qt::Key_Return || (e->key() == Qt::Key_Space && seek.isEmpty()))
1223  {
1224  seek = "";
1225  emit activateItem(cur->key);
1226  return;
1227  }
1228 
1229  //If the seek is empty I will pass the Esc. Probably it will be an exit.
1230  if(seek.isEmpty() && e->key() == Qt::Key_Escape)
1231  {
1232  QFrame::keyPressEvent(e);
1233  return;
1234  }
1235 
1236  //If there is some seek text, I'll delete it when esc pressed. Every time delete the seek text if delete pressed.
1237  if((!seek.isEmpty() && e->key() == Qt::Key_Escape) || (e->key() == Qt::Key_Delete))
1238  {
1239  seek = "";
1240  update();
1241  return;
1242  }
1243 
1244  if(e->key() == Qt::Key_Backspace)
1245  {
1246  seek.remove(QRegExp(".$"));
1247  sdebug("seek: "+seek);
1248  return;
1249  }
1250 
1251  if(e->key() == Qt::Key_F3)
1252  {
1254  for(t = cur ; t != NULL ; t=t->next)
1255  {
1256  if(((*t->rows)[curc]).startsWith(seek))
1257  {
1258  top = cur = t;
1259  }
1260  }
1261  update();
1262  return;
1263  }
1264 
1265  if(e->key() == Qt::Key_F5)
1266  {
1268  update();
1269  return;
1270  }
1271 
1272  //Click a mouse button
1274 
1275  seek.append(e->text());
1276  sdebug("seek: "+seek);
1277  for(t = start ; t != NULL ; t=t->next)
1278  {
1279  if(((*t->rows)[curc]).startsWith(seek))
1280  {
1281  //top = cur = t;
1282  cur = t;
1283 
1284  //Check the visibility of the current element, if needs I will recalc the top element
1285 
1286  if( cur->index < top->index ||
1287  height()-(rowh+4*CELLVMARGIN+12) < (cur->index - top->index)*(rowh+2*CELLVMARGIN)+2*rowh) //ok lesz a megadott top
1288  top = cur;
1289 
1290  update();
1291  return;
1292  }
1293  }
1294 }
1295 
1296 // Parameters: Lower limit, upper limit, value
1297 int border(int a,int b,int c)
1298 {
1299  if(a>c)
1300  return a;
1301  if(b<c)
1302  return b;
1303  return c;
1304 }
1305 
1306 #define inX(a,b) ( ((a) < e->x() && (b) > e->x()) || ((b) < e->x() && (a) > e->x()))
1307 #define inY(a,b) ( ((a) < e->y() && (b) > e->y()) || ((b) < e->y() && (a) > e->y()))
1308 bool HTableBrowser::mouseNetClick(QMouseEvent *e,int rmode)
1309 {
1310  int x,y;
1311  int stepx;
1312  HTableBrowserElement *stepy;
1313 
1314  if(cur == NULL)
1315  return false;
1316 
1317  //out from everything
1318  if(!inX(0,width()) || !inY(0,height()))
1319  {
1320  sdebug("==CLICK=> Outer click (do nothing)");
1321  return false;
1322  }
1323 
1324  //left click from the first cell, is scroll the column to back
1325  if(inX(0,LMARGIN+CELLHMARGIN))
1326  {
1327  sdebug("==CLICK=> Left from the first cell (backscroll the columns)");
1328  if(col_scroll == 0)
1329  return false;
1330  curc = --col_scroll;
1331  return true;
1332  }
1333 
1334  for(stepx=col_scroll,x=LMARGIN;
1335  (x<(width()-(LMARGIN+BARW)));
1336  x+=(colw[stepx]+2*CELLHMARGIN+plusw),stepx++)
1337  {
1338  if(stepx >= colw.size())
1339  break;
1340  if(inX(x+CELLHMARGIN,x+colw[stepx]+plusw+CELLHMARGIN*2) && inY(TMARGIN+CELLVMARGIN,TMARGIN+rowh+CELLHMARGIN))
1341  {
1342  sdebug("==CLICK=> Column header (sorting)");
1343 
1344  sdebug(QString("Click header: column %1").arg(stepx));
1345  sort(stepx);
1346  return rmode == NEED_UPDATE ? true : false;
1347  }
1348  }
1349 
1350  for(stepy=top,y=TMARGIN+rowh+4*CELLVMARGIN;
1351  (y < height()-TMARGIN) && (stepy != NULL);
1352  y+=(rowh+2*CELLVMARGIN),stepy=stepy->next)
1353 
1354  if(inY(y,y+rowh+2*CELLHMARGIN))
1355  {
1356  for(stepx=col_scroll,x=LMARGIN;
1357  (x<(width()-(LMARGIN+BARW)));
1358  x+=(colw[stepx]+2*CELLHMARGIN+plusw),stepx++)
1359  {
1360  if(stepx >= colw.size())
1361  break;
1362  if(inX(x,x+colw[stepx]+plusw+CELLHMARGIN*2))
1363  {
1364  sdebug("==CLICK=> To Cell (Marking)");
1365 
1366  if(cur != stepy || curc != stepx)
1367  {
1368  cur = stepy;
1369  curc = stepx;
1370 
1371  return true;
1372  }
1373  return rmode == NEED_UPDATE ? false : true;
1374  }
1375  }
1376  }
1377  sdebug("==Click=> Nothing targetted, don't hit anything (exiting)");
1378  return false;
1379 }
1380 
1381 void HTableBrowser::mouseMoveEvent(QMouseEvent *e)
1382 {
1383  int nTH;
1384  seek = "";
1385  //scrolling
1386  if( inscroll || inX(width()-BARW-LMARGIN+2,width()))
1387  {
1388  //sdebug("==MOVE/PRESS=> In the button area...");
1389 
1390  if( !inscroll && inY(8,8+BUTTH))
1391  {
1392  sdebug("==MOVE/PRESS=> Up button");
1393  if(stepUp())
1394  update();
1395  return;
1396  }
1397  if( !inscroll && inY(height()-(BUTTH+8),height()-8))
1398  {
1399  sdebug("==MOVE/PRESS=> Down button");
1400  if(stepDown())
1401  update();
1402  return;
1403  }
1404 
1405  nTH = ( (number-showrow+2) * (border(0,height()-(8+BUTTH),e->y()-(8+BUTTH))) ) / (height()-8*2-2*BUTTH);
1406  setTopElement(nTH);
1407  inscroll = true;
1408  return;
1409  }
1410 
1411  sdebug("==MOVE/PRESS=> Nothing hit --> Call mouseNetClick()");
1412 
1413  if(!inscroll && mouseNetClick(e))
1414  update();
1415 }
1416 
1417 void HTableBrowser::mouseReleaseEvent(QMouseEvent *e)
1418 {
1419  inscroll = false;
1420 
1421  if(e->button() == Qt::RightButton)
1422  {
1423  sdebug("HTableBrowser::mouseReleaseEvent RIGHT button!");
1424  if(mouseNetClick(e,CLICK_ON_CELL))
1425  if(last_right_clicked == cur->key)
1426  {
1427  sdebug("Emitting signal!");
1428  mouseRightClickPosX = e->x();
1429  mouseRightClickPosY = e->y();
1430  emit alternateActivateItem(cur->key);
1431  }
1432  return;
1433  }
1434 }
1435 
1436 void HTableBrowser::mousePressEvent(QMouseEvent *e)
1437 {
1438  seek = "";
1439  mouseMoveEvent(e);
1440  if(e->button() == Qt::RightButton)
1441  if(mouseNetClick(e,CLICK_ON_CELL))
1442  last_right_clicked = cur->key;
1443 }
1444 
1445 void HTableBrowser::mouseDoubleClickEvent(QMouseEvent *e)
1446 {
1447  seek = "";
1448 
1449  if(inX(width()-BARW-LMARGIN+2,width()))
1450  {
1451  mouseMoveEvent(e);
1452  return;
1453  }
1454 
1455  if(mouseNetClick(e,CLICK_ON_CELL))
1456  emit activateItem(cur->key);
1457 }
1458 
1459 #undef inX
1460 #undef inY
1461 
1462 
1463 bool HTableBrowser::ch(bool m,HTableBrowserElement *a,HTableBrowserElement *b)
1464 {
1465  bool asc = this->asc;
1466  bool asc2 = this->asc2;
1467 
1468  if(m)
1469  {
1470  asc = !asc;
1471  asc2 = !asc2;
1472  }
1473 
1474  if(sortmode == 1) //Dropchar sort mode
1475  {
1476  if(dropchar(a->getCVal(keycolumn).toLocal8Bit()) > dropchar(b->getCVal(keycolumn).toLocal8Bit()))
1477  return (asc ? true : false);
1478  if(dropchar(a->getCVal(keycolumn).toLocal8Bit()) < dropchar(b->getCVal(keycolumn).toLocal8Bit()))
1479  return (asc ? false : true );
1480 
1481  if(keycolumn2 == -1)
1482  return true;
1483 
1484  if(dropchar(a->getCVal(keycolumn2).toLocal8Bit()) > dropchar(b->getCVal(keycolumn2).toLocal8Bit()))
1485  return (asc2 ? true : false);
1486  if(dropchar(a->getCVal(keycolumn2).toLocal8Bit()) < dropchar(b->getCVal(keycolumn2).toLocal8Bit()))
1487  return (asc2 ? false : true );
1488  return true;
1489  }
1490 
1491  if(QString::localeAwareCompare(a->getCVal(keycolumn),b->getCVal(keycolumn)) > 0 )
1492  return (asc ? true : false);
1493  if(QString::localeAwareCompare(a->getCVal(keycolumn),b->getCVal(keycolumn)) < 0 )
1494  return (asc ? false : true );
1495 
1496  if(keycolumn2 == -1)
1497  return true;
1498 
1499  if(QString::localeAwareCompare(a->getCVal(keycolumn2),b->getCVal(keycolumn2)) > 0)
1500  return (asc2 ? true : false);
1501  if(QString::localeAwareCompare(a->getCVal(keycolumn2),b->getCVal(keycolumn2)) < 0)
1502  return (asc2 ? false : true );
1503  return true;
1504 
1505 }
1506 
1507 void HTableBrowser::q_sort(void)
1508 {
1509  HTableBrowserElementPair *t;
1510 
1511  if(start == NULL)
1512  return;
1513  q_sort_stack = new QStack<HTableBrowserElementPair *> ();
1514  q_sort_stack->clear();
1515  q_sort_stack->push(new HTableBrowserElementPair(start,end)); //Verem inicializalas a starthoz
1516 
1517  while( ! q_sort_stack->isEmpty() )
1518  {
1519  q_sort_run( (t=q_sort_stack->pop()) );
1520  delete t;
1521  }
1523 }
1524 
1525 //Quick sort algoritmus
1526 void HTableBrowser::q_sort_run(HTableBrowserElementPair *p)
1527  {
1528  int i;
1530 
1531  HTableBrowserElement *left=p->left;
1532  HTableBrowserElement *right=p->right;
1533 
1534  //it will be the middle element
1535  i = (int) ((p->left->index+p->right->index) / 2);
1536  for(m=p->left;m->index != i && m != p->right ;m=m->next) ;
1537 
1538  while(left->index < right->index)
1539  {
1540  while(ch(true,left,m) && (left->index < m->index))
1541  left = left->next;
1542 
1543  while(ch(false,right,m) && (right->index > m->index))
1544  right = right->prev;
1545 
1546  if(left != right)
1547  {
1548  if(m == left)
1549  m= right;
1550  else if(m == right)
1551  m = left;
1552 
1553  right->swapWith(left);
1554  }
1555  }
1556 
1557  if(p->left->index < m->index)
1558  q_sort_stack->push(new HTableBrowserElementPair(p->left,m->prev));
1559  if(p->right->index > m->index)
1560  q_sort_stack->push(new HTableBrowserElementPair(m->next,p->right));
1561  }
1562 
1563 void HTableBrowser::sort(int keycol)
1564 {
1565  if(colw.size() == 0 )
1566  return;
1567 
1568  if(keycolumn == keycol)
1569  {
1570  if(asc) asc=false;
1571  else asc=true;
1572  }
1573  else
1574  {
1575  keycolumn2 = keycolumn;
1576  asc2 = asc;
1577 
1578  asc = true;
1579  keycolumn = keycol;
1580  }
1581 
1582  sortmode = 0;
1583  if(spec_sort[keycol] == "dropchar")
1584  {
1585  sdebug("Special sort mask with->DROPCHAR");
1586  sortmode = 1;
1587  }
1588 
1589  sdebug(QString("start Qsort.. %1 %2").arg(keycolumn).arg(asc));
1590 
1591  q_sort();
1592 
1593  sdebug("..end");
1594 }
1595 
1597 {
1598  //sdebug("Flush drawing cache...");
1599  cacheMutex.lock();
1600  QLinkedList<HTableBrowserElement *>::Iterator i = cachedElements.begin();
1601  while(i != cachedElements.end())
1602  {
1603  if((*i)->cachePixmap != NULL)
1604  delete (*i)->cachePixmap;
1605  (*i)->cachePixmap = NULL;
1606 
1607  ++i;
1608  }
1609  cachedElements.clear();
1610  cacheMutex.unlock();
1611  return 0;
1612 }
1613 
1614 int HTableBrowser::limitCache(void)
1615 {
1616  HTableBrowserElement *toremove=NULL;
1617  cacheMutex.lock();
1618  while(cacheLimit <= cachedElements.size())
1619  {
1620  toremove = cachedElements.last();
1621  cachedElements.removeLast();
1622 
1623  if(toremove->cachePixmap != NULL)
1624  delete toremove->cachePixmap;
1625  toremove->cachePixmap = NULL;
1626  }
1627  cacheMutex.unlock();
1628  return 0;
1629 }
1630 
1631 void HTableBrowser::paintEvent(QPaintEvent *e)
1632 {
1633  Q_UNUSED(e);
1634 
1635  int c;
1636  int allcw=0;
1637  int dcY=0;
1638 
1639  QPixmap *pix=NULL;
1640  QColor color,cellcolor;
1641  HTableBrowserElement *run=top;
1642  HTableBrowserElement *dcI=NULL;
1643 
1644  //gr->fill(QColor(240,240,240));
1645 
1646  QPainter *p = new QPainter();
1647 
1648  color = color_cursor;
1649  p->begin(this);
1650  //p->setRenderHint(QPainter::Antialiasing);
1651 
1652  //Frame of the browser
1653  if(hasFocus())
1654  {
1655  p->setPen(QColor(190,190,190));
1656  p->drawRect(0,0,width()-1,height()-1);
1657  p->drawRect(1,1,width()-3,height()-3);
1658  p->setPen(QColor(130,130,130));
1659  p->drawRect(2,2,width()-5,height()-5);
1660  p->drawRect(3,3,width()-7,height()-7);
1661  p->setPen(QColor(90,90,90));
1662  p->drawRect(4,4,width()-9,height()-9);
1663  p->drawRect(5,5,width()-11,height()-11);
1664  p->setPen(QColor(0,0,0));
1665  p->drawRect(6,6,width()-13,height()-13);
1666  p->setClipRect(7,7,width()-15,height()-15);
1667  }
1668  else
1669  {
1670  p->setPen(QColor(220,220,220));
1671  p->drawRect(0,0,width()-1,height()-1);
1672  p->drawRect(1,1,width()-3,height()-3);
1673  p->setPen(QColor(190,190,190));
1674  p->drawRect(2,2,width()-5,height()-5);
1675  p->drawRect(3,3,width()-7,height()-7);
1676  p->setPen(QColor(130,130,130));
1677  p->drawRect(4,4,width()-9,height()-9);
1678  p->drawRect(5,5,width()-11,height()-11);
1679  p->setPen(QColor(50,50,50));
1680  p->drawRect(6,6,width()-13,height()-13);
1681  p->setClipRect(7,7,width()-15,height()-15);
1682  }
1683 
1684  int posX=LMARGIN,posY=TMARGIN;
1685 
1686  p->setPen(QColor(0,0,0));
1687 
1688  if(top == NULL || cur == NULL || start == NULL)
1689  {
1690  p->end();
1691  delete p;
1692  return;
1693  }
1694 
1695  //Calculating the width of columns
1696  double dv;
1697  for(c=0;c<(int)colw.size();++c)
1698  allcw+=colw[c]+CELLHMARGIN*2;
1699  dv = (double)(width()-(allcw+2*LMARGIN+BARW)) / (double)colw.size();
1700  if(dv < 1)
1701  plusw = 0;
1702  else
1703  plusw = (int)dv;
1704 
1705  while(head.size() < colw.size())
1706  head.push_back("");
1707 
1708  //Flush the ring cache if something marginal thing is changed
1709  if(oldw != width() || oldh != height() || old_col_scroll != col_scroll)
1711 
1712  old_col_scroll = col_scroll;
1713  oldw = width();
1714  oldh = height();
1715 
1716  //Allow bigger cache if necessary
1717  if( (int)((height()+50)/(rowh + 2*CELLVMARGIN)) > cacheLimit)
1718  cacheLimit = ((int)((height()+50)/(rowh + 2*CELLVMARGIN)) + 5);
1719 
1720  //Draw the headers
1721  //...Little back arrow, if we scroll horizontally
1722  if(col_scroll != 0)
1723  {
1724  QPen p1=p->pen(),
1725  p2=p->pen();
1726 
1727  p2.setWidth(3);
1728  p2.setColor(color_header);
1729  p->setPen(p2);
1730  p->drawLine(LMARGIN+CELLHMARGIN,TMARGIN+CELLVMARGIN,LMARGIN+CELLHMARGIN-5,TMARGIN+CELLVMARGIN+(rowh+CELLVMARGIN)/2);
1731  p->drawLine(LMARGIN+CELLHMARGIN,TMARGIN+CELLVMARGIN+rowh+CELLVMARGIN,LMARGIN+CELLHMARGIN-5,TMARGIN+CELLVMARGIN+(rowh+CELLVMARGIN)/2);
1732  p->setPen(p1);
1733  }
1734  //...Cells of header cells
1735  for(c=col_scroll;c<(int)colw.size();++c)
1736  {
1737  p->fillRect(posX+CELLHMARGIN,posY+CELLVMARGIN,colw[c]+CELLHMARGIN+plusw-1,rowh+CELLVMARGIN,
1738  QBrush( c == curc ? color_header_cursor : color_header));
1739 
1740  p->drawText(posX+CELLHMARGIN+1,posY+CELLVMARGIN+1,colw[c]+CELLHMARGIN+plusw,rowh+CELLVMARGIN,QTextOption::NoWrap, head[c] );
1741 
1742  //Draws the little sorting arrows
1743  if(keycolumn == c && asc) //0 - NO sort 1 - ascend 2 - descend
1744  p->drawPixmap(posX+CELLHMARGIN+colw[c]+CELLHMARGIN+plusw-BARW,posY+CELLVMARGIN,*pix_asc);
1745  if(keycolumn == c && !asc) //0 - NO sort 1 - ascend 2 - descend
1746  p->drawPixmap(posX+CELLHMARGIN+colw[c]+CELLHMARGIN+plusw-BARW,posY+CELLVMARGIN,*pix_desc);
1747 
1748  if(keycolumn2 == c && asc2) //0 - NO sort 1 - ascend 2 - descend
1749  p->drawPixmap(posX+CELLHMARGIN+colw[c]+CELLHMARGIN+plusw-BARW,posY+CELLVMARGIN,*pix_asc2);
1750  if(keycolumn2 == c && !asc2) //0 - NO sort 1 - ascend 2 - descend
1751  p->drawPixmap(posX+CELLHMARGIN+colw[c]+CELLHMARGIN+plusw-BARW,posY+CELLVMARGIN,*pix_desc2);
1752 
1753  posX += colw[c] + 2*CELLHMARGIN + plusw;
1754  }
1755 
1756  //put a little more place between the header and the first cell...
1757  posY += rowh + 4*CELLVMARGIN;
1758 
1759  dcI=NULL;
1760  showrow=0;
1761  //Drawing data rows
1762  for(;(posY < height()+rowh) && run != NULL;run = run->next)
1763  {
1764  posX=LMARGIN;
1765 
1766  if(cur != run) //If we are't drawing the cursor's row
1767  {
1768  cacheMutex.lock();
1769  if(run->cachePixmap == NULL) //if the cache is empty
1770  {
1771  run->cachePixmap = pix = new QPixmap(width()-5,rowh + 2*CELLVMARGIN);
1772  pix->fill(Qt::white);
1773  QPainter *cP = new QPainter(pix);
1774 
1775  //drawing cache pixmap..........................................
1776  posX=0;
1777  for(c=col_scroll;c<(int)colw.size();++c)
1778  {
1779  if(run->owncolor)
1780  cellcolor = QColor(run->ocr,run->ocg,run->ocb);
1781  else
1782  cellcolor = colc[c];
1783 
1784  //Color of the body of the cells.
1785  cP->fillRect(posX+CELLHMARGIN,CELLVMARGIN,colw[c]+CELLHMARGIN+plusw-1,rowh+CELLVMARGIN-1,
1786  QBrush(cellcolor));
1787 
1788  cP->drawText(posX+CELLHMARGIN+1,CELLVMARGIN+1,colw[c]+CELLHMARGIN+plusw,rowh+CELLVMARGIN,
1789  QTextOption::NoWrap,(*run)[c] );
1790  posX += colw[c] + 2*CELLHMARGIN + plusw;
1791 
1792  }
1793  //end drawing cache pixmap.......................................
1794  cP->end();
1795  delete cP;
1796 
1797  cachedElements.push_front(run);
1798  }
1799 
1800  p->drawPixmap(LMARGIN,posY,*(run->cachePixmap));
1801  cacheMutex.unlock();
1802 
1803  posY += rowh + 2*CELLVMARGIN;
1804  ++showrow;
1805  continue;
1806  }
1807 
1808  dcY = posY;
1809  dcI = run;
1810 
1811  posY += rowh + 2*CELLVMARGIN;
1812  ++showrow;
1813  }
1814 
1815  //Draw the cursor line if visible
1816  if(dcI != NULL)
1817  {
1818  posX=LMARGIN;
1819  for(c=col_scroll;c<(int)colw.size();++c)
1820  {
1821  cellcolor = color;
1822  //...Little back arrow,if we scroll horizontally
1823  if(c==col_scroll && col_scroll != 0)
1824  {
1825  QPen p1=p->pen(),
1826  p2=p->pen();
1827 
1828  p2.setWidth(3);
1829  p2.setColor(cellcolor);
1830  p->setPen(p2);
1831  p->drawLine(LMARGIN+CELLHMARGIN,dcY+CELLVMARGIN,LMARGIN+CELLHMARGIN-5,dcY+CELLVMARGIN+(rowh+CELLVMARGIN)/2);
1832  p->drawLine(LMARGIN+CELLHMARGIN,dcY+CELLVMARGIN+rowh+CELLVMARGIN,LMARGIN+CELLHMARGIN-5,dcY+CELLVMARGIN+(rowh+CELLVMARGIN)/2);
1833  p->setPen(p1);
1834  }
1835 
1836  //Color of the body of the cells.
1837  p->fillRect(posX+CELLHMARGIN,dcY+CELLVMARGIN,colw[c]+CELLHMARGIN+plusw-1,rowh+CELLVMARGIN-1,
1838  QBrush(cellcolor));
1839  if(c == curc)
1840  {
1841  //cursor inner
1842  p->setPen(QColor(60,60,60));
1843  p->drawRect(posX+CELLHMARGIN-2 ,dcY+CELLVMARGIN-2,
1844  colw[c]+CELLHMARGIN+3+plusw ,rowh+CELLVMARGIN+3); //Qt4-Qt3 4->3
1845 
1846  //...lines
1847  p->setPen(QColor(220,220,220));
1848 
1849  p->drawLine(posX+CELLHMARGIN-2+20 ,dcY+CELLVMARGIN-2,
1850  posX+CELLHMARGIN-2+colw[c]+CELLHMARGIN+4+plusw-20 ,dcY+CELLVMARGIN-2);
1851 
1852  p->drawLine(posX+CELLHMARGIN-2+20 ,dcY+CELLVMARGIN-2+rowh+CELLVMARGIN+3,
1853  posX+CELLHMARGIN-2+colw[c]+CELLHMARGIN+4+plusw-20 ,dcY+CELLVMARGIN-2+rowh+CELLVMARGIN+3);
1854 
1855  // ... cursor outer
1856  p->setPen(QColor(0,0,0));
1857  p->drawRect(posX+CELLHMARGIN-1,dcY+CELLVMARGIN-1,
1858  colw[c]+CELLHMARGIN+1+plusw,rowh+CELLVMARGIN+1); //Qt4-Qt3 2->1
1859 
1860  if(!seek.isEmpty()) //Seeking is active
1861  {
1862  if( (*dcI)[c].startsWith(seek) )
1863  {
1864  p->fillRect(posX+CELLHMARGIN,dcY+CELLVMARGIN,
1865  QApplication::fontMetrics().width(seek),rowh+CELLVMARGIN,
1866  QColor(254,230,100));
1867  }
1868  }
1869  //Inner white cursor (frame)
1870  p->setPen(QColor(254,254,254));
1871  p->drawRect(posX+CELLHMARGIN,dcY+CELLVMARGIN,colw[c]+CELLHMARGIN+plusw-1,rowh+CELLVMARGIN-1); //Qt3-Qt4 w,h = -1
1872  p->setPen(QColor(0,0,0));
1873  }
1874  p->drawText(posX+CELLHMARGIN+1,dcY+CELLVMARGIN+1,colw[c]+CELLHMARGIN+plusw,rowh+CELLVMARGIN,
1875  QTextOption::NoWrap,(*dcI)[c] );
1876  posX += colw[c] + 2*CELLHMARGIN + plusw;
1877  }
1878  }
1879 
1880  //side BAR
1881  int kx,ky,sx,sy;
1882 
1883  p->fillRect(width()-BARW-LMARGIN,6,BARW+LMARGIN,height()-12,color);
1884  p->drawRect(width()-BARW-LMARGIN,6,BARW+LMARGIN,height()-12);
1885 
1886  kx = width()-BARW-LMARGIN+4-1;
1887  sx = BARW-3;
1888 
1889  if(number == 0 || number <= showrow)
1890  {
1891  sy = height()-(2*TMARGIN+BUTTH);
1892  ky = TMARGIN+BUTTH;
1893  }
1894  else
1895  {
1896  sy = border(15,height()-(2*TMARGIN+BUTTH),
1897  (int)(showrow * (height()-(2*(BUTTH+8))) / number) );
1898 
1899  ky = border(TMARGIN+BUTTH,height()-(2*TMARGIN+BUTTH),
1900  (int)TMARGIN+BUTTH+(top->index * (height()-2*(BUTTH+TMARGIN)-sy) / (number-showrow)) );
1901  }
1902 
1903  p->fillRect(kx,ky,sx,sy,QColor(230,230,250));
1904  p->drawLine(kx+2,ky+2,kx+2,ky+sy-2);
1905  p->drawLine(kx+6,ky+2,kx+6,ky+sy-2);
1906  p->drawLine(kx+2,ky+sy/2,kx+6,ky+sy/2);
1907 
1908  //BAR-BUTTONS
1909  p->drawPixmap(width()-BARW-LMARGIN+2 ,8,*pix_up);
1910  p->drawPixmap(width()-BARW-LMARGIN+2 ,height()-(BUTTH+8),*pix_down);
1911 
1912  p->end();
1913  delete p;
1914 
1915  //freeing some cache data if necessary
1916  limitCache();
1917 
1918  if(lastkey != cur->key)
1919  {
1920  lastkey = cur->key;
1921  emit itemChanged(lastkey);
1922  }
1923 }
1924 
1925 void HTableBrowser::resizeEvent(QResizeEvent *e)
1926 {
1927  //fulshDrawingCache();
1928  QFrame::resizeEvent(e);
1929 }
1930 
1932 {
1933  return number;
1934 }
1935 
1937 {
1939 
1940  for(c = start; c != NULL ;c=c->next)
1941  if(c->index == n)
1942  return c;
1943  return c;
1944 }
1945 
1946 QStringList *HTableBrowser::valuesByIndex(int n)
1947 {
1949 
1950  c = elementByIndex(n);
1951 
1952  if(c == NULL)
1953  return NULL;
1954 
1955  return new QStringList(*c->rows);
1956 }
1957 
1959 {
1961 
1962  c = elementByIndex(n);
1963 
1964  if(c == NULL)
1965  return NULL;
1966 
1967  return new QString(c->key);
1968 }
1969 
1971 { query_cursor = start; }
1972 
1974 { query_cursor = top; }
1975 
1977 { query_cursor = cur; }
1978 
1980 {
1982 
1983  r = query_cursor;
1984  if(query_cursor != NULL)
1985  query_cursor = query_cursor->next;
1986  return r;
1987 }
1988 
1990 {
1992 
1993  r = query_cursor;
1994 
1995  if(query_cursor != NULL)
1996  {
1997  query_cursor = query_cursor->next;
1998  return new QStringList(*r->rows);
1999  }
2000  return NULL;
2001 }
2002 
2004 {
2006 
2007  r = query_cursor;
2008  if(query_cursor != NULL)
2009  {
2010  query_cursor = query_cursor->next;
2011  return new QString(r->key);
2012  }
2013  return NULL;
2014 }
2015 
2016 bool HTableBrowser::hasKey(QString key)
2017 {
2018  QString *strp;
2019 
2020  bool found = false;
2021  queryToTop();
2022 
2023  do
2024  {
2025  strp = queryNextKey();
2026  if(strp == NULL)
2027  continue;
2028  if(*strp == key)
2029  found = true;
2030  delete strp;
2031  }
2032  while(strp != NULL && !found);
2033  return found;
2034 }
2035 // /////////////////////////////////////////////////////////////////////////////////////////
2036 
2038 {
2039  key = k;
2040  rows = new QStringList(*c);
2041  owncolor = false;
2042  ocr=0; ocg=0; ocb=0;
2043 
2044  next = prev = NULL;
2045  cachePixmap = NULL;
2046 }
2047 
2048 HTableBrowserElement::HTableBrowserElement(QString k,QString v1,QString v2,QString v3,QString v4,QString v5,
2049  QString v6,QString v7,QString v8,QString v9)
2050 {
2051  key = k;
2052  rows = new QStringList();
2053  rows->push_back(v1);
2054  owncolor = false;
2055  ocr=0; ocg=0; ocb=0;
2056 
2057  if(v2.isEmpty()) { next = prev = NULL; cachePixmap = NULL; return; }
2058  else { rows->push_back(v2); }
2059 
2060  if(v3.isEmpty()) { next = prev = NULL; cachePixmap = NULL; return; }
2061  else { rows->push_back(v3); }
2062 
2063  if(v4.isEmpty()) { next = prev = NULL; cachePixmap = NULL; return; }
2064  else { rows->push_back(v4); }
2065 
2066  if(v5.isEmpty()) { next = prev = NULL; cachePixmap = NULL; return; }
2067  else { rows->push_back(v5); }
2068 
2069  if(v6.isEmpty()) { next = prev = NULL; cachePixmap = NULL; return; }
2070  else { rows->push_back(v6); }
2071 
2072  if(v7.isEmpty()) { next = prev = NULL; cachePixmap = NULL; return; }
2073  else { rows->push_back(v7); }
2074 
2075  if(v8.isEmpty()) { next = prev = NULL; cachePixmap = NULL; return; }
2076  else { rows->push_back(v8); }
2077 
2078  if(v9.isEmpty()) { next = prev = NULL; cachePixmap = NULL; return; }
2079  else { rows->push_back(v9); }
2080 
2081  next = prev = NULL;
2082  cachePixmap = NULL;
2083 }
2084 
2086 {
2087  if(cachePixmap != NULL)
2088  delete cachePixmap;
2089  cachePixmap = NULL;
2090 
2091  delete rows;
2092 }
2093 
2095 {
2096  owncolor = true;
2097  ocr=r;
2098  ocg=g;
2099  ocb=b;
2100  return this;
2101 }
2102 
2104 {
2105  owncolor = false;
2106  ocr=0;
2107  ocg=0;
2108  ocb=0;
2109  return this;
2110 }
2111 
2112 
2114 {
2115  if(rows == NULL)
2116  return "";
2117  if(rows->size() <= i)
2118  return "";
2119  return (*rows)[i];
2120 }
2121 
2123 {
2124  if(rows == NULL)
2125  return 0;
2126  return rows->size();
2127 }
2128 
2129 HTableBrowserElement& HTableBrowserElement::operator=(HTableBrowserElement& e)
2130 {
2131  rows->clear();
2132  *rows = *(e.rows);
2133  key = e.key;
2134 
2135  owncolor = e.owncolor;
2136  ocr = e.ocr; ocg = e.ocg; ocb = e.ocb;
2137 
2138  if(cachePixmap != NULL)
2139  delete cachePixmap;
2140  cachePixmap = NULL;
2141 
2142  return *this;
2143 }
2144 
2145 HTableBrowserElement& HTableBrowserElement::operator=(HTableBrowserElement* e)
2146 {
2147  rows->clear();
2148  *rows = *(e->rows);
2149  key = e->key;
2150 
2151  owncolor = e->owncolor;
2152  ocr = e->ocr; ocg = e->ocg; ocb = e->ocb;
2153 
2154  if(cachePixmap != NULL)
2155  delete cachePixmap;
2156  cachePixmap = NULL;
2157 
2158  return *this;
2159 }
2160 
2162 {
2163  QStringList *t1;
2164  QString t2;
2165  bool towncolor;
2166  int tocr,tocg,tocb;
2167 
2168  if(cachePixmap != NULL)
2169  delete cachePixmap;
2170  cachePixmap = NULL;
2171 
2172  if(x->cachePixmap != NULL)
2173  delete x->cachePixmap;
2174  x->cachePixmap = NULL;
2175 
2176  t1 = rows;
2177  t2 = key;
2178  towncolor = owncolor;
2179  tocr = ocr; tocg = ocg; tocb = ocb;
2180 
2181  rows = x->rows;
2182  key = x->key;
2183  owncolor = x->owncolor;
2184  ocr = x->ocr; ocg = x->ocg; ocb = x->ocb;
2185 
2186  x->rows = t1;
2187  x->key = t2;
2188  x->owncolor = towncolor;
2189  x->ocr = tocr; x->ocg = tocg; x->ocb = tocb;
2190 }
2191 
2192 // ///////////////////////////////////////////////////////////////////////////////
2193 // / Plain matrix class //////////////////////////////////////////////////////////
2194 // ///////////////////////////////////////////////////////////////////////////////
2195 
2196 HDispPlainDataMatrix::HDispPlainDataMatrix(QWidget *parent,HBase *d,bool htmlmode,int keyfield,int ddata)
2197 : QFrame(parent)
2198 {
2199  int i;
2200  data = (HPlainDataMatrix *)d;
2201  deletedata = ddata;
2202 
2203  genhtml_parameters = "html center";
2204  QVBoxLayout *layout= new QVBoxLayout(this);
2205  layout->setMargin(2);
2206  layout->setSpacing(2);
2207 
2208  list = new HTableBrowser(this);
2209 
2210  QToolButton *tp,*tx,*th;
2211  QHBoxLayout *toplay = new QHBoxLayout(0);
2212  tx = new QToolButton(this);
2213  tp = new QToolButton(this);
2214  tx->setIcon(QPixmap( (const char **) image_X ) );
2215  tp->setIcon(QPixmap( (const char **) image_P ) );
2216 
2217  toplay->addSpacing(5);
2218  toplay->addWidget(tp);
2219  toplay->addSpacing(3);
2220  toplay->addWidget(tx);
2221  if(htmlmode)
2222  {
2223  th = new QToolButton(this);
2224  th->setIcon(QPixmap( (const char **) image_F ) );
2225  toplay->addSpacing(3);
2226  toplay->addWidget(th);
2227 
2228  connect(th,SIGNAL(clicked()),this,SLOT(dialogHtmlShow()));
2229  }
2230  toplay->addStretch();
2231 
2232  layout->addLayout(toplay);
2233  connect(tx,SIGNAL(clicked()),this,SLOT(dialogXml()));
2234  connect(tp,SIGNAL(clicked()),this,SLOT(dialogPrint()));
2235 
2236  layout->addWidget(list);
2237 
2238  if(data->keyfield != -2)
2239  keyfield = data->keyfield;
2240 
2241  i = 0;
2242  QStringList *sl = new QStringList();
2243  QString k;
2244  if(data->rowCount() > 0)
2245  {
2246  data->firstRow();
2247  do
2248  {
2249  ++i;
2250  *sl = data->currentRowStr();
2251  if(keyfield == -1)
2252  k = QString("%1").arg(i);
2253  else
2254  k = (*sl)[keyfield];
2255  list->addElement(new HTableBrowserElement(k,sl));
2256  }
2257  while(data->nextRow());
2258  }
2259  list->setHeadTexts(data->getHeader());
2260  delete sl;
2261 
2262  connect(list,SIGNAL(activateItem(const QString&)),this,SLOT(slotActivateItem(const QString&)));
2263  connect(list,SIGNAL(alternateActivateItem(const QString&)),this,SLOT(itemAlternateActivated(const QString&)));
2264 }
2265 
2267 {
2268  QString key;
2269 
2270  key = k;
2271  emit activateItem(key);
2272  data->actLine(k);
2273  return 0;
2274 }
2275 
2277 {
2278  data->alternateActLine(s);
2279  return 0;
2280 }
2281 
2283 {
2284  HPrintTable *d = new HPrintTable(this,data);
2285  d->exec();
2286  delete d;
2287  return 0;
2288 }
2289 
2291 {
2292  HXmloTable *d = new HXmloTable(this,data);
2293  d->exec();
2294  delete d;
2295  return 0;
2296 }
2297 
2299 {
2300  HShowPrintHtml *d = new HShowPrintHtml(this);
2301  d->setContent(data->getContentAsHtml(genhtml_parameters));
2302  d->setWinTitle(data->getTitle());
2303  d->exec();
2304  delete d;
2305  return 0;
2306 }
2307 
2309 {
2310  if(deletedata == 1)
2311  {
2312  delete data;
2313  }
2314 }
2315 
2317 
2318 HPlainDMD::HPlainDMD(QWidget *parent,HBase *d,bool htmlmode)
2319 : QDialog(parent)
2320 {
2321  QVBoxLayout *layout= new QVBoxLayout(this);
2322  QHBoxLayout *bottom= new QHBoxLayout(0);
2323  dpdm = new HDispPlainDataMatrix(this,d,htmlmode);
2324 
2325  QPushButton *okb = new QPushButton("Ok",this);
2326  bottom->addStretch();
2327  bottom->addWidget(okb);
2328  bottom->addStretch();
2329 
2330 
2331  layout->addWidget(dpdm);
2332  layout->addLayout(bottom);
2333  setWindowTitle(((HPlainDataMatrix *)d)->getTitle());
2334  setSizeGripEnabled(true);
2335 
2336  connect(okb,SIGNAL(clicked()),this,SLOT(accept()));
2337 
2338  resize(400,200);
2339 }
2340 
2342 {
2343 
2344 }
2345 
2346 // ///////////////////////////////////////////////////////////////////////////////
2347 // / HDispList class /////////////////////////////////////////////////////////////
2348 // ///////////////////////////////////////////////////////////////////////////////
2349 
2350 HDispList::HDispList(QWidget *parent,HList *d,int datamodep,int ddata)
2351 :QFrame(parent)
2352 {
2353  sdebug("*** HDispList::HDispList ***");
2354  bool ok;
2355  list = NULL;
2356  data = d;
2357 
2358  deletedata = ddata;
2359  datamode = datamodep;
2360 
2362  data->clearList();
2363 
2364  QVBoxLayout *layout= new QVBoxLayout(this);
2365  layout->setMargin(2);
2366  layout->setSpacing(2);
2367  list = new HTableBrowser(this);
2368 
2369  if(data->extrafeatures)
2370  {
2371  QToolButton *tp,*tx;
2372 
2373  QHBoxLayout *toplay = new QHBoxLayout(0);
2374  tx = new QToolButton(this);
2375  tp = new QToolButton(this);
2376  tx->setIcon(QPixmap( (const char **) image_X ) );
2377  tp->setIcon(QPixmap( (const char **) image_P ) );
2378  toplay->addSpacing(5);
2379  toplay->addWidget(tp);
2380  toplay->addSpacing(3);
2381  toplay->addWidget(tx);
2382  toplay->addStretch();
2383 
2384  layout->addLayout(toplay);
2385  connect(tx,SIGNAL(clicked()),this,SLOT(dialogXml()));
2386  connect(tp,SIGNAL(clicked()),this,SLOT(dialogPrint()));
2387  }
2388 
2389  if(data->gui_showtabletitle && !data->tableTitle().isEmpty())
2390  {
2391  QLabel *titlelabel = new QLabel(this);
2392  titlelabel->setText(QString("<strong>%1</strong>").arg(data->tableTitle()));
2393  QHBoxLayout *titlelayout = new QHBoxLayout(0);
2394  titlelayout->addStretch();
2395  titlelayout->addWidget(titlelabel);
2396  titlelayout->addStretch();
2397  layout->addLayout(titlelayout);
2398  }
2399 
2400  layout->addWidget(list);
2401 
2402  ok = connect(data,SIGNAL(dataUpdatedSignal()),this,SLOT(updateDisplay()));
2403  sdebug(QString("connect0: ") + (ok ? "ok" : "not-ok"));
2404 
2405  updateDisplay();
2406  connect(list,SIGNAL(activateItem(const QString&)),this,SLOT(itemActivated(const QString&)));
2407  connect(list,SIGNAL(alternateActivateItem(const QString&)),this,SLOT(itemAlternateActivated(const QString&)));
2408  connect(list,SIGNAL(itemChanged(const QString&)),this,SLOT(litemChanged(const QString&)));
2409  sdebug("*** HDispList::HDispList *** END");
2410 }
2411 
2412 int HDispList::litemChanged(const QString& s)
2413 {
2414  data->soft_current_key = s;
2415  emit listItemChanged();
2416  return 0;
2417 }
2418 
2420 {
2421  list->sort(col);
2422  list->update();
2423  return 0;
2424 }
2425 
2427 {
2428  HPrintTable *d = new HPrintTable(this,data);
2429  d->exec();
2430  delete d;
2431  return 0;
2432 }
2433 
2435 {
2436  HXmloTable *d = new HXmloTable(this,data);
2437  d->exec();
2438  delete d;
2439  return 0;
2440 }
2441 
2443 {
2444  sdebug("*** HDispList::~HDispList ***");
2445  if(datamode == FULL_CLEAN || datamode == END_CLEAN)
2446  data->clearList();
2447  if(deletedata == 1)
2448  {
2450  delete data;
2451  }
2452  sdebug("*** HDispList::~HDispList *** END");
2453 }
2454 
2456 {
2457  QString oldtop;
2458  sdebug("*** HDispList::updateDisplay *** #"+ data->sqlTableName());
2459  int i;
2460 
2461  oldtop = list->topKey();
2462  list->clear();
2464  QStringList::Iterator ik = data->getKeys()->begin();
2465  QList<QStringList *>::Iterator iv = data->getValues()->begin();
2466  while(iv != data->getValues()->end() && ik != data->getKeys()->end())
2467  {
2468  list->addElement(new HTableBrowserElement(*ik,*iv));
2469  ++iv;
2470  ++ik;
2471  }
2472  i=0;
2473  data->firstField();
2474  HDataField *df;
2475  while((df = data->nextFieldAll()))
2476  {
2477  if(df->isShow() && df->isSQLField())
2478  {
2479  list->setColumnColor(i,QColor(df->getRColor(),df->getGColor(),df->getBColor()));
2480  if(!df->getSpecDisplaySortMode().isEmpty())
2482  ++i;
2483  }
2484  }
2485 
2486  list->setCurrentElement(data->activeKey(),oldtop);
2487  list->repaint();
2488  repaint();
2489 
2490  sdebug("*** HDispList::updateDisplay *** END");
2491  return 0;
2492 }
2493 void HDispList::keyPressEvent(QKeyEvent *e)
2494 {
2495  if(e->modifiers() == Qt::ControlModifier && e->key() == Qt::Key_R)
2496  {
2497  data->reReadList();
2498  }
2499  QFrame::keyPressEvent(e);
2500 }
2501 
2502 int HDispList::itemActivated(const QString& s)
2503 {
2504  sdebug("*** HDispList::itemActivated ***");
2505  data->setActiveKey(s);
2506  data->actLine();
2507  sdebug("*** HDispList::itemActivated *** END");
2508  return 0;
2509 }
2510 
2512 {
2513  sdebug("*** HDispList::itemAlternateActivated ***");
2514  data->setActiveKey(s);
2516  sdebug("*** HDispList::itemAlternateActivated *** END");
2517  return 0;
2518 }
2519 
2520 // ///////////////////////////////////////////////////////////////////////////////
2521 // / HDispTable class ////////////////////////////////////////////////////////////
2522 // ///////////////////////////////////////////////////////////////////////////////
2523 
2524 HDispTable::HDispTable(QWidget *parent,HTable *d,int datamodep,int ddata)
2525 :QFrame(parent)
2526 {
2527  sdebug("*** HDispTable::HDispTable ***");
2528 
2529  bool ok;
2530  HDataField *df=NULL;
2531  HDispDataField *ddf=NULL;
2532 
2533  deletedata = ddata;
2534  datamode = datamodep;
2535  layout= new QVBoxLayout(this);
2536  layout->setMargin(2);
2537  layout->setSpacing(2);
2538 
2539  data = d;
2540 
2541  ro_mask = data->readonlyMask();
2542 
2544  data->returnToDefault();
2545 
2546  if(data->extrafeatures)
2547  {
2548  QToolButton *tp,*tx;
2549 
2550  QHBoxLayout *toplay = new QHBoxLayout(0);
2551  tx = new QToolButton(this);
2552  tp = new QToolButton(this);
2553  tx->setIcon(QPixmap( (const char **) image_X ) );
2554  tp->setIcon(QPixmap( (const char **) image_P ) );
2555  toplay->addSpacing(5);
2556  toplay->addWidget(tp);
2557  toplay->addSpacing(3);
2558  toplay->addWidget(tx);
2559  toplay->addStretch();
2560 
2561  layout->addLayout(toplay);
2562  connect(tx,SIGNAL(clicked()),this,SLOT(dialogXml()));
2563  connect(tp,SIGNAL(clicked()),this,SLOT(dialogPrint()));
2564  }
2565 
2566  if(data->gui_showtabletitle && !data->tableTitle().isEmpty())
2567  {
2568  QLabel *titlelabel = new QLabel(this);
2569  titlelabel->setText(QString("<strong>%1</strong>").arg(data->tableTitle()));
2570  QHBoxLayout *titlelayout = new QHBoxLayout(0);
2571  titlelayout->addStretch();
2572  titlelayout->addWidget(titlelabel);
2573  titlelayout->addStretch();
2574  layout->addLayout(titlelayout);
2575  }
2576 
2577  data->firstField();
2578  while((df=data->nextFieldAll()) != NULL)
2579  {
2580  QHBoxLayout* static_sublayout_before = HDispDataField::static_sublayout;
2581  if(!df->isShow()) continue;
2582 
2583  if(df->getWhoami() == "HKey") { ddf=new HDispKey(this,df,ro_mask); }
2584  if(df->getWhoami() == "HSmallText") { ddf=new HDispSmallText(this,df,ro_mask); }
2585  if(df->getWhoami() == "HLargeText") { ddf=new HDispLargeText(this,df,ro_mask); }
2586  if(df->getWhoami() == "HCharHash") { ddf=new HDispCharHash(this,df,ro_mask); }
2587  if(df->getWhoami() == "HNumHash") { ddf=new HDispNumHash(this,df,ro_mask); }
2588  if(df->getWhoami() == "HNumber") { ddf=new HDispNumber(this,df,ro_mask); }
2589  if(df->getWhoami() == "HStatic") { ddf=new HDispStatic(this,df,ro_mask); }
2590  if(df->getWhoami() == "HFloating") { ddf=new HDispFloating(this,df,ro_mask); }
2591  if(df->getWhoami() == "HDate") { ddf=new HDispDate(this,df,ro_mask); }
2592  if(df->getWhoami() == "HCheck") { ddf=new HDispCheck(this,df,ro_mask); }
2593  if(df->getWhoami() == "HTimestamp") { ddf=new HDispTimestamp(this,df,ro_mask); }
2594  if(df->getWhoami() == "HSqlChoose") { ddf=new HDispSqlChoose(this,df,ro_mask); }
2595 
2596  ok = connect(this,SIGNAL(updateDisplaySignal()),ddf,SLOT(updateDisplaySlot()));
2597  if(!ok) error("libGUI system HDispTable constructor:\n Cannot connect to subfield slot! (1)");
2598 
2599  ok = connect(df,SIGNAL(disableControl()),ddf,SLOT(disableControlSlot()));
2600  if(!ok) error("libGUI system HDispTable constructor:\n Cannot connect to subfield slot! (2)");
2601  ok = connect(df,SIGNAL( enableControl()),ddf,SLOT( enableControlSlot()));
2602  if(!ok) error("libGUI system HDispTable constructor:\n Cannot connect to subfield slot! (3)");
2603 
2604  ok = connect(df,SIGNAL(updateStaticDisplayElementsSignal()),ddf,SLOT(updateStaticGuiElementsSlot()));
2605  if(!ok) error("libGUI system HDispTable constructor:\n Cannot connect to subfield slot! (4)");
2606 
2607 
2608  if(df->isGuienabled())
2609  ddf->enableControlSlot();
2610  else
2611  ddf->disableControlSlot();
2612 
2613  if(static_sublayout_before == NULL)
2614  layout->addWidget(ddf);
2615  else
2616  static_sublayout_before->addWidget(ddf);
2617 
2618  }
2619  connect(data,SIGNAL(dataUpdatedSignal()),this,SLOT(updateDisplay()));
2620  sdebug("*** HDispTable::HDispTable *** END");
2621 }
2622 
2624 {
2625  //layout->addStretch();
2626  QFrame *fr = new QFrame(this);
2627 
2628  QPalette palette;
2629  palette.setColor(QPalette::Window,QColor(180,180,180));
2630  fr->setPalette(palette);
2631  fr->setAutoFillBackground(true);
2632 
2633  QVBoxLayout *lay = new QVBoxLayout(fr);
2634  lay->addStretch();
2635 
2636  layout->addWidget(fr);
2637 
2638  return 0;
2639 }
2640 
2642 {
2643  HPrintTable *d = new HPrintTable(this,data);
2644  d->exec();
2645  delete d;
2646  return 0;
2647 }
2648 
2650 {
2651  HXmloTable *d = new HXmloTable(this,data);
2652  d->exec();
2653  delete d;
2654  return 0;
2655 }
2656 
2658 {
2659  sdebug("*** HDispTable::~HDispTable ***");
2660  if(datamode == FULL_CLEAN || datamode == END_CLEAN)
2661  data->returnToDefault();
2662  if(deletedata == 1)
2663  {
2665  delete data;
2666  }
2667  sdebug("*** HDispTable::~HDispTable *** END");
2668 }
2669 
2671 {
2672  sdebug("*** HDispTable::updateDisplay ***");
2673  /*
2674  I emits a signal which is connected the the slots of the child widgets.
2675  That's way I notify them to refresh the display from the memory.
2676  */
2677  emit updateDisplaySignal();
2678  sdebug("*** HDispTable::updateDisplay *** END");
2679  return 0;
2680 }
2681 
2682 // ///////////////////////////////////////////////////////////////////////////////
2683 // / Standard data fields ////////////////////////////////////////////////////////
2684 // ///////////////////////////////////////////////////////////////////////////////
2685 QHBoxLayout* HDispDataField::static_sublayout = NULL;
2686 
2687 HDispDataField::HDispDataField(QWidget *parent,HDataField *d,bool _ro_mask)
2688 :QFrame(parent)
2689 {
2690  data = d;
2691  ro_mask = _ro_mask;
2692 
2693  blink = 0;
2694 
2695  if(data->getRColor() != 0 &&
2696  data->getGColor() != 0 &&
2697  data->getBColor() != 0 )
2698  {
2699  QPalette palette;
2700  palette.setColor(QPalette::Window,QColor(data->getRColor(),
2701  data->getGColor(),
2702  data->getBColor() ));
2703 
2704  setPalette(palette);
2705  setAutoFillBackground(true);
2706  }
2707 
2708  sublayout = new QHBoxLayout(this);
2709  sublayout->setMargin(2);
2710  sublayout->setSpacing(2);
2711 
2712  if(d->isMeldedWithNext())
2713  static_sublayout = sublayout;
2714  else
2715  static_sublayout = NULL;
2716 
2717  tbool = false;
2718 }
2719 
2720 void HDispDataField::enableControl(void)
2721 {
2722 }
2723 
2724 void HDispDataField::disableControl(void)
2725 {
2726 }
2727 
2728 
2729 int HDispDataField::updateDisplaySlot(void)
2730 {
2731  /* Empty. Don't metter here. It's reimplemented in descendants */
2732  return 0;
2733 }
2734 
2735 int HDispDataField::timedUpdateSlot(void)
2736 {
2737  sdebug("*** HDispDataField::timedUpdateSlot ***");
2738 
2739  if(!data->getLastValidateStatus() )
2740  {
2741  blink = 0;
2742  update();
2743  }
2744 
2745  if(blink > 0)
2746  {
2747  blink++;
2748  if(blink >= 3) blink = 1;
2749 
2750  update();
2751  QTimer::singleShot(500,this,SLOT(timedUpdateSlot()));
2752  }
2753  return 0;
2754 }
2755 
2756 void HDispDataField::paintEvent(QPaintEvent *e)
2757 {
2758 
2759  if((blink == 0 && data->getLastValidateStatus()) ) //Field contains invalid data or already run blinking
2760  {
2761  blink = 1;
2762  timedUpdateSlot();
2763  }
2764 
2765  if(blink > 0)
2766  {
2767  QPainter p(this);
2768  p.setPen( blink%2 == 0 ? Qt::red : Qt::black);
2769  p.drawRect(0,0,width()-1,height()-1);
2770  }
2771  QFrame::paintEvent(e);
2772 }
2773 
2774 HDispDataField::~HDispDataField(void)
2775 {
2776 
2777 }
2778 
2779 // ///////////////////////////////////////////////////////////////////////////////
2780 // / Special data fields /////////////////////////////////////////////////////////
2781 // ///////////////////////////////////////////////////////////////////////////////
2782 
2783 HDispKey::HDispKey(QWidget *parent,HDataField *d,bool _ro_mask)
2784 : HDispDataField(parent,d,_ro_mask)
2785 {
2786  explain = new QLabel(this);
2787  key = new QLabel(this);
2788 
2789  explain->setText(data->getExplainText());
2790  key->setText(data->getValue().toString());
2791 
2792  sublayout->addWidget(explain);
2793  sublayout->addWidget(key);
2794 }
2795 
2796 void HDispKey::enableControl(void)
2797 {
2798 }
2799 
2800 void HDispKey::disableControl(void)
2801 {
2802 }
2803 
2804 int HDispKey::updateDisplaySlot(void)
2805 {
2806  //sdebug("*** HDispKey::updateDisplaySlot ***");
2807  key->setText(data->getValue().toString());
2808  //sdebug("*** HDispKey::updateDisplaySlot *** END ");
2809  return 0;
2810 }
2811 
2812 int HDispKey::updateStaticGuiElementsSlot(void)
2813 {
2814  if(explain != NULL)
2815  explain->setText(data->getExplainText());
2816  return 0;
2817 }
2818 
2819 HDispKey::~HDispKey(void)
2820 {
2821 }
2822 
2823 // ///////////////////////////////////////////////////////////////////////////////
2824 
2825 HDispSmallText::HDispSmallText(QWidget *parent,HDataField *d,bool _ro_mask)
2826 : HDispDataField(parent,d,_ro_mask)
2827 {
2828  edtext = NULL;
2829  nedtext = NULL;
2830  tailtext = NULL;
2831 
2832  explain = new QLabel(this);
2833  explain->setText(data->getExplainText());
2834  sublayout->addWidget(explain);
2835 
2836  if(!d->isNoMiddleStretch())
2837  sublayout->addStretch();
2838 
2839  if(!ro_mask && data->isEditable())
2840  {
2841  edtext = new QLineEdit(this);
2842  edtext->setText(data->getValue().toString());
2843  if(d->editBoxMaxWidth() != 0)
2844  edtext->setMaximumWidth(d->editBoxMaxWidth());
2845 
2846  sublayout->addWidget(edtext);
2847  if(!connect(edtext,SIGNAL(textChanged(const QString&)),this,SLOT(textUpdate(const QString&))))
2848  error("Error, connect(edtext,SIGNAL(textChanged(const QString&)),this,SLOT(textUpdate(const QString&)))");
2849  if(((HSmallText *)data)->isInitialSelected())
2850  {
2851  edtext->selectAll();
2852  sdebug(" HDispSmallText: Initial selection is YES -- call selectAll()");
2853  }
2854  }
2855  else
2856  {
2857  nedtext = new QLabel(this);
2858  nedtext->setText(data->getValue().toString());
2859  sublayout->addWidget(nedtext);
2860  }
2861 
2862  if(!data->getTailText().isEmpty())
2863  {
2864  tailtext = new QLabel(this);
2865  tailtext->setText(data->getTailText());
2866  sublayout->addWidget(tailtext);
2867  }
2868 }
2869 
2870 void HDispSmallText::enableControl(void)
2871 {
2872  if(edtext != NULL)
2873  edtext->setEnabled(true);
2874 }
2875 
2876 void HDispSmallText::disableControl(void)
2877 {
2878  if(edtext != NULL)
2879  edtext->setEnabled(false);
2880 }
2881 
2882 int HDispSmallText::textUpdate(const QString& n) //SLOT!
2883 {
2884  sdebug("*** HDispSmallText::textUpdate ***");
2885  data->setValue(QVariant(n));
2886  sdebug("*** HDispSmallText::textUpdate *** END");
2887  return 0;
2888 }
2889 
2890 int HDispSmallText::updateDisplaySlot(void)
2891 {
2892  sdebug("*** HDispSmallText::updateDisplaySlot ***");
2893  if(edtext != NULL)
2894  {
2895  if(edtext->text() != data->getValue().toString())
2896  {
2897  edtext->setText ( data->getValue().toString() );
2898  if(((HSmallText *)data)->isInitialSelected())
2899  {
2900  edtext->selectAll();
2901  sdebug(" HDispSmallText: Initial selection is YES -- call selectAll()");
2902  }
2903  }
2904  }
2905  if(nedtext != NULL) nedtext->setText( data->getValue().toString() );
2906  sdebug("*** HDispSmallText::updateDisplaySlot *** END");
2907  return 0;
2908 }
2909 
2910 int HDispSmallText::updateStaticGuiElementsSlot(void)
2911 {
2912  if(explain != NULL)
2913  explain->setText(data->getExplainText());
2914  if(tailtext != NULL)
2915  tailtext->setText(data->getTailText());
2916  return 0;
2917 }
2918 
2919 HDispSmallText::~HDispSmallText(void)
2920 {
2921 }
2922 
2923 // ///////////////////////////////////////////////////////////////////////////////
2924 
2925 HDispLargeText::HDispLargeText(QWidget *parent,HDataField *d,bool _ro_mask)
2926 : HDispDataField(parent,d,_ro_mask)
2927 {
2928  edtext = NULL;
2929  nedtext = NULL;
2930 
2931  explain = new QLabel(this);
2932  explain->setText(data->getExplainText());
2933  sublayout->addWidget(explain);
2934 
2935  if(!d->isNoMiddleStretch())
2936  sublayout->addStretch();
2937 
2938  if(!ro_mask && data->isEditable())
2939  {
2940  edtext = new QTextEdit(this);
2941  edtext->setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
2942  edtext->setText(data->getValue().toString());
2943  edtext->setTabChangesFocus(true);
2944  edtext->setMinimumSize(100,50);
2945  sublayout->addWidget(edtext);
2946  if(!connect(edtext,SIGNAL(textChanged()),this,SLOT(textUpdate())))
2947  error("Error, connect(edtext,SIGNAL(textChanged()),this,SLOT(textUpdate()))");
2948  }
2949  else
2950  {
2951  nedtext = new QTextEdit(this);
2952  nedtext->setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
2953  nedtext->setText(data->getValue().toString());
2954  nedtext->setReadOnly(true);
2955  nedtext->setMinimumSize(100,50);
2956  QPalette palette;
2957  palette.setColor(QPalette::Base,QColor(data->getRColor(),
2958  data->getGColor(),
2959  data->getBColor()));
2960  nedtext->setPalette(palette);
2961  sublayout->addWidget(nedtext);
2962  }
2963 }
2964 
2965 void HDispLargeText::enableControl(void)
2966 {
2967  if(edtext != NULL)
2968  edtext->setEnabled(true);
2969 }
2970 
2971 void HDispLargeText::disableControl(void)
2972 {
2973  if(edtext != NULL)
2974  edtext->setEnabled(false);
2975 }
2976 
2977 int HDispLargeText::textUpdate(void) //SLOT!
2978 {
2979  data->setValue(QVariant(edtext->toPlainText()));
2980  return 0;
2981 }
2982 
2983 int HDispLargeText::updateDisplaySlot(void)
2984 {
2985  if(edtext != NULL)
2986  {
2987  if(data->getValue().toString() != edtext->toPlainText())
2988  {
2989  edtext->setText ( data->getValue().toString() );
2990  }
2991  }
2992  if(nedtext != NULL)
2993  {
2994  nedtext->setText( data->getValue().toString() );
2995  }
2996  return 0;
2997 }
2998 
2999 int HDispLargeText::updateStaticGuiElementsSlot(void)
3000 {
3001  if(explain != NULL)
3002  explain->setText(data->getExplainText());
3003  return 0;
3004 }
3005 
3006 
3007 HDispLargeText::~HDispLargeText(void)
3008 {
3009 }
3010 
3011 // ///////////////////////////////////////////////////////////////////////////////
3012 HDispCharHash::HDispCharHash(QWidget *parent,HDataField *d,bool _ro_mask)
3013 : HDispDataField(parent,d,_ro_mask)
3014 {
3015  edval = NULL;
3016  nedtext = NULL;
3017  tailtext = NULL;
3018  int curr;
3019 
3020  explain = new QLabel(this);
3021  explain->setText(data->getExplainText());
3022  sublayout->addWidget(explain);
3023 
3024  if(!d->isNoMiddleStretch())
3025  sublayout->addStretch();
3026 
3027  if(!ro_mask && data->isEditable())
3028  {
3029  edval = new QComboBox(this);
3030  edval->clear();
3031  edval->addItems( ((HCharHash *)data)->values );
3032 
3033  curr = getIndexOf( ((HCharHash *)data)->keys , data->getValue().toString());
3034  edval->setCurrentIndex(curr);
3035  itemSelected(curr);
3036 
3037  sublayout->addWidget(edval);
3038 
3039  if(!connect(edval,SIGNAL(activated(int)),this,SLOT(itemSelected(int))))
3040  error("Error, connect(edval,SIGNAL(activated(int)),this,SLOT(itemSelected(int)))");
3041  }
3042  else
3043  {
3044  nedtext = new QLabel(this);
3045  curr = getIndexOf( ((HCharHash *)data)->keys , data->getValue().toString());
3046  nedtext->setText( ((HCharHash *)data)->values[curr] );
3047 
3048  sublayout->addWidget(nedtext);
3049  }
3050 
3051  if(!data->getTailText().isEmpty())
3052  {
3053  tailtext = new QLabel(this);
3054  tailtext->setText(data->getTailText());
3055  sublayout->addWidget(tailtext);
3056  }
3057 }
3058 
3059 
3060 void HDispCharHash::enableControl(void)
3061 {
3062  if(edval != NULL)
3063  edval->setEnabled(true);
3064 }
3065 
3066 void HDispCharHash::disableControl(void)
3067 {
3068  if(edval != NULL)
3069  edval->setEnabled(false);
3070 }
3071 
3072 int HDispCharHash::itemSelected(int index) //SLOT
3073 {
3074  sdebug("*** HDispCharHash::itemSelected ***");
3075  data->setValue(QVariant( ((HCharHash *)data)->keys[index] ));
3076  sdebug("*** HDispCharHash::itemSelected *** END");
3077  return 0;
3078 }
3079 
3080 int HDispCharHash::updateDisplaySlot(void)
3081 {
3082  int curr;
3083  curr = getIndexOf( ((HCharHash *)data)->keys , data->getValue().toString());
3084  if(edval != NULL) edval->setCurrentIndex(curr);
3085  if(nedtext != NULL) nedtext->setText( ((HCharHash *)data)->values[curr] );
3086  return 0;
3087 }
3088 
3089 int HDispCharHash::updateStaticGuiElementsSlot(void)
3090 {
3091  if(explain != NULL)
3092  explain->setText(data->getExplainText());
3093  if(tailtext != NULL)
3094  tailtext->setText(data->getTailText());
3095  return 0;
3096 }
3097 
3098 HDispCharHash::~HDispCharHash(void)
3099 {
3100 }
3101 
3102 // ///////////////////////////////////////////////////////////////////////////////
3103 
3104 HDispNumHash::HDispNumHash(QWidget *parent,HDataField *d,bool _ro_mask)
3105 : HDispDataField(parent,d,_ro_mask)
3106 {
3107  edval = NULL;
3108  nedtext = NULL;
3109  tailtext = NULL;
3110  int curr;
3111 
3112  explain = new QLabel(this);
3113  explain->setText(data->getExplainText());
3114  sublayout->addWidget(explain);
3115 
3116  if(!d->isNoMiddleStretch())
3117  sublayout->addStretch();
3118 
3119  if(!ro_mask && data->isEditable())
3120  {
3121  edval = new QComboBox(this);
3122  edval->clear();
3123  edval->addItems( ((HNumHash *)data)->values );
3124 
3125  curr = getIndexOf( ((HNumHash *)data)->keys , data->getValue().toString());
3126  edval->setCurrentIndex(curr);
3127  itemSelected(curr);
3128 
3129  sublayout->addWidget(edval);
3130 
3131  if(!connect(edval,SIGNAL(activated(int)),this,SLOT(itemSelected(int))))
3132  error("Error, connect(edval,SIGNAL(activated(int)),this,SLOT(itemSelected(int)))");
3133  }
3134  else
3135  {
3136  nedtext = new QLabel(this);
3137  curr = getIndexOf( ((HNumHash *)data)->keys , data->getValue().toString());
3138  nedtext->setText( ((HNumHash *)data)->values[curr] );
3139 
3140  sublayout->addWidget(nedtext);
3141  }
3142 
3143  if(!data->getTailText().isEmpty())
3144  {
3145  tailtext = new QLabel(this);
3146  tailtext->setText(data->getTailText());
3147  sublayout->addWidget(tailtext);
3148  }
3149 }
3150 
3151 void HDispNumHash::enableControl(void)
3152 {
3153  if(edval != NULL)
3154  edval->setEnabled(true);
3155 }
3156 
3157 void HDispNumHash::disableControl(void)
3158 {
3159  if(edval != NULL)
3160  edval->setEnabled(false);
3161 }
3162 
3163 int HDispNumHash::itemSelected(int index) //SLOT
3164 {
3165  sdebug("HDispNumHash::itemSelected");
3166  data->setValue(QVariant( ((HNumHash *)data)->keys[index] ));
3167  return 0;
3168 }
3169 
3170 int HDispNumHash::updateDisplaySlot(void)
3171 {
3172  int curr;
3173  curr = getIndexOf( ((HNumHash *)data)->keys , data->getValue().toString());
3174  if(edval != NULL) edval->setCurrentIndex(curr);
3175  if(nedtext != NULL) nedtext->setText( ((HNumHash *)data)->values[curr] );
3176  return 0;
3177 }
3178 
3179 int HDispNumHash::updateStaticGuiElementsSlot(void)
3180 {
3181  if(explain != NULL)
3182  explain->setText(data->getExplainText());
3183  if(tailtext != NULL)
3184  tailtext->setText(data->getTailText());
3185  return 0;
3186 }
3187 
3188 
3189 HDispNumHash::~HDispNumHash(void)
3190 {
3191 }
3192 
3193 // ///////////////////////////////////////////////////////////////////////////////
3194 
3195 HDispNumber::HDispNumber(QWidget *parent,HDataField *d,bool _ro_mask)
3196 : HDispDataField(parent,d,_ro_mask)
3197 {
3198  edval = NULL;
3199  nedtext = NULL;
3200  tailtext = NULL;
3201 
3202  explain = new QLabel(this);
3203  explain->setText(data->getExplainText());
3204  sublayout->addWidget(explain);
3205 
3206  if(!d->isNoMiddleStretch())
3207  sublayout->addStretch();
3208 
3209  if(!ro_mask && data->isEditable())
3210  {
3211  edval = new HSpinBox(this);
3212  edval->setMinValue( ((HNumber *)data)->getMinimum() );
3213  edval->setMaxValue( ((HNumber *)data)->getMaximum() );
3214  edval->setValue( data->getValue().toInt() );
3215  sublayout->addWidget(edval);
3216 
3217  valueUpdate(edval->value());
3218  if(!connect(edval,SIGNAL(valueChanged(int)),this,SLOT(valueUpdate(int))))
3219  error("Error, connect(edval,SIGNAL(valueChanged(int)),this,SLOT(valueUpdate(int)))");
3220  }
3221  else
3222  {
3223  nedtext = new QLabel(this);
3224  nedtext->setText( QString("%1").arg(data->getValue().toInt()) );
3225  sublayout->addWidget(nedtext);
3226  }
3227 
3228  if(!data->getTailText().isEmpty())
3229  {
3230  tailtext = new QLabel(this);
3231  tailtext->setText(data->getTailText());
3232  sublayout->addWidget(tailtext);
3233  }
3234 }
3235 
3236 void HDispNumber::enableControl(void)
3237 {
3238  if(edval != NULL)
3239  edval->setEnabled(true);
3240 }
3241 
3242 void HDispNumber::disableControl(void)
3243 {
3244  if(edval != NULL)
3245  edval->setEnabled(false);
3246 }
3247 
3248 int HDispNumber::valueUpdate(int value) //SLOT
3249 {
3250  data->setValue(QVariant(value));
3251  updateDisplaySlot();
3252  return 0;
3253 }
3254 
3255 int HDispNumber::updateDisplaySlot(void)
3256 {
3257  if(edval != NULL) edval->setValue( data->getValue().toInt() );
3258  if(nedtext != NULL) nedtext->setText( QString("%1").arg(data->getValue().toInt()) );
3259  return 0;
3260 }
3261 
3262 int HDispNumber::updateStaticGuiElementsSlot(void)
3263 {
3264  if(explain != NULL)
3265  explain->setText(data->getExplainText());
3266  if(tailtext != NULL)
3267  tailtext->setText(data->getTailText());
3268  return 0;
3269 }
3270 
3271 HDispNumber::~HDispNumber()
3272 {
3273 }
3274 
3275 // ///////////////////////////////////////////////////////////////////////////////
3276 
3277 HDispStatic::HDispStatic(QWidget *parent,HDataField *d,bool _ro_mask)
3278 : HDispDataField(parent,d,_ro_mask)
3279 {
3280  nedtext = NULL;
3281 
3282  if(data->getValue().toString().isEmpty())
3283  {
3284  sublayout->addStretch(99);
3285  }
3286 
3287  explain = new QLabel(this);
3288  explain->setText(data->getExplainText());
3289 
3290  sublayout->addWidget(explain);
3291 
3292  sublayout->addStretch(99);
3293 
3294  if(!data->getValue().toString().isEmpty())
3295  {
3296  nedtext = new QLabel(this);
3297  nedtext->setText( data->getValue().toString() );
3298  sublayout->addWidget(nedtext);
3299 
3300  }
3301 }
3302 
3303 void HDispStatic::enableControl(void)
3304 {
3305 }
3306 
3307 void HDispStatic::disableControl(void)
3308 {
3309 }
3310 
3311 int HDispStatic::updateDisplaySlot(void)
3312 {
3313  //sdebug("*** HDispStatic::updateDisplaySlot ***");
3314  if(!data->getValue().toString().isEmpty())
3315  {
3316  if(nedtext != NULL)
3317  nedtext->setText( data->getValue().toString() );
3318  }
3319  //sdebug("*** HDispStatic::updateDisplaySlot *** END");
3320  return 0;
3321 }
3322 
3323 int HDispStatic::updateStaticGuiElementsSlot(void)
3324 {
3325  if(explain != NULL)
3326  explain->setText(data->getExplainText());
3327  return 0;
3328 }
3329 
3330 HDispStatic::~HDispStatic(void)
3331 {
3332 }
3333 
3334 // ///////////////////////////////////////////////////////////////////////////////
3335 HDispCheck::HDispCheck(QWidget *parent,HDataField *d,bool _ro_mask)
3336 : HDispDataField(parent,d,_ro_mask)
3337 {
3338  edval = NULL;
3339  nedtext = NULL;
3340 
3341  explain = new QLabel(this);
3342  explain->setText(data->getExplainText());
3343  sublayout->addWidget(explain);
3344 
3345  if(!d->isNoMiddleStretch())
3346  sublayout->addStretch();
3347 
3348  if(!ro_mask && data->isEditable())
3349  {
3350  edval = new QCheckBox(this);
3351  edval->setChecked( data->getValue().toBool() );
3352  edval->setText( data->getTailText() );
3353  sublayout->addWidget(edval);
3354  valueUpdate();
3355  if(!connect(edval,SIGNAL(clicked()),this,SLOT(valueUpdate())))
3356  error("Error, connect(edval,SIGNAL(clicked()),this,SLOT(valueUpdate()))");
3357  }
3358  else
3359  {
3360  nedtext = new QLabel(this);
3361  nedtext->setText( QString("%1")
3362  .arg(data->getValue().toBool() ?
3363  ((HCheck *)data)->trues : ((HCheck *)data)->falses ));
3364 
3365  sublayout->addWidget(nedtext);
3366  }
3367 }
3368 
3369 void HDispCheck::enableControl(void)
3370 {
3371  if(edval != NULL)
3372  edval->setEnabled(true);
3373 }
3374 
3375 void HDispCheck::disableControl(void)
3376 {
3377  if(edval != NULL)
3378  edval->setEnabled(false);
3379 }
3380 
3381 int HDispCheck::valueUpdate(void) //SLOT
3382 {
3383  data->setValue(QVariant(edval->isChecked()));
3384  return 0;
3385 }
3386 
3387 int HDispCheck::updateDisplaySlot(void) //SLOT
3388 {
3389  if(edval != NULL)
3390  {
3391  edval->setChecked( data->getValue().toBool() );
3392  edval->setText( data->getTailText() );
3393  }
3394  if(nedtext != NULL)
3395  {
3396  nedtext->setText( QString("%1")
3397  .arg(data->getValue().toBool() ?
3398  ((HCheck *)data)->trues : ((HCheck *)data)->falses ));
3399  }
3400  return 0;
3401 }
3402 
3403 int HDispCheck::updateStaticGuiElementsSlot(void)
3404 {
3405  if(explain != NULL)
3406  explain->setText(data->getExplainText());
3407  return 0;
3408 }
3409 
3410 HDispCheck::~HDispCheck(void)
3411 {
3412 }
3413 
3414 // ///////////////////////////////////////////////////////////////////////////////
3415 HDispFloating::HDispFloating(QWidget *parent,HDataField *d,bool _ro_mask)
3416 : HDispDataField(parent,d,_ro_mask)
3417 {
3418  edtext = NULL;
3419  nedtext = NULL;
3420  tailtext = NULL;
3421 
3422  explain = new QLabel(this);
3423  explain->setText(data->getExplainText());
3424  sublayout->addWidget(explain);
3425 
3426 
3427  if(!d->isNoMiddleStretch())
3428  sublayout->addStretch();
3429 
3430  if(!ro_mask && data->isEditable())
3431  {
3432  edtext = new QLineEdit(this);
3433  if(d->editBoxMaxWidth() != 0)
3434  edtext->setMaximumWidth(d->editBoxMaxWidth());
3435  edtext->setAlignment(Qt::AlignRight);
3436  edtext->setText(data->getValue().toString());
3437  //edtext->setText( ((HFloating *)data)->getValueAsString() );
3438 
3439  sublayout->addWidget(edtext);
3440  if(!connect(edtext,SIGNAL(textChanged(const QString&)),this,SLOT(textUpdate(const QString&))))
3441  error("Error, connect(edtext,SIGNAL(textChanged(const QString&)),this,SLOT(textUpdate(const QString&)))");
3442  }
3443  else
3444  {
3445  nedtext = new QLabel(this);
3446  nedtext->setText(data->dbValueToDispValue(data->getValue()).toString());
3447  sublayout->addWidget(nedtext);
3448  }
3449 
3450  if(!data->getTailText().isEmpty() && nedtext==NULL)
3451  //If nedtext==NULL the field is readonly so the dbValueToDispValue function appends the tailtext to the value
3452  //so needless to set this label.
3453  {
3454  tailtext = new QLabel(this);
3455  tailtext->setText(data->getTailText());
3456  sublayout->addWidget(tailtext);
3457  }
3458 }
3459 
3460 void HDispFloating::enableControl(void)
3461 {
3462  if(edtext != NULL)
3463  edtext->setEnabled(true);
3464 }
3465 
3466 void HDispFloating::disableControl(void)
3467 {
3468  if(edtext != NULL)
3469  edtext->setEnabled(false);
3470 }
3471 
3472 int HDispFloating::textUpdate(const QString& n) //SLOT!
3473 {
3474  QString number = n;
3475 
3476  sdebug("*** HDispFloating::textUpdate ***");
3477  bool ok;
3478  double d;
3479 
3480  number.replace(" ","",Qt::CaseInsensitive);
3481 
3482  if(number.isEmpty() || number == "-" || number==".") //deleted to empty (or a "-" sign), it means 0 for me.
3483  {
3484  data->setValue(QVariant(0));
3485  return 0;
3486  }
3487 
3488  d = number.toDouble(&ok);
3489  if(!ok) //can't convert
3490  {
3491  error(QString("Cannot convert the string vale to floating!\nColumn \"%1\" (%2) \nPlease corrent the value!")
3492  .arg(data->getExplainText())
3493  .arg(data->sqlSelectHead()));
3494  updateDisplaySlot(); //set the value last time when we could convert it
3495  return 0;
3496  }
3497 
3498  data->setValue(QVariant(d));
3499  return 0;
3500 }
3501 
3502 int HDispFloating::updateDisplaySlot(void) //SLOT
3503 {
3504  sdebug("*** HDispFloating::updateDisplaySlot ***");
3505  if(edtext != NULL) edtext->setText (data->getValue().toString() );
3506  //if(edtext != NULL) edtext->setText( ((HFloating *)data)->getValueAsString() );
3507 
3508  if(nedtext != NULL) nedtext->setText(data->dbValueToDispValue(data->getValue()).toString());
3509  return 0;
3510 }
3511 
3512 int HDispFloating::updateStaticGuiElementsSlot(void)
3513 {
3514  if(explain != NULL)
3515  explain->setText(data->getExplainText());
3516  if(tailtext != NULL)
3517  tailtext->setText(data->getTailText());
3518  return 0;
3519 }
3520 
3521 HDispFloating::~HDispFloating(void)
3522 {
3523 }
3524 
3525 // ///////////////////////////////////////////////////////////////////////////////
3526 HDispDate::HDispDate(QWidget *parent,HDataField *d,bool _ro_mask)
3527 : HDispDataField(parent,d,_ro_mask)
3528 {
3529  edval = NULL;
3530  nedtext = NULL;
3531  unk = NULL;
3532 
3533  explain = new QLabel(this);
3534  explain->setText(data->getExplainText());
3535  sublayout->addWidget(explain);
3536 
3537  if(!d->isNoMiddleStretch())
3538  sublayout->addStretch();
3539 
3540  if(!ro_mask && data->isEditable())
3541  {
3542 
3543  edval = new QDateEdit(this);
3544  edval->setCalendarPopup(true);
3545  edval->setDate(((HDate *)data)->getKnownValue().toDate());
3546 
3547  if(((HDate *)data)->is_unknown_alive())
3548  {
3549  unk = new QCheckBox(this);
3550  unk->setText( GSAFETEXT_UNKNOWN " ");
3551  if(((HDate *)data)->is_value_unknown())
3552  {
3553  unk->setChecked(true);
3554  edval->setEnabled(false);
3555  }
3556  else
3557  {
3558  unk->setChecked(false);
3559  edval->setEnabled(true);
3560  }
3561 
3562  sublayout->addWidget(unk);
3563  if(!connect(unk,SIGNAL(clicked()),this,SLOT(valueUnkUpdate())))
3564  error("Error, connect(unk,SIGNAL(clicked()),this,SLOT(valueUnkUpdate()))");
3565 
3566  }
3567  sublayout->addWidget(edval);
3568  if(!connect(edval,SIGNAL(dateChanged(const QDate&)),this,SLOT(valueUpdate(const QDate&))))
3569  error("Error, connect(edval,SIGNAL(dateChanged(const QDate&)),this,SLOT(valueUpdate(const QDate&)))!");
3570  }
3571  else
3572  {
3573  nedtext = new QLabel(this);
3574  if( ((HDate *)data)->is_unknown_alive() && ((HDate *)data)->is_value_unknown() )
3575  nedtext->setText(GSAFETEXT_TEXT_UNKNOWN);
3576  else
3577  nedtext->setText(data->getValue().toString());
3578  sublayout->addWidget(nedtext);
3579  }
3580 }
3581 
3582 void HDispDate::enableControl(void)
3583 {
3584  if(edval != NULL)
3585  {
3586  if(unk != NULL)
3587  unk->setEnabled(true);
3588 
3589  if(((HDate *)data)->is_value_unknown())
3590  {
3591  edval->setEnabled(false);
3592  }
3593  else
3594  {
3595  edval->setEnabled(true);
3596  }
3597  }
3598 }
3599 
3600 void HDispDate::disableControl(void)
3601 {
3602  if(edval != NULL)
3603  edval->setEnabled(false);
3604  if(unk != NULL)
3605  unk->setEnabled(false);
3606 }
3607 
3608 int HDispDate::valueUnkUpdate(void) //SLOT
3609 {
3610  if(unk->isChecked())
3611  {
3612  ((HDate *)data)->value_is_unknown();
3613  edval->setEnabled( false );
3614  return 0;
3615  }
3616 
3617  ((HDate *)data)->value_is_known();
3618  edval->setEnabled( true );
3619  return 0;
3620 }
3621 
3622 int HDispDate::valueUpdate(const QDate &d) //SLOT
3623 {
3624  data->setValue(QVariant(d));
3625  return 0;
3626 }
3627 
3628 int HDispDate::updateDisplaySlot(void) //SLOT
3629 {
3630  if(edval != NULL)
3631  {
3632  edval->setDate(data->getValue().toDate());
3633  if(unk != NULL)
3634  {
3635  unk->setChecked( ((HDate *)data)->is_value_unknown() );
3636  edval->setEnabled( !((HDate *)data)->is_value_unknown() );
3637  }
3638  else
3639  edval->setEnabled(true);
3640  }
3641 
3642  if(nedtext != NULL)
3643  {
3644  if( ((HDate *)data)->is_unknown_alive() && ((HDate *)data)->is_value_unknown() )
3645  nedtext->setText(GSAFETEXT_TEXT_UNKNOWN);
3646  else
3647  nedtext->setText(data->getValue().toString());
3648  }
3649  return 0;
3650 }
3651 
3652 int HDispDate::updateStaticGuiElementsSlot(void)
3653 {
3654  if(explain != NULL)
3655  explain->setText(data->getExplainText());
3656  return 0;
3657 }
3658 
3659 HDispDate::~HDispDate(void)
3660 {
3661 }
3662 
3663 // ///////////////////////////////////////////////////////////////////////////////
3664 
3665 HDispTimestamp::HDispTimestamp(QWidget *parent,HDataField *d,bool _ro_mask)
3666 : HDispDataField(parent,d,_ro_mask)
3667 {
3668  nedtext = NULL;
3669 
3670  explain = new QLabel(this);
3671  explain->setText(data->getExplainText());
3672  sublayout->addWidget(explain);
3673 
3674  if(!d->isNoMiddleStretch())
3675  sublayout->addStretch();
3676 
3677  nedtext = new QLabel(this);
3678  nedtext->setText(data->dbValueToDispValue(data->getValue()).toString());
3679  sublayout->addWidget(nedtext);
3680 
3681 }
3682 
3683 void HDispTimestamp::enableControl(void)
3684 {
3685 }
3686 
3687 void HDispTimestamp::disableControl(void)
3688 {
3689 }
3690 
3691 int HDispTimestamp::updateDisplaySlot(void)
3692 {
3693  nedtext->setText( data->getValue().toString() );
3694  return 0;
3695 }
3696 
3697 int HDispTimestamp::updateStaticGuiElementsSlot(void)
3698 {
3699  if(explain != NULL)
3700  explain->setText(data->getExplainText());
3701  return 0;
3702 }
3703 
3704 HDispTimestamp::~HDispTimestamp(void)
3705 {
3706 }
3707 
3708 // ///////////////////////////////////////////////////////////////////////////////
3709 
3710 HDispSqlChoose::HDispSqlChoose(QWidget *parent,HDataField *d,bool _ro_mask)
3711 : HDispDataField(parent,d,_ro_mask)
3712 {
3713  edval = NULL;
3714  nedtext = NULL;
3715  rfbutt = NULL;
3716  pbutt = NULL;
3717  int curr;
3718 
3719  explain = new QLabel(this);
3720  explain->setText(data->getExplainText());
3721  sublayout->addWidget(explain);
3722 
3723  if(!d->isNoMiddleStretch())
3724  sublayout->addStretch();
3725  if(!ro_mask && data->isEditable())
3726  {
3727  if(((HSqlChoose *)data)->getEasyForm())
3728  {
3729  edval = new QComboBox(this);
3730  edval->clear();
3731 
3732  if(((HSqlChoose *)data)->getKeys().count() == 0)
3733  {
3734  QString mess;
3735  mess=QString("Warning: You selected an sqlchoose with easyform,\n"
3736  "but you don't have any element in the targetted table!\n"
3737  "You can't use initial null value in easyform sqlchoose!\n"
3738  "(%1)")
3739  .arg(data->sqlInsertHead());
3740 
3741  sdebug(mess);
3742  error(mess);
3743  }
3744  else
3745  {
3746  edval->addItems( ((HSqlChoose *)data)->getValues() );
3747  curr = getIndexOf( ((HSqlChoose *)data)->getKeys() , data->getValue().toString());
3748  //I'll set it. (The result is same, unless is bullshit the value)
3749  data->setValue(QVariant((((HSqlChoose *)data)->getKeys())[curr] ));
3750  itemSelected(curr);
3751  edval->setCurrentIndex(curr);
3752  }
3753 
3754  rfbutt = new QToolButton(this);
3755  rfbutt->setIcon( QPixmap( (const char **) refreshbutton_data ) );
3756  sublayout->addWidget(edval);
3757  sublayout->addWidget(rfbutt);
3758  if(!connect(edval,SIGNAL(activated(int)),this,SLOT(itemSelected(int))))
3759  error("Error, connect(edval,SIGNAL(activated(int)),this,SLOT(itemSelected(int)))");
3760  if(!connect(rfbutt,SIGNAL(clicked()),this,SLOT(refresh())))
3761  error("Error, connect(rfbutt,SIGNAL(clicked()),this,SLOT(refresh()))");
3762  }
3763  else
3764  {
3765  pbutt = new QPushButton(this);
3766 
3767  if(data->getValue().toString() == "NULL" || ((HSqlChoose *)data)->getKeys().count() == 0)
3768  {
3769  curr = -1;
3770  pbutt->setText(" - ");
3771  }
3772  else
3773  {
3774  curr = getIndexOf( ((HSqlChoose *)data)->getKeys() , data->getValue().toString());
3775  pbutt->setText((((HSqlChoose *)data)->getValues())[curr]);
3776  //I'll set it. (The result is same, unless is bullshit the value)
3777  data->setValue(QVariant( (((HSqlChoose *)data)->getKeys())[curr] ));
3778  }
3779 
3780  sublayout->addWidget(pbutt);
3781  if(!connect(pbutt,SIGNAL(clicked()),this,SLOT(popupSelector())))
3782  error("Error, connect(pbutt,SIGNAL(clicked()),this,SLOT(popupSelector()))");
3783 
3784  }
3785  }
3786  else
3787  {
3788  nedtext = new QLabel(this);
3789  if(data->getValue().toString() == "NULL")
3790  {
3791  curr = -1;
3792  nedtext->setText(" - ");
3793  }
3794  else
3795  {
3796  curr = getIndexOf( ((HSqlChoose *)data)->getKeys() , data->getValue().toString());
3797  nedtext->setText( (((HSqlChoose *)data)->getValues())[curr] );
3798  }
3799  sublayout->addWidget(nedtext);
3800  }
3801 }
3802 
3803 void HDispSqlChoose::enableControl(void)
3804 {
3805  if(edval != NULL)
3806  edval->setEnabled(true);
3807  if(pbutt != NULL)
3808  pbutt->setEnabled(true);
3809 }
3810 
3811 void HDispSqlChoose::disableControl(void)
3812 {
3813  if(edval != NULL)
3814  edval->setEnabled(false);
3815  if(pbutt != NULL)
3816  pbutt->setEnabled(false);
3817 }
3818 
3819 int HDispSqlChoose::popupSelector(void)
3820 {
3821  pupup_dialog=new SqlChooseDialog(this);
3822  /*The dialog box is connected to slot of this class(HDispSqlChoose)
3823  This slot is set the selected data, and call the close of the dialog.
3824  We don't do anything here, just cleans the data */
3825  pupup_dialog->exec();
3826  delete pupup_dialog;
3827  return 0;
3828 }
3829 
3830 int HDispSqlChoose::refresh(void) //SLOT
3831 {
3832  ((HSqlChoose *)data)->refreshSqlValues();
3833  updateDisplaySlot();
3834  return 0;
3835 }
3836 
3837 int HDispSqlChoose::itemSelected(int index) //SLOT
3838 {
3839  data->setValue(QVariant( (((HSqlChoose *)data)->getKeys())[index] ));
3840  return 0;
3841 }
3842 
3843 int HDispSqlChoose::updateDisplaySlot(void)
3844 {
3845  sdebug("*** HDispSqlChoose::updateDisplaySlot ***");
3846  int curr;
3847 
3848  if(data->getValue().toString() == "NULL" || ((HSqlChoose *)data)->getKeys().count() == 0)
3849  curr = -1;
3850  else
3851  curr = getIndexOf( (((HSqlChoose *)data)->getKeys()) , data->getValue().toString());
3852 
3853  if(edval != NULL)
3854  {
3855  if(curr == -1)
3856  curr = 0;
3857  edval->clear();
3858  edval->addItems( ((HSqlChoose *)data)->getValues() );
3859  edval->setCurrentIndex(curr);
3860  }
3861 
3862  if(pbutt != NULL)
3863  {
3864  if(curr == -1)
3865  pbutt->setText(" - ");
3866  else
3867  pbutt->setText((((HSqlChoose *)data)->getValues())[curr]);
3868  }
3869 
3870  if(nedtext != NULL)
3871  {
3872  if(curr == -1)
3873  nedtext->setText(" - ");
3874  else
3875  nedtext->setText( (((HSqlChoose *)data)->getValues())[curr]);
3876  }
3877  sdebug("*** HDispSqlChoose::updateDisplaySlot ***END");
3878  return 0;
3879 }
3880 
3881 int HDispSqlChoose::updateStaticGuiElementsSlot(void)
3882 {
3883  if(explain != NULL)
3884  explain->setText(data->getExplainText());
3885  return 0;
3886 }
3887 
3888 void HDispSqlChoose::setToolbarbuttonSignalOn(QString text)
3889 {
3890  ((HSqlChoose *)data)->toolbarbutton_down_text = text;
3891 }
3892 
3893 void HDispSqlChoose::setToolbarbuttonSignalOff()
3894 {
3895  ((HSqlChoose *)data)->toolbarbutton_down_text = "";
3896 }
3897 
3898 int HDispSqlChoose::itemSelected(const QString& s)
3899 {
3900  if(s.isEmpty())
3901  return 0;
3902  data->setValue(QVariant( s ));
3903  pupup_dialog->close();
3904  updateDisplaySlot();
3905  return 0;
3906 }
3907 
3908 HDispSqlChoose::~HDispSqlChoose(void)
3909 {
3910 }
3911 
3912 SqlChooseDialog::SqlChooseDialog( HDispSqlChoose* p )
3913 : QDialog( p , Qt::WindowMaximizeButtonHint|Qt::WindowCloseButtonHint)
3914 {
3915  int i;
3916  setModal(true);
3917  parent = p;
3918  SqlChooseDialogLayout = new QVBoxLayout(this);
3919  SqlChooseDialogLayout->setMargin(11);
3920  SqlChooseDialogLayout->setSpacing(6);
3921 
3922  disabled_recvkey = true;
3923 
3924  table = new HTableBrowser( this );
3925  SqlChooseDialogLayout->addWidget( table );
3926 
3927  layout1 = new QHBoxLayout(0);
3928  layout1->setMargin(0);
3929  layout1->setSpacing(6);
3930 
3931  QSpacerItem* spacer = new QSpacerItem( 50, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
3932  layout1->addItem( spacer );
3933 
3934  button = new QPushButton(this);
3935  button->setText( GSAFETEXT_DISPSQLCH_SELECTBUTTON );
3936 
3937  QPushButton *xbutton = new QPushButton(this);
3938 
3939  xbutton->setMinimumHeight(25);
3940  xbutton->setMinimumWidth (25);
3941  xbutton->setMaximumHeight(25);
3942  xbutton->setMaximumWidth (25);
3943  xbutton->setText("N");
3944 
3945  layout1->addWidget( xbutton );
3946  layout1->addWidget( button );
3947 
3948  if( parent->getHSqlChoose()->toolbrec != NULL && !parent->getHSqlChoose()->btext.isEmpty() )
3949  {
3950  QPushButton *plusbutton = new QPushButton(this);
3951  plusbutton->setText(parent->getHSqlChoose()->btext);
3952  //own chain:
3953  if(!connect(plusbutton,SIGNAL(clicked()),this,SLOT(toolbarButtonClicked())))
3954  error("Cannot connect to the plus_toolbar button!");
3955  //chaining out...
3956  if(!connect(this,SIGNAL(callToolButtonHandler()),parent->getHSqlChoose()->toolbrec,SLOT(toolbuttonclicked()) ))
3957  error("Cannot connect to the plus_toolbar button!");
3958 
3959  if(!connect(parent->getHSqlChoose()->toolbrec,SIGNAL(setKeyTo(QString)),this,SLOT(receivedASelectedKey(QString))))
3960  {
3961  ; //do nothing, it's normal
3962  }
3963 
3964  layout1->addWidget( plusbutton );
3965  }
3966 
3967  //Extra functionality
3968  have_extra_func = false;
3969  for(i=0;i<5;++i)
3970  if(!parent->getHSqlChoose()->extrafunc_text[i].isEmpty())
3971  {
3972  have_extra_func = true;
3973  switch(i)
3974  {
3975  case 0:
3976  connect(this,SIGNAL(sigToExtraFunc_0(QString)),
3977  parent->getHSqlChoose()->extrafunc_receiver[i],SLOT(extrafunc_0(QString))); break;
3978  case 1:
3979  connect(this,SIGNAL(sigToExtraFunc_1(QString)),
3980  parent->getHSqlChoose()->extrafunc_receiver[i],SLOT(extrafunc_1(QString))); break;
3981  case 2:
3982  connect(this,SIGNAL(sigToExtraFunc_2(QString)),
3983  parent->getHSqlChoose()->extrafunc_receiver[i],SLOT(extrafunc_2(QString))); break;
3984  case 3:
3985  connect(this,SIGNAL(sigToExtraFunc_3(QString)),
3986  parent->getHSqlChoose()->extrafunc_receiver[i],SLOT(extrafunc_3(QString))); break;
3987  case 4:
3988  connect(this,SIGNAL(sigToExtraFunc_4(QString)),
3989  parent->getHSqlChoose()->extrafunc_receiver[i],SLOT(extrafunc_4(QString))); break;
3990  }
3991  }
3992 
3993  if(have_extra_func)
3994  {
3995  connect(table,SIGNAL(alternateActivateItem(const QString& )),
3996  this,SLOT(popUpMenuActivated(const QString&)));
3997  }
3998 
3999  QSpacerItem* spacer_2 = new QSpacerItem( 50, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
4000  layout1->addItem( spacer_2 );
4001  SqlChooseDialogLayout->addLayout( layout1 );
4002 
4003  setWindowTitle(parent->getHSqlChoose()->getPopupDialogTitle().isEmpty()
4005  : parent->getHSqlChoose()->getPopupDialogTitle()
4006  );
4007 
4008  updateList();
4009 
4010  resize( QSize(300, 300).expandedTo(minimumSizeHint()) );
4011 
4012  //event handling of own gui elements
4013  connect(xbutton,SIGNAL(clicked()),this,SLOT(nullButtonPressed()));
4014  connect(button,SIGNAL(clicked()),this,SLOT(buttonPressed()));
4015  connect(table,SIGNAL(activateItem(const QString& )),
4016  this,SLOT(listviewitemSelected(const QString& )));
4017  //connecting, and data passig to parents (I connect the parent to my signal)
4018  connect(this,SIGNAL(itemSelected(const QString&))
4019  ,parent,SLOT(itemSelected(const QString&)));
4020 
4021  if(HRefreshAgent::getNotifyAgent() != NULL)
4022  connect(HRefreshAgent::getNotifyAgent(),SIGNAL(getnotify(QString)),
4023  this,SLOT(captureNotify(QString)));
4024 
4025  setSizeGripEnabled(true);
4026  setWindowState(Qt::WindowActive);
4027 }
4028 
4029 int SqlChooseDialog::captureNotify(QString tblname)
4030 {
4031  sdebug("*** SqlChooseDialog::captureNotify ***");
4032  QStringList::iterator i;
4033 
4034  sdebug(QString(" %1 == %2").arg(tblname).arg(parent->getHSqlChoose()->getConnectedTableName()));
4035  if(parent->getHSqlChoose()->getConnectedTableName() == tblname)
4036  {
4037  sdebug("Call updateList()");
4038  updateList();
4039  }
4040  return 0;
4041 }
4042 
4043 int SqlChooseDialog::updateList(void)
4044 {
4045  int i;
4046  HPleaseWaitWindow *pww = NULL;
4047 
4048  sdebug("*** SqlChooseDialog::updateList ***");
4049  table->clear();
4050 
4051  QString headertext="";
4052  HTableBrowserElement *record;
4053 
4054  #ifdef PROGRESS_POSSIBILITY
4055  if(parent->getHSqlChoose()->progress_on_read)
4056  {
4057  pww = HPleaseWaitWindow::start();
4058  if(!connect(parent->getHSqlChoose(),SIGNAL(doWorking()),pww,SLOT(progress())))
4059  sdebug("Cannot connect the SQLChoose-progress-signal to progress-dialog-slot!");
4060  }
4061  #endif
4062 
4063  parent->getHSqlChoose()->refreshSqlValues(false);
4064  headertext=parent->getHSqlChoose()->getFieldHeads();
4065  QStringList v = parent->getHSqlChoose()->getSeparatedValues();
4066  QStringList k = parent->getHSqlChoose()->getKeys();
4067  QStringList h;
4068 
4069  if(headertext.isEmpty())
4070  { h = QString("A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|R|S|T").split("|",QString::SkipEmptyParts); }
4071  else
4072  { h = headertext.split("|",QString::SkipEmptyParts); }
4073  table->setHeadTexts(h);
4074  QStringList::Iterator itv = v.begin();
4075  QStringList::Iterator itk = k.begin();
4076  while ( itv != v.end() && itk != k.end() )
4077  {
4078  QStringList vals = itv->split("|",QString::KeepEmptyParts);
4079  table->addElement( record = new HTableBrowserElement(*itk,&vals) );
4080  ++itv;
4081  ++itk;
4082  }
4083 
4084  if((i = parent->getHSqlChoose()->getGuiSortIndicator()) != -1)
4085  table->sort(i);
4086 
4087  #ifdef PROGRESS_POSSIBILITY
4088  if(pww != NULL)
4090  #endif
4091 
4092  table->setCurrentElement(parent->getHSqlChoose()->getValue().toString());
4093  return 0;
4094 }
4095 
4096 int SqlChooseDialog::popUpMenuActivated(const QString& key)
4097 {
4098  sdebug("*** SqlChooseDialog::popUpMenuActivated ***");
4099  int i;
4100  QMenu *popup = new QMenu(this);
4101  popup->setTitle(QString("Function on \"%1\"").arg(key));
4102  popup->addAction(" ");
4103  popup->addSeparator();
4104 
4105  for(i=0;i<5;++i)
4106  if(!parent->getHSqlChoose()->extrafunc_text[i].isEmpty())
4107  {
4108  switch(i)
4109  {
4110  case 0:
4111  popup->addAction(parent->getHSqlChoose()->extrafunc_text[i],this,SLOT(popup_catch_0()));
4112  break;
4113  case 1:
4114  popup->addAction(parent->getHSqlChoose()->extrafunc_text[i],this,SLOT(popup_catch_1()));
4115  break;
4116  case 2:
4117  popup->addAction(parent->getHSqlChoose()->extrafunc_text[i],this,SLOT(popup_catch_2()));
4118  break;
4119  case 3:
4120  popup->addAction(parent->getHSqlChoose()->extrafunc_text[i],this,SLOT(popup_catch_3()));
4121  break;
4122  case 4:
4123  popup->addAction(parent->getHSqlChoose()->extrafunc_text[i],this,SLOT(popup_catch_4()));
4124  break;
4125  }
4126  }
4127  popupped_key = key;
4128  popup->exec(table->mapToGlobal(QPoint(table->mouseRightClickPosX,table->mouseRightClickPosY)));
4129  delete popup;
4130  return 0;
4131 }
4132 
4133 int SqlChooseDialog::popup_catch_0(void) { emit sigToExtraFunc_0(popupped_key); return 0; }
4134 int SqlChooseDialog::popup_catch_1(void) { emit sigToExtraFunc_1(popupped_key); return 0; }
4135 int SqlChooseDialog::popup_catch_2(void) { emit sigToExtraFunc_2(popupped_key); return 0; }
4136 int SqlChooseDialog::popup_catch_3(void) { emit sigToExtraFunc_3(popupped_key); return 0; }
4137 int SqlChooseDialog::popup_catch_4(void) { emit sigToExtraFunc_4(popupped_key); return 0; }
4138 
4139 int SqlChooseDialog::toolbarButtonClicked(void)
4140 {
4141  QString ckey;
4142 
4143  parent->setToolbarbuttonSignalOn( parent->getHSqlChoose()->btext );
4144  key_received = false;
4145  ckey = table->currentKey();
4146  disabled_recvkey = false;
4147  emit callToolButtonHandler();
4148 
4149  disabled_recvkey = true;
4150 
4151  updateList();
4152 
4153  if(key_received)
4154  ckey = received_key;
4155 
4156  table->setCurrentElement(ckey);
4157  key_received = false;
4158  parent->setToolbarbuttonSignalOff();
4159  return 0;
4160 }
4161 
4162 int SqlChooseDialog::nullButtonPressed(void)
4163 {
4164  QString k;
4165  k = "NULL";
4166  emit itemSelected(k);
4167  return 0;
4168 }
4169 
4170 int SqlChooseDialog::buttonPressed(void)
4171 {
4172  QString k;
4173  k = table->currentKey();
4174  emit itemSelected(k);
4175  return 0;
4176 }
4177 
4178 int SqlChooseDialog::listviewitemSelected(const QString& s)
4179 {
4180  sdebug(" *** SqlChooseDialog::listviewitemSelected *** ");
4181  emit itemSelected(s);
4182  sdebug(" *** SqlChooseDialog::listviewitemSelected *** END");
4183  return 0;
4184 }
4185 
4186 SqlChooseDialog::~SqlChooseDialog()
4187 {
4188  delete table;
4189 }
4190 
4191 int SqlChooseDialog::receivedASelectedKey(QString key)
4192 {
4193  if(disabled_recvkey)
4194  return 0;
4195  if(key.isEmpty())
4196  return 0;
4197 
4198  received_key = key;
4199  key_received = true;
4200  return 0;
4201 }
4202 
4203 // /////////////////////////////////////////////////////////////////////////////////////
4204 
4205 HShowPrintHtml::HShowPrintHtml(QWidget *parent)
4206 : QDialog(parent)
4207 {
4208  QVBoxLayout *vl = new QVBoxLayout(this);
4209  QHBoxLayout *toolbuttons = new QHBoxLayout(0);
4210  QHBoxLayout *bottom = new QHBoxLayout(0);
4211 
4212  QToolButton *tp = new QToolButton(this);
4213  QToolButton *tst = new QToolButton(this);
4214  QToolButton *ts = new QToolButton(this);
4215 
4216  tp->setIcon(QPixmap(image_P));
4217  ts->setIcon(QPixmap(image_Y));
4218  tst->setIcon(QPixmap(image_E));
4219  toolbuttons->addWidget(tp);
4220  toolbuttons->addSpacing(3);
4221  toolbuttons->addWidget(tst);
4222  toolbuttons->addSpacing(3);
4223  toolbuttons->addWidget(ts);
4224  toolbuttons->addStretch();
4225 
4226  QPushButton *okbutt = new QPushButton("Ok",this);
4227  bottom->addStretch();
4228  bottom->addWidget(okbutt);
4229  bottom->addStretch();
4230 
4231 #ifdef WEBKITBASED_HTMLSHOW
4232  te = new QWebView(this);
4233 #else
4234  te = new QTextEdit(this);
4235  te->setReadOnly(true);
4236 #endif
4237 
4238  vl->addLayout(toolbuttons);
4239  vl->addWidget(te);
4240  vl->addLayout(bottom);
4241 
4242  connect(tp,SIGNAL(clicked()),this,SLOT(slotPrint()));
4243  connect(ts,SIGNAL(clicked()),this,SLOT(slotSave()));
4244  connect(tst,SIGNAL(clicked()),this,SLOT(slotStart()));
4245 
4246  connect(okbutt,SIGNAL(clicked()),this,SLOT(accept()));
4247  setSizeGripEnabled(true);
4248  html="";
4249 
4250  resize(640,480);
4251 }
4252 
4253 void HShowPrintHtml::setWinTitle(QString t)
4254 {
4255  setWindowTitle(t);
4256 }
4257 
4258 void HShowPrintHtml::setContent(QString str)
4259 {
4260  te->setHtml(html=str);
4261 }
4262 
4263 void HShowPrintHtml::slotSave(void)
4264 {
4265  QString o;
4266  o = QFileDialog::getSaveFileName(this,"The output .html file","","*.html");
4267 
4268  if(o.isEmpty())
4269  return;
4270  QFile f(o);
4271  if (f.open(QIODevice::WriteOnly))
4272  {
4273  QTextStream *s = new QTextStream(&f); // we will serialize the data into file f
4274  //s->setCodec(QTextCodec::codecForName("UTF-8"));
4275  *s << html;
4276  f.close();
4277  delete s;
4278  }
4279  else
4280  {
4281  error("Cannot create file!");
4282  return;
4283  }
4284 
4285 }
4286 
4287 void HShowPrintHtml::slotStart(void)
4288 {
4289  QString o="_temptoext_edit.html";
4290  QFile f(o);
4291  if (f.open(QIODevice::WriteOnly))
4292  {
4293  QTextStream *s = new QTextStream(&f);
4294  *s << convNationalToHtmlCodes(html);
4295  f.close();
4296  delete s;
4297  }
4298  else
4299  {
4300  error("Cannot create temporally file!");
4301  return;
4302  }
4303 
4304  QString program = EXT_EDIT_PROCESS;
4305  QStringList arguments;
4306  arguments << o ;
4307 
4308  QProcess *myProcess = new QProcess(this);
4309  myProcess->start(program, arguments);
4310 
4311  QDialog *d = new QDialog(this);
4312  d->setModal(true);
4313  d->setWindowTitle(GSAFETEXT_CALLEXTERNAL);
4314  QLabel *l=new QLabel(d);
4315  l->setText(GSAFETEXT_STARTDIATEXT1 EXT_EDIT_PROCESS GSAFETEXT_STARTDIATEXT2);
4316 
4317  QHBoxLayout *lay = new QHBoxLayout(d);
4318  lay->addWidget(l);
4319  d->resize(200,100);
4320  connect(myProcess,SIGNAL(finished(int,QProcess::ExitStatus)),d,SLOT(close()));
4321 
4322  d->exec();
4323 
4324  delete d;
4325  delete myProcess;
4326  }
4327 
4328 void HShowPrintHtml::slotPrint(void)
4329 {
4330  QPrinter *printer = new QPrinter();
4331  printer->setPageSize(QPrinter::A4);
4332  QPrintDialog printDialog(printer, this);
4333 
4334  if (printDialog.exec() == QDialog::Accepted)
4335  {
4336 
4337 #ifdef WEBKITBASED_HTMLSHOW
4338  te->print(printer);
4339 #else
4340  int dpi = printer->logicalDpiY();
4341  QTextDocument *textdoc = te->document();
4342 
4343  QRectF pageRect(printer->pageRect());
4344  QRectF body = QRectF(0,0, pageRect.width(),pageRect.height());
4345 
4346  textdoc->setPageSize(body.size());
4347 
4348  QTextFrame *rootframe = textdoc->rootFrame();
4349  QTextFrameFormat tff = rootframe->frameFormat();
4350 
4351  //setting up 2 cm margin
4352  tff.setMargin((2/2.54)*dpi);
4353  tff.setTopMargin((2/2.54)*dpi);
4354  tff.setLeftMargin((2/2.54)*dpi);
4355  tff.setRightMargin((2/2.54)*dpi);
4356  tff.setBottomMargin((2/2.54)*dpi);
4357 
4358  rootframe->setFrameFormat(tff);
4359 
4360  textdoc->print(printer);
4361 #endif
4362  }
4363 }
4364 
4365 
4366 HShowPrintHtml::~HShowPrintHtml(void)
4367 {
4368 
4369 }
4370 
4372 
4374 
4375 HPleaseWaitWindow::HPleaseWaitWindow(int sizex_,int sizey_,int refreshTime_) :
4376 QWidget(0,Qt::SplashScreen | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::BypassGraphicsProxyWidget)
4377  {
4378  sizex = sizex_;
4379  sizey = sizey_;
4380 
4381  refreshTime = refreshTime_;
4382  setMinimumSize(sizex,sizey);
4383  setMaximumSize(sizex,sizey);
4384 
4385  //determine the window position
4386  if(QApplication::activeWindow() == NULL)
4387  {
4388  QRect r;
4389  QDesktopWidget *d = QApplication::desktop();
4390  r = d->screenGeometry();
4391  setGeometry((r.width()-sizex)/2,(r.height()-sizey)/2,sizex,sizey);
4392  }
4393  else
4394  {
4395  QWidget *w;
4396 
4397  w = QApplication::activeWindow();
4398  QPoint gpos=w->mapToGlobal(QPoint(0,0));
4399  setGeometry(gpos.x()+((w->width()-sizex)/2),gpos.y()+((w->height()-sizey)/2),sizex,sizey);
4400  }
4401 
4402  /*Get the firt value of the timer*/
4403  t=QTime::currentTime();
4404  seq=0;
4405  show();
4406  }
4407 
4408 HPleaseWaitWindow::~HPleaseWaitWindow(void)
4409 {
4410 
4411 }
4412 
4414  {
4415  QTime tt;
4416  tt=QTime::currentTime();
4417  if(t.msecsTo(tt) < refreshTime) return;
4418  t = tt;
4419 
4420  if(!isActiveWindow())
4421  show();
4422 
4423  update();
4424  QApplication::processEvents();
4425  }
4426 
4427 void HPleaseWaitWindow::mousePressEvent(QMouseEvent *me)
4428  {
4429  lastx = me->x();
4430  lasty = me->y();
4431  }
4432 
4433 void HPleaseWaitWindow::mouseMoveEvent(QMouseEvent *me)
4434  {
4435  move(me->globalX()-lastx,me->globalY()-lasty);
4436  }
4437 
4438 void HPleaseWaitWindow::paintEvent(QPaintEvent *e)
4439  {
4440  Q_UNUSED(e);
4441 
4442  int i;
4443  QPainter p(this);
4444 
4445  p.setRenderHint(QPainter::Antialiasing);
4446  p.setClipping(FALSE);
4447  p.drawRect(1,1,78,78);
4448 
4449  p.setBrush(Qt::SolidPattern);
4450 
4451  for(i=0;i<=7;i++)
4452  {
4453  p.setBrush(QColor(7*30-i*30,7*30-i*30,7*30-i*30));
4454  p.setPen(QColor(7*30-i*30,7*30-i*30,7*30-i*30));
4455  p.drawPie(15,15,50,50,360*16-(seq*640+i*10*16),10*16);
4456  }
4457 
4458  if(++seq==9) seq=0;
4459  }
4460 
4462  {
4463  if(pww == NULL)
4464  {
4465  pww = new HPleaseWaitWindow();
4466  pww->progress();
4467  }
4468  return pww;
4469  }
4470 
4472  {
4473  if(pww != NULL)
4474  pww->progress();
4475  return;
4476  }
4477 
4479  {
4480  if(pww != NULL)
4481  {
4482  pww->close();
4483  delete pww;
4484  pww=NULL;
4485  }
4486  return;
4487  }
4488 
4490 
4491 HDecorDialog::HDecorDialog(QWidget *parent,QString title,int no_action_closetime)
4492 : QDialog(parent,Qt::FramelessWindowHint)
4493 {
4494  setModal(true);
4495  setMouseTracking(true);
4496 
4497  this->no_action_closetime = no_action_closetime;
4498  this->title = title;
4499 
4500  anywhere_click_close = false;
4501  dont_reset_timer = false;
4502 
4503  titlefont = QFont("times", 24);
4504  bgcolor = QColor(80,80,80); //QColor(100,100,255);
4505  framewidth = 10;
4506  frcolor = QColor(255,0,0);
4507  titleheight = 80;
4508  closerwidth = 80;
4509  crossthick = 10;
4510  crossmargin = 10;
4511  titlecolor = QColor(0,0,0);
4512  indcolor = QColor(160,100,100);
4513 
4514  t_time = 100;
4515  if(no_action_closetime != 0)
4516  {
4517  end_t = ((int)(1000 / t_time)) * no_action_closetime;
4518  t_t = 0;
4519  QTimer::singleShot(t_time,this,SLOT(incr_t()));
4520  }
4521  setTitleFont(titlefont);
4522 }
4523 
4525 {
4526  int mw;
4527 
4528  titlefont = f;
4529  QFontMetrics fm(titlefont);
4530  mw = fm.width(title);
4531  mw += 4*framewidth+closerwidth+20;
4532  setMinimumWidth(mw);
4533  update();
4534 }
4535 
4536 int HDecorDialog::incr_t(void)
4537 {
4538  ++t_t;
4539  if(t_t >= end_t)
4540  {
4541  close();
4542  }
4543  else
4544  {
4545  update();
4546  QTimer::singleShot(t_time,this,SLOT(incr_t()));
4547  }
4548  return 0;
4549 }
4550 
4551 void HDecorDialog::paintEvent(QPaintEvent *pe)
4552 {
4553 
4554  QPainter p(this);
4555 
4556  p.setRenderHint(QPainter::Antialiasing);
4557  p.fillRect(0,0,width(),height(),QBrush(bgcolor,Qt::SolidPattern));
4558  p.setPen(frcolor);
4559  p.drawRect(framewidth,framewidth,width()-2*framewidth-1,height()-2*framewidth-1);
4560  p.fillRect(framewidth,framewidth,width()-2*framewidth-1,titleheight,QBrush(frcolor,Qt::SolidPattern));
4561  p.setPen(titlecolor);
4562  p.drawText(framewidth,framewidth,width()-2*framewidth-closerwidth-1,titleheight,Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextSingleLine ,title);
4563  p.fillRect(width()-framewidth-closerwidth,framewidth+2,closerwidth-2,titleheight-4,QBrush(titlecolor,Qt::SolidPattern));
4564  if(t_t >= (int)((1000 / t_time)))
4565  {
4566  float max,curr;
4567  max = end_t-(1000 / t_time);
4568  curr = t_t -(1000 / t_time);
4569  p.setPen(indcolor);
4570  p.setBrush(QBrush(indcolor,Qt::SolidPattern));
4571  p.drawPie(width()-framewidth-closerwidth+(3),framewidth+2+(3),closerwidth-2-(6),titleheight-4-(6),0,/*2*3.1416f*/5760*(curr/max));
4572  }
4573 
4574  p.setPen(QPen(QBrush(frcolor,Qt::SolidPattern),crossthick,Qt::SolidLine,Qt::RoundCap));
4575  p.drawLine(width()-framewidth-closerwidth+crossmargin,
4576  framewidth+2+crossmargin,
4577  width()-framewidth-closerwidth+closerwidth-2-crossmargin,
4578  framewidth+2+titleheight-4-crossmargin);
4579  p.drawLine(width()-framewidth-closerwidth+crossmargin,
4580  framewidth+2+titleheight-4-crossmargin ,
4581  width()-framewidth-closerwidth+closerwidth-2-crossmargin,
4582  framewidth+2+crossmargin);
4583 
4584  QDialog::paintEvent(pe);
4585 
4586 }
4587 
4588 void HDecorDialog::mousePressEvent(QMouseEvent *e)
4589 {
4591  {
4592  close();
4593  return;
4594  }
4595 
4596  if(e->x() > width()-framewidth-closerwidth &&
4597  e->x() < width()-framewidth-closerwidth+closerwidth-2 &&
4598  e->y() > framewidth+2 &&
4599  e->y() < framewidth+2+titleheight-4 )
4600  {
4601  close();
4602  }
4603  if(!dont_reset_timer)
4604  t_t = 0;
4605 }
4606 
4607 void HDecorDialog::mouseMoveEvent(QMouseEvent *e)
4608 {
4609  Q_UNUSED(e);
4610  if(!dont_reset_timer)
4611  t_t = 0;
4612 }
4613 
4614 void HDecorDialog::keyPressEvent(QKeyEvent *e)
4615 {
4616  Q_UNUSED(e);
4617  if(!dont_reset_timer)
4618  t_t = 0;
4619 }
4620 
4622 
4623 HPressButton::HPressButton(QWidget *parent,QString text,QString code)
4624 : QFrame(parent)
4625 {
4626  size_sync = NULL;
4627  textstr = text;
4628  idstr = code;
4629  font = QApplication::font();
4630  font.setBold(true);
4631  font.setPointSize(8);
4632  cmargin = 5;
4633  c3deffect = 15;
4634 
4635  r=200; rd=3;
4636  g=200; gd=3;
4637  b=200; bd=3;
4638 
4639  setFocusPolicy(Qt::StrongFocus);
4640 
4641  mid = false;
4642  down = false;
4643 
4644  hidestat = false;
4645  enablestat = true;
4646  calcSize();
4647 }
4648 
4650 {
4651 
4652 }
4653 
4655 {
4656  hidestat = true;
4657  update();
4658  return 0;
4659 }
4661 {
4662  hidestat = false;
4663  update();
4664  return 0;
4665 }
4666 
4668 {
4669  enablestat = enable;
4670  update();
4671  return 0;
4672 
4673 }
4674 
4675 void HPressButton::setEffect(int effectwidth)
4676 {
4677  c3deffect = effectwidth;
4678  calcSize();
4679 }
4680 
4681 void HPressButton::setMargin(int margin)
4682 {
4683  cmargin = margin;
4684  calcSize();
4685 }
4686 
4688 {
4689  font.setPointSize(size);
4690  calcSize();
4691 }
4692 
4693 
4695 {
4696  calcSize();
4697  return 0;
4698 }
4699 
4700 void HPressButton::calcSize()
4701 {
4702  int x,y;
4703  QFontMetrics fm(font);
4704  QRect boundingr;
4705 
4706  boundingr = fm.boundingRect(textstr);
4707 
4708  x = boundingr.width() + 2*(c3deffect + cmargin);
4709  y = boundingr.height() + 2*(c3deffect + cmargin);
4710  if(size_sync != NULL)
4711  {
4712  if(size_sync->mx < x ) size_sync->mx = x;
4713  if(size_sync->my < y ) size_sync->my = y;
4714  x = size_sync->mx;
4715  y = size_sync->my;
4716  }
4717  setMinimumSize(x,y);
4718  resize(x,y);
4719 }
4720 
4721 void HPressButton::setColor(int red,int green,int blue)
4722 {
4723  r = red;
4724  g = green;
4725  b = blue;
4726 
4727  if(r < c3deffect*rd) r=c3deffect*rd;
4728  if(g < c3deffect*gd) g=c3deffect*gd;
4729  if(b < c3deffect*bd) b=c3deffect*bd;
4730 
4731  if(r + c3deffect*rd > 255) r=255-c3deffect*rd;
4732  if(g + c3deffect*gd > 255) g=255-c3deffect*gd;
4733  if(b + c3deffect*bd > 255) b=255-c3deffect*bd;
4734 }
4735 
4736 void HPressButton::paintEvent(QPaintEvent *e)
4737 {
4738  int i,sx,sy,ex,ey;
4739  QPainter p(this);
4740 
4741 
4742  if(hidestat)
4743  {
4744  QWidget::paintEvent(e);
4745  return;
4746  }
4747 
4748  p.setRenderHint(QPainter::Antialiasing);
4749 
4750  sx = c3deffect;
4751  sy = c3deffect;
4752  ex = width()-c3deffect;
4753  ey = height()-c3deffect;
4754 
4755  p.fillRect(0,0,width(),height(),QBrush(QColor(r,g,b)));
4756 
4757  if(!down)
4758  for(i=0;i<c3deffect;++i)
4759  {
4760  p.setPen(QColor(r+rd*i,g+gd*i,b+bd*i)); p.drawLine(sx-i,sy-i,ex+i,sy-i);
4761  p.setPen(QColor(r-rd*i,g-gd*i,b-bd*i)); p.drawLine(ex+i,sy-i,ex+i,ey+i);
4762  p.setPen(QColor(r-rd*i,g-gd*i,b-bd*i)); p.drawLine(ex+i,ey+i,sx-i,ey+i);
4763  p.setPen(QColor(r+rd*i,g+gd*i,b+bd*i)); p.drawLine(sx-i,sy-i,sx-i,ey+i);
4764  }
4765  else
4766  for(i=0;i<c3deffect;++i)
4767  {
4768  p.setPen(QColor(r-rd*i,g-gd*i,b-bd*i)); p.drawLine(sx-i,sy-i,ex+i,sy-i);
4769  p.setPen(QColor(r+rd*i,g+gd*i,b+bd*i)); p.drawLine(ex+i,sy-i,ex+i,ey+i);
4770  p.setPen(QColor(r+rd*i,g+gd*i,b+bd*i)); p.drawLine(ex+i,ey+i,sx-i,ey+i);
4771  p.setPen(QColor(r-rd*i,g-gd*i,b-bd*i)); p.drawLine(sx-i,sy-i,sx-i,ey+i);
4772  }
4773 
4774  p.setFont(font);
4775  if(enablestat)
4776  p.setPen(QColor(0,0,0));
4777  else
4778  p.setPen(QColor(100,100,100));
4779 
4780  p.drawText(sx,sy+(down ? 1 : -1),ex-sx,ey-sy+(down ? 1 : -1),
4781  Qt::AlignHCenter | Qt::AlignVCenter , textstr);
4782 
4783  if(!enablestat)
4784  {
4785  p.setPen(QPen(QBrush(QColor(255,0,0),Qt::SolidPattern),6,Qt::SolidLine,Qt::RoundCap));
4786  p.drawLine(c3deffect+cmargin+15,
4787  c3deffect+cmargin,
4788  width()-(c3deffect+cmargin+15),
4789  height()-(c3deffect+cmargin));
4790  p.drawLine(c3deffect+cmargin+15,
4791  height()-(c3deffect+cmargin),
4792  width()-(c3deffect+cmargin+15),
4793  c3deffect+cmargin);
4794  }
4795 
4796  QWidget::paintEvent(e);
4797 }
4798 
4799 void HPressButton::keyPressEvent(QKeyEvent *e)
4800 {
4801  if(hidestat || !enablestat)
4802  {
4803  QFrame::keyPressEvent(e);
4804  return;
4805  }
4806 
4807  down = true;
4808  update();
4809  QFrame::keyPressEvent(e);
4810 }
4811 
4812 void HPressButton::keyReleaseEvent(QKeyEvent *e)
4813 {
4814  if(hidestat || !enablestat)
4815  {
4816  QFrame::keyReleaseEvent(e);
4817  return;
4818  }
4819 
4820  if(down)
4821  {
4822  emit clicked();
4823  emit clickedCode(idstr);
4824  }
4825  down = false;
4826  update();
4827  QFrame::keyReleaseEvent(e);
4828 }
4829 
4830 void HPressButton::mousePressEvent(QMouseEvent *e)
4831 {
4832  if(hidestat || !enablestat)
4833  {
4834  QFrame::mousePressEvent(e);
4835  return;
4836  }
4837 
4838  down = true;
4839  update();
4840  QFrame::mousePressEvent(e);
4841 }
4842 
4843 void HPressButton::mouseReleaseEvent(QMouseEvent *e)
4844 {
4845  if(hidestat || !enablestat)
4846  {
4847  QFrame::mouseReleaseEvent(e);
4848  return;
4849  }
4850 
4851  bool willemit=false;
4852 
4853  if(down)
4854  willemit = true;
4855  down = false;
4856  update();
4857  QFrame::mouseReleaseEvent(e);
4858 
4859  if(willemit)
4860  {
4861  emit clicked();
4862  emit clickedCode(idstr);
4863  }
4864 }
4865 
4866 void HPressButton::mouseMoveEvent(QMouseEvent *e)
4867 {
4868  if(hidestat || !enablestat)
4869  {
4870  QFrame::mouseMoveEvent(e);
4871  return;
4872  }
4873 
4874  if(down && ( e->x() < 0 || e->x() > width()))
4875  {
4876  down = false;
4877  update();
4878  return;
4879  }
4880 
4881  if(down && ( e->y() < 0 || e->y() > height()))
4882  {
4883  down = false;
4884  update();
4885  return;
4886  }
4887  QFrame::mouseMoveEvent(e);
4888 }
4889 
4891 {
4892  return new HPressButtonSizeSyncronizer();
4893 }
4894 
4895 // ///////////////////////////////////////////////////////////////////////////////
4896 // / Classes of HDynTable (and related) //////////////////////////////////////////
4897 // ///////////////////////////////////////////////////////////////////////////////
4898 
4900 {
4901  ccprogress = false;
4902  rfprogress = false;
4903  int c,r,cc,rr;
4904  QList<QString> hhead;
4905  QList<QString> vhead;
4906 
4907  this->dynt = dynt;
4908 
4909  dynt->firstElement();
4910  while(!dynt->isEnded())
4911  {
4912  if(!hhead.contains( dynt->currentElementColumnName() ))
4913  hhead.push_back( dynt->currentElementColumnName() );
4914  if(!vhead.contains( dynt->currentElementRowName() ))
4915  vhead.push_back( dynt->currentElementRowName() );
4916 
4917  dynt->nextElement();
4918  }
4919 
4920  c = hhead.count();
4921  r = vhead.count();
4922  qtw->setColumnCount(c);
4923  qtw->setRowCount(r);
4924 
4925  qtw->setHorizontalHeaderLabels(hhead);
4926  qtw->setVerticalHeaderLabels(vhead);
4927 
4928  QTableWidgetItem *item;
4929  bool f;
4930  QString val;
4931  for(cc = 0 ; cc < c ; ++cc)
4932  for(rr = 0; rr < r ; ++rr)
4933  {
4934  item = new QTableWidgetItem();
4935 
4936  f = false;
4937  dynt->firstElement();
4938  while(!dynt->isEnded())
4939  {
4940  if(dynt->currentElementRowName() == vhead[rr] &&
4941  dynt->currentElementColumnName() == hhead[cc] )
4942  {
4943  cellData cd;
4944 
4945  cd.name = dynt->currentElementName();
4946  cd.c = cc;
4947  cd.r = rr;
4948  cd.glink = item;
4949  cells.push_back(cd);
4950 
4951  f = true;
4952  val = dynt->currentElementValueString();
4953  }
4954  dynt->nextElement();
4955  }
4956 
4957  if(f)
4958  {
4959  item->setText(val);
4960  item->setBackground(Qt::white);
4961  }
4962  else
4963  {
4964  //item->setFlags(!Qt::ItemIsEnabled);
4965  item->setFlags(!Qt::ItemIsEditable);
4966  item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
4967 
4968  item->setBackground(Qt::darkGray);
4969  }
4970  qtw->setItem(rr,cc,item);
4971  }
4972  //change gui->data
4973  connect(qtw,SIGNAL(cellChanged(int,int)),this,SLOT(slotCellChanged(int,int)));
4974  //change data->gui
4975  connect(dynt,SIGNAL(dataChangedNongui()),this,SLOT(refreshGui()));
4976 }
4977 
4978 HDynTableDispConnector::~HDynTableDispConnector(void)
4979 {
4980  dynt = NULL;
4981  cells.clear();
4982 }
4983 
4985 {
4986  if(dynt == NULL)
4987  return 0;
4988  if(rfprogress)
4989  return 0;
4990  bool realchange;
4991  realchange = false;
4992  ccprogress = true;
4993  QTableWidgetItem *item = NULL;
4994  QList<cellData>::iterator i = cells.begin();
4995  while(i != cells.end())
4996  {
4997  if(i->r == row && i->c == column)
4998  {
4999  QColor c = Qt::white;
5000 
5001  item = i->glink;
5002  realchange = true;
5003  dynt->setElementValue(i->name,item->text());
5004  if(item->text() != dynt->getElementValueString(i->name))
5005  {
5006  realchange = false;
5007  c.setRgb(255,100,100);
5008  }
5009  item->setBackground(QBrush(c));
5010  }
5011  ++i;
5012  }
5013  ccprogress = false;
5014  if(realchange)
5015  emit dataChangedByGui();
5016  return 0;
5017 }
5018 
5020 {
5021  if(ccprogress)
5022  return 0;
5023  rfprogress = true;
5024  QTableWidgetItem *item = NULL;
5025  QList<cellData>::iterator i = cells.begin();
5026  while(i != cells.end())
5027  {
5028  item = i->glink;
5029  if(item != NULL)
5030  {
5031  item->setText( dynt->getElementValueString(i->name) );
5032  item->setBackground(QBrush(Qt::white));
5033  }
5034 
5035  ++i;
5036  }
5037  rfprogress = false;
5038  return 0;
5039 }
5040 
5041 //end code
HDataField * nextFieldAll(void)
Definition: datalib.cpp:2843
int recalcSize()
Definition: guilib.cpp:4694
void queryToCurrent(void)
Definition: guilib.cpp:1976
QStringList * queryNextValues(void)
Definition: guilib.cpp:1989
QString currentKey(void)
Definition: guilib.cpp:772
QString * queryNextKey(void)
Definition: guilib.cpp:2003
bool hasKey(QString key)
Definition: guilib.cpp:2016
int dialogPrint(void)
Definition: guilib.cpp:2641
HSpinBox(QWidget *parent)
HSpinBox ////////////////////////////////////////////////////////////////////.
Definition: guilib.cpp:531
HPlainDMD(QWidget *parent, HBase *d, bool htmlmode=false)
Definition: guilib.cpp:2318
static void step(void)
Definition: guilib.cpp:4471
bool nextRow(void)
Definition: datalib.cpp:1722
QString currentElementColumnName(void)
Definition: datalib.cpp:8018
QString getElementValueString(QString name, bool *found=NULL)
Definition: datalib.cpp:7911
int editBoxMaxWidth(void)
Definition: datalib.h:2382
int alternateActLine(void)
Definition: datalib.cpp:4511
~HDispPlainDataMatrix(void)
Definition: guilib.cpp:2308
static HPressButtonSizeSyncronizer * createSizeSyncronizer(void)
Definition: guilib.cpp:4890
void setColumnColor(int col, QColor c)
Definition: guilib.cpp:819
QStringList getShortTitleHeads(void)
Definition: datalib.h:1138
int setHeadTexts(QStringList h)
Definition: guilib.cpp:758
virtual int setValue(QVariant v, bool sdisabled=false)
Definition: datalib.cpp:5390
QStringList * rows
The visible data of the element.
Definition: guilib.h:470
virtual QStringList * getKeys(void)
Definition: datalib.h:1801
int setEnabled(bool enable)
Definition: guilib.cpp:4667
void sort(int keycol)
Definition: guilib.cpp:1563
int alternateActLine(QString key)
Definition: datalib.cpp:2176
int setValue(int v)
Definition: guilib.cpp:631
int dialogPrint(void)
Definition: guilib.cpp:2426
bool readonlyMask(void)
Definition: datalib.h:1440
int dialogPrint(void)
Definition: guilib.cpp:2282
QString sqlTableName(void)
Definition: datalib.cpp:2574
bool isSQLField(void)
Definition: datalib.h:2270
int crossthick
Definition: guilib.h:1345
HTableBrowserElement * elementByIndex(int n)
Definition: guilib.cpp:1936
HDispTable(QWidget *parent, HTable *d, int datamodep=FULL_CLEAN, int ddata=DONT_DELETE_DATA)
Definition: guilib.cpp:2524
bool isMeldedWithNext(void)
Definition: datalib.h:2360
QString getTitle(void)
Definition: datalib.h:366
int getGColor(void)
Definition: datalib.h:2336
QString * keyByIndex(int n)
Definition: guilib.cpp:1958
void nextElement(void)
Definition: datalib.cpp:8003
int cursorToBegin(void)
Definition: guilib.cpp:1096
QString getContentAsHtml(QString params)
Definition: datalib.cpp:1960
HTableBrowserElement * next
Pointer to the next element.
Definition: guilib.h:518
HTable * data
The HTable data pointer;.
Definition: guilib.h:646
int datamode
Data handling mode.
Definition: guilib.h:696
HTableBrowser * list
The HTableBrowser object.
Definition: guilib.h:699
#define FULL_CLEAN
Definition: guilib.h:49
void activateItem(QString k)
~HDispTable(void)
Definition: guilib.cpp:2657
int dialogXml(void)
Definition: guilib.cpp:2434
HTableBrowserElement * currentElement(void)
Definition: guilib.cpp:1013
int reReadList(void)
Definition: datalib.h:1870
QString soft_current_key
Definition: datalib.h:1824
void setSpecSort(int col, QString specsortname)
Definition: guilib.cpp:940
int clear()
Definition: guilib.cpp:786
QString currentElementValueString(void)
Definition: datalib.cpp:8043
void queryToStart(void)
Definition: guilib.cpp:1970
QPixmap * cachePixmap
Definition: guilib.h:476
int titleheight
Definition: guilib.h:1339
int setCurrentElement(QString c, QString t="")
Definition: guilib.cpp:951
QString getCVal(int i)
Definition: guilib.h:496
static HRefreshAgent * getNotifyAgent(void)
Definition: datalib.h:215
QString currentElementName(void)
Definition: datalib.cpp:8008
int deletedata
Data allocation handling mode.
Definition: guilib.h:537
HTableBrowserElement * setColor(int r, int g, int b)
Definition: guilib.cpp:2094
static QLayout * abc_filt(QWidget *parent, const QObject *receiver, const char *member)
Definition: guilib.cpp:460
QString currentElementRowName(void)
Definition: datalib.cpp:8013
int addElement(HTableBrowserElement *e)
Definition: guilib.cpp:830
virtual QList< QStringList * > * getValues(void)
Definition: datalib.h:1798
int getRColor(void)
Definition: datalib.h:2334
void progress(void)
Definition: guilib.cpp:4413
~HSpinBox(void)
Definition: guilib.cpp:661
int returnToDefault(bool all=true)
Definition: datalib.cpp:3378
bool isNoMiddleStretch(void)
Definition: datalib.h:2374
int setTopElement(int index)
Definition: guilib.cpp:990
int sortByColumn(int col)
Definition: guilib.cpp:2419
int actLine(void)
Definition: datalib.cpp:4503
bool owncolor
If this attribute is true the element has own color.
Definition: guilib.h:472
#define GSAFETEXT_DISPSQLCH_SELECTBUTTON
Definition: gstexts.h:82
int actLine(QString key)
Definition: datalib.cpp:2170
static HPleaseWaitWindow * start(void)
Definition: guilib.cpp:4461
void firstField(void)
Definition: datalib.cpp:2822
void wheelEvent(QWheelEvent *e)
Definition: guilib.cpp:651
void setBackgroundColor(QColor c)
Definition: guilib.cpp:749
bool stepUp(void)
Definition: guilib.cpp:1020
void setActiveKey(QString k)
Definition: datalib.cpp:4706
QColor bgcolor
Definition: guilib.h:1333
void dataChangedByGui(void)
void setEffect(int effectwidth)
Definition: guilib.cpp:4675
int fulshDrawingCache(void)
Definition: guilib.cpp:1596
QString getTailText(void)
Definition: datalib.h:2188
static void end(void)
Definition: guilib.cpp:4478
void setTitleFont(QFont f)
Definition: guilib.cpp:4524
int removeAllElementByKey(QString key)
Definition: guilib.cpp:884
#define GSAFETEXT_STARTDIATEXT2
Definition: gstexts.h:79
int deletedata
Data allocation handling mode.
Definition: guilib.h:697
int slotCellChanged(int row, int column)
Definition: guilib.cpp:4984
int addStretchToEnd(void)
Definition: guilib.cpp:2623
int deletedata
Data allocation handling mode.
Definition: guilib.h:645
virtual int clearList(void)
Definition: datalib.cpp:4490
HTableBrowserElement * prev
Pointer to the previous element.
Definition: guilib.h:519
static int defaultSizeX
Definition: guilib.h:88
int setShow()
Definition: guilib.cpp:4660
bool dont_reset_timer
Definition: guilib.h:1330
Definition: datalib.h:312
HDispPlainDataMatrix(QWidget *parent, HBase *d, bool htmlmode=false, int keyfield=-1, int ddata=DONT_DELETE_DATA)
Definition: guilib.cpp:2196
int updateDisplay(void)
Definition: guilib.cpp:2670
~HPressButton(void)
Definition: guilib.cpp:4649
QStringList * valuesByIndex(int n)
Definition: guilib.cpp:1946
bool anywhere_click_close
Definition: guilib.h:1327
int slotActivateItem(const QString k)
Definition: guilib.cpp:2266
HDecorDialog(QWidget *parent, QString title, int no_action_closetime)
Definition: guilib.cpp:4491
int updateDisplay(void)
Definition: guilib.cpp:2455
void itemChanged(const QString &s)
void setElementValue(QString name, double value)
Definition: datalib.cpp:7867
QString operator[](int i)
Definition: guilib.cpp:2113
QString activeKey(void)
Definition: datalib.cpp:4701
HTableBrowser(QWidget *parent)
Definition: guilib.cpp:692
QList< QString > currentRowStr(void)
Definition: datalib.cpp:1775
HDispList(QWidget *parent, HList *d, int datamodep=FULL_CLEAN, int ddata=DONT_DELETE_DATA)
Definition: guilib.cpp:2350
virtual QVariant dbValueToDispValue(QVariant v)
Definition: datalib.cpp:5309
int itemAlternateActivated(const QString &s)
Definition: guilib.cpp:2511
QString getSpecDisplaySortMode(void)
Definition: datalib.h:2208
void sdebug(QString s)
Definition: dconsole.cpp:48
HList * data
The HList data pointer.
Definition: guilib.h:698
#define GSAFETEXT_CALLEXTERNAL
Definition: gstexts.h:72
bool extrafeatures
Definition: datalib.h:948
int dialogXml(void)
Definition: guilib.cpp:2649
void clicked(void)
virtual QString sqlSelectHead(void)
Definition: datalib.cpp:5438
~HTableBrowser(void)
Definition: guilib.cpp:764
HArrayButton(QString text, QWidget *parent)
Definition: guilib.cpp:443
QString getExplainText(void)
Definition: datalib.h:2184
int getBColor(void)
Definition: datalib.h:2338
#define START_CLEAN
Definition: guilib.h:50
bool mouseNetClick(QMouseEvent *e, int rmode=NEED_UPDATE)
Definition: guilib.cpp:1308
HTableBrowserElement * topElement(void)
Definition: guilib.cpp:1006
HTableBrowserElement * queryNextElement(void)
Definition: guilib.cpp:1979
QString getWhoami(void)
Definition: datalib.cpp:774
#define GSAFETEXT_TEXT_UNKNOWN
Definition: gstexts.h:64
int ocb
If the owncolor is true these variables holds the color.
Definition: guilib.h:473
bool gui_showtabletitle
Definition: datalib.h:952
void firstRow(void)
Definition: datalib.cpp:1716
void alternateActivateItem(const QString &s)
int setHide()
Definition: guilib.cpp:4654
void activateItem(const QString &s)
void listItemChanged(void)
HTableBrowserElement(QString k, QStringList *c)
Definition: guilib.cpp:2037
HDynTableDispConnector(HDynTable *dynt, QTableWidget *qtw)
Definition: guilib.cpp:4899
void firstElement(void)
Definition: datalib.cpp:7990
int cursorToEnd(void)
Definition: guilib.cpp:1104
int itemAlternateActivated(const QString &s)
Definition: guilib.cpp:2276
HTableBrowserElement * clearColor(void)
Definition: guilib.cpp:2103
int itemActivated(const QString &s)
Definition: guilib.cpp:2502
void queryToTop(void)
Definition: guilib.cpp:1973
void paintEvent(QPaintEvent *pe)
Definition: guilib.cpp:4438
~HPlainDMD(void)
Definition: guilib.cpp:2341
HPressButton(QWidget *parent, QString text, QString code="")
Definition: guilib.cpp:4623
int datamode
Data handling mode.
Definition: guilib.h:644
int dialogHtmlShow(void)
Definition: guilib.cpp:2298
virtual QVariant getValue(void)
Definition: datalib.cpp:5418
int litemChanged(const QString &s)
Definition: guilib.cpp:2412
void error(QString s)
Definition: datalib.cpp:37
#define GSAFETEXT_STARTDIATEXT1
Definition: gstexts.h:76
int index
Index of the element.
Definition: guilib.h:468
void swapWith(HTableBrowserElement *x)
Definition: guilib.cpp:2161
int closerwidth
Definition: guilib.h:1341
bool isShow(void)
Definition: datalib.h:2278
#define END_CLEAN
Definition: guilib.h:51
~HDispList(void)
Definition: guilib.cpp:2442
bool isGuienabled(void)
Definition: datalib.h:2286
int numberOfElements(void)
Definition: guilib.cpp:1931
QString topKey(void)
Definition: guilib.cpp:779
static HPleaseWaitWindow * pww
Definition: guilib.h:1265
void setColor(int red, int green, int blue)
Definition: guilib.cpp:4721
void clearAndFreeConnections(void)
Definition: datalib.cpp:2414
bool ro_mask
Readonly mask.
Definition: guilib.h:643
int dialogXml(void)
Definition: guilib.cpp:2290
bool getLastValidateStatus()
Definition: datalib.h:2542
QString key
Key value of the element.
Definition: guilib.h:469
#define GSAFETEXT_UNKNOWN
Definition: gstexts.h:62
QString tableTitle(void)
Definition: datalib.h:1127
bool stepDown(void)
Definition: guilib.cpp:1047
void valueChanged(int)
QColor frcolor
Definition: guilib.h:1337
~HTableBrowserElement(void)
Definition: guilib.cpp:2085
void setTextPointSize(int size)
Definition: guilib.cpp:4687
void updateDisplaySignal(void)
void clickedCode(QString code)
int framewidth
Definition: guilib.h:1335
bool isEnded(void)
Definition: datalib.cpp:7996
#define GSAFETEXT_DISPSQLCH_TITLE
Definition: gstexts.h:84
QList< QString > getHeader(void)
Definition: datalib.cpp:1500
void setMargin(int margin)
Definition: guilib.cpp:4681