22 setWindowTitle( tr(
"Select Run(s) with Edits as Models Pre-Filter (%1)" )
23 .arg(
sel_db ?
"DB" :
"Local" ) );
25 setMinimumSize( 480, 300 );
28 QVBoxLayout*
main =
new QVBoxLayout(
this );
29 main->setContentsMargins( 2, 2, 2, 2 );
30 main->setSpacing ( 2 );
33 QGridLayout* top =
new QGridLayout;
49 QLabel* lb_filtdata =
us_label( tr(
"Search" ) );
54 top->addWidget(
pb_invest, row, 0, 1, 2 );
55 top->addWidget(
le_invest, row++, 2, 1, 2 );
56 top->addWidget( lb_filtdata, row, 0, 1, 1 );
59 connect(
le_dfilter, SIGNAL( textChanged(
const QString& ) ),
60 SLOT (
search (
const QString& ) ) );
62 main->addLayout( top );
67 headers <<
"Run" <<
"Date" <<
"dbID" <<
"Label";
68 tw_data =
new QTableWidget( 20, 4,
this );
69 tw_data->setFrameStyle ( QFrame::NoFrame );
72 tw_data->setSelectionMode ( QAbstractItemView::ExtendedSelection );
73 tw_data->setSelectionBehavior( QAbstractItemView::SelectRows );
74 tw_data->setHorizontalHeaderLabels( headers );
75 tw_data->verticalHeader()->hide();
77 tw_data->setColumnWidth( 0, 250 );
78 tw_data->setColumnWidth( 1, 100 );
79 tw_data->setColumnWidth( 2, 50 );
80 tw_data->setColumnWidth( 3, 350 );
85 QHBoxLayout* buttons =
new QHBoxLayout;
88 connect( pb_help, SIGNAL( clicked() ), SLOT(
help() ) );
89 buttons->addWidget( pb_help );
92 connect( pb_cancel, SIGNAL( clicked() ), SLOT(
cancelled() ) );
93 buttons->addWidget( pb_cancel );
95 QPushButton* pb_accept =
us_pushbutton( tr(
"Select PreFilter(s)" ) );
96 connect( pb_accept, SIGNAL( clicked() ), SLOT(
accepted() ) );
97 buttons->addWidget( pb_accept );
99 main->addLayout( buttons );
108 bool have_search = ! search_string.isEmpty();
111 QFontMetrics* fm =
new QFontMetrics( tw_font );
112 int rowht = fm->height() + 2;
114 tw_data->setSortingEnabled(
false );
116 for (
int ii = 0; ii <
rlabels.size(); ii++ )
118 QTableWidgetItem* twi;
119 QString runID =
rlabels.at( ii );
122 ! runID.contains( search_string, Qt::CaseInsensitive ) )
125 twi =
new QTableWidgetItem( runID );
126 twi->setFlags( twi->flags() ^ Qt::ItemIsEditable );
127 tw_data->setItem ( ii, 0, twi );
128 twi =
new QTableWidgetItem(
runmap[ runID ].date );
129 twi->setFlags( twi->flags() ^ Qt::ItemIsEditable );
130 tw_data->setItem ( ii, 1, twi );
131 twi =
new QTableWidgetItem(
runmap[ runID ].DB_id );
132 twi->setFlags( twi->flags() ^ Qt::ItemIsEditable );
133 tw_data->setItem ( ii, 2, twi );
134 twi =
new QTableWidgetItem(
runmap[ runID ].label );
135 twi->setFlags( twi->flags() ^ Qt::ItemIsEditable );
136 tw_data->setItem ( ii, 3, twi );
138 tw_data->setRowHeight( ii, rowht );
141 tw_data->setSortingEnabled(
true );
142 tw_data->sortByColumn( 1, Qt::DescendingOrder );
143 tw_data->resizeColumnsToContents();
145 int twwid = size().width() - 4;
146 int twhgt = qMax( height(),
tw_data->size().height() );
147 tw_data->resize( twwid, twhgt );
148 qApp->processEvents();
156 QFontMetrics* fm =
new QFontMetrics( tw_font );
157 int rowht = fm->height() + 2;
174 QString clabel = tr(
"No data found." );
175 tw_data->setItem ( 0, 0,
new QTableWidgetItem( clabel ) );
179 tw_data->setSortingEnabled(
false );
182 for (
int ii = 0; ii <
rlabels.size(); ii++ )
184 QString runID =
rlabels.at( ii );
186 tw_data->setItem( ii, 0,
new QTableWidgetItem( runID ) );
188 new QTableWidgetItem(
runmap[ runID ].date ) );
190 new QTableWidgetItem(
runmap[ runID ].DB_id ) );
192 new QTableWidgetItem(
runmap[ runID ].label ) );
194 tw_data->setRowHeight( ii, rowht );
197 tw_data->setSortingEnabled(
true );
198 tw_data->sortByColumn( 1, Qt::DescendingOrder );
199 tw_data->resizeColumnsToContents();
201 int twwid = size().width() - 4;
202 int twhgt = qMax( height(),
tw_data->size().height() );
203 tw_data->resize( twwid, twhgt );
204 qApp->processEvents();
220 QList< QTableWidgetItem* > selitems =
tw_data->selectedItems();
222 if ( selitems.size() == 0 )
224 QMessageBox::information(
this,
225 tr(
"No Data Selected" ),
226 tr(
"You have not selected any data.\nSelect or Cancel" ) );
233 for (
int ii = 0; ii < selitems.size(); ii++ )
235 QTableWidgetItem* twi = selitems.at( ii );
236 if ( twi->column() != 0 )
238 int row = twi->row();
241 QString rlabel = twi->text() +
" :";
244 QStringList elabs =
elabels.filter( rlabel );
246 for (
int jj = 0; jj < elabs.size(); jj++ )
248 QString editID =
editmap[ elabs[ jj ] ].editID;
250 if ( !
editIDs.contains( editID ) )
254 qDebug() <<
"Acpt: editIDs size" <<
editIDs.size();
255 qDebug() <<
"Acpt: editIDs" <<
editIDs;
270 QMessageBox::information(
this,
271 tr(
"DB Connection Problem" ),
272 tr(
"There was an error connecting to the database:\n" )
277 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
282 QMap< QString, QString > explabs;
284 query <<
"get_experiment_desc" << invID;
290 QString expID = db.value( 0 ).toString();
291 QString label = db.value( 4 ).toString();
292 explabs[ expID ] = label;
294 qDebug() <<
"ScDB: explabs size" << explabs.size();
298 query <<
"all_editedDataIDs" << invID;
305 QString recID = db.value( 0 ).toString();
308 QString descrip = db.value( 1 ).toString();
309 QString filename = db.value( 2 ).toString().replace(
"\\",
"/" );
310 QString expID = db.value( 4 ).toString();
312 .toDateTime().toString( Qt::ISODate ), true )
313 .section(
" ", 0, 0 );
314 QString recGUID = db.value( 9 ).toString();
315 QString filebase = filename.section(
"/", -1, -1 );
316 QString runID = descrip.isEmpty() ? filebase.section(
".", 0, -7 )
318 QString editID = filebase.section(
".", -6, -6 );
319 QString tripID = filebase.section(
".", -4, -2 );
322 QString key = runID +
" : " + tripID +
" : " + editID;
327 qDebug() <<
"edesc key" << key <<
"expID" << expID <<
"label" <<
edesc.
label;
336 qDebug() <<
"ScDB: editmap size" <<
editmap.size();
340 QApplication::restoreOverrideCursor();
341 QApplication::restoreOverrideCursor();
349 QStringList aucdirs = QDir( rdir ).entryList(
350 QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name );
352 QStringList aucfilt(
"*.auc" );
354 QStringList edtfiles;
355 QStringList aucfiles;
356 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
358 for (
int ii = 0; ii < aucdirs.size(); ii++ )
360 QString subdir = rdir +
"/" + aucdirs.at( ii );
361 QDir dirRun( subdir );
362 QStringList aucfiles = QDir( subdir ).entryList(
363 aucfilt, QDir::Files, QDir::Name );
365 if ( aucfiles.size() < 1 )
368 QString aucfbase = aucfiles.at( 0 );
369 QString aucfname = subdir +
"/" + aucfbase;
370 QString runID = aucfbase.section(
".", 0, -6 );
371 QString subType = aucfbase.section(
".", -5, -5 );
372 QString tripl = aucfbase.section(
".", -4, -2 );
373 QString explabel = runID;
377 edtfilt << runID +
"." + subType +
".xml";
378 edtfiles = dirRun.entryList( edtfilt, QDir::Files, QDir::Name );
379 if ( edtfiles.size() != 1 )
382 QString expfpath = subdir +
"/" + edtfiles[ 0 ];
383 QFile fileri( expfpath );
386 if ( fileri.open( QIODevice::ReadOnly | QIODevice::Text ) )
388 QXmlStreamReader xml( &fileri );
389 QXmlStreamAttributes attr;
391 while( ! xml.atEnd() )
395 if ( xml.isStartElement() )
397 if ( xml.name() ==
"experiment" )
399 attr = xml.attributes();
400 expID = attr.value(
"id" ).toString();
404 else if ( xml.name() ==
"label" )
407 explabel = xml.text().toString();
417 edtfilt << runID +
".*." + subType +
".*.xml";
418 edtfiles = dirRun.entryList( edtfilt, QDir::Files, QDir::Name );
421 if ( edtfiles.size() < 1 )
424 for (
int jj = 0; jj < edtfiles.size(); jj++ )
426 QString filebase = edtfiles.at( jj );
427 QString filename = subdir +
"/" + filebase;
428 QString runID = filebase.section(
".", 0, -7 );
429 QString editID = filebase.section(
".", -6, -6 );
430 editID = ( editID.length() == 12 && editID.startsWith(
"20" ) ) ?
431 editID.mid( 2 ) : editID;
432 QString tripID = filebase.section(
".", -4, -2 );
433 QString key = runID +
" : " + tripID +
" : " + editID;
435 .lastModified().toUTC().toString( Qt::ISODate ),
true )
436 .section(
" ", 0, 0 );
438 QFile filei( filename );
440 if ( ! filei.open( QIODevice::ReadOnly | QIODevice::Text ) )
443 QXmlStreamReader xml( &filei );
444 QXmlStreamAttributes a;
447 while( ! xml.atEnd() )
451 if ( xml.isStartElement() )
453 if ( xml.name() ==
"editGUID" )
455 a = xml.attributes();
456 recGUID = a.value(
"value" ).toString();
476 QApplication::restoreOverrideCursor();
477 QApplication::restoreOverrideCursor();
486 QString runID =
"Unassigned";
487 QString ekey = runID +
" : 0.Z.280 : 1";
498 qDebug() <<
"BldR: elabels size" <<
elabels.size();
502 for (
int ii = 0; ii <
elabels.size(); ii++ )
506 qDebug() <<
"BldR: ii ekey runID" << ii << ekey << runID;
508 if ( !
rlabels.contains( runID ) )
512 qDebug() <<
"BldR: *UNIQUE* runID";
515 qDebug() <<
"BldR: rlabels size" <<
rlabels.size();
516 qDebug() <<
"BldR: runmap size" <<
runmap.size();
526 connect( dialog, SIGNAL( investigator_accepted(
int ) ),
535 QString number = ( ID > 0 ) ? QString::number( ID ) +
": " :
"";
554 tr(
"Select Run(s) with Edits as Models Pre-Filter (DB)" ) );
560 tr(
"Select Run(s) with Edits as Models Pre-Filter (Local)" ) );
566 if ( ! sfilt.isEmpty() )