15 US_Model& amodel, QString& adescr,
const QString eGUID )
17 omodel( amodel ), odescr( adescr ), omodels( wmodels ), odescrs( mdescrs ),
28 US_Model& amodel, QString& adescr, QStringList& arunIDs )
30 omodel( amodel ), odescr( adescr ), omodels( wmodels ), odescrs( mdescrs ),
41 QList< US_Model >& amodels, QStringList& adescrs,
42 QStringList& arunIDs )
44 omodel( model ), odescr( search ), omodels( amodels ), odescrs( adescrs ),
55 QList< US_Model >& amodels, QStringList& adescrs )
57 omodel( model ), odescr( search ), omodels( amodels ), odescrs( adescrs ),
69 qDebug() <<
"ML:BD: runIDs empty" <<
runIDs.isEmpty();
70 setWindowTitle(
multi ? tr(
"Load Distribution Model(s)" )
71 : tr(
"Load Distribution Model" ) );
73 setMinimumSize( 320, 300 );
79 QVBoxLayout*
main =
new QVBoxLayout(
this );
80 main->setContentsMargins( 2, 2, 2, 2 );
81 main->setSpacing ( 2 );
84 QGridLayout* top =
new QGridLayout( );
96 gray.setColor( QPalette::Base, QColor( 0xe0, 0xe0, 0xe0 ) );
103 QString number = ( inv > 0 ) ? QString::number( inv ) +
": " :
"";
140 connect(
le_mfilter, SIGNAL( returnPressed() ),
142 connect(
le_mfilter, SIGNAL( textChanged(
const QString& ) ),
143 this, SLOT(
msearch(
const QString& ) ) );
152 main->addLayout( top );
158 lw_models->setSelectionMode( QAbstractItemView::ExtendedSelection );
164 QGridLayout* advtypes =
new QGridLayout;
165 QLabel* lb_advopts =
us_banner( tr(
"Advanced Model List Options" ) );
166 lb_advopts->setMaximumHeight(
le_mfilter->height() );
168 QGridLayout* lo_single =
us_checkbox( tr(
"Monte Carlo Singles" ),
170 QGridLayout* lo_edit =
us_checkbox( tr(
"Filter by Edit/Run" ),
172 QGridLayout* lo_unasgn =
us_checkbox( tr(
"Edit-Unassigned Only" ),
175 advtypes->addWidget( lb_advopts, arow++, 0, 1, 3 );
176 advtypes->addLayout( lo_single, arow, 0, 1, 1 );
177 advtypes->addLayout( lo_edit, arow, 1, 1, 1 );
178 advtypes->addLayout( lo_unasgn, arow++, 2, 1, 1 );
180 connect(
ck_single, SIGNAL( toggled (
bool ) ),
182 connect(
ck_edit, SIGNAL( toggled (
bool ) ),
184 connect(
ck_unasgn, SIGNAL( toggled (
bool ) ),
187 main->addLayout( advtypes );
190 QHBoxLayout* buttons =
new QHBoxLayout;
193 connect( pb_help, SIGNAL( clicked() ),
this, SLOT(
help() ) );
194 buttons->addWidget( pb_help );
197 connect( pb_cancel, SIGNAL( clicked() ),
this, SLOT(
cancelled() ) );
198 buttons->addWidget( pb_cancel );
201 connect( pb_accept, SIGNAL( clicked() ),
this, SLOT(
accepted() ) );
202 buttons->addWidget( pb_accept );
204 main->addLayout( buttons );
231 QMessageBox::information(
this,
232 tr(
"DB Connection Problem" ),
233 tr(
"There was an error connecting to the database:\n" )
242 rc = model.
load( modelID,
dbP );
243 qDebug() <<
"LdM: model load rc" << rc;
250 rc = model.
load( filename );
251 qDebug() <<
"LdM: Dk filename" << filename;
262 for (
int jj = 0; jj < nxmls; jj++ )
264 QString mcont = xmls[ jj ];
265 int kk = mcont.indexOf(
"description=" );
266 QString mdescr = QString( mcont ).mid( kk, 100 )
267 .section(
'"', 1, 1 );
268 if ( mdescr == sdescr )
271 qDebug() <<
"LdM: match at jj" << jj <<
"ncomp" << model.
components.size();
324 SIGNAL( investigator_accepted(
int ) ),
333 QString number = ( ID > 0 ) ? QString::number( ID ) +
": " :
"";
342 qDebug() <<
"LIST_MODELS";
343 QDateTime time0=QDateTime::currentDateTime();
344 QDateTime time1=QDateTime::currentDateTime();
345 QDateTime time2=QDateTime::currentDateTime();
346 const QString uaGUID(
"00000000-0000-0000-0000-000000000000" );
348 le_mfilter->disconnect( SIGNAL( textChanged(
const QString& ) ) );
349 bool listdesc = !mfilt.isEmpty();
352 bool listall = !listdesc;
353 QRegExp mpart = QRegExp(
".*" + mfilt +
".*", Qt::CaseInsensitive );
355 qDebug() <<
"LM: desc single edit" << listdesc << listsing << listedit
367 QMessageBox::information(
this,
368 tr(
"Edit GUID Problem" ),
369 tr(
"No EditGUID/runIDs given.\nEdit filter turned off." ) );
384 qDebug() <<
"listall" << listall <<
"do_manual" <<
do_manual;
385 qDebug() <<
" listdesc listedit listsing" << listdesc << listedit << listsing;
396 QMessageBox::information(
this,
397 tr(
"DB Connection Problem" ),
398 tr(
"There was an error connecting to the database:\n" )
411 qDebug() <<
" rd count" << countRD;
415 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
417 if ( countRD > 0 && countRD == countSD )
422 qDebug() <<
" kid1 kid2" << kid1 << kid2;
425 if ( countRD == 0 || kid1 !=
db_id1 || kid2 != db_id2 )
432 int nruns =
runIDs.size();
435 if ( nruns == 0 && !
editGUID.isEmpty() )
443 editID =
dbP->
value( 0 ).toString();
446 qDebug() <<
" edit GUID,ID" <<
editGUID << editID;
448 int kruns = listedit ? qMax( nruns, 1 ) : 1;
449 qDebug() <<
" kruns listedit" << kruns << listedit;
451 for (
int ii = 0; ii < kruns; ii++ )
453 qDebug() <<
" ii kruns nruns" << ii << kruns << nruns;
455 time1=QDateTime::currentDateTime();
459 query <<
"get_model_desc_by_editID"
463 else if ( listedit &&
can_run )
465 query <<
"get_model_desc_by_runID"
466 << invID <<
"%" +
runIDs[ ii ] +
"%";
470 query <<
"get_model_desc_by_editID" << invID <<
"1";
473 query <<
"get_model_desc" << invID;
475 qDebug() <<
" query" << query;
478 time2=QDateTime::currentDateTime();
479 qDebug() <<
"Timing: get_model_desc" << time1.msecsTo(time2);
491 .section(
"_", 0, 3 );
494 bool skip_it =
false;
499 + tr(
" : empty description )" );
505 skip_it = ( desc.
editGUID != uaGUID );
513 qDebug() <<
" (m)desc" << desc.
description <<
"skip_it" << skip_it;
518 skip_it = ( desc.
editGUID != uaGUID );
519 qDebug() <<
" (u)desc" << desc.
description <<
"skip_it" << skip_it;
530 qDebug() <<
" mcndx" << mcndx <<
"descr" << desc.
description;
535 .mid( mcndx + 4, 3 ).toInt();
537 qDebug() <<
" desc.iters(nimods)" << desc.
iterations;
547 QDateTime time3=QDateTime::currentDateTime();
556 QDateTime time4=QDateTime::currentDateTime();
558 qDebug() <<
"Timing: DB-read" << time0.msecsTo(time3) << time2.msecsTo(time3);
559 qDebug() <<
"Timing: Compress" << time3.msecsTo(time4) << time2.msecsTo(time4);
562 QApplication::restoreOverrideCursor();
569 if ( !dir.exists( path ) )
576 QStringList filter(
"M*.xml" );
577 QStringList f_names = dir.entryList( filter, QDir::Files, QDir::Name );
579 qDebug() <<
" fn size" << f_names.size();
583 QXmlStreamAttributes attr;
586 int nruns =
runIDs.size();
587 qDebug() <<
"nruns" << nruns <<
"editGUID" <<
editGUID;
589 for (
int ii = 0; ii < f_names.size(); ii++ )
591 QString fname( path +
"/" + f_names[ ii ] );
592 qDebug() <<
"fname" << f_names[ii] <<
"do_manual" <<
do_manual;
593 QFile m_file( fname );
595 if ( !m_file.open( QIODevice::ReadOnly | QIODevice::Text ) )
599 QXmlStreamReader xml( &m_file );
601 while ( ! xml.atEnd() )
605 if ( xml.isStartElement() && xml.name() ==
"model" )
607 attr = xml.attributes();
608 QString edGUID = attr.value(
"editGUID" ).toString();
609 QString descript = attr.value(
"description" ).toString();
610 QString runID = QString( descript ).section(
".", 0, -4);
611 QString mCarl = attr.value(
"monteCarlo" ).toString();
612 int iters = mCarl.toInt();
613 iters = descript.contains(
"mcN" ) ? 1 : iters;
616 if ( (
do_edit && edGUID != editGUID ) ||
620 qDebug() <<
" nimods" << nimods <<
"edGUID" << edGUID <<
"iters" << iters;
624 if ( nimods > 1 )
continue;
629 desc.
modelGUID = attr.value(
"modelGUID" ).toString();
633 desc.
reqGUID = attr.value(
"requestGUID" ).toString();
635 QString aType = attr.value(
"analysisType" ).toString();
636 QString gType = attr.value(
"globalType" ).toString();
641 "... : " + tr(
"empty description )" );
653 int iaType = aType.toInt();
661 int iaType = aType.toInt();
662 int igType = gType.toInt();
677 qDebug() <<
" kmmmod" << kmmmod <<
"kmmold" << kmmold;
687 else if ( xml.isEndElement() && xml.name() ==
"ModelData" )
695 + QString().sprintf(
"_mcN%03i", nimods )
722 QString msg = tr(
"%1 MC model sets are old-style separate models\n"
723 "%2 MC models are new-style composite models\n"
724 "%3 total MC model records currently exist.\n"
725 "The old-style models should be converted\n"
727 .arg( kmmold).arg( kmmnew ).arg( kmmmod );
728 QMessageBox::information(
this,
729 tr(
"Deprecated MC Model Types Exist" ), msg );
733 QDateTime time5=QDateTime::currentDateTime();
734 qDebug() <<
"Timing: Time5" << time0.msecsTo(time5) << time2.msecsTo(time5);
760 lw_models->disconnect( SIGNAL( currentRowChanged(
int ) ) );
769 maxlch = qMax( maxlch,
779 lw_models->addItem(
"No models found." );
781 QDateTime time6=QDateTime::currentDateTime();
782 qDebug() <<
"Timing: Time6" << time0.msecsTo(time6) << time2.msecsTo(time6);
787 QFontMetrics fm =
lw_models->fontMetrics();
791 int width = qMin( 600, maxlch * fm.maxWidth() );
792 int height = qMin( 800, nlines * fm.lineSpacing() );
793 width = qMax( width, olwid );
794 height = ( height > olhgt ) ? height : ( ( olhgt + height ) / 2 );
795 width = this->width() + width - olwid;
796 height = this->height() + height - olhgt;
798 resize( width, height );
800 connect(
le_mfilter, SIGNAL( textChanged(
const QString& ) ),
801 this, SLOT(
msearch(
const QString& ) ) );
817 QList< QListWidgetItem* > selmods =
lw_models->selectedItems();
826 QString mdesc = selmods[ ii ]->text();
836 QMessageBox::information(
this,
837 tr(
"No Model Selected" ),
838 tr(
"You have not selected a model.\nSelect+Accept or Cancel" ) );
842 qDebug() <<
"ACC: multi" <<
multi;
845 qDebug() <<
"ACC: load... (single)";
847 qDebug() <<
"ACC: ...loaded (single)";
856 QDateTime time1=QDateTime::currentDateTime();
857 qDebug() <<
"ACC: load... (multi) mCnt" <<
modelsCount;
865 qDebug() <<
"ACC: ...loaded (multi)";
866 QDateTime time2=QDateTime::currentDateTime();
867 qDebug() <<
"Timing: accept-load: mcount" << modelsCount
868 <<
"time(ms)" << time1.msecsTo(time2);
893 e->type() == QEvent::ContextMenu )
896 QPoint mpos = ((QContextMenuEvent*)e)->pos();
906 return US_WidgetsDialog::eventFilter( obj, e );
915 for (
int jj = 0; jj < mds.size(); jj++ )
917 if ( mdesc.compare( mds[ jj ].description ) == 0 )
951 lblid = tr(
"\n Model File Name: " );
956 lblid = tr(
"\n Database Model ID: " );
960 QList< QListWidgetItem* > selmods =
lw_models->selectedItems();
969 mdesc = selmods[ 0 ]->text();
975 mdesc =
lw_models->itemAt( pos )->text();
985 mdesc = mdesc.length() < 50 ? mdesc :
986 mdesc.left( 23 ) +
"..." + mdesc.right( 24 );
993 runid = mdesc.section(
".", 0, 0 );
994 int jts = runid.indexOf(
"_" + tdesc );
995 runid = jts > 0 ? runid.left( jts ) : runid;
999 mdlid = mdlid.length() < 50 ? mdlid :
1000 "*/" + mdlid.section(
"/", -3, -1 );
1002 dtext = tr(
"Model Information:" )
1003 + tr(
"\n Description: " ) + mdesc
1004 + tr(
"\n Implied RunID: " ) + runid
1005 + tr(
"\n Type: " ) + tdesc
1006 +
" (" + QString::number( (
int)mtype ) +
")"
1013 + tr(
"\n Iterations: " ) + QString::number( iters )
1014 + tr(
"\n Components Count: " ) + QString::number( ncomp )
1015 + tr(
"\n Associations Count: " ) + QString::number( nassoc )
1016 + tr(
"\n List Row: " ) + QString::number( row )
1017 + tr(
"\n Analysis Run ID: " ) + anlid
1029 mdesc = selmods[ 0 ]->text();
1034 runid = mdesc.section(
".", 0, 0 );
1038 int jts = runid.indexOf(
"_" + tdesc );
1039 runid = jts > 0 ? runid.left( jts ) : runid;
1050 mdesc = selmods[ jj ]->text();
1055 runid = mdesc.section(
".", 0, 0 );
1059 if ( !aruni.isEmpty() && aruni.compare( runid ) != 0 )
1062 if ( !atype.isEmpty() && atype.compare( tdesc ) != 0 )
1065 if ( !aegid.isEmpty() && aegid.compare( eguid ) != 0 )
1068 if ( aruni.isEmpty() && atype.isEmpty() && aegid.isEmpty() )
1073 dtext = tr(
"Common Model Information ( " )
1074 + QString::number( modelsCount )
1075 + tr(
" models ):" );
1077 if ( !aruni.isEmpty() )
1078 dtext = dtext + tr(
"\n Run ID: " ) + aruni;
1080 if ( !atype.isEmpty() )
1081 dtext = dtext + tr(
"\n Type: " ) + atype;
1083 if ( !aegid.isEmpty() )
1084 dtext = dtext + tr(
"\n Related Edit GUID: " ) + aegid;
1091 mdesc = selmods[ jj ]->text();
1097 mdesc = mdesc.length() < 50 ? mdesc :
1098 mdesc.left( 23 ) +
"..." + mdesc.right( 24 );
1102 runid = mdesc.section(
".", 0, 0 );
1106 mdlid = mdlid.length() < 50 ? mdlid :
1107 "*/" + mdlid.section(
"/", -3, -1 );
1108 mdlid = mdlid.length() < 50 ? mdlid :
1109 mdlid.left( 23 ) +
"..." + mdlid.right( 24 );
1114 dtext = dtext + tr(
"\n\nModel Information: (" )
1115 + QString::number( ( jj + 1 ) ) +
"):"
1116 + tr(
"\n Description: " ) + mdesc
1117 + tr(
"\n Implied RunID: " ) + runid
1118 + tr(
"\n Type: " ) + tdesc
1119 +
" (" + QString::number( (
int)mtype ) +
")"
1126 + tr(
"\n Iterations: " ) + QString::number( iters )
1127 + tr(
"\n Components Count: " ) + QString::number( ncomp )
1128 + tr(
"\n Associations Count: " ) + QString::number( nassoc )
1129 + tr(
"\n List Row: " ) + QString::number( row )
1130 + tr(
"\n Analysis Run ID: " ) + anlid
1137 edit->setWindowTitle( tr(
"Model Information" ) );
1138 edit->move( this->pos() + pos + QPoint( 100, 100 ) );
1139 edit->resize( 600, 400 );
1141 edit->
e->setText( dtext );
1161 qDebug() <<
"SL: ii" << ii <<
"mindx" << mindx;
1171 QString cmiter = QString( cdtext ).mid( mindx, 7 );
1172 int niters = QString( cmiter ).mid( 4 ).toInt();
1174 qDebug() <<
"SL: niters" << niters <<
"cmiter" << cmiter;
1176 for (
int jj = 1; jj <= niters; jj++ )
1178 QString imiter = QString().sprintf(
"_mc%04d", jj );
1180 idesc.
description = QString( cdtext ).replace( cmiter, imiter );
1181 qDebug() <<
"SL: jj" << jj <<
"imiter" << imiter;
1194 if ( search_string.endsWith(
"=" ) )