author | cniehaus <cniehaus> | 2002-09-15 16:18:47 (UTC) |
---|---|---|
committer | cniehaus <cniehaus> | 2002-09-15 16:18:47 (UTC) |
commit | 7a8dc6b0a16db160a1e50fde8f298eb9e3cb0099 (patch) (unidiff) | |
tree | 16e49af9eabdcf6621654a1f80488c65951fe4b5 | |
parent | a013fbe2ba39e5ebd249766f223dbb67fe18027c (diff) | |
download | opie-7a8dc6b0a16db160a1e50fde8f298eb9e3cb0099.zip opie-7a8dc6b0a16db160a1e50fde8f298eb9e3cb0099.tar.gz opie-7a8dc6b0a16db160a1e50fde8f298eb9e3cb0099.tar.bz2 |
wow... I just don't get my own code... Help needed
-rw-r--r-- | noncore/apps/checkbook/calcdlg.ui | 44 | ||||
-rw-r--r-- | noncore/apps/checkbook/calcdlgui.cpp | 69 | ||||
-rw-r--r-- | noncore/apps/checkbook/calcdlgui.h | 29 | ||||
-rw-r--r-- | noncore/apps/checkbook/kmolcalc.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/checkbook/oxygen.cpp | 5 | ||||
-rw-r--r-- | noncore/apps/checkbook/oxygen.pro | 4 |
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 | |||
@@ -2,25 +2,25 @@ | |||
2 | <class>CalcDlg</class> | 2 | <class>CalcDlg</class> |
3 | <widget> | 3 | <widget> |
4 | <class>QWidget</class> | 4 | <class>QWidget</class> |
5 | <property stdset="1"> | 5 | <property stdset="1"> |
6 | <name>name</name> | 6 | <name>name</name> |
7 | <cstring>CalcDlg</cstring> | 7 | <cstring>CalcDlg</cstring> |
8 | </property> | 8 | </property> |
9 | <property stdset="1"> | 9 | <property stdset="1"> |
10 | <name>geometry</name> | 10 | <name>geometry</name> |
11 | <rect> | 11 | <rect> |
12 | <x>0</x> | 12 | <x>0</x> |
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>222</width> | 14 | <width>218</width> |
15 | <height>274</height> | 15 | <height>274</height> |
16 | </rect> | 16 | </rect> |
17 | </property> | 17 | </property> |
18 | <property stdset="1"> | 18 | <property stdset="1"> |
19 | <name>caption</name> | 19 | <name>caption</name> |
20 | <string>Network Time</string> | 20 | <string>Network Time</string> |
21 | </property> | 21 | </property> |
22 | <property> | 22 | <property> |
23 | <name>layoutMargin</name> | 23 | <name>layoutMargin</name> |
24 | </property> | 24 | </property> |
25 | <property> | 25 | <property> |
26 | <name>layoutSpacing</name> | 26 | <name>layoutSpacing</name> |
@@ -91,44 +91,24 @@ | |||
91 | <x>1</x> | 91 | <x>1</x> |
92 | <y>1</y> | 92 | <y>1</y> |
93 | <width>298</width> | 93 | <width>298</width> |
94 | <height>16</height> | 94 | <height>16</height> |
95 | </rect> | 95 | </rect> |
96 | </property> | 96 | </property> |
97 | <property stdset="1"> | 97 | <property stdset="1"> |
98 | <name>text</name> | 98 | <name>text</name> |
99 | <string>Formula:</string> | 99 | <string>Formula:</string> |
100 | </property> | 100 | </property> |
101 | </widget> | 101 | </widget> |
102 | <widget> | 102 | <widget> |
103 | <class>QLabel</class> | ||
104 | <property stdset="1"> | ||
105 | <name>name</name> | ||
106 | <cstring>TextLabel2_4</cstring> | ||
107 | </property> | ||
108 | <property stdset="1"> | ||
109 | <name>geometry</name> | ||
110 | <rect> | ||
111 | <x>1</x> | ||
112 | <y>86</y> | ||
113 | <width>298</width> | ||
114 | <height>16</height> | ||
115 | </rect> | ||
116 | </property> | ||
117 | <property stdset="1"> | ||
118 | <name>text</name> | ||
119 | <string>Result:</string> | ||
120 | </property> | ||
121 | </widget> | ||
122 | <widget> | ||
123 | <class>QLayoutWidget</class> | 103 | <class>QLayoutWidget</class> |
124 | <property stdset="1"> | 104 | <property stdset="1"> |
125 | <name>name</name> | 105 | <name>name</name> |
126 | <cstring>Layout7</cstring> | 106 | <cstring>Layout7</cstring> |
127 | </property> | 107 | </property> |
128 | <property stdset="1"> | 108 | <property stdset="1"> |
129 | <name>geometry</name> | 109 | <name>geometry</name> |
130 | <rect> | 110 | <rect> |
131 | <x>0</x> | 111 | <x>0</x> |
132 | <y>50</y> | 112 | <y>50</y> |
133 | <width>175</width> | 113 | <width>175</width> |
134 | <height>30</height> | 114 | <height>30</height> |
@@ -194,36 +174,56 @@ | |||
194 | <rect> | 174 | <rect> |
195 | <x>0</x> | 175 | <x>0</x> |
196 | <y>130</y> | 176 | <y>130</y> |
197 | <width>170</width> | 177 | <width>170</width> |
198 | <height>80</height> | 178 | <height>80</height> |
199 | </rect> | 179 | </rect> |
200 | </property> | 180 | </property> |
201 | </widget> | 181 | </widget> |
202 | <widget> | 182 | <widget> |
203 | <class>QLineEdit</class> | 183 | <class>QLineEdit</class> |
204 | <property stdset="1"> | 184 | <property stdset="1"> |
205 | <name>name</name> | 185 | <name>name</name> |
206 | <cstring>LineEdit2</cstring> | 186 | <cstring>result</cstring> |
207 | </property> | 187 | </property> |
208 | <property stdset="1"> | 188 | <property stdset="1"> |
209 | <name>geometry</name> | 189 | <name>geometry</name> |
210 | <rect> | 190 | <rect> |
211 | <x>0</x> | 191 | <x>0</x> |
212 | <y>100</y> | 192 | <y>100</y> |
213 | <width>170</width> | 193 | <width>170</width> |
214 | <height>22</height> | 194 | <height>22</height> |
215 | </rect> | 195 | </rect> |
216 | </property> | 196 | </property> |
217 | </widget> | 197 | </widget> |
198 | <widget> | ||
199 | <class>QLabel</class> | ||
200 | <property stdset="1"> | ||
201 | <name>name</name> | ||
202 | <cstring>TextLabel2_4</cstring> | ||
203 | </property> | ||
204 | <property stdset="1"> | ||
205 | <name>geometry</name> | ||
206 | <rect> | ||
207 | <x>1</x> | ||
208 | <y>86</y> | ||
209 | <width>298</width> | ||
210 | <height>16</height> | ||
211 | </rect> | ||
212 | </property> | ||
213 | <property stdset="1"> | ||
214 | <name>text</name> | ||
215 | <string>Result:</string> | ||
216 | </property> | ||
217 | </widget> | ||
218 | </widget> | 218 | </widget> |
219 | </widget> | 219 | </widget> |
220 | <widget> | 220 | <widget> |
221 | <class>QWidget</class> | 221 | <class>QWidget</class> |
222 | <property stdset="1"> | 222 | <property stdset="1"> |
223 | <name>name</name> | 223 | <name>name</name> |
224 | <cstring>tabNtp</cstring> | 224 | <cstring>tabNtp</cstring> |
225 | </property> | 225 | </property> |
226 | <attribute> | 226 | <attribute> |
227 | <name>title</name> | 227 | <name>title</name> |
228 | <string>Nernst</string> | 228 | <string>Nernst</string> |
229 | </attribute> | 229 | </attribute> |
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 | |||
@@ -1,52 +1,55 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * ( at your option ) any later version. * | 6 | * ( at your option ) any later version. * |
7 | * * | 7 | * * |
8 | * ***********************************************************************/ | 8 | **************************************************************************/ |
9 | #include "oxygen.h" | 9 | #include "oxygen.h" |
10 | 10 | ||
11 | #include <qmenubar.h> | 11 | #include "calcdlgui.h" |
12 | #include <qstatusbar.h> | 12 | #include "kmolcalc.h" |
13 | #include <qpopupmenu.h> | 13 | #include <qlineedit.h> |
14 | #include <qlabel.h> | 14 | #include <qmultilineedit.h> |
15 | #include <qapplication.h> | ||
16 | #include <qpushbutton.h> | 15 | #include <qpushbutton.h> |
17 | #include <qfile.h> | ||
18 | #include <qdir.h> | ||
19 | #include <qvbox.h> | ||
20 | #include "calcdlg.h" | ||
21 | 16 | ||
22 | Oxygen::Oxygen() | 17 | calcDlgUI::calcDlgUI() : CalcDlg() |
23 | : QMainWindow() | ||
24 | { | 18 | { |
25 | this->setCaption( "Oxygen" ); | 19 | kmolcalc = new KMolCalc; |
26 | vbox = new QVBox( this ); | 20 | connect( calculate, SIGNAL( clicked() ), this, SLOT( calc() ) ); |
27 | QPushButton *setButton = new QPushButton( "Settings", vbox ); | 21 | connect( clear_fields, SIGNAL( clicked() ), this, SLOT( clear() ) ); |
28 | connect ( setButton, SIGNAL( clicked() ), this, SLOT( slotSettings() ) ); | ||
29 | QPushButton *calcButton = new QPushButton( "Calculations", vbox ); | ||
30 | connect ( calcButton, SIGNAL( clicked() ), this, SLOT( slotCalculations() ) ); | ||
31 | QPushButton *pseButton = new QPushButton( "PSE", vbox ); | ||
32 | connect ( pseButton, SIGNAL( clicked() ), this, SLOT( slotPSE() ) ); | ||
33 | |||
34 | setCentralWidget( vbox ); | ||
35 | } | 22 | } |
36 | 23 | ||
37 | 24 | void calcDlgUI::calc() | |
38 | void Oxygen::close() | ||
39 | { | 25 | { |
40 | QApplication::exit(); | 26 | QString compound( formula->text() ); |
27 | if ( compound.isEmpty() ) { | ||
28 | clear(); | ||
29 | return; | ||
30 | } | ||
31 | QString errors( kmolcalc->readFormula( compound ) ); | ||
32 | QString mw, ea; | ||
33 | double weight = kmolcalc->getWeight(); | ||
34 | if ( errors == "OK" ) { | ||
35 | mw.setNum( weight ); | ||
36 | ea = kmolcalc->getEmpFormula() + " :\n" + kmolcalc->getEA(); | ||
37 | } else { | ||
38 | mw = "???"; | ||
39 | ea = tr( "ERROR: \n" ) + errors + "\n"; | ||
40 | } | ||
41 | result->setText( mw ); | ||
42 | anal_display->setText( ea ); | ||
41 | } | 43 | } |
42 | 44 | ||
43 | //SLOTS | 45 | /** |
44 | 46 | * * Clear all text entry / result fields. | |
45 | void Oxygen::slotCalculations(){ | 47 | * */ |
46 | CalcDlgUI *calcDlgUI = new calcDlgUI(); | 48 | void calcDlgUI::clear() |
47 | calcDlgUI->show(); | 49 | { |
48 | }; | 50 | formula->clear(); |
51 | result->clear(); | ||
52 | anal_display->clear(); | ||
53 | } | ||
49 | 54 | ||
50 | void Oxygen::slotSettings(){ }; | ||
51 | void Oxygen::slotPSE(){ }; | ||
52 | 55 | ||
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,22 +1,27 @@ | |||
1 | 1 | ||
2 | #include <qpe/resource.h> | 2 | /*************************************************************************** |
3 | #include <qmainwindow.h> | 3 | * * |
4 | #include <qtoolbar.h> | 4 | * This program is free software; you can redistribute it and/or modify * |
5 | * it under the terms of the GNU General Public License as published by * | ||
6 | * the Free Software Foundation; either version 2 of the License, or * | ||
7 | * ( at your option ) any later version. * | ||
8 | * * | ||
9 | **************************************************************************/ | ||
5 | #include <qstring.h> | 10 | #include <qstring.h> |
6 | #include <qpopupmenu.h> | 11 | #include "calcdlg.h" |
7 | 12 | ||
8 | class QVBox; | 13 | class QVBox; |
14 | class KMolCalc; | ||
9 | 15 | ||
10 | class Oxygen : public QMainWindow | 16 | class calcDlgUI : public CalcDlg |
11 | { | 17 | { |
12 | Q_OBJECT | 18 | Q_OBJECT |
13 | 19 | ||
14 | public: | 20 | public: |
15 | Oxygen(); | 21 | calcDlgUI(); |
16 | QVBox *vbox; | 22 | KMolCalc *kmolcalc; |
17 | private slots: | 23 | |
18 | void slotCalculations(); | 24 | public slots: |
19 | void slotSettings(); | 25 | void calc(); |
20 | void slotPSE(); | 26 | void clear(); |
21 | void close(); | ||
22 | }; | 27 | }; |
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 | |||
@@ -1,50 +1,52 @@ | |||
1 | /* | 1 | /* |
2 | * kmolcalc.cpp | 2 | * kmolcalc.cpp |
3 | * | 3 | * |
4 | * Copyright (C) 2000 Tomislav Gountchev <tomi@idiom.com> | 4 | * Copyright (C) 2000 Tomislav Gountchev <tomi@idiom.com> |
5 | * Copyright (C) 2002 Carsten Niehaus <cniehaus@handhelds.org> | ||
5 | */ | 6 | */ |
6 | 7 | ||
7 | /** | 8 | /** |
8 | * KMOLCALC is the calculation engine. It knows about a hashtable of user defined atomic | 9 | * KMOLCALC is the calculation engine. It knows about a hashtable of user defined atomic |
9 | * weights and group definitions ELSTABLE, and the currently processed formula, stored | 10 | * weights and group definitions ELSTABLE, and the currently processed formula, stored |
10 | * as a list of elements and their coefficients, ELEMENTS. | 11 | * as a list of elements and their coefficients, ELEMENTS. |
11 | */ | 12 | */ |
12 | 13 | ||
13 | #include "kmolcalc.h" | 14 | #include "kmolcalc.h" |
14 | #include <qdict.h> | 15 | #include <qdict.h> |
15 | #include <qdir.h> | 16 | #include <qdir.h> |
17 | #include <qfile.h> | ||
16 | #include <iostream.h> | 18 | #include <iostream.h> |
17 | 19 | ||
18 | 20 | ||
19 | /** | 21 | /** |
20 | * Construct a new calculator object. | 22 | * Construct a new calculator object. |
21 | */ | 23 | */ |
22 | KMolCalc::KMolCalc() { | 24 | KMolCalc::KMolCalc() { |
23 | elements = new ElementList; | 25 | elements = new ElementList; |
24 | elstable = NULL; | 26 | elstable = NULL; |
25 | readElstable(); | 27 | readElstable(); |
26 | } | 28 | } |
27 | 29 | ||
28 | KMolCalc::~KMolCalc() { | 30 | KMolCalc::~KMolCalc() { |
29 | delete elements; | 31 | delete elements; |
30 | } | 32 | } |
31 | 33 | ||
32 | void KMolCalc::readElstable() { | 34 | void KMolCalc::readElstable() { |
33 | weight = -1; // not calculated yet | 35 | weight = -1; // not calculated yet |
34 | if (elstable) delete elstable; | 36 | if (elstable) delete elstable; |
35 | elstable = new QDict<SubUnit> (197, TRUE); | 37 | elstable = new QDict<SubUnit> (197, TRUE); |
36 | elstable->setAutoDelete(TRUE); | 38 | elstable->setAutoDelete(TRUE); |
37 | QStringList files;// = // KGlobal::dirs()->findAllResources("appdata", "kmolweights"); | 39 | QStringList files;// = // KGlobal::dirs()->findAllResources("appdata", "kmolweights"); |
38 | // mwfile = locateLocal("data", "kmol")+"/kmolweights"; | 40 | mwfile = "/home/opie/opie/noncore/apps/oxigen/kmolweights"; |
39 | QFile f(mwfile); | 41 | QFile f(mwfile); |
40 | QString* latest_f = &mwfile; | 42 | QString* latest_f = &mwfile; |
41 | for (uint i=0; i<files.count(); i++) { | 43 | for (uint i=0; i<files.count(); i++) { |
42 | if (QFileInfo(QFile(files[i])).lastModified() > QFileInfo(QFile(*latest_f)).lastModified()) { | 44 | if (QFileInfo(QFile(files[i])).lastModified() > QFileInfo(QFile(*latest_f)).lastModified()) { |
43 | latest_f = &files[i]; | 45 | latest_f = &files[i]; |
44 | } | 46 | } |
45 | } | 47 | } |
46 | QFile lf(*latest_f); | 48 | QFile lf(*latest_f); |
47 | if (f.exists()) readMwfile(f); | 49 | if (f.exists()) readMwfile(f); |
48 | if (!f.exists()) { | 50 | if (!f.exists()) { |
49 | readMwfile(lf); | 51 | readMwfile(lf); |
50 | writeElstable(); | 52 | writeElstable(); |
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 | |||
@@ -9,24 +9,25 @@ | |||
9 | #include "oxygen.h" | 9 | #include "oxygen.h" |
10 | 10 | ||
11 | #include <qmenubar.h> | 11 | #include <qmenubar.h> |
12 | #include <qstatusbar.h> | 12 | #include <qstatusbar.h> |
13 | #include <qpopupmenu.h> | 13 | #include <qpopupmenu.h> |
14 | #include <qlabel.h> | 14 | #include <qlabel.h> |
15 | #include <qapplication.h> | 15 | #include <qapplication.h> |
16 | #include <qpushbutton.h> | 16 | #include <qpushbutton.h> |
17 | #include <qfile.h> | 17 | #include <qfile.h> |
18 | #include <qdir.h> | 18 | #include <qdir.h> |
19 | #include <qvbox.h> | 19 | #include <qvbox.h> |
20 | #include "calcdlg.h" | 20 | #include "calcdlg.h" |
21 | #include "calcdlgui.h" | ||
21 | 22 | ||
22 | Oxygen::Oxygen() | 23 | Oxygen::Oxygen() |
23 | : QMainWindow() | 24 | : QMainWindow() |
24 | { | 25 | { |
25 | this->setCaption( "Oxygen" ); | 26 | this->setCaption( "Oxygen" ); |
26 | vbox = new QVBox( this ); | 27 | vbox = new QVBox( this ); |
27 | QPushButton *setButton = new QPushButton( "Settings", vbox ); | 28 | QPushButton *setButton = new QPushButton( "Settings", vbox ); |
28 | connect ( setButton, SIGNAL( clicked() ), this, SLOT( slotSettings() ) ); | 29 | connect ( setButton, SIGNAL( clicked() ), this, SLOT( slotSettings() ) ); |
29 | QPushButton *calcButton = new QPushButton( "Calculations", vbox ); | 30 | QPushButton *calcButton = new QPushButton( "Calculations", vbox ); |
30 | connect ( calcButton, SIGNAL( clicked() ), this, SLOT( slotCalculations() ) ); | 31 | connect ( calcButton, SIGNAL( clicked() ), this, SLOT( slotCalculations() ) ); |
31 | QPushButton *pseButton = new QPushButton( "PSE", vbox ); | 32 | QPushButton *pseButton = new QPushButton( "PSE", vbox ); |
32 | connect ( pseButton, SIGNAL( clicked() ), this, SLOT( slotPSE() ) ); | 33 | connect ( pseButton, SIGNAL( clicked() ), this, SLOT( slotPSE() ) ); |
@@ -34,19 +35,19 @@ Oxygen::Oxygen() | |||
34 | setCentralWidget( vbox ); | 35 | setCentralWidget( vbox ); |
35 | } | 36 | } |
36 | 37 | ||
37 | 38 | ||
38 | void Oxygen::close() | 39 | void Oxygen::close() |
39 | { | 40 | { |
40 | QApplication::exit(); | 41 | QApplication::exit(); |
41 | } | 42 | } |
42 | 43 | ||
43 | //SLOTS | 44 | //SLOTS |
44 | 45 | ||
45 | void Oxygen::slotCalculations(){ | 46 | void Oxygen::slotCalculations(){ |
46 | CalcDlgUI *calcDlgUI = new calcDlgUI(); | 47 | calcDlgUI *CalcDlgUI = new calcDlgUI(); |
47 | calcDlgUI->show(); | 48 | CalcDlgUI->show(); |
48 | }; | 49 | }; |
49 | 50 | ||
50 | void Oxygen::slotSettings(){ }; | 51 | void Oxygen::slotSettings(){ }; |
51 | void Oxygen::slotPSE(){ }; | 52 | void Oxygen::slotPSE(){ }; |
52 | 53 | ||
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 | |||
@@ -1,18 +1,20 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | HEADERS = oxygen.h \ | 3 | HEADERS = oxygen.h \ |
4 | kmolcalc.h \ | 4 | kmolcalc.h \ |
5 | kmolelements.h | 5 | kmolelements.h \ |
6 | calcdlgui.h | ||
6 | 7 | ||
7 | SOURCES = main.cpp \ | 8 | SOURCES = main.cpp \ |
8 | oxygen.cpp \ | 9 | oxygen.cpp \ |
9 | kmolcalc.cpp \ | 10 | kmolcalc.cpp \ |
11 | calcdlgui.cpp \ | ||
10 | kmolelements.cpp | 12 | kmolelements.cpp |
11 | INCLUDEPATH += $(OPIEDIR)/include | 13 | INCLUDEPATH += $(OPIEDIR)/include |
12 | DEPENDPATH += $(OPIEDIR)/include | 14 | DEPENDPATH += $(OPIEDIR)/include |
13 | LIBS += -lqpe | 15 | LIBS += -lqpe |
14 | INTERFACES= calcdlg.ui | 16 | INTERFACES= calcdlg.ui |
15 | TARGET = oxygen | 17 | TARGET = oxygen |
16 | DESTDIR = $(OPIEDIR)/bin | 18 | DESTDIR = $(OPIEDIR)/bin |
17 | 19 | ||
18 | TRANSLATIONS = ../../../i18n/de/oxygen.ts | 20 | TRANSLATIONS = ../../../i18n/de/oxygen.ts |