gSAFE  1.3.8
printlib.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  printlib.cpp
10 */
11 
12 #include <QtCore>
13 #include <QtGui>
14 
15 #define LMARGIN 30
16 #define RMARGIN 30
17 #define TMARGIN 40
18 #define BMARGIN 30
19 
20 #define CELLHMARGIN 5
21 #define CELLVMARGIN 3
22 
23 #define BREAKPOLICY Qt::TextWrapAnywhere
24 
25 #define A4_X 750
26 #define A4_Y 1080
27 
28 #define PRBGCOLOR QColor(80,80,80)
29 
30 #define SHADOWPATTERN Qt::Dense2Pattern
31 
32 #include "datalib.h"
33 #include "printlib.h"
34 #include "dconsole.h"
35 
36 
40 
42 :QFrame(parent)
43 {
44  pt = p;
45  scale=0.50;
46 
47  gr = new QPixmap();
48  QPalette palette;
49  palette.setColor(QPalette::Window,PRBGCOLOR);
50  palette.setColor(QPalette::WindowText,QColor(0,0,0));
51  setPalette(palette);
52  setAutoFillBackground(true);
53 
54 
55  setFocusPolicy(Qt::StrongFocus);
56  setFocus();
57  setCursor(Qt::PointingHandCursor);
58  resize(A4_X+100,A4_Y+100);
59 
60  repaint();
61 }
62 
64 {
65  delete gr;
66 }
67 
68 void HPreviewFrame::reset(void)
69 {
70  scale=0.5;
71  panx = 0;
72  pany = 0;
73 }
74 
75 void HPreviewFrame::mousePressEvent(QMouseEvent *e)
76 {
77  dx = e->x();
78  dy = e->y();
79 }
80 
81 void HPreviewFrame::mouseMoveEvent(QMouseEvent *e)
82 {
83  panx -= dx - e->x();
84  pany -= dy - e->y();
85  dx = e->x();
86  dy = e->y();
87  repaint();
88 }
89 
90 void HPreviewFrame::mouseReleaseEvent(QMouseEvent *e)
91 {
92  panx -= dx - e->x();
93  pany -= dy - e->y();
94  repaint();
95 }
96 
97 void HPreviewFrame::resizeEvent(QResizeEvent *e)
98 {
99  Q_UNUSED(e);
100 }
101 
102 void HPreviewFrame::wheelEvent(QWheelEvent *e)
103 {
104  if(e->modifiers() != Qt::NoModifier)
105  {
106  if(e->delta() > 0)
107  {
108  pany += 50;
109  }
110  else
111  {
112  pany -= 50;
113  }
114  }
115  else
116  {
117  if(e->delta() > 0)
118  {
119  //Max scale
120  if(scale >= 3) return;
121  scale += 0.1;
122 
123  }
124  else
125  {
126  //Min scale
127  if(scale <= 0.2) return;
128  scale -= 0.1;
129  }
130  }
131  repaint();
132 }
133 
134 void HPreviewFrame::keyPressEvent(QKeyEvent *e)
135 {
136  sdebug("*** HPreviewFrame::keyPressEvent ***");
137  if(e->key() == Qt::Key_PageUp)
138  {
139  pany += A4_Y;
140  repaint();
141  return;
142  }
143 
144  if(e->key() == Qt::Key_PageDown)
145  {
146  pany -= A4_Y;
147  repaint();
148  return;
149  }
150 
151  if(e->key() == Qt::Key_S)
152  {
153  pany += 10;
154  repaint();
155  return;
156  }
157 
158  if(e->key() == Qt::Key_W)
159  {
160  pany -= 10;
161  repaint();
162  return;
163  }
164 
165  if(e->key() == Qt::Key_A)
166  {
167  panx -= 10;
168  repaint();
169  return;
170  }
171 
172  if(e->key() == Qt::Key_D)
173  {
174  panx += 10;
175  repaint();
176  return;
177  }
178 }
179 
180 void HPreviewFrame::paintEvent(QPaintEvent *e)
181 {
182 
183  QFrame::paintEvent(e);
184 
185  QPainter *p;
186  p = new QPainter();
187  p->begin(this);
188  pt->drawIt(p,scale);
189  p->end();
190  delete p;
191 }
192 
196 HPrintTable::HPrintTable(QWidget *parent,HBase *d,QFont *pf)
197 :QDialog(parent)
198 {
199  setWindowTitle("Print preview...");
200  page = 1;
201  data = d;
202  printer = NULL;
203  cellh = 20;
204  cellw.clear();
205  cellrh.clear();
206  rownum = 0;
207  column = 0;
208  hide = false;
209 
210  QString tTitle;
211  if(pf==NULL)
212  printfont = QApplication::font();
213  else
214  printfont = *pf;
215 
216  QVBoxLayout *vl;
217  QHBoxLayout *hl;
218 
219  QPushButton *printButton,*refreshButton,*closeButton;
220 
221  vl = new QVBoxLayout( this );
222  vl->setMargin(2);
223  vl->setSpacing(2);
224  hl = new QHBoxLayout( 0 );
225  hl->setMargin(2);
226  hl->setSpacing(2);
227 
228  printButton = new QPushButton(this);
229  printButton->setText("Print");
230  refreshButton = new QPushButton(this);
231  refreshButton->setText("Refresh");
232  closeButton = new QPushButton(this);
233  closeButton->setText("Close");
234  pn = new QLabel(this);
235 
236  if(data->getWhoami() == "HTable" || data->getWhoami() == "HList")
237  tTitle = ((HTableBase *)data)->tableTitle();
238  else if(data->getWhoami() == "HPlainDataMatrix")
239  tTitle = ((HPlainDataMatrix *)data)->getTitle();
240  pn->setText(" Print preview: "+tTitle);
241 
242 
243  preview = new HPreviewFrame(this,this);
244  preview->reset();
245 
246 
247  QPalette palette;
248  palette.setColor(QPalette::Window,PRBGCOLOR);
249  preview->setPalette(palette);
250  preview->setAutoFillBackground(true);
251  preview->setFrameShape ( QFrame::StyledPanel );
252  preview->setFrameShadow( QFrame::Raised );
253  preview->setLineWidth( 4 );
254 
255  hl->addWidget(printButton);
256  hl->addWidget(refreshButton);
257  hl->addWidget(pn);
258  hl->addStretch();
259  hl->addWidget(closeButton);
260 
261  vl->addLayout(hl);
262  vl->addWidget(preview);
263 
264  resize( QSize(525, 639).expandedTo(minimumSizeHint()) );
265 
266  connect(closeButton ,SIGNAL(clicked()),this,SLOT(close()));
267  connect(refreshButton,SIGNAL(clicked()),this,SLOT(updateDisplay()));
268  connect(printButton ,SIGNAL(clicked()),this,SLOT(printIt()));
269 
270  scanIt(); // Have to call before the drawing
271 
272  show();
273  updateDisplay();
274 }
275 
276 void HPrintTable::keyPressEvent(QKeyEvent *e)
277 {
278 
279  QWidget::keyPressEvent(e);
280 }
281 
282 void HPrintTable::resizeEvent(QResizeEvent *e)
283 {
284  Q_UNUSED(e);
285 }
286 
287 // Determine the necessary data to drawing
288 void HPrintTable::scanIt(void)
289 {
290  if(data->getWhoami() == "HPlainDataMatrix")
291  scanPlainDataMatrix();
292  else if(data->getWhoami() == "HTable")
293  scanTable();
294  else if(data->getWhoami() == "HList")
295  scanList();
296  else
297  error("HPrintTable::scanIt - Cannot draw item: Not supported type!");
298 }
299 
300 void HPrintTable::scanPlainDataMatrix(void)
301 {
302  sdebug("*** HPrintTable::scanPlainDataMatrix ***");
303  /*
304  Calculates the following data
305  cellh - cellheight
306  cellw - cellwidth
307  rownum - number of rows
308  colnum - number of columns
309  page - page number
310  */
311 
312  int pageY;
313  int t;
314  int i,j;
315  int curr_cellh=0;
316  QStringList *slist;
317  slist = new QStringList();
318 
319  HPlainDataMatrix *data = (HPlainDataMatrix *) this->data; //hide the class variable with a local
320  QPainter *p = new QPainter();
321 
322 
323  cellh = 20;
324  cellw.clear();
325  cellrh.clear();
326  rownum=0;
327  column = -1;
328 
329  //CELLHEIGHT
330 
331  //cellh = ( QApplication::fontMetrics() ).height();
332  cellh = QFontMetrics(printfont).height();
333 
334  cellh += CELLVMARGIN*2;
335 
336  //pagenum=1
337  page = 1;
338  //futoY = upper header
339  pageY = 50+cellh;
340 
341  //BODY
342  data->firstRow();
343  do
344  {
345  ++rownum;
346  *slist = data->currentRowStr();
347  if(column == -1) //first row
348  {
349  column = (int)slist->size();
350  //Initializing a column number int list for the columnwidth
351  for(i=0;i<column;i++)
352  cellw.push_back(0);
353  }
354  else //other rows
355  {
356  if(column != (int)slist->size())
357  {
358  error("*** HPrintTable::scanList *** - found different column number in lines!");
359  delete p;
360  close();
361  }
362  }
363 
364  //working on columns
365  curr_cellh = cellh;
366  for(i=0;i < column;++i)
367  {
368  //CELLA : slist[i]
369  j = QFontMetrics(printfont).width( (*slist)[i] );
370 
371  //We can wrap
372  if(data->getColumnPrintWrap(i))
373  {
374  int maxcellw =
375  data->getColumnPrintMaxWidth(i);
376 
377  if(maxcellw == 0)
378  maxcellw = 100; //TODO !!!! sould be an average !!!
379 
380  //need line wrap
381  if(j > maxcellw)
382  {
383  t = QFontMetrics(printfont)
384  .boundingRect(0,0,maxcellw
385  ,A4_Y,Qt::AlignLeft | BREAKPOLICY,(*slist)[i]).height();
386 
387  t+=2*CELLVMARGIN;
388  if(curr_cellh < t)
389  curr_cellh = t;
390  cellw[i] = maxcellw;
391 
392 //sdebug(QString("LINE WRAP! Examined cellheight: %1 (+ CELLVMARGIN*2) /%2/").arg( t ).arg(cellrh.size()));
393  }
394  else //the line wrap is possible but don't need
395  {
396  if(j > cellw[i])
397  cellw[i] = j;
398 //sdebug(QString("DON'T NEED LINE WERAP! (Fall to default: %1) /%2/").arg(cellh).arg(cellrh.size()));
399  }
400  }
401  else //There is no line wrap possibility
402  {
403  //Saving the calculated cell width
404  if(j > cellw[i])
405  cellw[i] = j;
406  //Saving the normal cell height
407 
408  }
409  }//end examinig of actual columns (for cycle)
410 
411  cellrh.push_back(curr_cellh);
412  pageY+=curr_cellh;
413 
414  //Need more page or not?
415  if(pageY > A4_Y - cellh)
416  {
417  ++page;
418  //futoY = upper header
419  pageY = 50+cellh;
420  }
421 
422 
423  }
424  while(data->nextRow());
425 
426  //HEADLINE
427  for(i=0;i < column;++i)
428  {
429  j = QFontMetrics(printfont).width( data->getHeaderItem(i) );
430  if(j > cellw[i])
431  cellw[i] = j;
432  }
433 
434  //Grows the cellwidth with CELLHMARGIN
435  for(i=0;i < column;++i)
436  {
437  cellw[i] += CELLHMARGIN*2;
438  }
439 
440 sdebug(QString(">>>>Calculated pagenum: %1").arg(page));
441 
442  delete p;
443  delete slist;
444  sdebug("*** HPrintTable::scanPlainDataMatrix *** END");
445 
446 }
447 
448 void HPrintTable::scanList(void)
449 {
450  sdebug("*** HPrintTable::scanList ***");
451  /*
452  Calculates the following data
453  cellh - cellheight
454  cellw - cellwidth
455  rownum - number of rows
456  colnum - number of columns
457  page - page number
458  */
459 
460  int pageY;
461  int t;
462  int i,j;
463  int curr_cellh=0;
464  QStringList *slist;
465 
466  HList *data = (HList *) this->data; //hide the class variable with a local
467  QPainter *p = new QPainter();
468 
469 
470  cellh = 20;
471  cellw.clear();
472  cellrh.clear();
473  rownum=0;
474  column = -1;
475 
476  //CELLHEIGHT
477 
478  //cellh = ( QApplication::fontMetrics() ).height();
479  cellh = QFontMetrics(printfont).height();
480 
481  cellh += CELLVMARGIN*2;
482 
483  //pagenum=1
484  page = 1;
485  //futoY = upper header
486  pageY = 50+cellh;
487 
488  //BODY
489  QList<QStringList *>::Iterator iv = data->getValues()->begin();
490  while(iv != data->getValues()->end())
491  {
492  ++rownum;
493  slist = *iv;
494  if(column == -1) //first line
495  {
496  column = (int)slist->size();
497  //Initializing a column number int list for the columnwidth
498  for(i=0;i<column;i++)
499  cellw.push_back(0);
500  }
501  else //other lines
502  {
503  if(column != (int)slist->size())
504  {
505  error("*** HPrintTable::scanList *** - found different column number in lines!");
506  delete p;
507  close();
508  }
509  }
510 
511  //working on columns
512  curr_cellh = cellh;
513  for(i=0;i < column;++i)
514  {
515  //CELLA : slist[i]
516  j = QFontMetrics(printfont).width( (*slist)[i] );
517 
518  //Line wrapping is enabled
519  if(data->fieldByIndex(i)->isPrintCellWrap())
520  {
521  int maxcellw =
522  data->fieldByIndex(i)->getPrintCellWidth();
523 
524  if(maxcellw == 0)
525  maxcellw = 100; /*TODO !!!! should be an average !!! */
526 
527  //need a line wrap
528  if(j > maxcellw)
529  {
530  t = QFontMetrics(printfont)
531  .boundingRect(0,0,maxcellw
532  ,A4_Y,Qt::AlignLeft | BREAKPOLICY,(*slist)[i]).height();
533 
534  t+=2*CELLVMARGIN;
535  if(curr_cellh < t)
536  curr_cellh = t;
537  cellw[i] = maxcellw;
538 
539 //sdebug(QString("LINE WRAP! Examined cellheight: %1 (+ CELLVMARGIN*2) /%2/").arg( t ).arg(cellrh.size()));
540  }
541  else //Line wrap is possible, but don't need
542  {
543  if(j > cellw[i])
544  cellw[i] = j;
545 //sdebug(QString("DON'T NEED LINE WERAP! (Fall to default: %1) /%2/").arg(cellh).arg(cellrh.size()));
546  }
547  }
548  else //There is no line wrap possibility
549  {
550  //Save the calculated cellwidth
551  if(j > cellw[i])
552  cellw[i] = j;
553  //Save the calculated cellheight
554 
555  }
556  }//end examinig of actual columns (for cycle)
557 
558  cellrh.push_back(curr_cellh);
559  pageY+=curr_cellh;
560 
561  //Next page or not?
562  if(pageY > A4_Y - cellh)
563  {
564  ++page;
565  //futoY = upper header
566  pageY = 50+cellh;
567  }
568 
569  ++iv;
570  }
571 
572  //HEADLINE
573  for(i=0;i < column;++i)
574  {
575  j = QFontMetrics(printfont).width( (*data)[i] );
576  if(j > cellw[i])
577  cellw[i] = j;
578  }
579 
580  //grows the cellwidth with CELLHMARGIN
581  for(i=0;i < column;++i)
582  {
583  cellw[i] += CELLHMARGIN*2;
584  }
585 
586 sdebug(QString(">>>>Calculated pagenum: %1").arg(page));
587 
588  delete p;
589  sdebug("*** HPrintTable::scanList *** END");
590 }
591 
592 void HPrintTable::scanTable(void)
593 {
594  sdebug("*** HPrintTable::scanTable ***");
595  int i;
596 
597  cellw.clear();
598  cellh = QFontMetrics(printfont).height()*2+CELLVMARGIN*3;
599  i = (A4_X-(LMARGIN+RMARGIN+4*CELLHMARGIN))/2;
600  cellw.push_back(i);
601 
602  //Don't know... This will fail on big table. Fixme.
603  page = 1;
604  sdebug("*** HPrintTable::scanTable *** END");
605 }
606 
607 int HPrintTable::drawIt(QPainter *p,double scale,bool print)
608 {
609  //Scale, Pan
610 
611  //preview->panx = preview->pany = 0;
612  if(!print)
613  {
614  p->setClipRect(4,4,preview->width()-8,preview->height()-8);
615  p->translate(preview->panx,preview->pany); //scroll
616 
617  p->translate(60,10); //border
618  p->scale(scale,scale);
619 
620  //Draw an empty page with border and shadow ;-)
621  p->fillRect(20,20,A4_X,A4_Y,QBrush(QColor(50,50,50),SHADOWPATTERN));
622  p->fillRect(0,0,A4_X,A4_Y,QBrush(QColor(255,255,255),Qt::SolidPattern));
623  }
624  p->setPen(QColor(0,0,0));
625  //Page border
626  p->drawRect(LMARGIN,TMARGIN,A4_X-(RMARGIN+LMARGIN),A4_Y-(BMARGIN+TMARGIN));
627 
628  if(data->getWhoami() == "HPlainDataMatrix")
629  return drawPlainDataMatrix(p,print);
630  else if(data->getWhoami() == "HTable")
631  return drawTable(p,print);
632  else if(data->getWhoami() == "HList")
633  return drawList(p,print);
634  else
635  error("HPrintTable::drawIt - Cannot draw item: Not supported type!");
636 
637 
638  return 0;
639 }
640 
641 int HPrintTable::newPage(QPainter *p,bool print)
642 {
643  //++page;
644  if(!print) //Drawing to display
645  {
646  p->translate(0,(A4_Y+100));
647 
648  //Draw an empty page with borders
649  p->fillRect(20,20,A4_X,A4_Y,QBrush(QColor(50,50,50),SHADOWPATTERN));
650  p->fillRect(0,0,A4_X,A4_Y,QBrush(QColor(255,255,255),Qt::SolidPattern));
651 
652  //OFF if( p->xForm(QPoint(0,-100 )).y() > preview->height() )
653  //OFF hide = true;
654  //OFF else if( p->xForm(QPoint(0,A4_Y+200)).y() < 0 )
655  //OFF hide = true;
656  //OFF else
657 
658  hide = false;
659 
660  }
661  else //We are printing now!
662  {
663  printer->newPage();
664  }
665 
666  p->setPen(QColor(0,0,0));
667  p->drawRect(LMARGIN,TMARGIN,A4_X-(RMARGIN+LMARGIN),A4_Y-(BMARGIN+TMARGIN));
668  return 0;
669 }
670 
671 #define HLINE \
672  DRAWLINE(LMARGIN,downY,A4_X-RMARGIN,downY);
673 
674 #define DRAWTEXT(a,b,c) \
675  p->drawText(a,b,c);
676 
677 #define DRAWTEXTBOX(a,b,c,d,s) \
678  p->drawText(a,b,c,d,Qt::AlignLeft | BREAKPOLICY,s);
679 
680 #define DRAWLINE(a,b,c,d) \
681  p->drawLine(a,b,c,d);
682 
683 #define DRAWRECT(a,b,c,d) \
684  p->drawRect(a,b,c,d);
685 
686 int HPrintTable::drawPlainDataMatrix(QPainter *p,bool print)
687 {
688 
689  QStringList *slist;
690  int rowrun;
691  int downX=LMARGIN,downY=TMARGIN;
692  bool head=false;
693  int i;
694  pagerun = 1;
695  HPlainDataMatrix *data = (HPlainDataMatrix *) this->data; //hide the class variable with a local
696  slist = new QStringList();
697 
698  hide = false;
699 
700  rowrun = 0;
701  data->firstRow();
702  do
703  {
704  if(print || (!print && !hide )) //not printable
705  {
706  *slist = data->currentRowStr();
707  if(!head) //Draw the header if haven't drawn yet
708  {
709  downY += 35;
710  DRAWTEXT(LMARGIN + 20,TMARGIN+20,(
711  data->getTitle().isEmpty() ? "Printed page" : data->getTitle()) + QString("(%1)").arg(pagerun));
712 
713  downX = LMARGIN;
714  for(i=0;i < column;++i)
715  {
716  DRAWTEXTBOX(downX+CELLHMARGIN,downY+CELLVMARGIN,cellw[i],cellh,data->getHeaderItem(i));
717  downX += cellw[i]+2;
718  }
719  downY += 1;
720  HLINE;
721  downY += cellh;
722  HLINE;
723  downY += 1;
724  downX = LMARGIN;
725  head = true;
726  }
727  //draw the cells
728  for(i=0;i<column;++i)
729  {
730  DRAWTEXTBOX(downX+CELLHMARGIN,downY+CELLVMARGIN,cellw[i],cellrh[rowrun],(*slist)[i]);
731  downX += cellw[i]+2;
732  }
733  }
734  else //empty running
735  {
736  if(!head)
737  {
738  head = true;
739  downY += 35 + 2 + cellh;
740  }
741 
742  }
743 
744  downY += cellrh[rowrun];
745  downX = LMARGIN;
746 
747  if(downY >= A4_Y - (TMARGIN+BMARGIN)) //we reach the bottom of the page
748  {
749  pagerun++;
750  newPage(p,print);
751  downX=LMARGIN;
752  downY=TMARGIN;
753  //Page Headline
754  head=false;
755  }
756  ++rowrun;
757  }
758  while(data->nextRow());
759  delete slist;
760  return 0;
761 }
762 
763 
764 int HPrintTable::drawList(QPainter *p,bool print)
765 {
766  QStringList *slist;
767  int rowrun;
768  int downX=LMARGIN,downY=TMARGIN;
769  bool head=false;
770  int i;
771  pagerun = 1;
772  HList *data = (HList *) this->data; //hide the class variable with a local
773 
774  hide = false;
775 
776  rowrun = 0;
777  QList<QStringList *>::Iterator iv = data->getValues()->begin();
778  while(iv != data->getValues()->end())
779  {
780  if(print || (!print && !hide )) //not printable
781  {
782  slist=*iv;
783  if(!head) //Draw the header if haven't drawn yet
784  {
785  downY += 35;
786  DRAWTEXT(LMARGIN + 20,TMARGIN+20,(
787  data->tableTitle ().isEmpty() ? "Printed page" : data->tableTitle ())+QString("(%1)").arg(pagerun));
788 
789  downX = LMARGIN;
790  for(i=0;i < column;++i)
791  {
792  DRAWTEXTBOX(downX+CELLHMARGIN,downY+CELLVMARGIN,cellw[i],cellh,(*data)[i]);
793  downX += cellw[i]+2;
794  }
795  downY += 1;
796  HLINE;
797  downY += cellh;
798  HLINE;
799  downY += 1;
800  downX = LMARGIN;
801  head = true;
802  }
803  //draw the cells
804  for(i=0;i<column;++i)
805  {
806  DRAWTEXTBOX(downX+CELLHMARGIN,downY+CELLVMARGIN,cellw[i],cellrh[rowrun],(*slist)[i]);
807  downX += cellw[i]+2;
808  }
809  }
810  else //empty running
811  {
812  if(!head)
813  {
814  head = true;
815  downY += 35 + 2 + cellh;
816  }
817 
818  }
819 
820  downY += cellrh[rowrun];
821  downX = LMARGIN;
822 
823  if(downY >= A4_Y - (TMARGIN+BMARGIN)) //we reach the bottom of the page
824  {
825  pagerun++;
826  newPage(p,print);
827  downX=LMARGIN;
828  downY=TMARGIN;
829  //Page Headline
830  head=false;
831  }
832  ++iv;
833  ++rowrun;
834  }
835  return 0;
836 }
837 
838 int HPrintTable::drawTable(QPainter *p,bool print)
839 {
840  Q_UNUSED(print);
841  int downX=LMARGIN,downY=TMARGIN;
842  pagerun = 1;
843  HTable *data = (HTable *) this->data; //hide the class variable with a local
844 
845  HDataField *df;
846 
847  downY += 35;
848  DRAWTEXT(LMARGIN + 20,TMARGIN+20,(
849  data->tableTitle ().isEmpty() ? "Printed page" : data->tableTitle ())+QString("(%1)").arg(pagerun));
850 
851  downX = LMARGIN;
852  HLINE;
853  downY += 3;
854  HLINE;
855  downY += 3;
856  data->firstField();
857 
858  while((df = data->nextFieldAll()))
859  {
860  if(df->isShow())
861  {
862  DRAWTEXTBOX(downX+CELLHMARGIN,downY+CELLVMARGIN,
863  cellw[0],cellh,df->getExplainText());
864 
865 
866  if(df->getWhoami() != "HStatic" || !df->getValue().toString().isEmpty())
867  {
868  downX += cellw[0];
869 
870  DRAWLINE(downX,downY-2,downX,downY+cellh);
871  DRAWTEXTBOX(downX+CELLHMARGIN,downY+CELLVMARGIN,
872  cellw[0],cellh,df->dbValueToDispValue(df->getValue()).toString());
873  }
874 
875  downX = LMARGIN;
876  downY += cellh;
877  HLINE;
878  downY += 2;
879  }
880  }
881  return 0;
882 }
883 
884 int HPrintTable::printIt(void)
885 {
886  QPainter *p;
887  p=new QPainter();
888  sdebug("*** HPrintTable::printIt ***");
889  printer = new QPrinter();
890  printer->setPageSize(QPrinter::A4);
891  QPrintDialog psdialog(printer,this);
892  if(psdialog.exec())
893  {
894  p->begin(printer);
895  drawIt(p,1.0,true);
896  p->end();
897  }
898  delete p;
899  delete printer;
900  printer = NULL;
901  return 0;
902 }
903 
904 int HPrintTable::updateDisplay(void)
905 {
906  scanIt();
907  preview->reset();
908  preview->repaint();
909  return 0;
910 }
911 //end code
HDataField * nextFieldAll(void)
Definition: datalib.cpp:2843
HPrintTable(QWidget *parent, HBase *d, QFont *pf=NULL)
HPtintTable //////////////////////////////////////////////////////////////.
Definition: printlib.cpp:196
int getColumnPrintMaxWidth(int col)
Definition: datalib.h:416
bool nextRow(void)
Definition: datalib.cpp:1722
HPreviewFrame(HPrintTable *p, QWidget *parent)
PreviewTable ///////////////////////////////////////////////////////////////.
Definition: printlib.cpp:41
QString getTitle(void)
Definition: datalib.h:366
HDataField * fieldByIndex(int i, bool all=false)
Definition: datalib.cpp:2363
bool isPrintCellWrap(void)
Definition: datalib.h:2432
virtual QList< QStringList * > * getValues(void)
Definition: datalib.h:1798
void firstField(void)
Definition: datalib.cpp:2822
QString getHeaderItem(int col)
Definition: datalib.cpp:1495
Definition: datalib.h:312
QList< QString > currentRowStr(void)
Definition: datalib.cpp:1775
virtual QVariant dbValueToDispValue(QVariant v)
Definition: datalib.cpp:5309
void sdebug(QString s)
Definition: dconsole.cpp:48
QString getExplainText(void)
Definition: datalib.h:2184
QString getWhoami(void)
Definition: datalib.cpp:774
int getPrintCellWidth(void)
Definition: datalib.h:2425
void firstRow(void)
Definition: datalib.cpp:1716
virtual QVariant getValue(void)
Definition: datalib.cpp:5418
void error(QString s)
Definition: datalib.cpp:37
bool isShow(void)
Definition: datalib.h:2278
bool getColumnPrintWrap(int col)
Definition: datalib.h:412
~HPreviewFrame(void)
Definition: printlib.cpp:63
QString tableTitle(void)
Definition: datalib.h:1127