16 const QString eGUID,
const QString arunID )
18 omrecs( amrecs ), odescr( adescr )
23 setWindowTitle( tr(
"Load a Model Records Vector" ) );
25 setMinimumSize( 320, 300 );
31 QVBoxLayout*
main =
new QVBoxLayout(
this );
32 main->setContentsMargins( 2, 2, 2, 2 );
33 main->setSpacing ( 2 );
36 QGridLayout* top =
new QGridLayout( );
55 connect(
le_mfilter, SIGNAL( returnPressed() ),
57 connect(
le_mfilter, SIGNAL( textChanged(
const QString& ) ),
58 this, SLOT(
msearch(
const QString& ) ) );
64 main->addLayout( top );
72 QGridLayout* lo_edit =
us_checkbox( tr(
"Filter by Edit" ),
74 connect(
ck_edit, SIGNAL( toggled (
bool ) ),
77 main->addLayout( lo_edit );
80 QHBoxLayout* buttons =
new QHBoxLayout;
90 connect( pb_help, SIGNAL( clicked() ),
this, SLOT(
help() ) );
91 connect( pb_cancel, SIGNAL( clicked() ),
this, SLOT(
cancelled() ) );
96 buttons->addWidget( pb_help );
97 buttons->addWidget( pb_cancel );
104 main->addLayout( buttons );
128 QMessageBox::information(
this,
129 tr(
"DB Connection Problem" ),
130 tr(
"There was an error connecting to the database:\n" )
139 query <<
"get_mrecs_info" << mrecsID;
140 qDebug() <<
" query" << query;
147 xmlstr =
dbP->
value( 1 ).toString();
148 QString dcksm =
dbP->
value( 7 ).toString();
149 int dsize =
dbP->
value( 8 ).toInt();
150 qDebug() <<
" len(xmlstr)" << xmlstr.length();
154 QString frunID = QString( descript ).section(
".", -4, -4 );
155 QString triple = QString( descript ).section(
".", -3, -3 );
156 QString analID = QString( descript ).section(
".", -2, -2 );
157 QString anedit = QString( analID ).section(
"_", -5, -5 );
158 QString anadat = QString( analID ).section(
"_", -4, -4 );
159 QString antype = QString( analID ).section(
"_", -3, -3 );
160 QString anrqid = QString( analID ).section(
"_", -2, -2 );
161 analID = anedit.left( 7 ) +
"_"
162 + anadat.left( 7 ) +
"_"
163 + antype +
"_" + anrqid;
164 QString fname =
"pcsa-mrs." + triple +
"." + analID +
".xml";
167 QFile filemr( fpath );
168 if ( filemr.exists() )
171 QString fcksm = QString( sumsiz ).section(
" ", 0, 0 );
172 QString sfsize = QString( sumsiz ).section(
" ", 1, 1 );
173 int fsize = sfsize.toInt();
174 if ( fcksm != dcksm || fsize != dsize )
176 if ( filemr.open( QIODevice::WriteOnly | QIODevice::Text ) )
178 QTextStream tso( &filemr );
181 qDebug() <<
"File written:" << fpath;
187 if ( filemr.open( QIODevice::WriteOnly | QIODevice::Text ) )
189 QTextStream tso( &filemr );
192 qDebug() <<
"File written:" << fpath;
206 QString filedir = filepath.section(
"/", 0, -2 );
207 QString filename = filepath.section(
"/", -1, -1 );
209 QFile filei( filepath );
211 if ( filei.open( QIODevice::ReadOnly | QIODevice::Text ) )
213 QTextStream tsi( &filei );
214 xmlstr = tsi.readAll();
220 qDebug() <<
" *ERROR* cannot open" << filepath;
224 QXmlStreamReader xmlr( xmlstr );
232 qDebug() <<
" ==Call load_modelrecs==";
234 xmin, xmax, ymin, ymax, stype );
235 rc = ( nmrec > 0 ) ? 0 : 1;
236 qDebug() <<
" ==load_modelrecs== rc" << rc <<
"nmrec" << nmrec;
262 qDebug() <<
"LIST_MODELS";
263 QDateTime time0=QDateTime::currentDateTime();
264 QDateTime time1=QDateTime::currentDateTime();
265 QDateTime time2=QDateTime::currentDateTime();
266 const QString uaGUID(
"00000000-0000-0000-0000-000000000000" );
268 le_mfilter->disconnect( SIGNAL( textChanged(
const QString& ) ) );
269 bool listdesc = !mfilt.isEmpty();
271 bool listall = !listdesc;
272 QRegExp mpart = QRegExp(
".*" + mfilt +
".*", Qt::CaseInsensitive );
274 qDebug() <<
"LM: desc edit" << listdesc << listedit
286 QMessageBox::information(
this,
287 tr(
"Edit GUID Problem" ),
288 tr(
"No EditGUID given.\nEdit filter turned off." ) );
294 qDebug() <<
"listall" << listall <<
"listdesc listedit" << listdesc << listedit;
305 QMessageBox::information(
this,
306 tr(
"DB Connection Problem" ),
307 tr(
"There was an error connecting to the database:\n" )
319 qDebug() <<
" rd count" << countRD;
323 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
330 qDebug() <<
" kid1 kid2" << kid1 << kid2;
333 if ( countRD == 0 || kid1 !=
db_id1 || kid2 != db_id2 )
348 editID =
dbP->
value( 0 ).toString();
350 qDebug() <<
" edit GUID,ID" << editGUID << editID;
353 time1=QDateTime::currentDateTime();
357 query <<
"get_mrecs_desc_by_editID" << invID << editID;
362 query <<
"get_mrecs_desc" << invID;
365 qDebug() <<
" query" << query;
368 time2=QDateTime::currentDateTime();
369 qDebug() <<
"Timing: get_mrecs_desc" << time1.msecsTo(time2);
386 + tr(
" : empty description )" );
393 QDateTime time3=QDateTime::currentDateTime();
397 QApplication::restoreOverrideCursor();
404 if ( !dir.exists( path ) )
411 QStringList filter(
"pcsa-mrs*.xml" );
416 if (
runID.isEmpty() )
418 QStringList r_dirs = dir.entryList( QDir::Dirs );
420 for (
int jj = 0; jj < r_dirs.size(); jj++ )
422 QString rpath = r_dirs[ jj ];
424 QDir rdir = QDir( rpath );
426 QStringList rf_names = rdir.entryList( filter, QDir::Files,
429 for (
int ii = 0; ii < rf_names.size(); ii++ )
431 f_names << rf_names[ ii ];
432 f_paths << path +
"/" + rpath +
"/" + rf_names[ ii ];
439 QString rpath = path +
"/" +
runID;
441 QDir rdir = QDir( rpath );
443 QStringList rf_names = rdir.entryList( filter, QDir::Files,
446 for (
int ii = 0; ii < rf_names.size(); ii++ )
448 f_names << rf_names[ ii ];
449 f_paths << rpath +
"/" + rf_names[ ii ];
455 QXmlStreamAttributes attr;
460 for (
int ii = 0; ii < f_paths.size(); ii++ )
462 QString fpath( f_paths[ ii ] );
463 QString fname( f_names[ ii ] );
464 qDebug() <<
"fpath" << f_paths[ii];
465 QFile m_file( fpath );
467 if ( !m_file.open( QIODevice::ReadOnly | QIODevice::Text ) )
473 QString descript =
"";
475 QXmlStreamReader xml( &m_file );
477 while ( ! xml.atEnd() )
481 if ( xml.isStartElement() && xml.name() ==
"modelrecords" )
483 attr = xml.attributes();
484 mrGUID = attr.value(
"mrecGUID" ).toString();
485 edGUID = attr.value(
"editGUID" ).toString();
486 moGUID = attr.value(
"modelGUID" ).toString();
487 descript = attr.value(
"description" ).toString();
490 else if ( xml.isStartElement() && xml.name() ==
"modelrecord" )
492 attr = xml.attributes();
493 mrGUID = ( ! mrGUID.isEmpty() ) ? mrGUID :
494 attr.value(
"mrecGUID" ).toString();
495 edGUID = ( ! edGUID.isEmpty() ) ? edGUID :
496 attr.value(
"editGUID" ).toString();
497 moGUID = ( ! moGUID.isEmpty() ) ? moGUID :
498 attr.value(
"modelGUID" ).toString();
499 descript = ( ! descript.isEmpty() ) ? descript :
500 attr.value(
"description" ).toString();
503 else if ( xml.isEndElement() && xml.name() ==
"modelrecord" )
510 if (
do_edit && edGUID != editGUID )
513 if ( descript.isEmpty() )
515 descript = QString( fpath ).section(
"/", -2, -2 )
517 + QString( fname ).replace(
".xml",
".mrecs" );
519 qDebug() <<
" edGUID" << edGUID <<
"descr" << descript;
532 desc.
description =
" ( Fname " + QString( fname ).left( 20 )
533 + tr(
" : empty description )" );
554 QString msg = tr(
"%1 MC model sets are old-style separate models\n"
555 "%2 MC models are new-style composite models\n"
556 "%3 total MC model records currently exist.\n"
557 "The old-style models should be converted\n"
559 .arg( kmmold).arg( kmmnew ).arg( kmmmod );
560 QMessageBox::information(
this,
561 tr(
"Deprecated MC Model Types Exist" ), msg );
565 QDateTime time5=QDateTime::currentDateTime();
566 qDebug() <<
"Timing: Time5" << time0.msecsTo(time5) << time2.msecsTo(time5);
592 lw_vmrecs->disconnect( SIGNAL( currentRowChanged(
int ) ) );
601 maxlch = qMax( maxlch,
611 lw_vmrecs->addItem(
"No models found." );
613 QDateTime time6=QDateTime::currentDateTime();
614 qDebug() <<
"Timing: Time6" << time0.msecsTo(time6) << time2.msecsTo(time6);
617 QFontMetrics fm =
lw_vmrecs->fontMetrics();
621 int width = qMin( 600, maxlch * fm.maxWidth() );
622 int height = qMin( 800, nlines * fm.lineSpacing() );
623 width = qMax( width, olwid );
624 height = ( height > olhgt ) ? height : ( ( olhgt + height ) / 2 );
625 width = this->width() + width - olwid;
626 height = this->height() + height - olhgt;
628 resize( width, height );
630 connect(
lw_vmrecs, SIGNAL( currentRowChanged(
int ) ),
632 connect(
le_mfilter, SIGNAL( textChanged(
const QString& ) ),
633 this, SLOT(
msearch(
const QString& ) ) );
650 QString mdesc =
lw_vmrecs->currentItem()->text();
652 qDebug() <<
"ACC: sel_row mdx" <<
sel_row << mdx;
657 QMessageBox::information(
this,
658 tr(
"No Mrecs Selected" ),
659 tr(
"You have not selected a model.\nSelect+Accept or Cancel" ) );
664 qDebug() <<
"ACC: load... (single)";
666 qDebug() <<
"ACC: ...loaded (single)";
687 for (
int jj = 0; jj < mds.size(); jj++ )
689 if ( mdesc.compare( mds[ jj ].description ) == 0 )
720 lblid = tr(
"\n Mrecs File Name: " );
725 lblid = tr(
"\n Database Mrecs ID: " );
731 mdesc =
lw_vmrecs->currentItem()->text();
733 qDebug() <<
" sel_row" <<
sel_row <<
"mdx" << mdx;
740 runid = mdesc.section(
".", 0, -4 );
744 mrcid = mrcid.length() < 50 ? mrcid :
745 "*/" + mrcid.section(
"/", -3, -1 );
747 dtext = tr(
"Mrecs Information:" )
748 + tr(
"\n Description: " ) + mdesc
749 + tr(
"\n Implied RunID: " ) + runid
750 + tr(
"\n Mrecs ID: " ) + mrcid
752 + tr(
"\n Type: " ) + tdesc
753 +
" (" + QString::number( (
int)mtype ) +
")"
756 + tr(
"\n List Row: " ) + QString::number( row + 1 )
757 + tr(
"\n Mrecs xmin: " ) + QString::number(
mrec.
xmin )
758 + tr(
"\n Mrecs xmax: " ) + QString::number(
mrec.
xmax )
759 + tr(
"\n Mrecs ymin: " ) + QString::number(
mrec.
ymin )
760 + tr(
"\n Mrecs ymax: " ) + QString::number(
mrec.
ymax )
761 + tr(
"\n Mrecs count: " ) + QString::number(
mrecs.count() )
762 + tr(
"\n Best Model Type: " )
764 + tr(
"\n Best Model taskx: " ) + QString::number(
mrec.
taskx )
765 + tr(
"\n Best Model str_y: " ) + QString::number(
mrec.
str_y )
766 + tr(
"\n Best Model end_y: " ) + QString::number(
mrec.
end_y )
767 + tr(
"\n Best Model par1: " ) + QString::number(
mrec.
par1 )
768 + tr(
"\n Best Model par2: " ) + QString::number(
mrec.
par2 )
769 + tr(
"\n Best Model RMSD: " ) + QString::number(
mrec.
rmsd )
770 + tr(
"\n BM C_Solutes size: " )
772 + tr(
"\n BM I_Solutes size: " )
779 edit->setWindowTitle( tr(
"Mrecs Entry Information" ) );
780 edit->move( this->pos() + QPoint( 200, 200 ) );
781 edit->resize( 800, 460 );
783 edit->
e->setText( dtext );
792 if ( search_string.endsWith(
"=" ) )
824 QString mdesc =
lw_vmrecs->currentItem()->text();
836 QMessageBox::critical(
this,
837 tr(
"DB Connection Problem" ),
838 tr(
"There was an error connecting to the database:\n" )
847 qry <<
"delete_mrecs" << mrecsID;
851 QMessageBox::information(
this,
852 tr(
"Successful DB Delete" ),
853 tr(
"The mrecs record '%1' has been deleted from the database." )
861 QMessageBox::critical(
this,
862 tr(
"DB Delete Problem" ),
863 tr(
"There was an error deleting an entry from the database:\n" )
871 QFile filemr( fpath );
872 if ( filemr.exists() )
874 if ( filemr.remove() )
876 QMessageBox::information(
this,
877 tr(
"Successful Local File Delete" ),
878 tr(
"The mrecs file '%1' has been deleted." )
886 QMessageBox::critical(
this,
887 tr(
"Error in Local File Delete" ),
888 tr(
"The mrecs file '%1' was not deleted"
889 " due to a remove error." ).arg( fpath ) );
895 QMessageBox::critical(
this,
896 tr(
"Error in Local File Delete" ),
897 tr(
"The mrecs file '%1' was not deleted."
898 " It did not exist." ).arg( fpath ) );