1 /***************************************************************************
3 copyright : (C) 2004 by Carsten Niehaus
4 email : cniehaus@kde.org
5 ***************************************************************************/
7 /***************************************************************************
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
14 ***************************************************************************/
15 #include "isotopewidget.h"
27 IsotopeWidget::IsotopeWidget( QWidget
*parent
, const char* name
)
28 : QWidget( parent
, name
)
30 vbox
= new QVBoxLayout( this );
33 void IsotopeWidget::setIsotopes( const QString
& isotopes_string
)
35 widget
= new QWidget( this );
37 vbox
->addWidget( widget
);
39 QHBoxLayout
*h
= new QHBoxLayout( widget
);
40 QLabel
*l1
= new QLabel( i18n( "<b>Weight</b>" ) , widget
);
41 QLabel
*l2
= new QLabel( i18n( "<b>Neutrons</b>" ) , widget
);
42 QLabel
*l3
= new QLabel( i18n( "<b>Percentage</b>" ) , widget
);
47 QString isotopes
= isotopes_string
;
52 for ( int num
= 0; num
< isotopes_string
.contains( ";" ) ; ++num
)
54 pos
= isotopes
.find( ";" );
55 l
= isotopes
.length();
57 QString str
= isotopes
.left( pos
);
58 QString new_str
= isotopes
.right( l
-pos
-1 );
60 vbox
->addWidget( isotopeLabel( str
) );
65 vbox
->addWidget( isotopeLabel( isotopes
) );
68 QWidget
* IsotopeWidget::isotopeLabel( const QString
& str
)
70 QWidget
*w
= new QWidget( this );
72 QHBoxLayout
*hbox
= new QHBoxLayout( w
);
74 //number of neutrons of the isotope
75 int pos
= str
.find( ":" );
76 QString neutrons_str
= str
.left( pos
);
77 QString tmp
= str
.right( str
.length()-pos
-1 );
79 //Weight of the isotope
80 pos
= tmp
.find( ":" );
81 QString weight_str
= tmp
.left( pos
);
82 weight_str
.append( i18n( " u" ) );
84 //Percentage of the isotope
85 tmp
= tmp
.right( tmp
.length()-pos
-1 );
87 QLabel
*weight
= new QLabel( w
);
88 QLabel
*neutrons
= new QLabel( w
);
89 QLabel
*percentage
= new QLabel( w
);
92 weight
->setText( weight_str
);
93 neutrons
->setText( neutrons_str
);
94 percentage
->setText( tmp
);
96 hbox
->addWidget( weight
);
97 hbox
->addWidget( neutrons
);
98 hbox
->addWidget( percentage
);
103 #include "isotopewidget.moc"