summaryrefslogtreecommitdiff
path: root/noncore/apps/oxygen/calcdlgui.cpp
authorcniehaus <cniehaus>2002-09-15 17:09:54 (UTC)
committer cniehaus <cniehaus>2002-09-15 17:09:54 (UTC)
commit33ec9ead7ce30bf9450b9048506f0bda49ba4791 (patch) (side-by-side diff)
tree1683b16a3cb06d7773427193fc4ea5284bf3bdaa /noncore/apps/oxygen/calcdlgui.cpp
parent7a8dc6b0a16db160a1e50fde8f298eb9e3cb0099 (diff)
downloadopie-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) (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 @@
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * ( at your option ) any later version. *
+ * *
+ **************************************************************************/
+#include "oxygen.h"
+
+#include "calcdlgui.h"
+#include "kmolcalc.h"
+#include <qlineedit.h>
+#include <qmultilineedit.h>
+#include <qpushbutton.h>
+
+calcDlgUI::calcDlgUI() : CalcDlg()
+{
+ kmolcalc = new KMolCalc;
+ connect( calculate, SIGNAL( clicked() ), this, SLOT( calc() ) );
+ connect( clear_fields, SIGNAL( clicked() ), this, SLOT( clear() ) );
+}
+
+void calcDlgUI::calc()
+{
+ QString compound( formula->text() );
+ if ( compound.isEmpty() ) {
+ clear();
+ return;
+ }
+ QString errors( kmolcalc->readFormula( compound ) );
+ QString mw, ea;
+ double weight = kmolcalc->getWeight();
+ if ( errors == "OK" ) {
+ mw.setNum( weight );
+ ea = kmolcalc->getEmpFormula() + " :\n" + kmolcalc->getEA();
+ } else {
+ mw = "???";
+ ea = tr( "ERROR: \n" ) + errors + "\n";
+ }
+ result->setText( mw );
+ anal_display->setText( ea );
+}
+
+/**
+ * * Clear all text entry / result fields.
+ * */
+void calcDlgUI::clear()
+{
+ formula->clear();
+ result->clear();
+ anal_display->clear();
+}
+
+