summaryrefslogtreecommitdiff
path: root/noncore
authorcniehaus <cniehaus>2002-09-15 14:02:04 (UTC)
committer cniehaus <cniehaus>2002-09-15 14:02:04 (UTC)
commitffb701b9a482ca30eda8901506c0c39ad8461e4c (patch) (side-by-side diff)
tree82fa34a6083a48c877f4a7b41c15672832095fbb /noncore
parentd01f8da912a2bed9de1943d174ec10dba505bf38 (diff)
downloadopie-ffb701b9a482ca30eda8901506c0c39ad8461e4c.zip
opie-ffb701b9a482ca30eda8901506c0c39ad8461e4c.tar.gz
opie-ffb701b9a482ca30eda8901506c0c39ad8461e4c.tar.bz2
Ok, this is what I have so far. I know it is not really working thus it is
not in the toplevel-Makefile. I am putting as much work in it as possible. Currently I am doing the kmol-port, after that the PSE-stuff.
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/TODO4
-rw-r--r--noncore/apps/checkbook/calcdlgui.cpp52
-rw-r--r--noncore/apps/checkbook/calcdlgui.h22
-rw-r--r--noncore/apps/checkbook/kmolcalc.cpp233
-rw-r--r--noncore/apps/checkbook/kmolcalc.h110
-rw-r--r--noncore/apps/checkbook/kmolelements.cpp238
-rw-r--r--noncore/apps/checkbook/kmolelements.h161
-rw-r--r--noncore/apps/checkbook/main.cpp22
-rw-r--r--noncore/apps/checkbook/moc_kmoledit.cpp95
-rw-r--r--noncore/apps/checkbook/opie-oxygen.control9
-rw-r--r--noncore/apps/checkbook/oxygen.cpp52
-rw-r--r--noncore/apps/checkbook/oxygen.h22
-rw-r--r--noncore/apps/checkbook/oxygen.pro18
13 files changed, 1028 insertions, 10 deletions
diff --git a/noncore/apps/checkbook/TODO b/noncore/apps/checkbook/TODO
index adc9665..bc60bf4 100644
--- a/noncore/apps/checkbook/TODO
+++ b/noncore/apps/checkbook/TODO
@@ -1,5 +1 @@
TODO:
- * Date widget
- * Various bug fixes
- * Fix "the" crash
- * Fix graph's legend not showing up \ No newline at end of file
diff --git a/noncore/apps/checkbook/calcdlgui.cpp b/noncore/apps/checkbook/calcdlgui.cpp
new file mode 100644
index 0000000..a86374b
--- a/dev/null
+++ b/noncore/apps/checkbook/calcdlgui.cpp
@@ -0,0 +1,52 @@
+/***************************************************************************
+ * *
+ * 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 <qmenubar.h>
+#include <qstatusbar.h>
+#include <qpopupmenu.h>
+#include <qlabel.h>
+#include <qapplication.h>
+#include <qpushbutton.h>
+#include <qfile.h>
+#include <qdir.h>
+#include <qvbox.h>
+#include "calcdlg.h"
+
+Oxygen::Oxygen()
+ : QMainWindow()
+{
+ this->setCaption( "Oxygen" );
+ vbox = new QVBox( this );
+ QPushButton *setButton = new QPushButton( "Settings", vbox );
+ connect ( setButton, SIGNAL( clicked() ), this, SLOT( slotSettings() ) );
+ QPushButton *calcButton = new QPushButton( "Calculations", vbox );
+ connect ( calcButton, SIGNAL( clicked() ), this, SLOT( slotCalculations() ) );
+ QPushButton *pseButton = new QPushButton( "PSE", vbox );
+ connect ( pseButton, SIGNAL( clicked() ), this, SLOT( slotPSE() ) );
+
+ setCentralWidget( vbox );
+}
+
+
+void Oxygen::close()
+{
+ QApplication::exit();
+}
+
+//SLOTS
+
+void Oxygen::slotCalculations(){
+ CalcDlgUI *calcDlgUI = new calcDlgUI();
+ calcDlgUI->show();
+};
+
+void Oxygen::slotSettings(){ };
+void Oxygen::slotPSE(){ };
+
diff --git a/noncore/apps/checkbook/calcdlgui.h b/noncore/apps/checkbook/calcdlgui.h
new file mode 100644
index 0000000..1e923ee
--- a/dev/null
+++ b/noncore/apps/checkbook/calcdlgui.h
@@ -0,0 +1,22 @@
+
+#include <qpe/resource.h>
+#include <qmainwindow.h>
+#include <qtoolbar.h>
+#include <qstring.h>
+#include <qpopupmenu.h>
+
+class QVBox;
+
+class Oxygen : public QMainWindow
+{
+ Q_OBJECT
+
+ public:
+ Oxygen();
+ QVBox *vbox;
+ private slots:
+ void slotCalculations();
+ void slotSettings();
+ void slotPSE();
+ void close();
+};
diff --git a/noncore/apps/checkbook/kmolcalc.cpp b/noncore/apps/checkbook/kmolcalc.cpp
new file mode 100644
index 0000000..e5ab736
--- a/dev/null
+++ b/noncore/apps/checkbook/kmolcalc.cpp
@@ -0,0 +1,233 @@
+/*
+ * kmolcalc.cpp
+ *
+ * Copyright (C) 2000 Tomislav Gountchev <tomi@idiom.com>
+ */
+
+/**
+ * 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.
+ */
+
+#include "kmolcalc.h"
+#include <qdict.h>
+#include <qdir.h>
+#include <iostream.h>
+
+
+/**
+ * Construct a new calculator object.
+ */
+KMolCalc::KMolCalc() {
+ elements = new ElementList;
+ elstable = NULL;
+ readElstable();
+}
+
+KMolCalc::~KMolCalc() {
+ delete elements;
+}
+
+void KMolCalc::readElstable() {
+ weight = -1; // not calculated yet
+ if (elstable) delete elstable;
+ elstable = new QDict<SubUnit> (197, TRUE);
+ elstable->setAutoDelete(TRUE);
+ QStringList files;// = // KGlobal::dirs()->findAllResources("appdata", "kmolweights");
+// mwfile = locateLocal("data", "kmol")+"/kmolweights";
+ QFile f(mwfile);
+ QString* latest_f = &mwfile;
+ for (uint i=0; i<files.count(); i++) {
+ if (QFileInfo(QFile(files[i])).lastModified() > QFileInfo(QFile(*latest_f)).lastModified()) {
+ latest_f = &files[i];
+ }
+ }
+ QFile lf(*latest_f);
+ if (f.exists()) readMwfile(f);
+ if (!f.exists()) {
+ readMwfile(lf);
+ writeElstable();
+ } else if (QFileInfo(f).lastModified() < QFileInfo(lf).lastModified()) {
+ // announce
+ QMessageBox::information
+ (0, "Warning:", "Found new global Mw file.\nLocal definitions will be updated.", QMessageBox::Ok);
+ readMwfile(lf);
+ writeElstable();
+ }
+
+}
+
+
+/**
+ * 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.
+ * See help files for correct formula syntax.
+ */
+QString KMolCalc::readFormula(const QString& s) {
+ weight = -1;
+ if (elements) delete elements;
+ elements = new ElementList;
+ return KMolCalc::readGroup(s, elements);
+}
+
+// read a formula group recursively. Called by readFormula.
+QString KMolCalc::readGroup(const QString& s, ElementList* els) {
+ if (s.isEmpty()) return QString ("Enter a formula."); //ERROR
+ int sl = s.length();
+ int i = 0;
+ QString errors ("OK");
+ 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));
+ if (! ok || i == sl || prefix == 0) return QString ("Bad formula."); // ERROR
+ ElementList* elstemp = new ElementList;
+ while (i < sl) {
+ int j = i;
+ if (s[i] == '(') {
+ ElementList* inner = new ElementList;
+ int level = 1; // count levels of nested ( ).
+ while (1) {
+ if (i++ == sl) {
+ delete inner;
+ delete elstemp;
+ return QString ("Bad formula."); //ERROR
+ }
+ if (s[i] == '(') level++;
+ if (s[i] == ')') level--;
+ if (level == 0) break;
+ }
+ errors = KMolCalc::readGroup(s.mid(j+1, i-j-1), inner);
+ 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));
+ 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] == '*' ||
+ 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));
+ if (! ok || suffix == 0) {
+ delete elstemp;
+ return QString ("Bad formula."); // ERROR
+ }
+ SubUnit* group = elstable->find(elname);
+ if (group == 0) {
+ delete elstemp;
+ return QString ("Undefined symbol: ") + elname; //ERROR
+ }
+ group->addTo(*elstemp, suffix);
+ } else if (s[i] == '+') {
+ if (elstemp->isEmpty()) {
+ delete elstemp;
+ return QString ("Bad formula."); //ERROR
+ }
+ elstemp->addTo(*els, prefix);
+ delete elstemp;
+ errors = KMolCalc::readGroup(s.mid(i+1, sl-i-1), els);
+ return errors;
+ } else {
+ delete elstemp;
+ return QString ("Bad formula."); //ERROR
+ }
+ }
+ elstemp->addTo(*els, prefix);
+ delete elstemp;
+ return errors;
+}
+
+/**
+ * Calculate and return the molecular weight of the current chemical formula.
+ */
+double KMolCalc::getWeight() {
+ if (weight == -1) weight = elements->getWeight(elstable);
+ return weight;
+}
+
+/**
+ * Return the elemental composition of the current formula, as a string of tab-separated
+ * element - percentage pairs, separated by newlines.
+ */
+QString KMolCalc::getEA() {
+ if (weight == -1) weight = elements->getWeight(elstable);
+ if (weight == -1) return QString("ERROR: Couldn't get Mw..."); // ERROR
+ return elements->getEA(elstable, weight);
+}
+
+/**
+ * Return the empirical formula of the current compound as a QString.
+ */
+QString KMolCalc::getEmpFormula() {
+ return elements->getEmpFormula();
+}
+
+// Read the element definition file.
+void KMolCalc::readMwfile(QFile& f) {
+ if (! f.open(IO_ReadOnly)) return; //ERROR
+ QTextStream fs (&f);
+ QString line;
+ while (! fs.eof()) {
+ line = fs.readLine();
+ SubUnit* s = SubUnit::makeSubUnit(line);
+ elstable->replace(s->getName(), s);
+ }
+ f.close();
+}
+
+/**
+ * Save the element definitions file.
+ */
+void KMolCalc::writeElstable() {
+ QFile f(mwfile);
+ if (! f.open(IO_WriteOnly)) return; //ERROR
+ QTextStream fs (&f);
+ QString line;
+ QDictIterator<SubUnit> it(*elstable);
+ while (it.current()) {
+ it.current()->writeOut(line);
+ fs << line << endl;
+ ++it;
+ }
+ f.close();
+}
+
+/**
+ * Remove a group or element definition from ELSTABLE.
+ */
+void KMolCalc::undefineGroup (const QString& name) {
+ elstable->remove (name);
+}
+
+/**
+ * Add a new element name - atomic weight record to the ELSTABLE hashtable. Assumes
+ * NAME has valid syntax.
+
+ */
+void KMolCalc::defineElement (const QString& name, double weight) {
+ Element* el = new Element(name, weight);
+ elstable->replace(name, el);
+}
+
+/**
+ * Add a new group definition to the ELSTABLE. Returns 0 if OK, -1 if parsing FORMULA
+ * fails. Assumes the syntax of grpname is correct.
+ */
+QString KMolCalc::defineGroup (const QString& grpname, const QString& formula) {
+ ElementList* els = new ElementList(grpname);
+ QString error = readGroup(formula, els);
+ if (error != "OK") return error;
+ if (els->contains(grpname)) return QString("Can't define a group recursively!\n");
+ elstable->replace(grpname, els);
+ return QString("OK");
+}
diff --git a/noncore/apps/checkbook/kmolcalc.h b/noncore/apps/checkbook/kmolcalc.h
new file mode 100644
index 0000000..c3e02f3
--- a/dev/null
+++ b/noncore/apps/checkbook/kmolcalc.h
@@ -0,0 +1,110 @@
+/*
+ * kmolcalc.h
+ *
+ * Copyright (C) 2000 Tomislav Gountchev <tomi@idiom.com>
+ */
+
+
+#ifndef KMOLCALC_H
+#define KMOLCALC_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include "kmolelements.h"
+#include <qdict.h>
+#include <qlist.h>
+#include <qstring.h>
+#include <qfile.h>
+#include <qfileinfo.h>
+#include <qmessagebox.h>
+#include <qtextstream.h>
+
+
+/**
+ * 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.
+ */
+class KMolCalc {
+
+public:
+
+ KMolCalc();
+ ~KMolCalc();
+
+ /**
+ * Parse a string S and construct the ElementList ELEMENTS, representing the composition
+ * of S. Returns "OK" if successful, or an error message if parsing failed.
+ * The elements is S must be valid element or group symbols, as stored in ELSTABLE.
+ * See help files for correct formula syntax.
+ */
+ QString readFormula(const QString& s);
+
+ /**
+ * Calculate and return the molecular weight of the current chemical formula.
+ */
+ double getWeight();
+
+ /**
+ * Return the elemental composition of the current formula, as a string of tab-separated
+ * element - percentage pairs, separated by newlines.
+ */
+ QString getEA();
+
+
+ /**
+ * Return the empirical formula of the current compound as a QString.
+ */
+ QString getEmpFormula();
+
+ /**
+ * Add a new element name - atomic weight record to the ELSTABLE hashtable.
+ * Assumes NAME has valid syntax.
+ */
+ void defineElement(const QString& name, double weight);
+
+ /**
+ * Add a new group definition to the ELSTABLE. Returns "OK" if OK, error message
+ * if parsing FORMULA fails. Assumes the syntax of NAME is correct.
+ */
+ QString defineGroup(const QString& name, const QString& formula);
+
+ /**
+ * Remove a group or element definition from ELSTABLE.
+ */
+ void undefineGroup(const QString& name);
+
+ /**
+ * Save the element definitions file.
+ */
+ void writeElstable();
+
+ /**
+ * Read the element definitions file and construct ELSTABLE.
+ */
+ void readElstable();
+
+ /**
+ * The element dictionary.
+ */
+ QDict<SubUnit>* elstable;
+
+ QString mwfile;
+
+ private:
+ double weight;
+
+ QString readGroup(const QString& s, ElementList* els);
+ void readMwfile(QFile& f);
+ ElementList* elements;
+};
+
+#endif
+
+
+
+
+
diff --git a/noncore/apps/checkbook/kmolelements.cpp b/noncore/apps/checkbook/kmolelements.cpp
new file mode 100644
index 0000000..ce8f9c1
--- a/dev/null
+++ b/noncore/apps/checkbook/kmolelements.cpp
@@ -0,0 +1,238 @@
+/*
+ * kmolelements.cpp
+ *
+ * Copyright (C) 2000 Tomislav Gountchev <tomi@idiom.com>
+ */
+
+// classes that store and manipulate chemical formulas represented as
+// lists of elements
+
+#include <stdio.h>
+#include "kmolelements.h"
+
+/**
+ * A generic chemical entity. Can be an element or a group.
+ */
+SubUnit::SubUnit () {}
+
+SubUnit::~SubUnit () {}
+
+/**
+ * Construct a subunit and return a pointer to it. The syntax of LINE is
+ * the one used in the element definition file.
+ */
+SubUnit* SubUnit::makeSubUnit(QString line) {
+ QString name, grpname, weight, coef;
+ QTextStream str (line, IO_ReadOnly);
+ str >> name;
+ if (name != "-group") { // not a group - must be represented as Element
+ str >> weight >> ws;
+ return new Element(name, weight.toDouble());
+ }
+ else {
+ str >> grpname;
+ ElementList* els = new ElementList(grpname); // group - make an ElementList
+ while (!str.eof()) {
+ str >> name >> ws;
+ str >> coef >> ws;
+ els->addElement(name, coef.toDouble());
+ }
+ return els;
+ }
+}
+
+QString SubUnit::getName() const {
+ return QString("None");
+}
+
+/**
+ * Get the molecular weight of THIS, based on the data from ELSTABLE.
+ */
+double SubUnit::getWeight(QDict<SubUnit>* elstable) const {
+ return -1;
+}
+
+/**
+ * A group of elements.
+ */
+ElementList::ElementList () {
+ elements = new QList<ElementCoef>;
+}
+
+ElementList::~ElementList () {
+ delete elements;
+}
+
+
+/**
+ * A group of elements.
+ */
+ElementList::ElementList (QString name) {
+ this->name = name;
+ elements = new QList<ElementCoef>;
+}
+
+/**
+ * Write THIS to LINE, in a format suitable for the element definition file.
+ */
+void ElementList::writeOut(QString& line) {
+ QString coef;
+ line = "-group " + name;
+ ElementCoef* current = elements->first();
+ while (current != 0) {
+ line += " " + current->name + " " + coef.setNum(current->coef, 'g', 10);
+ // precision set to 10 digits
+ current = elements->next();
+ }
+}
+
+/**
+ * Get the molecular weight of THIS, based on the data from ELSTABLE.
+ */
+double ElementList::getWeight(QDict<SubUnit>* elstable) const {
+ double weight = 0;
+ ElementCoef* current = elements->first();
+ while (current != 0) {
+ SubUnit* e = elstable->find(current->name);
+ if (e != 0) {
+ weight += (current->coef) * (e->getWeight(elstable));
+ } else return -1; //ERROR
+ current = elements->next();
+ }
+ return weight;
+}
+
+/**
+ * Return a string representing the elemental composition of THIS, as
+ * a tab-separated element - percentage pairs, separated by newlines.
+ */
+QString ElementList::getEA(QDict<SubUnit>* elstable, double mw) const {
+ if (mw == 0) mw = getWeight(elstable);
+ QString ea;
+ QString temp;
+ ElementCoef* current = elements->first();
+ while (current != 0) {
+ SubUnit* e = elstable->find(current->name);
+ if (e != 0) {
+ double current_percent = 100 * (current->coef) *
+ (e->getWeight(elstable))
+ / mw;
+ ea += current->name + "\t" +
+ temp.setNum(current_percent) + "\n";
+ } else return QString("ERROR!\n"); //ERROR
+ current = elements->next();
+ }
+ return ea;
+}
+
+/**
+ * Return a string representing THIS as an empirical chemical formula.
+ */
+QString ElementList::getEmpFormula() const {
+ QString ef;
+ QString temp;
+ ElementCoef* current = elements->first();
+ while (current != 0) {
+ ef += current->name + temp.setNum(current->coef);
+ current = elements->next();
+ }
+ return ef;
+}
+
+/**
+ * Multiply THIS (i.e. the coefficient of each element) by coef.
+ */
+void ElementList::multiplyBy(double coef) {
+ ElementCoef* current = elements->first();
+ while (current != 0) {
+ (current->coef) *= coef;
+ current = elements->next();
+ }
+}
+
+/**
+ * Add THIS to ELS. THIS is not modified; ELS is.
+ */
+void ElementList::addTo(ElementList& els, double coef) {
+ ElementCoef* current = elements->first();
+ while (current != 0) {
+ els.addElement(current->name, (current->coef) * coef);
+ current = elements->next();
+ }
+}
+
+/**
+ * Add an element to THIS, with a coefficient COEF. If THIS already contains
+ * an element with the same name, adjust its coefficient only; if not, create
+ * a new ElementCoef pair and add to THIS.
+ */
+void ElementList::addElement(const QString& name, double coef) {
+ ElementCoef* current = elements->first();
+ while (current != 0) {
+ if (current->name == name) {
+ current->coef += coef;
+ return;
+ }
+ current = elements->next();
+ }
+ elements->append(new ElementCoef(name, coef));
+}
+
+/**
+ * True iff THIS contains element named NAME.
+ */
+bool ElementList::contains(const QString& name) {
+ ElementCoef* current = elements->first();
+ while (current != 0) {
+ if (current->name == name)
+ return true;
+ current = elements->next();
+ }
+ return false;
+}
+
+bool ElementList::isEmpty() {
+ return elements->isEmpty();
+}
+
+QString ElementList::getName() const {
+ return name;
+}
+
+/**
+ * A chemical element.
+ */
+Element::Element(const QString& n, double w)
+ : weight(w), name(n) { }
+
+
+Element::~Element() {
+}
+
+
+/**
+ * Write THIS to LINE, in a format suitable for the element definition file.
+ */
+void Element::writeOut(QString& line) {
+ line.setNum(weight);
+ line = name + " " + line;
+}
+
+double Element::getWeight(QDict<SubUnit>* elstable) const {
+ return weight;
+}
+
+void Element::addTo(ElementList& els, double coef) {
+ els.addElement(name, coef);
+}
+
+QString Element::getName() const {
+ return name;
+}
+
+/**
+ * An element - coefficient pair. Used to represent elements within an
+ * element list.
+ */
+ElementCoef::ElementCoef(const QString& n, double c) : name(n), coef(c) {}
+
diff --git a/noncore/apps/checkbook/kmolelements.h b/noncore/apps/checkbook/kmolelements.h
new file mode 100644
index 0000000..06d1469
--- a/dev/null
+++ b/noncore/apps/checkbook/kmolelements.h
@@ -0,0 +1,161 @@
+/*
+ * kmolelements.h
+ *
+ * Copyright (C) 2000 Tomislav Gountchev <tomi@idiom.com>
+ */
+
+// classes that store and manipulate chemical formulas represented as
+// lists of elements
+
+#ifndef KMOLELEMENTS_H
+#define KMOLELEMENTS_H
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include <qlist.h>
+#include <qdict.h>
+#include <qstring.h>
+#include <qtextstream.h>
+
+class ElementCoef;
+class ElementList;
+
+/**
+ * A generic chemical entity. Can be an element or a group.
+ */
+class SubUnit {
+ public:
+
+ SubUnit();
+
+ virtual ~SubUnit();
+
+ /**
+ * Construct a subunit and return a pointer to it. The syntax of LINE is
+ * the one used in the element definition file.
+ */
+ static SubUnit* makeSubUnit(QString line);
+
+ /**
+ * Get the molecular weight of THIS, based on the data from ELSTABLE.
+ */
+ virtual double getWeight(QDict<SubUnit>* elstable) const;
+
+ /**
+ * Add THIS to ELS.
+ */
+ virtual void addTo(ElementList& els, double coef) = 0;
+
+ virtual QString getName() const;
+
+ /**
+ * Write THIS to LINE, in the format used in the definition file.
+ */
+ virtual void writeOut(QString& line) = 0;
+};
+
+
+/**
+ * A group of elements.
+ */
+class ElementList : public SubUnit {
+ public:
+ ElementList ();
+ ElementList (QString name);
+ virtual ~ElementList();
+ double getWeight(QDict<SubUnit>* elstable) const;
+
+ /**
+ * Return a string representing the elemental composition of THIS, as
+ * a tab-separated element - percentage pairs, separated by newlines.
+ */
+ QString getEA(QDict<SubUnit>* elstable, double mw = 0) const;
+
+ /**
+ * Return a string representing THIS as an empirical chemical formula.
+ */
+ QString getEmpFormula() const;
+
+ /**
+ * Multiply THIS (i.e. the coefficient of each element) by coef.
+ */
+ void multiplyBy(double coef);
+
+ /**
+ * Add THIS to ELS. THIS is not modified; ELS is.
+ */
+ void addTo(ElementList& els, double coef);
+
+ /**
+ * Add an element to THIS, with a coefficient COEF.
+ */
+ void addElement(const QString& name, double coef);
+
+ /**
+ * True iff THIS contains element named NAME.
+ */
+ bool contains(const QString& name);
+
+
+ bool isEmpty();
+
+ /**
+ * The name of THIS, as a chemical group.
+ */
+ QString getName() const;
+
+ /**
+ * Write THIS to LINE, in a format suitable for the element definition file.
+ */
+ void writeOut(QString& line);
+
+ private:
+ QString name;
+ QList<ElementCoef>* elements;
+};
+
+/**
+ * A chemical element.
+ */
+class Element : public SubUnit {
+ public:
+ Element(const QString& name, double weight);
+ virtual ~Element();
+ double getWeight(QDict<SubUnit>* elstable) const;
+
+ /**
+ * Add THIS to ELS, with a coefficient COEF.
+ */
+ void addTo(ElementList& els, double coef);
+
+ QString getName() const;
+
+ void writeOut(QString& line);
+
+ private:
+ double weight;
+ QString name;
+};
+
+
+/**
+ * An element - coefficient pair. Used to represent elements within an
+ * element list.
+ */
+class ElementCoef {
+ friend class ElementList;
+ public:
+ ElementCoef(const QString& name, double coef = 1.0);
+ private:
+ QString name;
+ double coef;
+};
+
+
+#endif
+
+
diff --git a/noncore/apps/checkbook/main.cpp b/noncore/apps/checkbook/main.cpp
index 68f00e6..328b61f 100644
--- a/noncore/apps/checkbook/main.cpp
+++ b/noncore/apps/checkbook/main.cpp
@@ -1,11 +1,21 @@
+/***************************************************************************
+ * *
+ * 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 <qpe/qpeapplication.h>
-#include "qcheckbook.h"
+#include "oxygen.h"
int main(int argc, char **argv)
{
- QPEApplication app(argc, argv);
- QCheckBook *qcb = new QCheckBook();
- app.setMainWidget(qcb);
- qcb->showMaximized();
- return app.exec();
+ QPEApplication app(argc, argv);
+ Oxygen *oxi = new Oxygen();
+ app.setMainWidget(oxi);
+ oxi->showMaximized();
+ return app.exec();
}
diff --git a/noncore/apps/checkbook/moc_kmoledit.cpp b/noncore/apps/checkbook/moc_kmoledit.cpp
new file mode 100644
index 0000000..a94e93b
--- a/dev/null
+++ b/noncore/apps/checkbook/moc_kmoledit.cpp
@@ -0,0 +1,95 @@
+/****************************************************************************
+** KMolEdit meta object code from reading C++ file 'kmoledit.h'
+**
+** Created: Sun Sep 15 15:21:49 2002
+** by: The Qt MOC ($Id$)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#if !defined(Q_MOC_OUTPUT_REVISION)
+#define Q_MOC_OUTPUT_REVISION 9
+#elif Q_MOC_OUTPUT_REVISION != 9
+#error "Moc format conflict - please regenerate all moc files"
+#endif
+
+#include "kmoledit.h"
+#include <qmetaobject.h>
+#include <qapplication.h>
+
+
+
+const char *KMolEdit::className() const
+{
+ return "KMolEdit";
+}
+
+QMetaObject *KMolEdit::metaObj = 0;
+
+void KMolEdit::initMetaObject()
+{
+ if ( metaObj )
+ return;
+ if ( qstrcmp(QDialog::className(), "QDialog") != 0 )
+ badSuperclassWarning("KMolEdit","QDialog");
+ (void) staticMetaObject();
+}
+
+#ifndef QT_NO_TRANSLATION
+
+QString KMolEdit::tr(const char* s)
+{
+ return qApp->translate( "KMolEdit", s, 0 );
+}
+
+QString KMolEdit::tr(const char* s, const char * c)
+{
+ return qApp->translate( "KMolEdit", s, c );
+}
+
+#endif // QT_NO_TRANSLATION
+
+QMetaObject* KMolEdit::staticMetaObject()
+{
+ if ( metaObj )
+ return metaObj;
+ (void) QDialog::staticMetaObject();
+#ifndef QT_NO_PROPERTIES
+#endif // QT_NO_PROPERTIES
+ typedef bool (KMolEdit::*m1_t0)();
+ typedef bool (QObject::*om1_t0)();
+ typedef void (KMolEdit::*m1_t1)();
+ typedef void (QObject::*om1_t1)();
+ typedef void (KMolEdit::*m1_t2)();
+ typedef void (QObject::*om1_t2)();
+ m1_t0 v1_0 = &KMolEdit::edit;
+ om1_t0 ov1_0 = (om1_t0)v1_0;
+ m1_t1 v1_1 = &KMolEdit::save;
+ om1_t1 ov1_1 = (om1_t1)v1_1;
+ m1_t2 v1_2 = &KMolEdit::undo;
+ om1_t2 ov1_2 = (om1_t2)v1_2;
+ QMetaData *slot_tbl = QMetaObject::new_metadata(3);
+ QMetaData::Access *slot_tbl_access = QMetaObject::new_metaaccess(3);
+ slot_tbl[0].name = "edit()";
+ slot_tbl[0].ptr = (QMember)ov1_0;
+ slot_tbl_access[0] = QMetaData::Private;
+ slot_tbl[1].name = "save()";
+ slot_tbl[1].ptr = (QMember)ov1_1;
+ slot_tbl_access[1] = QMetaData::Private;
+ slot_tbl[2].name = "undo()";
+ slot_tbl[2].ptr = (QMember)ov1_2;
+ slot_tbl_access[2] = QMetaData::Private;
+ metaObj = QMetaObject::new_metaobject(
+ "KMolEdit", "QDialog",
+ slot_tbl, 3,
+ 0, 0,
+#ifndef QT_NO_PROPERTIES
+ 0, 0,
+ 0, 0,
+#endif // QT_NO_PROPERTIES
+ 0, 0 );
+ metaObj->set_slot_access( slot_tbl_access );
+#ifndef QT_NO_PROPERTIES
+#endif // QT_NO_PROPERTIES
+ return metaObj;
+}
diff --git a/noncore/apps/checkbook/opie-oxygen.control b/noncore/apps/checkbook/opie-oxygen.control
new file mode 100644
index 0000000..4f84158
--- a/dev/null
+++ b/noncore/apps/checkbook/opie-oxygen.control
@@ -0,0 +1,9 @@
+Files: bin/oxygen apps/Applications/oxygencheckbook.desktop pics/oxygen/oxygen.png
+Priority: optional
+Section: applications
+Maintainer: Carsten Niehaus <cniehaus@handhelds.org>
+Architecture: arm
+Version: $QPE_VERSION-$SUB_VERSION
+Depends: opie-base ($QPE_VERSION)
+Description: Periodic System of the Elements
+ The chemistry application for the Opie-environment
diff --git a/noncore/apps/checkbook/oxygen.cpp b/noncore/apps/checkbook/oxygen.cpp
new file mode 100644
index 0000000..a86374b
--- a/dev/null
+++ b/noncore/apps/checkbook/oxygen.cpp
@@ -0,0 +1,52 @@
+/***************************************************************************
+ * *
+ * 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 <qmenubar.h>
+#include <qstatusbar.h>
+#include <qpopupmenu.h>
+#include <qlabel.h>
+#include <qapplication.h>
+#include <qpushbutton.h>
+#include <qfile.h>
+#include <qdir.h>
+#include <qvbox.h>
+#include "calcdlg.h"
+
+Oxygen::Oxygen()
+ : QMainWindow()
+{
+ this->setCaption( "Oxygen" );
+ vbox = new QVBox( this );
+ QPushButton *setButton = new QPushButton( "Settings", vbox );
+ connect ( setButton, SIGNAL( clicked() ), this, SLOT( slotSettings() ) );
+ QPushButton *calcButton = new QPushButton( "Calculations", vbox );
+ connect ( calcButton, SIGNAL( clicked() ), this, SLOT( slotCalculations() ) );
+ QPushButton *pseButton = new QPushButton( "PSE", vbox );
+ connect ( pseButton, SIGNAL( clicked() ), this, SLOT( slotPSE() ) );
+
+ setCentralWidget( vbox );
+}
+
+
+void Oxygen::close()
+{
+ QApplication::exit();
+}
+
+//SLOTS
+
+void Oxygen::slotCalculations(){
+ CalcDlgUI *calcDlgUI = new calcDlgUI();
+ calcDlgUI->show();
+};
+
+void Oxygen::slotSettings(){ };
+void Oxygen::slotPSE(){ };
+
diff --git a/noncore/apps/checkbook/oxygen.h b/noncore/apps/checkbook/oxygen.h
new file mode 100644
index 0000000..1e923ee
--- a/dev/null
+++ b/noncore/apps/checkbook/oxygen.h
@@ -0,0 +1,22 @@
+
+#include <qpe/resource.h>
+#include <qmainwindow.h>
+#include <qtoolbar.h>
+#include <qstring.h>
+#include <qpopupmenu.h>
+
+class QVBox;
+
+class Oxygen : public QMainWindow
+{
+ Q_OBJECT
+
+ public:
+ Oxygen();
+ QVBox *vbox;
+ private slots:
+ void slotCalculations();
+ void slotSettings();
+ void slotPSE();
+ void close();
+};
diff --git a/noncore/apps/checkbook/oxygen.pro b/noncore/apps/checkbook/oxygen.pro
new file mode 100644
index 0000000..f8e0197
--- a/dev/null
+++ b/noncore/apps/checkbook/oxygen.pro
@@ -0,0 +1,18 @@
+TEMPLATE = app
+CONFIG = qt warn_on release
+HEADERS = oxygen.h \
+ kmolcalc.h \
+ kmolelements.h
+
+SOURCES = main.cpp \
+ oxygen.cpp \
+ kmolcalc.cpp \
+ kmolelements.cpp
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDPATH += $(OPIEDIR)/include
+LIBS += -lqpe
+INTERFACES = calcdlg.ui
+TARGET = oxygen
+DESTDIR = $(OPIEDIR)/bin
+
+TRANSLATIONS = ../../../i18n/de/oxygen.ts