summaryrefslogtreecommitdiff
path: root/noncore/apps/oxygen/kmolcalc.cpp
Side-by-side diff
Diffstat (limited to 'noncore/apps/oxygen/kmolcalc.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/oxygen/kmolcalc.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/noncore/apps/oxygen/kmolcalc.cpp b/noncore/apps/oxygen/kmolcalc.cpp
index 0ba52da..33666b1 100644
--- a/noncore/apps/oxygen/kmolcalc.cpp
+++ b/noncore/apps/oxygen/kmolcalc.cpp
@@ -1,3 +1,3 @@
-/*
+/*
* kmolcalc.cpp
*
@@ -9,5 +9,5 @@
* KMOLCALC is the calculation engine. It knows about a hashtable of user defined atomic
* weights and group definitions ELSTABLE, and the currently processed formula, stored
- * as a list of elements and their coefficients, ELEMENTS.
+ * as a list of elements and their coefficients, ELEMENTS.
*/
@@ -16,4 +16,5 @@
#include <qdir.h>
#include <qfile.h>
+#include <qpe/qpeapplication.h>
#include <iostream.h>
@@ -37,5 +38,5 @@ void KMolCalc::readElstable() {
elstable = new QDict<SubUnit> (197, TRUE);
elstable->setAutoDelete(TRUE);
- mwfile = "/home/opie/opie/noncore/apps/oxygen/kmolweights";
+ mwfile = QPEApplication::qpeDir() +"share/oxygen/kmolweights";
QFile f(mwfile);
if (f.exists()) readMwfile(f);
@@ -43,7 +44,7 @@ void KMolCalc::readElstable() {
-/**
- * Parse a string S and construct the ElementList this->ELEMENTS, representing the
- * composition of S. Returns 0 if successful, or an error code (currently -1) if
+/**
+ * Parse a string S and construct the ElementList this->ELEMENTS, representing the
+ * composition of S. Returns 0 if successful, or an error code (currently -1) if
* parsing failed.
* The elements is S must be valid element or group symbols, as stored in this->ELSTABLE.
@@ -65,5 +66,5 @@ QString KMolCalc::readGroup(const QString& s, ElementList* els) {
bool ok = TRUE;
while (i < sl && ((s[i] <= '9' && s[i] >= '0') || s[i] == '.')) i++;
- double prefix = (i == 0 ? 1 : s.left(i).toDouble(&ok));
+ double prefix = (i == 0 ? 1 : s.left(i).toDouble(&ok));
if (! ok || i == sl || prefix == 0) return QString ("Bad formula."); // ERROR
ElementList* elstemp = new ElementList;
@@ -86,20 +87,20 @@ QString KMolCalc::readGroup(const QString& s, ElementList* els) {
j = ++i;
while (i < sl && ((s[i] <= '9' && s[i] >= '0') || s[i] == '.')) i++;
- double suffix = (i == j ? 1 : s.mid(j, i-j).toDouble(&ok));
+ double suffix = (i == j ? 1 : s.mid(j, i-j).toDouble(&ok));
if (! ok || suffix == 0) {
delete inner;
delete elstemp;
return QString ("Bad formula."); // ERROR
- }
+ }
inner->addTo(*elstemp, suffix);
delete inner;
inner = NULL;
} else if ((s[i] >= 'A' && s[i] <= 'Z') || (s[i] >= 'a' && s[i] <= 'z')) {
- while (++i < sl && ((s[i] >= 'a' && s[i] <= 'z') || s[i] == '*' ||
+ while (++i < sl && ((s[i] >= 'a' && s[i] <= 'z') || s[i] == '*' ||
s[i] == '\''));
QString elname = s.mid(j, i-j);
j = i;
while (i < sl && ((s[i] <= '9' && s[i] >= '0') || s[i] == '.')) i++;
- double suffix = (i == j ? 1 : s.mid(j, i-j).toDouble(&ok));
+ double suffix = (i == j ? 1 : s.mid(j, i-j).toDouble(&ok));
if (! ok || suffix == 0) {
delete elstemp;
@@ -177,5 +178,5 @@ void KMolCalc::undefineGroup (const QString& name) {
/**
- * Add a new element name - atomic weight record to the ELSTABLE hashtable. Assumes
+ * Add a new element name - atomic weight record to the ELSTABLE hashtable. Assumes
* NAME has valid syntax.