author | cniehaus <cniehaus> | 2002-09-15 17:09:54 (UTC) |
---|---|---|
committer | cniehaus <cniehaus> | 2002-09-15 17:09:54 (UTC) |
commit | 33ec9ead7ce30bf9450b9048506f0bda49ba4791 (patch) (unidiff) | |
tree | 1683b16a3cb06d7773427193fc4ea5284bf3bdaa /noncore/apps/oxygen/calcdlgui.cpp | |
parent | 7a8dc6b0a16db160a1e50fde8f298eb9e3cb0099 (diff) | |
download | opie-33ec9ead7ce30bf9450b9048506f0bda49ba4791.zip opie-33ec9ead7ce30bf9450b9048506f0bda49ba4791.tar.gz opie-33ec9ead7ce30bf9450b9048506f0bda49ba4791.tar.bz2 |
Fell free to shoot me if I messed up CVS again... *fingercrossed*
Diffstat (limited to 'noncore/apps/oxygen/calcdlgui.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/oxygen/calcdlgui.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/noncore/apps/oxygen/calcdlgui.cpp b/noncore/apps/oxygen/calcdlgui.cpp new file mode 100644 index 0000000..e9b40d3 --- a/dev/null +++ b/noncore/apps/oxygen/calcdlgui.cpp | |||
@@ -0,0 +1,55 @@ | |||
1 | /*************************************************************************** | ||
2 | * * | ||
3 | * This program is free software; you can redistribute it and/or modify * | ||
4 | * it under the terms of the GNU General Public License as published by * | ||
5 | * the Free Software Foundation; either version 2 of the License, or * | ||
6 | * ( at your option ) any later version. * | ||
7 | * * | ||
8 | **************************************************************************/ | ||
9 | #include "oxygen.h" | ||
10 | |||
11 | #include "calcdlgui.h" | ||
12 | #include "kmolcalc.h" | ||
13 | #include <qlineedit.h> | ||
14 | #include <qmultilineedit.h> | ||
15 | #include <qpushbutton.h> | ||
16 | |||
17 | calcDlgUI::calcDlgUI() : CalcDlg() | ||
18 | { | ||
19 | kmolcalc = new KMolCalc; | ||
20 | connect( calculate, SIGNAL( clicked() ), this, SLOT( calc() ) ); | ||
21 | connect( clear_fields, SIGNAL( clicked() ), this, SLOT( clear() ) ); | ||
22 | } | ||
23 | |||
24 | void calcDlgUI::calc() | ||
25 | { | ||
26 | QString compound( formula->text() ); | ||
27 | if ( compound.isEmpty() ) { | ||
28 | clear(); | ||
29 | return; | ||
30 | } | ||
31 | QString errors( kmolcalc->readFormula( compound ) ); | ||
32 | QString mw, ea; | ||
33 | double weight = kmolcalc->getWeight(); | ||
34 | if ( errors == "OK" ) { | ||
35 | mw.setNum( weight ); | ||
36 | ea = kmolcalc->getEmpFormula() + " :\n" + kmolcalc->getEA(); | ||
37 | } else { | ||
38 | mw = "???"; | ||
39 | ea = tr( "ERROR: \n" ) + errors + "\n"; | ||
40 | } | ||
41 | result->setText( mw ); | ||
42 | anal_display->setText( ea ); | ||
43 | } | ||
44 | |||
45 | /** | ||
46 | * * Clear all text entry / result fields. | ||
47 | * */ | ||
48 | void calcDlgUI::clear() | ||
49 | { | ||
50 | formula->clear(); | ||
51 | result->clear(); | ||
52 | anal_display->clear(); | ||
53 | } | ||
54 | |||
55 | |||