UltraScan III
us_choice.cpp
Go to the documentation of this file.
1 #include "us_choice.h"
3 #include "us_gui_settings.h"
4 #include "us_analyte.h"
5 
6 US_Choice::US_Choice( const US_Solution& solution )
7  : US_WidgetsDialog( 0, 0 )
8 
9 {
10  setPalette ( US_GuiSettings::frameColor() );
11  setAttribute( Qt::WA_DeleteOnClose );
12 
13  int row = 0;
14 
15  QGridLayout* main = new QGridLayout( this );
16  main->setSpacing ( 2 );
17  main->setContentsMargins ( 2, 2, 2, 2 );
18 
19  QPalette p = US_GuiSettings::normalColor();
20 
21  main->addWidget( us_textlabel( "Description" ), row, 0 );
22  main->addWidget( us_textlabel( "MW" ), row, 1 );
23  main->addWidget( us_textlabel( "vbar20" ), row++, 2 );
24 
25  QLayoutItem* item = main->itemAtPosition( 0, 0 );
26  item->widget()->setPalette( p );
27 
28 
29  for ( int i = 0; i < solution.analyteInfo.size(); i++ )
30  {
31  bool selected = ( i == 0 );
32  QRadioButton* radio;
33 
34  const US_Analyte* analyte = &solution.analyteInfo[ i ].analyte;
35 
36  QGridLayout* radioLayout = us_radiobutton( analyte->description,
37  radio, selected );
38  radios << radio;
39 
40  QLabel* mw = us_textlabel( QString::number( analyte->mw, 'e', 4 ) );
41  QLabel* vbar = us_textlabel( QString::number( analyte->vbar20, 'f', 4 ) );
42 
43  main->addLayout( radioLayout, row, 0 );
44  main->addWidget( mw, row, 1 );
45  main->addWidget( vbar, row++, 2 );
46  }
47 
48  QPushButton* pb_ok = us_pushbutton( tr( "OK" ) );
49  connect( pb_ok, SIGNAL( clicked() ), SLOT( done() ) );
50  main->addWidget( pb_ok, row, 0, 1, 3 );
51 }
52 
53 void US_Choice::done( void )
54 {
55  for ( int i = 0; i < radios.size(); i++ )
56  {
57  if ( radios[ i ]->isChecked() )
58  {
59  emit choice( i );
60  break;
61  }
62  }
63  close();
64 }
65 
66