20 runIDs( runIDs ), mDescrs( mdescrs )
27 setWindowTitle( tr(
"Select Run ID(s) for Discrete Distributions (%1)" )
28 .arg(
sel_db ?
"DB" :
"Local" ) );
30 setMinimumSize( 480, 300 );
34 QVBoxLayout*
main =
new QVBoxLayout(
this );
35 main->setContentsMargins( 2, 2, 2, 2 );
36 main->setSpacing ( 2 );
39 QGridLayout* top =
new QGridLayout;
50 QLabel* lb_filtdata =
us_label( tr(
"Search" ) );
58 connect(
le_dfilter, SIGNAL( textChanged(
const QString& ) ),
59 SLOT (
search (
const QString& ) ) );
63 top->addWidget(
pb_invest, row, 0, 1, 1 );
64 top->addWidget(
le_invest, row++, 1, 1, 2 );
65 top->addWidget( lb_filtdata, row, 0, 1, 1 );
68 main->addLayout( top );
73 lw_data =
new QListWidget(
this );
74 lw_data->setFrameStyle ( QFrame::NoFrame );
77 lw_data->setSelectionMode( QAbstractItemView::ExtendedSelection );
78 connect(
lw_data, SIGNAL( itemSelectionChanged() ),
84 QHBoxLayout* buttons =
new QHBoxLayout;
89 connect( pb_cancel, SIGNAL( clicked() ), SLOT(
cancelled() ) );
90 connect( pb_accept, SIGNAL( clicked() ), SLOT(
accepted() ) );
92 buttons->addWidget( pb_cancel );
93 buttons->addWidget( pb_accept );
95 main->addLayout( buttons );
98 QFontMetrics fm( font );
99 int fhigh = fm.lineSpacing();
100 int fwide = fm.width( QChar(
'6' ) );
101 int lhigh = fhigh * 4 + 12;
102 int lwide = fwide * 32;
119 lw_data->setCurrentItem( NULL );
121 for (
int ii = 0; ii <
lw_data->count(); ii++ )
123 QListWidgetItem* lwi =
lw_data->item( ii );
124 bool hide = ! lwi->text().contains( search_string, Qt::CaseInsensitive );
125 lwi->setHidden( hide );
132 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
144 QApplication::restoreOverrideCursor();
149 QString clabel = tr(
"No data found." );
150 lw_data->addItem(
new QListWidgetItem( clabel ) );
155 for (
int ii = 0; ii <
rlabels.size(); ii++ )
157 QString clabel =
rlabels.at( ii );
159 lw_data->addItem(
new QListWidgetItem( clabel ) );
166 tr(
"%1 scanned run IDs were used to derive the list. Of these,\n"
167 "%2 (may) have associated distributions (models), and\n"
168 "%3 %4 currently selected for combination plot components." )
170 .arg(
count_seld != 1 ? tr(
"runs are" ) : tr(
"run is" ) ) );
185 DbgLv(1) <<
"SE:accepted()";
186 QList< QListWidgetItem* > selitems =
lw_data->selectedItems();
188 if ( selitems.size() == 0 )
190 QMessageBox::information(
this,
191 tr(
"No Data Selected" ),
192 tr(
"You have not selected any data.\nSelect or Cancel" ) );
196 QString slines =
te_status->toPlainText() +
197 tr(
"\nScanning models for selected run(s)..." );
199 qApp->processEvents();
200 DbgLv(1) <<
"SE: slines" << slines;
201 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
205 for (
int ii = 0; ii < selitems.size(); ii++ )
207 QListWidgetItem* lwi_data = selitems.at( ii );
208 QString clabel = lwi_data->text();
209 DbgLv(1) <<
"SE: ii clabel" << ii << clabel;
221 QApplication::restoreOverrideCursor();
222 qApp->processEvents();
227 QMessageBox::warning(
this,
228 tr(
"No Implied Models" ),
229 tr(
"There were no Discrete Distributions associated\n"
230 " with the selected run(s).\n"
231 "Cancel or select a new set of runs." ) );
254 QMessageBox::critical(
this,
255 tr(
"DB Connection Problem" ),
256 tr(
"There was an error connecting to the database:\n" )
268 query <<
"get_experiment_desc" << invID;
273 QString runid = db.value( 1 ).toString();
274 DbgLv(1) <<
"ScDB: runid" << runid;
276 if ( !
runIDs.contains( runid ) )
284 DbgLv(1) <<
"ScDB:scan time(1)" << timer.elapsed();
288 DbgLv(1) <<
"ScDB:scan time(9)" << timer.elapsed();
297 QMap< QString, QString > ddmap;
300 QStringList mfilt(
"M*.xml" );
301 QStringList f_names = QDir( mdir )
302 .entryList( mfilt, QDir::Files, QDir::Name );
304 for (
int ii = 0; ii < f_names.size(); ii++ )
306 QString fname( mdir +
"/" + f_names[ ii ] );
307 QFile m_file( fname );
309 if ( ! m_file.open( QIODevice::ReadOnly | QIODevice::Text ) )
312 QXmlStreamReader xml( &m_file );
314 while( ! xml.atEnd() )
318 if ( xml.isStartElement() )
320 if ( xml.name() ==
"model" )
322 QXmlStreamAttributes attr = xml.attributes();
323 QString mdesc = attr.value(
"description" ).toString();
324 QString ddesc = attr.value(
"dataDescrip" ).toString();
325 QString mGUID = attr.value(
"modelGUID" ).toString();
326 QString eGUID = attr.value(
"editGUID" ).toString();
327 int kk = mdesc.lastIndexOf(
".model" );
328 mdesc = ( kk < 1 ) ? mdesc : mdesc.left( kk );
329 QString runid = mdesc.section(
".", 0, -3 );
331 if ( runid.isEmpty() || runid.length() < 2 )
continue;
333 if ( ddesc.isEmpty() )
335 if ( ddmap.contains( eGUID ) )
336 ddesc = ddmap[ eGUID ];
340 if ( !ddmap.contains( eGUID ) )
341 ddmap[ eGUID ] = ddesc;
345 if ( mdesc.contains(
"-MC" ) )
347 kk = mdesc.indexOf(
"_mc0" );
350 int niters = attr.value(
"MCIteration" ).toString()
352 mdesc = QString( mdesc ).left( kk ) +
353 QString().sprintf(
"_mcN%03d", niters ) +
354 QString( mdesc ).mid( kk + 7 );
359 QString odesc = runid +
"\t" + mGUID +
"\t" + mdesc
364 if((
dbg_level>0) && (!mdesc.contains(
"-MC_")||mdesc.contains(
"_mc")))
365 DbgLv(1) <<
"ScLo: odesc" << odesc;
368 if ( xml.name() ==
"analyte" )
376 for (
int mm = 0; mm <
wDescrs.count(); mm++ )
379 QString ddesc = mdesc.section(
"\t", 3, 3 );
381 if ( ddesc.isEmpty() )
383 QString eGUID = mEdtIDs[ mm ];
384 if ( ddmap.contains( eGUID ) )
386 ddesc = ddmap[ eGUID ];
387 DbgLv(1) <<
"ScLo: mm" << mm <<
"eGUID" << eGUID <<
"new ddesc" << ddesc;
388 mdesc = mdesc.section(
"\t", 0, 2 ) +
"\t" + ddesc;
394 DbgLv(1) <<
"ScLo:scan time(1)" << timer.elapsed();
397 QStringList aucdirs = QDir( rdir ).entryList(
398 QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name );
399 DbgLv(1) <<
"ScLo:rdir" << rdir <<
"aucdir count" << aucdirs.count();
401 QStringList aucfilt(
"*.auc" );
409 for (
int ii = 0; ii < aucdirs.count(); ii++ )
411 QString subdir = rdir +
"/" + aucdirs.at( ii );
412 QStringList aucfiles = QDir( subdir ).entryList(
413 aucfilt, QDir::Files, QDir::Name );
414 DbgLv(1) <<
"ScLo: subdir" << subdir <<
"aucfiles count" << aucfiles.count();
416 if ( aucfiles.count() < 1 )
419 QString aucfbase = aucfiles.at( 0 );
420 QString runID = aucfbase.section(
".", 0, -6 );
424 if (
mRunIDs.contains( runID ) )
430 <<
" runID" << runID;
433 DbgLv(1) <<
"ScLo:scan time(9)" << timer.elapsed();
444 connect( dialog, SIGNAL( investigator_accepted(
int ) ),
453 QString number = ( ID > 0 ) ? QString::number( ID ) +
": " :
"";
472 setWindowTitle( tr(
"Select Run ID(s) for Discrete Distributions (%1)" )
473 .arg(
sel_db ?
"DB" :
"Local" ) );
479 QList< QListWidgetItem* > selitems =
lw_data->selectedItems();
480 int kseld = selitems.size();
486 QString slabel = selitems[ 0 ]->text();
490 DbgLv(1) <<
"sChg: count_models()";
496 selitems =
lw_data->findItems( slabel, Qt::MatchFixedString );
497 kseld = selitems.size();
499 lw_data->setCurrentItem( selitems[ 0 ] );
500 connect(
lw_data, SIGNAL( itemSelectionChanged() ),
506 tr(
"%1 scanned run IDs were used to derive the list. Of these,\n"
507 "%2 have associated distributions (models), and\n"
508 "%3 %4 currently selected for combination plot components." )
510 .arg(
count_seld != 1 ? tr(
"runs are" ) : tr(
"run is" ) ) );
521 QMessageBox::information(
this,
522 tr(
"DB Connection Problem" ),
523 tr(
"There was an error connecting to the database:\n" )
531 QVector< QString > mmDescs;
532 QMap< QString, QString > ddmap;
542 for (
int rr = 0; rr <
runIDs.count(); rr++ )
544 QString runid =
runIDs[ rr ];
546 query <<
"get_model_desc_by_runID" << invID << runid;
551 QString mdlid = db.value( 0 ).toString();
552 QString mdlGid = db.value( 1 ).toString();
553 QString mdesc = db.value( 2 ).toString();
554 QString edtid = db.value( 6 ).toString();
555 int kk = mdesc.lastIndexOf(
".model" );
556 mdesc = ( kk < 1 ) ? mdesc : mdesc.left( kk );
563 DbgLv(1) <<
"ScMd: runid" << runid <<
"nmodel" << nmodel;
566 QString grunid =
"global-" + runid +
"%";
568 query <<
"get_model_desc_by_runID" << invID << grunid;
573 QString mdlid = db.value( 0 ).toString();
574 QString mdlGid = db.value( 1 ).toString();
575 QString mdesc = db.value( 2 ).toString();
576 QString edtid = db.value( 6 ).toString();
577 int kk = mdesc.lastIndexOf(
".model" );
578 mdesc = ( kk < 1 ) ? mdesc : mdesc.left( kk );
585 DbgLv(1) <<
"ScMd: runid" << runid <<
"nmodel" << nmodel;
587 DbgLv(1) <<
"ScMd:scan time(1)" << timer.elapsed();
590 query <<
"count_models" << invID;
591 ntmodel = db.functionQuery( query );
592 DbgLv(1) <<
"ScMd: ntmodel" << ntmodel <<
"nmodel" << nmodel;
593 DbgLv(1) <<
"ScMd:scan time(2)" << timer.elapsed();
596 DbgLv(1) <<
"ScMd: 0: id,gid,eid,desc" << mmIDs[0] << mmGUIDs[0] << meIDs[0] << mmDescs[0];
597 DbgLv(1) <<
"ScMd: m: id,gid,eid,desc" << mmIDs[m] << mmGUIDs[m] << meIDs[m] << mmDescs[m]; }
601 for (
int mm = nmodel - 1; mm >=0; mm-- )
603 QString medtid = meIDs[ mm ];
605 if ( ddmap.contains( medtid ) )
continue;
608 QString mdlid = mmIDs[ mm ];
610 query <<
"get_model_info" << mdlid;
613 QString mxml = db.value( 2 ).toString();
614 int kk = mxml.indexOf(
"dataDescrip=" );
615 DbgLv(1) <<
"ScMd: mm kk medtid" << mm << kk << medtid;
619 QString ddesc = mxml.mid( kk + 13 );
620 kk = ddesc.indexOf(
"\"" );
621 ddesc = ddesc.left( kk );
622 ddmap[ medtid ] = ddesc;
625 DbgLv(1) <<
"ScMd:scan time(3)" << timer.elapsed();
629 for (
int mm = 0; mm < nmodel; mm++ )
631 QString mID = mmIDs [ mm ];
632 QString mGUID = mmGUIDs[ mm ];
633 QString mdesc = mmDescs[ mm ];
634 QString meID = meIDs [ mm ];
635 QString ddesc = ddmap.contains( meID ) ? ddmap[ meID ] :
"";
636 QString runid = mdesc.section(
".", 0, -3 );
637 QString odesc = runid +
"\t" + mGUID +
"\t" + mdesc +
"\t" + ddesc;
639 DbgLv(1) <<
"ScMd: mm meID" << mm << meID <<
"ddesc" << ddesc;
642 DbgLv(1) <<
"ScMd:scan time(9)" << timer.elapsed();
653 for (
int mm = 0; mm < aDescrs.count(); mm++ )
655 QString mdesc = aDescrs[ mm ];
656 QString runid = mdesc.section(
"\t", 0, 0 );
657 QString grunid =
"global-" + runid;
659 if (
runIDs.contains( runid ) ||
runIDs.startsWith( grunid ) )
662 DbgLv(1) <<
"ScMl:counts: aDescrs" << aDescrs.count() <<
"wDescrs" <<
wDescrs.count();
675 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
676 te_status->setText( tr(
"Scanning runs for model counts..." ) );
677 qApp->processEvents();
682 for (
int rr = 0; rr <
runIDs.count(); rr++ )
684 QString runid =
runIDs[ rr ];
686 query <<
"count_models_by_runID" << invID << runid;
687 int nrmods = db.functionQuery( query );
688 QString grunid =
"global-" + runid +
"%";
690 query <<
"count_models_by_runID" << invID << grunid;
691 nrmods += db.functionQuery( query );
695 DbgLv(1) <<
"KntM: counts: runIDs rmodKnts"
697 DbgLv(1) <<
"KntM:scan time(2)" << timer.elapsed();
703 for (
int rr = 0; rr <
runIDs.count(); rr++ )
707 QString clabel =
runIDs[ rr ];
709 lw_data->addItem(
new QListWidgetItem( clabel ) );
712 DbgLv(1) <<
"KntM:scan time(3)" << timer.elapsed();
715 QApplication::restoreOverrideCursor();
719 tr(
"%1 scanned run IDs were used to derive the list. Of these,\n"
720 "%2 have associated distributions (models), and\n"
721 "%3 %4 currently selected for combination plot components." )
723 .arg(
count_seld != 1 ? tr(
"runs are" ) : tr(
"run is" ) ) );
724 qApp->processEvents();