22 setWindowTitle( tr(
"Select Run(s) 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" ) );
232 for (
int ii = 0; ii < selitems.size(); ii++ )
234 QTableWidgetItem* twi = selitems.at( ii );
235 if ( twi->column() != 0 )
237 int row = twi->row();
240 QString runID = twi->text();
241 if ( !
runIDs.contains( runID ) )
244 qDebug() <<
"Acpt: runIDs size" <<
runIDs.size();
245 qDebug() <<
"Acpt: runIDs" <<
runIDs;
253 query <<
"count_models_by_runID" << invID <<
runIDs[0];
254 int nmodl= db.functionQuery(query);
255 qDebug() <<
"Acpt: runID" << runIDs[0] <<
"count_models_by_runID" << nmodl;
271 QMessageBox::information(
this,
272 tr(
"DB Connection Problem" ),
273 tr(
"There was an error connecting to the database:\n" )
278 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
283 QMap< QString, QString > explabs;
285 query <<
"get_experiment_desc" << invID;
291 QString expID = db.value( 0 ).toString();
292 QString runID = db.value( 1 ).toString();
293 QString label = db.value( 4 ).toString();
295 .toDateTime().toString( Qt::ISODate ), true )
296 .section(
" ", 0, 0 );
305 qDebug() <<
"ScDB: runmap size" <<
runmap.size();
310 QApplication::restoreOverrideCursor();
311 QApplication::restoreOverrideCursor();
319 QStringList aucdirs = QDir( rdir ).entryList(
320 QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name );
322 QStringList aucfilt(
"*.auc" );
323 QStringList aucfiles;
324 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
326 for (
int ii = 0; ii < aucdirs.size(); ii++ )
328 QString subdir = rdir +
"/" + aucdirs.at( ii );
329 QDir dirRun( subdir );
330 QStringList aucfiles = QDir( subdir ).entryList(
331 aucfilt, QDir::Files, QDir::Name );
333 if ( aucfiles.size() < 1 )
336 QString aucfbase = aucfiles.at( 0 );
337 QString aucfname = subdir +
"/" + aucfbase;
338 QString runID = aucfbase.section(
".", 0, -6 );
339 QString subType = aucfbase.section(
".", -5, -5 );
340 QString tripl = aucfbase.section(
".", -4, -2 );
341 QString explabel = runID;
342 QString expID =
"-1";
346 edtfilt << runID +
"." + subType +
".xml";
347 QStringList edtfiles;
348 edtfiles = dirRun.entryList( edtfilt, QDir::Files, QDir::Name );
350 if ( edtfiles.size() != 1 )
353 QString efpath = subdir +
"/" + edtfiles[ 0 ];
354 QFile fileri( efpath );
355 if ( fileri.open( QIODevice::ReadOnly | QIODevice::Text ) )
357 QXmlStreamReader xml( &fileri );
358 QXmlStreamAttributes attr;
360 while( ! xml.atEnd() )
364 if ( xml.isStartElement() )
366 if ( xml.name() ==
"experiment" )
368 attr = xml.attributes();
369 expID = attr.value(
"id" ).toString();
372 else if ( xml.name() ==
"label" )
375 explabel = xml.text().toString();
384 .lastModified().toUTC().toString( Qt::ISODate ),
385 true ).section(
"", 0, 0 );
398 QApplication::restoreOverrideCursor();
399 QApplication::restoreOverrideCursor();
408 QString runID =
"Unassigned";
415 qDebug() <<
"BldR: rlabels size" <<
rlabels.size();
416 qDebug() <<
"BldR: runmap size" <<
runmap.size();
426 connect( dialog, SIGNAL( investigator_accepted(
int ) ),
435 QString number = ( ID > 0 ) ? QString::number( ID ) +
": " :
"";
453 setWindowTitle( tr(
"Select Run(s) as Models Pre-Filter (DB)" ) );
458 setWindowTitle( tr(
"Select Run(s) as Models Pre-Filter (Local)" ) );
464 if ( ! sfilt.isEmpty() )