author | cniehaus <cniehaus> | 2002-09-21 13:43:51 (UTC) |
---|---|---|
committer | cniehaus <cniehaus> | 2002-09-21 13:43:51 (UTC) |
commit | 65cf44292ac6abfb1a60be5f582cab26333cfb0a (patch) (side-by-side diff) | |
tree | 8fec45b6ca9302055dd497fc7857015cf571665d /noncore/apps/oxygen/kmolcalc.cpp | |
parent | 99d546ce72f40e28b04f09201d92d58294401591 (diff) | |
download | opie-65cf44292ac6abfb1a60be5f582cab26333cfb0a.zip opie-65cf44292ac6abfb1a60be5f582cab26333cfb0a.tar.gz opie-65cf44292ac6abfb1a60be5f582cab26333cfb0a.tar.bz2 |
* moving oxygendata and kmolweights
* fixing the datafile-problems (thanks to Max)
Diffstat (limited to 'noncore/apps/oxygen/kmolcalc.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/oxygen/kmolcalc.cpp | 25 |
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. |