18 setWindowTitle( tr(
"Available US3 Runs in DB" ) );
23 setWindowTitle( tr(
"Available US3 Runs on Local Disk" ) );
29 QVBoxLayout*
main =
new QVBoxLayout(
this );
30 main->setSpacing ( 2 );
31 main->setContentsMargins( 2, 2, 2, 2 );
39 QHBoxLayout* investigator =
new QHBoxLayout;
42 QString invval = QString::number(
personID ) +
": " +
50 QHBoxLayout* search =
new QHBoxLayout;
51 QLabel* lb_search =
us_label( tr(
"Search" ) );
53 search ->addWidget( lb_search );
55 connect(
le_search, SIGNAL( textChanged(
const QString& ) ),
56 this, SLOT (
limit_data (
const QString& ) ) );
65 tw =
new QTableWidget(
runInfo.size(), 4, this );
69 QHBoxLayout* buttons =
new QHBoxLayout;
72 connect( pb_cancel, SIGNAL( clicked() ), SLOT( reject() ) );
73 buttons->addWidget( pb_cancel );
76 connect( pb_delete, SIGNAL( clicked() ), SLOT(
deleteRun() ) );
77 buttons->addWidget( pb_delete );
80 connect( pb_accept, SIGNAL( clicked() ), SLOT(
select() ) );
81 buttons->addWidget( pb_accept );
84 main->addLayout( investigator );
85 main->addLayout( search );
86 main->addWidget(
tw );
87 main->addLayout( buttons );
88 qDebug() <<
"gDBr: size" << size();
90 qDebug() <<
"gDBr: size" << size();
96 qDebug() <<
"LdDb: IN";
103 QMessageBox::information(
this,
105 tr(
"Error making the DB connection.\n" ) );
111 QStringList q(
"get_experiment_desc" );
118 rr.
ID = db.
value( 0 ).toString().toInt();
122 .toDateTime().toString( Qt::ISODate ), true )
123 .section(
" ", 0, 0 ).simplified();
132 QMessageBox::information(
this,
134 tr(
"There are no US3 runs in the DB to load.\n" ) );
144 QStringList rdirs = QDir( resdir ).entryList(
145 QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name );
146 qDebug() <<
"LdDk: rdirs count" << rdirs.count();
147 resdir = resdir +
"/";
149 efilt <<
"*.auc" <<
"*.??.xml";
153 for (
int ii = 0; ii < rdirs.count(); ii++ )
155 QString wdir = resdir + rdirs[ ii ];
156 QStringList efiles = QDir( wdir ).entryList( efilt, QDir::Files,
159 if ( efiles.count() < 1 )
162 runids << rdirs[ ii ];
165 qDebug() <<
"LdDk: runids count" << runids.count();
170 for (
int ii = 0; ii < runids.count(); ii++ )
172 QString
runID = runids[ ii ];
173 QString wdir = resdir +
runID;
175 efilt << runID +
".??.xml";
176 QStringList efiles = QDir( wdir ).entryList( efilt, QDir::Files,
181 if ( efiles.count() != 1 )
184 QString rfn = wdir +
"/" + efiles[ 0 ];
188 QFileInfo( rfn ).lastModified().toUTC()
189 .toString( Qt::ISODate ),
true )
190 .section(
" ", 0, 0 ).simplified();
194 if ( ! xfi.open( QIODevice::ReadOnly | QIODevice::Text ) )
197 QXmlStreamReader xml( &xfi );
199 while ( ! xml.atEnd() )
203 QXmlStreamAttributes attr;
207 if ( xml.isStartElement() )
209 xname = xml.name().toString();
211 if ( xname ==
"experiment" )
213 attr = xml.attributes();
214 expID = attr.value(
"id" ).toString();
217 else if ( xname ==
"label" )
220 label = xml.text().toString();
226 rr.
ID = expID.toInt();
238 QMessageBox::information(
this,
240 tr(
"There are no US3 runs on the local Disk to load.\n" ) );
249 int ndx =
tw ->currentRow();
251 runID =
tw ->item( ndx, 0 )->text();
252 qDebug() <<
"GetRun: accept : runID" <<
runID;
265 QMessageBox::information(
this,
267 tr(
"Error making the DB connection.\n" ) );
271 int status = QMessageBox::information(
this,
273 tr(
"Are you sure you want to delete this run from the DB? " ) +
274 tr(
"This action is not reversible. Proceed? " ),
275 tr(
"&OK" ), tr(
"&Cancel" ),
277 if ( status != 0 )
return;
279 int ndx =
tw ->currentRow();
280 QString expID =
tw ->item( ndx, 2 )->text();
283 QStringList q(
"count_calibration_experiments " );
289 qDebug() <<
"count_calibration_experiments( "
291 <<
" ) returned a negative count";
295 else if ( count > 0 )
297 QMessageBox::information(
this,
299 tr(
"Cannot delete an experiment that is associated "
300 "with a rotor calibration\n" ) );
304 tw->removeRow( ndx );
308 q <<
"delete_experiment_solutions"
314 q <<
"delete_cell_experiments"
321 q <<
"delete_experiment"
324 qDebug() <<
"GetRun:delRun: del_exp stat" << status;
328 QMessageBox::information(
this,
329 tr(
"Error / Warning" ),
330 db.
lastError() + tr(
" (error=%1, expID=%2)" )
331 .arg( status ).arg( expID ) );
340 QFontMetrics* fm =
new QFontMetrics( tw_font );
341 int rowht = fm->height() + 2;
343 tw->setFont ( tw_font );
353 tw->setHorizontalHeaderLabels( headers );
354 tw->verticalHeader()->hide();
355 tw->setShowGrid(
false );
356 tw->setSelectionBehavior( QAbstractItemView::SelectRows );
357 tw->setMinimumWidth( 640 );
358 tw->setMinimumHeight( 480 );
359 tw->setColumnWidth( 0, 250 );
360 tw->setColumnWidth( 1, 150 );
361 tw->setColumnWidth( 2, 50 );
362 tw->setColumnWidth( 3, 350 );
363 tw->setSortingEnabled(
false );
367 for (
int ii = 0; ii <
runInfo.size(); ii++ )
369 QTableWidgetItem* item;
372 item =
new QTableWidgetItem( rr.
runID );
373 item->setFlags( item->flags() ^ Qt::ItemIsEditable );
374 tw ->setItem( ii, 0, item );
376 item =
new QTableWidgetItem( rr.
date );
377 item->setFlags( item->flags() ^ Qt::ItemIsEditable );
378 tw ->setItem( ii, 1, item );
380 item =
new QTableWidgetItem( QString().sprintf(
"%6d", rr.
ID ) );
381 item->setFlags( item->flags() ^ Qt::ItemIsEditable );
382 tw ->setItem( ii, 2, item );
384 item =
new QTableWidgetItem( rr.
label );
385 item->setFlags( item->flags() ^ Qt::ItemIsEditable );
386 tw ->setItem( ii, 3, item );
390 tw ->setRowHeight( ii, rowht );
393 tw->setSortingEnabled(
true );
394 tw->sortByColumn( 1, Qt::DescendingOrder );
395 tw->resizeColumnsToContents();
397 tw->resize( size().width() - 4,
tw->size().height() );
398 qApp->processEvents();
404 qDebug() <<
"UpdDkDb: isDB" << isDB;
408 setWindowTitle( tr(
"Available US3 Runs in DB" ) );
413 setWindowTitle( tr(
"Available US3 Runs on Local Disk" ) );
419 if ( ! sfilt.isEmpty() )
428 qDebug() <<
"LimData: sfilt" << sfilt;
429 bool have_search = ! sfilt.isEmpty();
432 QFontMetrics* fm =
new QFontMetrics( tw_font );
433 int rowht = fm->height() + 2;
435 tw->setSortingEnabled(
false );
437 for (
int ii = 0; ii <
runInfo.size(); ii++ )
439 QTableWidgetItem* item;
444 ! rr.
runID.contains( sfilt, Qt::CaseInsensitive ) )
447 item =
new QTableWidgetItem( rr.
runID );
448 item->setFlags( item->flags() ^ Qt::ItemIsEditable );
449 tw ->setItem( ii, 0, item );
451 item =
new QTableWidgetItem( rr.
date );
452 item->setFlags( item->flags() ^ Qt::ItemIsEditable );
453 tw ->setItem( ii, 1, item );
455 item =
new QTableWidgetItem( QString().sprintf(
"%6d", rr.
ID ) );
456 item->setFlags( item->flags() ^ Qt::ItemIsEditable );
457 tw ->setItem( ii, 2, item );
459 item =
new QTableWidgetItem( rr.
label );
460 item->setFlags( item->flags() ^ Qt::ItemIsEditable );
461 tw ->setItem( ii, 3, item );
465 tw ->setRowHeight( ii, rowht );
468 tw->setSortingEnabled(
true );
469 tw->sortByColumn( 1, Qt::DescendingOrder );
470 tw->resizeColumnsToContents();
474 tw->resize( size().width() - 4,
tw->size().height() );
475 qApp->processEvents();
485 connect( inv_dialog, SIGNAL( investigator_accepted(
int ) ),
495 QString number = ( invID > 0 ) ? QString::number( invID ) +
": " :
"";