summaryrefslogtreecommitdiff
path: root/noncore/apps/oxygen/calcdlgui.cpp
Unidiff
Diffstat (limited to 'noncore/apps/oxygen/calcdlgui.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/oxygen/calcdlgui.cpp55
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
17calcDlgUI::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
24void 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 * */
48void calcDlgUI::clear()
49{
50 formula->clear();
51 result->clear();
52 anal_display->clear();
53}
54
55