summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/checkbook/calcdlg.ui44
-rw-r--r--noncore/apps/checkbook/calcdlgui.cpp69
-rw-r--r--noncore/apps/checkbook/calcdlgui.h29
-rw-r--r--noncore/apps/checkbook/kmolcalc.cpp4
-rw-r--r--noncore/apps/checkbook/oxygen.cpp5
-rw-r--r--noncore/apps/checkbook/oxygen.pro4
6 files changed, 84 insertions, 71 deletions
diff --git a/noncore/apps/checkbook/calcdlg.ui b/noncore/apps/checkbook/calcdlg.ui
index 7637ca8..e0b19f9 100644
--- a/noncore/apps/checkbook/calcdlg.ui
+++ b/noncore/apps/checkbook/calcdlg.ui
@@ -13,3 +13,3 @@
<y>0</y>
- <width>222</width>
+ <width>218</width>
<height>274</height>
@@ -102,22 +102,2 @@
<widget>
- <class>QLabel</class>
- <property stdset="1">
- <name>name</name>
- <cstring>TextLabel2_4</cstring>
- </property>
- <property stdset="1">
- <name>geometry</name>
- <rect>
- <x>1</x>
- <y>86</y>
- <width>298</width>
- <height>16</height>
- </rect>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>Result:</string>
- </property>
- </widget>
- <widget>
<class>QLayoutWidget</class>
@@ -205,3 +185,3 @@
<name>name</name>
- <cstring>LineEdit2</cstring>
+ <cstring>result</cstring>
</property>
@@ -217,2 +197,22 @@
</widget>
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel2_4</cstring>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>1</x>
+ <y>86</y>
+ <width>298</width>
+ <height>16</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Result:</string>
+ </property>
+ </widget>
</widget>
diff --git a/noncore/apps/checkbook/calcdlgui.cpp b/noncore/apps/checkbook/calcdlgui.cpp
index a86374b..e9b40d3 100644
--- a/noncore/apps/checkbook/calcdlgui.cpp
+++ b/noncore/apps/checkbook/calcdlgui.cpp
@@ -7,46 +7,49 @@
* *
- * ***********************************************************************/
+ **************************************************************************/
#include "oxygen.h"
-#include <qmenubar.h>
-#include <qstatusbar.h>
-#include <qpopupmenu.h>
-#include <qlabel.h>
-#include <qapplication.h>
+#include "calcdlgui.h"
+#include "kmolcalc.h"
+#include <qlineedit.h>
+#include <qmultilineedit.h>
#include <qpushbutton.h>
-#include <qfile.h>
-#include <qdir.h>
-#include <qvbox.h>
-#include "calcdlg.h"
-Oxygen::Oxygen()
- : QMainWindow()
+calcDlgUI::calcDlgUI() : CalcDlg()
{
- 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 );
+ kmolcalc = new KMolCalc;
+ connect( calculate, SIGNAL( clicked() ), this, SLOT( calc() ) );
+ connect( clear_fields, SIGNAL( clicked() ), this, SLOT( clear() ) );
}
-
-void Oxygen::close()
+void calcDlgUI::calc()
{
- QApplication::exit();
+ 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 );
}
-//SLOTS
-
-void Oxygen::slotCalculations(){
- CalcDlgUI *calcDlgUI = new calcDlgUI();
- calcDlgUI->show();
-};
+/**
+ * * Clear all text entry / result fields.
+ * */
+void calcDlgUI::clear()
+{
+ formula->clear();
+ result->clear();
+ anal_display->clear();
+}
-void Oxygen::slotSettings(){ };
-void Oxygen::slotPSE(){ };
diff --git a/noncore/apps/checkbook/calcdlgui.h b/noncore/apps/checkbook/calcdlgui.h
index 1e923ee..33a1ec1 100644
--- a/noncore/apps/checkbook/calcdlgui.h
+++ b/noncore/apps/checkbook/calcdlgui.h
@@ -1,11 +1,17 @@
-#include <qpe/resource.h>
-#include <qmainwindow.h>
-#include <qtoolbar.h>
+/***************************************************************************
+ * *
+ * 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 <qstring.h>
-#include <qpopupmenu.h>
+#include "calcdlg.h"
class QVBox;
+class KMolCalc;
-class Oxygen : public QMainWindow
+class calcDlgUI : public CalcDlg
{
@@ -14,9 +20,8 @@ class Oxygen : public QMainWindow
public:
- Oxygen();
- QVBox *vbox;
- private slots:
- void slotCalculations();
- void slotSettings();
- void slotPSE();
- void close();
+ calcDlgUI();
+ KMolCalc *kmolcalc;
+
+ public slots:
+ void calc();
+ void clear();
};
diff --git a/noncore/apps/checkbook/kmolcalc.cpp b/noncore/apps/checkbook/kmolcalc.cpp
index e5ab736..50e1375 100644
--- a/noncore/apps/checkbook/kmolcalc.cpp
+++ b/noncore/apps/checkbook/kmolcalc.cpp
@@ -4,2 +4,3 @@
* Copyright (C) 2000 Tomislav Gountchev <tomi@idiom.com>
+ * Copyright (C) 2002 Carsten Niehaus <cniehaus@handhelds.org>
*/
@@ -15,2 +16,3 @@
#include <qdir.h>
+#include <qfile.h>
#include <iostream.h>
@@ -37,3 +39,3 @@ void KMolCalc::readElstable() {
QStringList files;// = // KGlobal::dirs()->findAllResources("appdata", "kmolweights");
-// mwfile = locateLocal("data", "kmol")+"/kmolweights";
+ mwfile = "/home/opie/opie/noncore/apps/oxigen/kmolweights";
QFile f(mwfile);
diff --git a/noncore/apps/checkbook/oxygen.cpp b/noncore/apps/checkbook/oxygen.cpp
index a86374b..81897e9 100644
--- a/noncore/apps/checkbook/oxygen.cpp
+++ b/noncore/apps/checkbook/oxygen.cpp
@@ -20,2 +20,3 @@
#include "calcdlg.h"
+#include "calcdlgui.h"
@@ -45,4 +46,4 @@ void Oxygen::close()
void Oxygen::slotCalculations(){
- CalcDlgUI *calcDlgUI = new calcDlgUI();
- calcDlgUI->show();
+ calcDlgUI *CalcDlgUI = new calcDlgUI();
+ CalcDlgUI->show();
};
diff --git a/noncore/apps/checkbook/oxygen.pro b/noncore/apps/checkbook/oxygen.pro
index f8e0197..c5448e7 100644
--- a/noncore/apps/checkbook/oxygen.pro
+++ b/noncore/apps/checkbook/oxygen.pro
@@ -4,3 +4,4 @@ HEADERS = oxygen.h \
kmolcalc.h \
- kmolelements.h
+ kmolelements.h \
+ calcdlgui.h
@@ -9,2 +10,3 @@ SOURCES = main.cpp \
kmolcalc.cpp \
+ calcdlgui.cpp \
kmolelements.cpp