3 #include <QApplication>
6 #include <QWebSettings>
22 int main(
int argc,
char* argv[] )
24 QApplication application( argc, argv );
32 return application.exec();
39 setWindowTitle( tr(
"Report Chooser/Generator" ) );
52 hsclogo = logopath +
"logo_hsc.png";
55 becklogo = logopath +
"beckman_logo.png";
58 us3logo = logopath +
"ultrascan3.png";
61 QHBoxLayout* mainLayout =
new QHBoxLayout(
this );
62 QVBoxLayout* leftLayout =
new QVBoxLayout();
63 QVBoxLayout* rghtLayout =
new QVBoxLayout();
64 QGridLayout* dctlLayout =
new QGridLayout();
65 QGridLayout* tctlLayout =
new QGridLayout();
66 mainLayout->setSpacing ( 2 );
67 mainLayout->setContentsMargins( 2, 2, 2, 2 );
68 leftLayout->setSpacing ( 0 );
69 leftLayout->setContentsMargins( 0, 1, 0, 1 );
70 rghtLayout->setSpacing ( 0 );
71 rghtLayout->setContentsMargins( 0, 1, 0, 1 );
72 dctlLayout->setSpacing ( 1 );
73 dctlLayout->setContentsMargins( 0, 0, 0, 0 );
74 tctlLayout->setSpacing ( 1 );
75 tctlLayout->setContentsMargins( 0, 0, 0, 0 );
78 QLabel* lb_runids =
us_label( tr(
"Runs:" ) );
82 QPushButton* pb_loadpr =
us_pushbutton( tr(
"Load Profile" ) );
83 QPushButton* pb_savepr =
us_pushbutton( tr(
"Save Profile" ) );
84 QPushButton* pb_syncdb =
us_pushbutton( tr(
"Sync with Database" ) );
91 dctlLayout->addWidget( lb_runids, row, 0, 1, 1 );
92 dctlLayout->addWidget(
cb_runids, row++, 1, 1, 3 );
93 dctlLayout->addWidget(
pb_view, row++, 0, 1, 4 );
94 dctlLayout->addWidget(
pb_save, row++, 0, 1, 4 );
95 dctlLayout->addWidget( pb_loadpr, row++, 0, 1, 4 );
96 dctlLayout->addWidget( pb_savepr, row++, 0, 1, 4 );
97 dctlLayout->addWidget( pb_syncdb, row++, 0, 1, 4 );
98 dctlLayout->addWidget(
pb_help, row, 0, 1, 2 );
99 dctlLayout->addWidget(
pb_close, row++, 2, 1, 2 );
101 connect(
cb_runids, SIGNAL( currentIndexChanged(
int ) ),
103 connect(
pb_view, SIGNAL( clicked() ),
104 this, SLOT(
view() ) );
105 connect(
pb_save, SIGNAL( clicked() ),
106 this, SLOT(
save() ) );
107 connect( pb_loadpr, SIGNAL( clicked() ),
109 connect( pb_savepr, SIGNAL( clicked() ),
111 connect( pb_syncdb, SIGNAL( clicked() ),
113 connect(
pb_help, SIGNAL( clicked() ),
114 this, SLOT(
help() ) );
115 connect(
pb_close, SIGNAL( clicked() ),
116 this, SLOT( close() ) );
119 tr(
"Select the Run for which to produce a composite report" ) );
121 tr(
"View the composite report of selected individual reports" ) );
123 tr(
"Create a composite report using selected individual reports" ) );
124 pb_loadpr->setToolTip(
125 tr(
"Load a previously saved report-selection profile" ) );
126 pb_savepr->setToolTip(
127 tr(
"Save a report-selection profile for later use" ) );
129 tr(
"Display detailed US_Reporter documentation text and images" ) );
131 tr(
"Close the US_Reporter window and exit" ) );
139 QPalette tpal =
pb_help->palette();
140 tpal.setColor( QPalette::Base, QColor( Qt::white ) );
142 tctlLayout->addWidget(
tw_recs );
145 theads <<
"Selected" <<
"Report" <<
"Item Type";
148 tw_recs->setHeaderLabels( theads );
151 tw_recs->setObjectName( QString(
"tree-widget" ) );
152 tw_recs->setAutoFillBackground(
true );
153 tw_recs->installEventFilter (
this );
155 connect(
tw_recs, SIGNAL( itemClicked( QTreeWidgetItem*,
int ) ),
157 connect(
tw_recs, SIGNAL( itemChanged( QTreeWidgetItem*,
int ) ),
158 this, SLOT(
changedItem( QTreeWidgetItem*,
int ) ) );
161 leftLayout->addLayout( dctlLayout );
162 leftLayout->addStretch();
163 rghtLayout->addLayout( tctlLayout );
165 mainLayout->addLayout( leftLayout );
166 mainLayout->addLayout( rghtLayout );
167 mainLayout->setStretchFactor( leftLayout, 2 );
168 mainLayout->setStretchFactor( rghtLayout, 8 );
178 if ( obj->objectName() ==
"tree-widget" &&
179 e->type() == QEvent::ContextMenu )
188 return US_Widgets::eventFilter( obj, e );
209 int state = (int)item->checkState( 0 );
210 int row = item->type() - (int)QTreeWidgetItem::UserType;
218 if ( row == 0 && state == 2 )
231 int row = item->type() - (int)QTreeWidgetItem::UserType;
232 DbgLv(1) <<
" context menu row" << row + 1;
233 QMenu* cmenu =
new QMenu();
234 QAction* showact =
new QAction( tr(
"Show Details" ),
this );
235 QAction* viewact =
new QAction( tr(
"View Item" ),
this );
236 QAction* saveact =
new QAction( tr(
"Save As" ),
this );
238 connect( showact, SIGNAL( triggered() ),
240 connect( viewact, SIGNAL( triggered() ),
242 connect( saveact, SIGNAL( triggered() ),
245 cmenu->addAction( showact );
246 cmenu->addAction( viewact );
247 cmenu->addAction( saveact );
249 if (
adescs.at( row ).level < 3 )
251 viewact->setEnabled(
false );
252 saveact->setEnabled(
false );
255 cmenu->exec( QCursor::pos() );
263 QStringList rdirs = QDir( rdir )
264 .entryList( QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name );
265 QStringList aucfil(
"*.auc" );
268 for (
int ii = 0; ii < rdirs.size(); ii++ )
270 QString runid = rdirs.at( ii );
271 QString subdir = rdir + runid;
273 QStringList afiles = QDir( subdir )
274 .entryList( aucfil, QDir::Files, QDir::Name );
275 int naucf = afiles.size();
294 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
295 qApp->processEvents();
297 DbgLv(1) <<
" new runID row runid" << row << runID;
306 if ( runID ==
"all" )
308 for (
int ii = 1; ii <
sl_runids.size(); ii++ )
323 QApplication::restoreOverrideCursor();
324 qApp->processEvents();
330 DbgLv(1) <<
"build_descs runID" << runID <<
" linex" << linex;
332 QStringList appnames =
appmap.keys();
333 QStringList extnames =
extmap.keys();
334 QStringList rptnames =
rptmap.keys();
356 DbgLv(1) <<
" BD: line lev label" << cdesc.linen << cdesc.level << cdesc.label;
360 QStringList aucfil(
"*.auc" );
361 QStringList afiles = QDir( rdir )
362 .entryList( aucfil, QDir::Files, QDir::Name );
363 int naucf = afiles.size();
364 DbgLv(1) <<
" BD: naucf" << naucf <<
"aucfil" << aucfil[0];
366 for (
int ii = 0; ii <= naucf; ii++ )
374 fname = afiles.at( ii );
375 trnam = fname.section(
".", -4, -2 ).replace(
".",
"" );
376 tripl = fname.section(
".", -4, -4 ) +
" / "
377 + fname.section(
".", -3, -3 ) +
" / "
378 + fname.section(
".", -2, -2 );
383 fname =
"vHW.0Z9999.combo-distrib.svgz";
385 tripl =
"0 / Z / 9999";
386 cdesc.label =
"Combined Analyses";
389 QStringList trifil(
"*." + trnam +
".*.*" );
390 QStringList rfiles = QDir( path )
391 .entryList( trifil, QDir::Files, QDir::Name );
392 int nrptf = rfiles.size();
393 DbgLv(1) <<
" BD: nrptf" << nrptf <<
"trifil" << trifil[0];
395 if ( nrptf == 0 )
continue;
398 cdesc.linen = linex + 1;
400 cdesc.label = tr(
"Cell " )
401 + tripl.section(
"/", 0, 0 ).simplified()
403 + tripl.section(
"/", 1, 1 ).simplified() +
"/"
404 + tripl.section(
"/", 2, 2 ).simplified() +
" nm";
405 cdesc.type =
"Data(triple)";
406 cdesc.filename = fname;
407 cdesc.filepath = rdir + fname;
408 cdesc.triple = tripl;
409 cdesc.analysis =
"all";
410 cdesc.lastmodDate =
"";
411 cdesc.description =
"";
423 if ( ! trdesc.isEmpty() )
425 cdesc.label = QString( cdesc.label ) +
" " + trdesc;
426 cdesc.description = trdesc;
432 trdesc =
"Combined Analyses";
433 cdesc.label = trdesc;
434 cdesc.description = trdesc;
439 DbgLv(1) <<
" BD: line lev label" << cdesc.linen << cdesc.level << cdesc.label;
441 for (
int jj = 0; jj < appnames.size(); jj++ )
443 QString appname = appnames.at( jj );
444 QString aplabel =
appmap[ appname ];
445 appname = appname.section(
":", 1, 1 );
446 QString appnmLo = appname.toLower();
447 QString appnmUp = appname.toUpper();
449 QStringList rafilt( appname +
"." + trnam +
".*.*" );
450 rafilt << appnmLo +
"." + trnam +
".*.*"
451 << appnmUp +
"." + trnam +
".*.*";
452 QStringList rafiles = QDir( path )
453 .entryList( rafilt, QDir::Files, QDir::Name );
454 DbgLv(1) <<
" BD: nappf" << rafiles.size() <<
"rafilt" << rafilt[0]
455 << rafilt[1] << rafilt[2];
457 if ( rafiles.size() < 1 )
continue;
460 cdesc.linen = linex + 1;
462 cdesc.label = aplabel;
463 cdesc.type =
"Analysis";
464 cdesc.filename = rafilt[ 0 ];
465 cdesc.filepath = path + rafilt[ 0 ];
466 cdesc.triple = tripl;
467 cdesc.analysis = aplabel;
468 cdesc.lastmodDate =
"";
473 for (
int kk = 0; kk < extnames.size(); kk++ )
475 QString extname = extnames.at( kk );
476 QString exlabel =
extmap[ extname ];
477 extname = extname.section(
":", 1, 1 );
479 for (
int mm = 0; mm < rptnames.size(); mm++ )
481 QString rptname = rptnames.at( mm );
482 QString rplabel =
rptmap[ rptname ];
483 rptname = rptname.section(
":", 1, 1 );
486 QString basname =
"." + trnam +
"." + rptname +
"." + extname;
487 QString rpfname = appname + basname;
488 QString rpfnmLo = appnmLo + basname;
489 QString rpfnmUp = appnmUp + basname;
492 if ( rafiles.indexOf( rpfname ) < 0 )
494 int jj1 = rafiles.indexOf( appnmLo + basname );
495 int jj2 = rafiles.indexOf( appnmUp + basname );
496 if ( jj1 < 0 && jj2 < 0 )
498 rpfname = ( jj1 < 0 ) ? rpfname : rpfnmLo;
499 rpfname = ( jj2 < 0 ) ? rpfname : rpfnmUp;
502 if ( rpfname.contains(
".svg" ) )
504 QString rpfnpng = QString( rpfname ).section(
".", 0, -2 )
506 if ( rafiles.indexOf( rpfnpng ) >= 0 )
511 cdesc.linen = linex + 1;
513 cdesc.label = rplabel;
514 cdesc.type = exlabel;
515 cdesc.filename = rpfname;
516 cdesc.filepath = path + rpfname;
517 cdesc.triple = tripl;
518 cdesc.analysis = aplabel;
520 QFileInfo( cdesc.filepath ).lastModified()
521 .toUTC().toString( Qt::ISODate ), true );
525 DbgLv(1) <<
" BD: line lev label" << cdesc.linen << cdesc.level << cdesc.label;
537 DbgLv(1) <<
"build_map: ttag" << ttag <<
" path" << path;
540 if ( file.open( QIODevice::ReadOnly | QIODevice::Text ) )
542 QXmlStreamReader xml( &file );
544 while( ! xml.atEnd() )
548 if ( xml.isStartElement() && xml.name() == ttag )
550 QXmlStreamAttributes a = xml.attributes();
551 QString name = a.value(
"name" ).toString();
552 QString label = a.value(
"label" ).toString();
553 QString anum = QString().sprintf(
"%3.3i", kmap++ );
554 QString akey = anum +
":" + name;
555 DbgLv(1) <<
" b_m: name label" << name << label;
557 labmap[ akey ] = label;
566 QMessageBox::warning(
this,
567 tr(
"UltraScan Error" ),
568 tr(
"Unable to open the file:\n\n" ) + path );
571 int nmap = labmap.count();
572 QString nam0 = labmap.keys().at( 0 );
573 QString namn = labmap.keys().at( nmap-1 );
574 DbgLv(1) <<
"build_map: ttag" << ttag <<
" nmap" << nmap;
575 DbgLv(1) <<
" b_m: name0,label0" << nam0 << labmap[ nam0 ];
576 DbgLv(1) <<
" b_m: namen,labeln" << namn << labmap[ namn ];
582 QTreeWidgetItem* pitems[ 8 ];
583 QTreeWidgetItem* item;
584 int wiubase = (int)QTreeWidgetItem::UserType;
585 int wiutype = wiubase + 0;
586 int nitems =
adescs.size();
589 QString indent(
" " );
594 for (
int ii = 0; ii < nitems; ii++ )
600 wiutype = wiubase + ii;
604 item =
new QTreeWidgetItem( pitems[ lev - 1 ], cvals, wiutype );
606 if ( lev == 2 ) nl2its++;
611 item =
new QTreeWidgetItem(
tw_recs, cvals, wiutype );
614 item->setCheckState( 0, Qt::Unchecked );
615 pitems[ lev ] = item;
619 tw_recs->resizeColumnToContents( 0 );
620 tw_recs->resizeColumnToContents( 1 );
621 tw_recs->resizeColumnToContents( 2 );
630 QList< QTreeWidgetItem* > items =
tw_recs->findItems( QString(
"" ),
631 Qt::MatchFixedString | Qt::MatchWrap | Qt::MatchRecursive, 0 );
633 for (
int ii = 0; ii < nitems; ii++ )
634 if (
adescs.at( ii ).level == 2 )
635 tw_recs->collapseItem( items.at( ii ) );
640 DbgLv(1) <<
"WIDGET SIZE" << size();
648 int nitems =
adescs.size();
649 int jndx = idesc->
linen;
650 int plev = idesc->
level;
651 DbgLv(1) <<
" CnCh: jndx nitems plev" << jndx << nitems << plev;
655 for (
int jj = jndx; jj < nitems; jj++ )
658 int clev = chdesc->
level;
660 if ( clev <= plev )
break;
666 DbgLv(1) <<
" CnCh: jj clev plev nchild nchkd" << jj << clev << plev
672 if ( nchkd == nchild && nchild > 0 )
675 else if ( nchkd > 0 )
685 int nitems =
adescs.size();
686 int jndx = idesc->
linen;
687 int plev = idesc->
level;
689 DbgLv(1) <<
" StCh: items jndx plev state" << nitems << jndx << plev << state;
691 if ( jndx == nitems )
return;
693 for (
int jj = jndx; jj < nitems; jj++ )
696 int clev = chdesc->
level;
697 DbgLv(1) <<
" StCh: jj clev state" << jj << clev << state;
699 if ( clev <= plev )
break;
708 int lndx = idesc->
linen - 2;
709 int clev = idesc->
level;
713 for (
int jj = lndx; jj >= 0; jj-- )
716 int plev = pdesc->
level;
717 DbgLv(1) <<
" StPa: jj plev clev state" << jj << plev << clev << state;
719 if ( plev >= clev )
continue;
722 DbgLv(1) <<
" StPa: nchild nchkd" << nchild << nchkd;
741 QList< QTreeWidgetItem* > items =
tw_recs->findItems( QString(
"" ),
742 Qt::MatchFixedString | Qt::MatchWrap | Qt::MatchRecursive, 0 );
743 QTreeWidgetItem* item;
747 for (
int jj = 0; jj <
adescs.size(); jj++ )
750 item = items.at( jj );
751 item->setCheckState( 0, (Qt::CheckState)
adescs.at( jj ).checkState );
763 QString file_url = QString(
"file:///" ) +
ppdfpath;
765 QString file_url = QString(
"file://" ) +
ppdfpath;
767 if ( ! QDesktopServices::openUrl( file_url ) )
768 QMessageBox::warning(
this, tr(
"Composite Report *ERROR*" ),
769 tr(
"Unable to open the composite report file:\n" )
775 QMessageBox::warning(
this, tr(
"Composite Report *ERROR*" ),
776 tr(
"Unable to create a composite report file:\n" )
788 QString indent = QString(
" " );
789 int jj =
pagedir.lastIndexOf(
"/" );
790 pagesdir = pagesdir.mid( jj + 1 );
791 compdir = compdir .left( jj );
792 QMessageBox::information(
this, tr(
"Composite Report" ),
793 tr(
"In the composite reports folder:\n" )
794 + indent + compdir +
" ,\n"
795 + tr(
"a composite report file has been saved:\n" )
796 + indent +
"report_composite.pdf ;\n"
797 + tr(
"with supporting HTML and components in subdirectory:\n" )
798 + indent + pagesdir );
803 QMessageBox::warning(
this, tr(
"Composite Report *ERROR*" ),
804 tr(
"Unable to create a composite report file:\n" )
812 const int mxpageht = 1100;
817 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
818 qApp->processEvents();
826 QMessageBox::warning(
this, tr(
"Select Error" ),
827 tr(
"No reports have been selected" ) );
828 QApplication::restoreOverrideCursor();
829 qApp->processEvents();
839 pagedir =
pagedir + QDateTime::currentDateTime().toString(
"-yyMMddhhmm" );
842 QString cmppath = rptpath +
"/composite";
844 QDir dirrpt( rptpath );
850 QMessageBox::warning(
this, tr(
"File Error" ),
851 tr(
"Could not create the directory:\n" ) +
pagepath );
852 QApplication::restoreOverrideCursor();
853 qApp->processEvents();
859 pagepath = pagedir +
"/report_composite.html";
864 rptpage = QString(
"<?xml version=\"1.0\"?>\n" );
865 rptpage +=
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n";
866 rptpage +=
" \"http://www.w3.org/TR/xhtml1/DTD"
867 "/xhtml1-strict.dtd\">\n";
868 rptpage +=
"<html xmlns=\"http://www.w3.org/1999/xhtml\""
869 " xml:lang=\"en\" lang=\"en\">\n";
870 rptpage +=
" <head>\n";
871 rptpage +=
" <title> Ultrascan III Composite Report </title>\n";
872 rptpage +=
" <meta http-equiv=\"Content-Type\" content="
873 "\"text/html; charset=iso-8859-1\"/>\n";
874 rptpage +=
" <style type=\"text/css\" >\n";
875 rptpage +=
" td { padding-right: 1em; }\n";
876 rptpage +=
" body { background-color: white; }\n";
877 rptpage +=
" .pagebreak\n";
879 rptpage +=
" page-break-before: always; border: 1px solid; \n";
881 rptpage +=
" .parahead\n";
883 rptpage +=
" font-weight: bold;\n";
884 rptpage +=
" font-style: italic;\n";
886 rptpage +=
" .datatext\n";
888 rptpage +=
" font-family: monospace;\n";
890 rptpage +=
" </style>\n";
891 rptpage +=
" </head>\n <body>\n";
897 int logof = (
hsclogo .isEmpty() ? 0 : 4 )
899 + (
us3logo .isEmpty() ? 0 : 1 );
905 if ( ( logof & 4 ) != 0 )
906 rptpage +=
" <img src=\"" +
hsclogo
907 +
"\" alt=\"HSC logo\"/>\n";
909 if ( ( logof & 2 ) != 0 )
910 rptpage +=
" <img src=\"" +
becklogo
911 +
"\" alt=\"Beckman logo\"/>";
913 if ( ( logof & 1 ) != 0 )
918 rptpage +=
"\n <img src=\"" +
us3logo
919 +
"\" alt=\"Ultrascan III logo\"/>\n";
925 rptpage +=
" </p>\n";
929 QString ppageclass =
" <p class=\"pagebreak parahead\">\n";
930 QString pheadclass =
" <p class=\"parahead\">\n";
931 QString dtextclass =
"\n <p class=\"datatext\">\n";
939 rptpage +=
" <h2> Reports from Run ";
941 rptpage +=
": </h2>\n\n";
946 rptpage +=
" <h2> Reports from Multiple Runs </h2>";
952 for (
int ii = 0; ii <
nsrpts; ii++ )
955 bool is_plot = ( idesc->
type.contains(
"Plot" ) );
956 bool is_data = ( idesc->
type.contains(
"text", Qt::CaseInsensitive ) )
957 || ( idesc->
type.contains(
"comma", Qt::CaseInsensitive ) );
963 if ( idesc->
filepath.contains(
".svg" ) )
965 QSvgRenderer svgrend;
967 chght = svgrend.defaultSize().height();
972 chght = QPixmap( idesc->
filepath ).height();
974 DbgLv(1) <<
" plot.height" << chght << idesc->
filename <<
"ph" << phght;
976 if ( jplot != 1 && ii > 0 )
979 rptpage += ppageclass;
985 if ( ( chght + phght ) < mxpageht )
988 rptpage += pheadclass;
994 DbgLv(1) <<
"++comb.height" << (chght+phght) <<
"NEW PAGE" << idesc->
filename;
995 rptpage += ppageclass;
1003 rptpage += ppageclass;
1010 rptpage += pheadclass;
1013 QString trdesc = idesc->
triple;
1016 trdesc = trdesc +
" " + idesc->
description;
1020 rptpage +=
" " + idesc->
runid +
" ";
1021 rptpage += trdesc +
"<br/>\n ";
1022 rptpage += idesc->
analysis +
"<br/>\n ";
1023 rptpage += idesc->
label +
"\n </p>\n";
1029 if ( fileimg.contains(
".svg" ) )
1031 QSvgRenderer svgrend;
1034 fileimg = QString( filesvg ).section(
".", 0, -2 ) +
".png";
1035 QString pathimg = pagedir +
"/" + fileimg;
1036 svgrend.load( pathsvg );
1037 QSize imgsize = svgrend.defaultSize();
1038 QPixmap pixmap( imgsize );
1039 pixmap.fill( Qt::white );
1040 QPainter pa( &pixmap );
1041 svgrend.render( &pa );
1042 DbgLv(1) <<
" size" << imgsize <<
" filesvg" << filesvg;
1043 DbgLv(1) <<
" size" << pixmap.size() <<
" fileimg" << fileimg;
1044 if ( ! pixmap.save( pathimg ) )
1046 QMessageBox::warning(
this, tr(
"Composite Report *ERROR*" ),
1047 tr(
"Unable to create an svg-to-png file:\n" )
1051 chght = imgsize.height();
1056 rptpage +=
" <div><img src=\"" + fileimg
1057 +
"\" alt=\"" + idesc->
label +
"\"/></div>\n\n";
1063 if ( fi.open( QIODevice::ReadOnly | QIODevice::Text ) )
1065 rptpage += dtextclass;
1066 QTextStream ts( &fi );
1068 while ( ! ts.atEnd() )
1070 rptpage +=
pad_line( ts.readLine() );
1073 rptpage +=
" </p>\n\n";
1081 if ( fi.open( QIODevice::ReadOnly | QIODevice::Text ) )
1083 QTextStream ts( &fi );
1086 while ( ! ts.atEnd() )
1088 QString ln = ts.readLine() +
"\n";
1092 if ( ln.contains(
"<body>" ) )
1097 else if ( stage == 2 )
1101 else if ( ln.contains(
"</body>" ) )
1104 if ( ln.contains(
"</table>" ) )
1110 if ( ln.contains(
"<br>" ) )
1111 ln.replace(
"<br>",
"<br/>" );
1124 rptpage +=
" </body>\n</html>";
1127 if ( flo.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
1129 QTextStream tso( &flo );
1135 for (
int ii = 0; ii <
nsrpts; ii++ )
1145 QApplication::restoreOverrideCursor();
1146 qApp->processEvents();
1155 QPrinter printer( QPrinter::HighResolution );
1156 printer.setOutputFormat ( QPrinter::PdfFormat );
1157 printer.setOutputFileName(
ppdfpath );
1159 printer.setCreator (
"UltraScan" );
1160 printer.setDocName ( QString(
"report_composite.html" ) );
1161 printer.setOrientation ( QPrinter::Portrait );
1162 printer.setPaperSize ( QPrinter::A2 );
1167 if ( fili.open( QIODevice::ReadOnly | QIODevice::Text ) )
1169 QTextStream ts( &fili );
1170 rpttext = ts.readAll();
1176 QString cmppath = QString(
pagepath ).section(
"/", 0, -2 );
1177 QDir::setCurrent( cmppath );
1178 QTextDocument document;
1179 document.setDefaultFont( QFont(
"serif", 14 ) );
1180 QSizeF pgsize = printer.paperSize( QPrinter::Point );
1181 document.setPageSize( pgsize );
1182 document.setHtml( rpttext );
1183 document.print( &printer );
1193 if ( pdff.exists() )
1196 if ( ! QFile::copy( ppdffold ,
ppdfpath ) )
1198 QMessageBox::information(
this, tr(
"UltraScan Error" ),
1199 tr(
"Unable to (over-)write the file:\n\n" ) +
ppdfpath );
1215 for (
int ii = 0; ii <
adescs.size(); ii++ )
1220 if ( idesc->
level != 3 ||
1236 if ( idesc->
type.contains(
"HTML" ) )
1239 else if ( idesc->
type.contains(
"Plot" ) )
1251 QString fileexts = tr(
1252 "HTML files (*.html);;PLOT files (*.svgz *.svg *.png);;"
1253 "Report file (*.rpt);;Data files (*.csv *.dat);;"
1254 "All files (*.*)" );
1255 int row =
tw_recs->currentItem()->type() - (int)QTreeWidgetItem::UserType;
1263 QString(
"</title>\n</head>\n<img src=\"" ) +
cdesc.
filepath +
1264 QString(
"\" alt=\"" +
cdesc.
label +
"\" />\n" );
1270 if ( fi.open( QIODevice::ReadOnly | QIODevice::Text ) )
1272 QTextStream ts( &fi );
1274 while ( ! ts.atEnd() )
1275 mtext += ts.readLine() +
"\n";
1287 editd->setWindowTitle( tr(
"Report Tree Item View" ) );
1288 editd->move( QCursor::pos() + QPoint( 100, 100 ) );
1289 editd->resize( 600, 500 );
1293 editd->
e->setHtml( mtext );
1295 editd->
e->setText( mtext );
1302 QString fileexts = tr(
"Text,Log files (*.txt, *.log);;All files (*)" );
1303 int row =
tw_recs->currentItem()->type() - (int)QTreeWidgetItem::UserType;
1309 tr(
"Data Tree Item at Row %1 -- \n\n" ).arg( row + 1 ) +
1310 tr(
" Tree Level : " ) + QString::number(
cdesc.
level ) +
"\n" +
1311 tr(
" Check State : " ) + QString::number(
cdesc.
checkState ) +
"\n" +
1315 tr(
" File Directory : " ) + filedir +
"\n" +
1322 editd->setWindowTitle( tr(
"Report Tree Item Details" ) );
1323 editd->move( QCursor::pos() + QPoint( 100, 100 ) );
1324 editd->resize( 600, 500 );
1327 editd->
e->setText( mtext );
1334 int row =
tw_recs->currentItem()->type() - (int)QTreeWidgetItem::UserType;
1339 QString fileext = filename.mid( filename.lastIndexOf(
"." ) + 1 );
1340 QString fileanp = filename.left( filename.indexOf(
"." ) );
1342 QString fileexts = fileext + tr(
" files (*." ) + fileext +
");;"
1343 + fileanp + tr(
" files (" ) + fileanp +
"*);;"
1344 + tr(
"All files (*)" );
1345 QString ofilname =
archdir + filename;
1348 QString fn = QFileDialog::getSaveFileName(
this,
1349 tr(
"Save Report File As ..." ), ofilname, fileexts );
1351 if ( fn.isEmpty() )
return;
1356 archdir = fn.left( fn.lastIndexOf(
"/" ) + 1 );
1362 QStringList selects;
1366 QString fn = QFileDialog::getOpenFileName(
this,
1367 tr(
"Load Report-Select Parameters in:" ),
1369 tr(
"ReportSelect files (rs_*.xml);;"
1370 "All XML files (*.xml);;"
1371 "All files (*)" ) );
1373 if ( fn.isEmpty() )
return;
1377 if ( xfi.open( QIODevice::ReadOnly | QIODevice::Text ) )
1380 QXmlStreamReader xml( &xfi );
1381 QXmlStreamAttributes att;
1383 while ( ! xml.atEnd() )
1387 if ( xml.isStartElement() && xml.name() ==
"selection" )
1389 att = xml.attributes();
1391 QString analys = att.value(
"analysis" ).toString();
1392 QString report = att.value(
"report" ).toString();
1394 rselect = analys + report;
1396 if ( selects.isEmpty() || ! selects.contains( rselect ) )
1404 for (
int ii = 0; ii <
adescs.size(); ii++ )
1408 if ( idesc->
level != 3 )
continue;
1411 int state = ( selects.contains( rselect ) ) ? 2 : 0;
1424 QString fn = QFileDialog::getSaveFileName(
this,
1425 tr(
"Save Report-Selection Parameters in:" ),
1427 tr(
"ReportSelect files (rs_*.xml);;"
1428 "All XML files (*.xml);;"
1429 "All files (*)" ) );
1431 if ( fn.isEmpty() )
return;
1434 fn = fn.replace(
"\\",
"/" );
1435 int jj = fn.lastIndexOf(
"/" ) + 1;
1436 QString fdir = fn.left( jj );
1437 QString fnam = fn.mid( jj );
1439 if ( fn.endsWith(
"." ) )
1441 fn = fn.left( fn.length() - 1 );
1442 fnam = fnam.left( fnam.length() - 1 );
1445 else if ( ! fn.endsWith(
".xml" ) )
1448 fnam = fnam +
".xml";
1451 if ( fnam.startsWith(
"." ) )
1453 fn = fdir + fnam.mid( 1 );
1456 else if ( ! fnam.startsWith(
"rs_" ) )
1458 fn = fdir +
"rs_" + fnam;
1465 if ( QMessageBox::No == QMessageBox::warning(
this,
1468 "This file exists already!\n\n"
1469 "Do you want to overwrite it?" ),
1470 QMessageBox::Yes, QMessageBox::No ) )
1474 bool saved_ok =
false;
1476 if ( xfo.open( QIODevice::WriteOnly | QIODevice::Text ) )
1478 QXmlStreamWriter xml( &xfo );
1479 xml.setAutoFormatting(
true );
1480 xml.writeStartDocument();
1481 xml.writeDTD (
"<!DOCTYPE US_ReportSelect>" );
1482 xml.writeStartElement(
"ReportSelect" );
1483 xml.writeAttribute (
"version",
"1.0" );
1485 for (
int ii = 0; ii <
adescs.size(); ii++ )
1492 xml.writeStartElement(
"selection" );
1493 xml.writeAttribute (
"analysis", idesc->
analysis );
1494 xml.writeAttribute (
"report", idesc->
label );
1495 xml.writeEndElement ();
1498 xml.writeEndElement ();
1499 xml.writeEndDocument ();
1505 QMessageBox::information(
this,
1506 tr(
"UltraScan Information" ),
1507 tr(
"Please note:\n\n"
1508 "The Report-Select Profile was successfully saved to:\n\n" ) +
1512 QMessageBox::information(
this,
1513 tr(
"UltraScan Error" ),
1514 tr(
"Please note:\n\n"
1515 "The Report-Select Profile could not be saved to:\n\n" ) +
1533 if (
hsclogo .startsWith(
".." ) &&
1543 QString etcnewp = cmppath +
"/etc/";
1544 QString relpath =
"../etc/";
1546 hsclogo .replace( etcpath, relpath );
1548 becklogo.replace( etcpath, relpath );
1550 us3logo .replace( etcpath, relpath );
1551 QString hscnewp = QString( hscorig ).replace( etcpath, etcnewp );
1552 QString becknewp = QString( beckorig ).replace( etcpath, etcnewp );
1553 QString us3newp = QString( us3orig ).replace( etcpath, etcnewp );
1554 DbgLv(1) <<
"hscOrig" << hscorig;
1556 DbgLv(1) <<
"hscNewp" << hscnewp;
1557 DbgLv(1) <<
"etcPath" << etcpath;
1558 DbgLv(1) <<
"etcNewp" << etcnewp;
1560 if ( (
hsclogo .isEmpty() || QFile( hscnewp ).exists() ) &&
1561 (
becklogo.isEmpty() || QFile( becknewp ).exists() ) &&
1562 (
us3logo .isEmpty() || QFile( us3newp ).exists() ) )
1566 QDir dircmp( cmppath );
1568 if ( ! dircmp.mkpath( etcnewp ) )
1570 QMessageBox::warning(
this, tr(
"Composite Report *ERROR*" ),
1571 tr(
"Unable to create a composite report directory:\n" )
1577 if ( !
hsclogo .isEmpty() && QFile( hscorig ).exists() )
1578 QFile::copy( hscorig , hscnewp );
1580 if ( !
becklogo.isEmpty() && QFile( beckorig ).exists() )
1581 QFile::copy( beckorig, becknewp );
1583 if ( !
us3logo .isEmpty() && QFile( us3orig ).exists() )
1584 QFile::copy( us3orig , us3newp );
1592 const QChar cbln(
' ' );
1593 const QChar ctab(
'\t' );
1594 const QString s_nbsp(
" " );
1598 for (
int ii = 0; ii < linein.size(); ii++ )
1600 QChar lchar = linein.at( ii );
1602 if ( lchar == cbln )
1604 lineout.append( s_nbsp );
1608 else if ( lchar == ctab )
1610 int nspc = 4 - ( kk & 3 );
1612 lineout.append( cbln );
1613 lineout.append( s_nbsp );
1615 for (
int jj = 0; jj < nspc; jj++ )
1616 lineout.append( s_nbsp );
1621 lineout.append( lchar );
1626 lineout +=
"<br/>\n";