19 this->
signal = signal_wanted;
21 setAttribute( Qt::WA_DeleteOnClose );
26 QMessageBox::information(
this,
28 tr(
"Please enter the calibration name, omega2t, "
29 "and click Save Calibration Data, or Close" ) );
36 QList< QListWidgetItem* > items
37 =
lw_rotors->findItems( QString::number( rotorID ), Qt::MatchStartsWith );
38 if ( items.count() == 1 )
70 currentRotor( rotorIn ),
71 currentCalibration( calibrationIn ),
72 signal( signal_wanted )
74 setAttribute( Qt::WA_DeleteOnClose );
85 if ( rotorID > 0 && calibrationID > 0 )
88 status =
readRotor ( select_db_disk, rotorID );
92 QList< QListWidgetItem* > items
93 =
lw_rotors->findItems( QString::number( rotorID ), Qt::MatchStartsWith );
94 if ( items.count() == 1 )
99 items =
lw_calibrations->findItems( QString::number( calibrationID ), Qt::MatchStartsWith );
100 if ( items.count() == 1 )
110 setWindowTitle( tr(
"Rotor Management" ) );
113 QGridLayout* top =
new QGridLayout(
this );
114 top->setSpacing ( 2 );
115 top->setContentsMargins ( 2, 2, 2, 2 );
119 gray.setColor( QPalette::Base, QColor( 0xe0, 0xe0, 0xe0 ) );
123 if ( DB.isEmpty() ) DB <<
"Undefined";
125 QLabel* lbl_bannerDB =
us_banner( tr(
"Current Database: " ) + DB.at( 0 ) );
127 top->addWidget( lbl_bannerDB, row++, 0, 1, 4 );
135 QLabel* lbl_lab =
us_label( tr(
" Please select a Laboratory:" ) );
136 top->addWidget( lbl_lab, row, 0, 1, 2 );
137 cb_lab =
new QComboBox(
this );
138 connect(
cb_lab, SIGNAL( activated(
int ) ),
140 top->addWidget(
cb_lab, row++, 2, 1, 2 );
142 QLabel* lbl_bannerRotor =
us_banner( tr(
"Click to select a Rotor: " ), -1 );
144 top->addWidget( lbl_bannerRotor, row, 0, 1, 2 );
153 connect(
lw_rotors, SIGNAL( itemClicked ( QListWidgetItem* ) ),
155 top->addWidget(
lw_rotors, row, 0, 3, 2);
161 QLabel *lbl_name =
us_label( tr(
" Name of Rotor:"), -1 );
162 top->addWidget( lbl_name, row, 2 );
165 le_name->setText( tr(
"< not selected >"));
168 connect(
le_name, SIGNAL( textEdited (
const QString & ) ),
170 top->addWidget(
le_name, row++, 3);
172 QLabel *lbl_serialNumber =
us_label( tr(
" Rotor Serial Number:"), -1 );
173 top->addWidget( lbl_serialNumber, row, 2 );
183 QLabel* lbl_bannerCalibration =
us_banner( tr(
"Click to select a Rotor Calibration: " ), -1 );
185 top->addWidget( lbl_bannerCalibration, row, 0, 1, 2);
205 QLabel* lbl_calibName =
us_label( tr(
" Calibration Name:"), -1 );
206 top->addWidget( lbl_calibName, row, 2 );
216 QLabel *lbl_coefficients =
us_label( tr(
" Rotor Stretch Coefficient 1:"), -1 );
217 top->addWidget( lbl_coefficients, row, 2 );
225 QLabel *lbl_date =
us_label( tr(
" Rotor Stretch Coefficient 2:"), -1 );
226 top->addWidget( lbl_date, row, 2 );
234 QLabel *lbl_force =
us_label( tr(
" Rotor omega2t:"), -1 );
235 top->addWidget( lbl_force, row, 2 );
238 le_omega2t->setText( tr(
"< not available >"));
241 connect(
le_omega2t, SIGNAL( textEdited (
const QString& ) ),
246 QHBoxLayout* buttons =
new QHBoxLayout;
249 connect(
pb_reset, SIGNAL( clicked() ),
this, SLOT(
load() ) );
253 connect(
pb_help, SIGNAL( clicked() ),
this, SLOT(
help() ) );
261 connect( pb_cancel, SIGNAL( clicked() ), SLOT(
cancel() ) );
262 buttons->addWidget( pb_cancel );
270 top->addLayout( buttons, row, 0, 1, 4 );
298 else if (
lw_rotors->currentIndex().row() == -1 )
329 QString itemText =
lw_rotors->currentItem()->text();
330 QStringList parts = itemText.split(
":" );
331 int rotorID = parts[ 0 ].toInt();
343 connect( arDialog, SIGNAL ( accepted() ),
this, SLOT (
newRotor() ) );
344 connect( arDialog, SIGNAL (
use_db (
bool ) ),
410 QMessageBox::warning(
this, tr(
"Database Problem" ),
411 tr(
"Database returned the following error: \n" ) + error );
416 QString selected = item->text();
417 QStringList parts = selected.split(
":" );
419 int rotorID = parts[ 0 ].toInt();
485 QString selected =
lw_rotors->currentItem()->text();
486 QStringList parts = selected.split(
":" );
488 int rotorID = parts[ 0 ].toInt();
505 QString error = tr(
"This rotor is in use, and can't be deleted" );
519 QMessageBox::warning(
this,
521 tr(
"Deleting rotors on the local disk is not implemented yet." ) );
534 QStringList calibrationDescriptions;
549 QStringList q(
"get_rotor_calibration_profiles" );
550 q << QString::number( rotorID );
556 QString ID = db.
value( 0 ).toString();
557 QStringList dateParts = db.
value( 1 ).toString().split(
" " );
558 QDate dateUpdated = QDate::fromString( dateParts[ 0 ],
"yyyy-MM-dd" );
559 QString label = db.
value( 2 ).toString();
560 calibrationDescriptions << ( ID +
": " + label + dateUpdated.toString(
" (d MMMM yyyy)" ) );
568 QVector< US_Rotor::RotorCalibration > rc;
572 QMessageBox::warning(
this, tr(
"Disk Problem" ),
573 tr(
"Could not find rotor calibration profiles \n" ) );
577 for (
int i = 0; i < rc.size(); i++ )
579 if ( rc[ i ].rotorID == rotorID )
580 calibrationDescriptions << ( QString::number( rc[ i ].ID ) +
": " +
581 rc[ i ].lastUpdated.toString(
"d MMMM yyyy" ) );
600 QString selected = item->text();
601 QStringList parts = selected.split(
":" );
603 int calibrationID = parts[ 0 ].toInt();
633 if ( calibrationID <= 0 )
666 edit->setWindowTitle( tr(
"Rotor Calibration Report") );
667 edit->move( this->pos() + QPoint( 100, 100 ) );
668 edit->resize( 500, 400 );
679 QStringList parts = selected.split(
":" );
681 int calibrationID = parts[ 0 ].toInt();
698 QString error = tr(
"This rotor calibration is in use, and can't be deleted" );
712 QMessageBox::warning(
this,
714 tr(
"Deleting rotor calibrations on the local disk is not implemented yet." ) );
768 QMessageBox::information(
this,
770 tr(
"Calibration was saved to the DB." ) );
780 QMessageBox::information(
this,
782 tr(
"Calibration was saved to the Disk." ) );
790 gray.setColor( QPalette::Base, QColor( 0xe0, 0xe0, 0xe0 ) );
809 QString error = tr(
"This is a database-only function." );
824 int oldCalibrationID = -1;
829 QString error = tr(
"The replacement rotor calibration could not be found." );
841 else if ( oldCalibrationID == -1 )
848 QString error = tr(
"The database shows the dummy calibration is still in use, and can't be deleted" );
864 if ( db && ( DB.size() < 5 ) )
866 QMessageBox::warning(
this,
868 tr(
"There is no default database set." ) );
874 qApp->processEvents();
901 QVector < US_Rotor::Lab > labList;
919 QMessageBox::warning(
this, tr(
"Database Problem" ),
920 tr(
"Could not read lab information \n" ) );
932 QMessageBox::warning(
this, tr(
"Disk Problem" ),
933 tr(
"Could not read lab information \n" ) );
944 cb_lab->addItem( QString::number( lab.
ID ) +
": " + lab.
name );
946 index =
cb_lab->currentIndex();
948 if (
cb_lab->count() > 0 )
949 cb_lab->setCurrentIndex( index );
961 if (
cb_lab->count() == 0 )
966 QString itemText =
cb_lab->currentText();
967 QStringList parts = itemText.split(
":" );
968 labID = parts[ 0 ].toInt();
979 QStringList rotorDescriptions;
985 le_name ->setText(
"< not selected >" );
1008 QStringList q(
"get_rotor_names" );
1009 q << QString::number( labID );
1014 QString rotorID = db.
value( 0 ).toString();
1015 QString rotorDesc = db.
value( 1 ).toString();
1016 rotorDescriptions << ( rotorID +
": " + rotorDesc );
1024 QVector< US_Rotor::Rotor > rotors;
1028 QMessageBox::warning(
this, tr(
"Disk Problem" ),
1029 tr(
"Could not read rotor information \n" ) );
1033 for (
int i = 0; i < rotors.size(); i++ )
1035 if ( rotors[ i ].labID == labID )
1036 rotorDescriptions << ( QString::number( rotors[ i ].ID ) +
": " + rotors[ i ].name );
1040 lw_rotors->addItems( rotorDescriptions );
1047 QMessageBox::warning(
this, tr(
"Connection Problem" ),
1048 tr(
"Could not connect to database \n" ) + error );