void
MSCalibrationForm::getCalibrateMethod( adcontrols::MSCalibrateMethod& method ) const
{
    QStandardItemModel& model = *pModel_;

    method.polynomialDegree( ui->spinPolynomials->value() );
    method.massToleranceDa( ui->spinMassTolerance->value() );
    method.minimumRAPercent( ui->spinMinimumRA->value() );
    method.lowMass( ui->spinLowMass->value() );
    method.highMass( ui->spinHighMass->value() );

    adcontrols::MSReferences references;
    
    int nRows = model.rowCount();

    for ( int row = 0; row < nRows; ++row ) {
        adcontrols::MSReference reference;

		reference.charge_count( model.index( row, c_charge ).data( Qt::EditRole ).toInt() );
		// parse formula that contains adduct or lose followed by '+' or '-' sign
        std::wstring text = model.index( row, c_formula ).data( Qt::EditRole ).toString().toStdWString();
        if ( ! parse_formula( text, reference ) )
            continue;
		reference.exact_mass( model.index( row, c_exact_mass ).data( Qt::EditRole ).toDouble() );
		reference.description( model.index( row, c_description ).data( Qt::EditRole ).toString().toStdWString().c_str() );

        QVariant enable  = model.index( row, c_enable ).data( Qt::EditRole );
        reference.enable( enable.toBool() );

        references << reference;
    }
    method.references( references );
}
Exemple #2
0
void
MSCalibrateForm::setContents( const adcontrols::MSCalibrateMethod& m )
{
    ui_locator accessor( ui );

    boost::get< QSpinBox *>( accessor( ePolynomialDegree ) )->setValue( m.polynomialDegree() );
    boost::get< QDoubleSpinBox *>( accessor( eMassTolerance ) )->setValue(m.massToleranceDa() );
    boost::get< QDoubleSpinBox *>( accessor( eMinimumRA ) )->setValue( m.minimumRAPercent() );
    boost::get< QDoubleSpinBox *>( accessor( eLowMass ) )->setValue( m.lowMass() );
    boost::get< QDoubleSpinBox *>( accessor( eHighMass ) )->setValue( m.highMass() );
}
void
MSCalibrationForm::setCalibrateMethod( const adcontrols::MSCalibrateMethod& method )
{
    QStandardItemModel& model = *pModel_;

    ui->spinPolynomials->setValue( method.polynomialDegree() );
    ui->spinMassTolerance->setValue( method.massToleranceDa() );
    ui->spinMinimumRA->setValue( method.minimumRAPercent() );
    ui->spinLowMass->setValue( method.lowMass() );
    ui->spinHighMass->setValue( method.highMass() );

    const adcontrols::MSReferences& references = method.references();
    int nRows = static_cast<int>( references.size() );
    if ( nRows < model.rowCount() )
        model.removeRows( 0, model.rowCount() ); // make sure all clear

    model.setRowCount( nRows + 1 ); // be sure last empty line

    int row = 0;
    for ( auto& ref: references ) {
		std::wstring formula = ref.display_formula();
        
		model.setData( model.index( row, c_formula ),     qtwrapper::qstring::copy( formula ) );
		model.setData( model.index( row, c_exact_mass ),  ref.exact_mass() );
		model.setData( model.index( row, c_enable ),      ref.enable() );

        QStandardItem * chk = model.itemFromIndex( model.index( row, c_enable ) );
        if ( chk ) {
            chk->setFlags( Qt::ItemIsUserCheckable | Qt::ItemIsEnabled );
            chk->setEditable( true );
            model.setData( model.index( row, c_enable ),  ref.enable() ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole );
        }
		model.setData( model.index( row, c_description ), qtwrapper::qstring::copy( ref.description() ) );
		model.setData( model.index( row, c_charge ), ref.charge_count() );

        ++row;
    }
}