author | kergoth <kergoth> | 2002-09-15 17:23:20 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2002-09-15 17:23:20 (UTC) |
commit | 9bd6edd077df796677c9d069200172f930ac1304 (patch) (unidiff) | |
tree | 3b473d4280249b5ade8e5276758cc8f9aa3c2822 | |
parent | 33ec9ead7ce30bf9450b9048506f0bda49ba4791 (diff) | |
download | opie-9bd6edd077df796677c9d069200172f930ac1304.zip opie-9bd6edd077df796677c9d069200172f930ac1304.tar.gz opie-9bd6edd077df796677c9d069200172f930ac1304.tar.bz2 |
Reverting to checkbook in its previous state, hopefully i got everything.
42 files changed, 3683 insertions, 1285 deletions
diff --git a/noncore/apps/checkbook/TODO b/noncore/apps/checkbook/TODO index bc60bf4..adc9665 100644 --- a/noncore/apps/checkbook/TODO +++ b/noncore/apps/checkbook/TODO | |||
@@ -1 +1,5 @@ | |||
1 | TODO: | 1 | TODO: |
2 | * Date widget | ||
3 | * Various bug fixes | ||
4 | * Fix "the" crash | ||
5 | * Fix graph's legend not showing up \ No newline at end of file | ||
diff --git a/noncore/apps/checkbook/calcdlg.ui b/noncore/apps/checkbook/calcdlg.ui deleted file mode 100644 index e0b19f9..0000000 --- a/noncore/apps/checkbook/calcdlg.ui +++ b/dev/null | |||
@@ -1,243 +0,0 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>CalcDlg</class> | ||
3 | <widget> | ||
4 | <class>QWidget</class> | ||
5 | <property stdset="1"> | ||
6 | <name>name</name> | ||
7 | <cstring>CalcDlg</cstring> | ||
8 | </property> | ||
9 | <property stdset="1"> | ||
10 | <name>geometry</name> | ||
11 | <rect> | ||
12 | <x>0</x> | ||
13 | <y>0</y> | ||
14 | <width>218</width> | ||
15 | <height>274</height> | ||
16 | </rect> | ||
17 | </property> | ||
18 | <property stdset="1"> | ||
19 | <name>caption</name> | ||
20 | <string>Network Time</string> | ||
21 | </property> | ||
22 | <property> | ||
23 | <name>layoutMargin</name> | ||
24 | </property> | ||
25 | <property> | ||
26 | <name>layoutSpacing</name> | ||
27 | </property> | ||
28 | <widget> | ||
29 | <class>QTabWidget</class> | ||
30 | <property stdset="1"> | ||
31 | <name>name</name> | ||
32 | <cstring>TabWidgetMain</cstring> | ||
33 | </property> | ||
34 | <property stdset="1"> | ||
35 | <name>geometry</name> | ||
36 | <rect> | ||
37 | <x>10</x> | ||
38 | <y>0</y> | ||
39 | <width>200</width> | ||
40 | <height>260</height> | ||
41 | </rect> | ||
42 | </property> | ||
43 | <property> | ||
44 | <name>layoutMargin</name> | ||
45 | </property> | ||
46 | <property> | ||
47 | <name>layoutSpacing</name> | ||
48 | </property> | ||
49 | <widget> | ||
50 | <class>QWidget</class> | ||
51 | <property stdset="1"> | ||
52 | <name>name</name> | ||
53 | <cstring>tabMain</cstring> | ||
54 | </property> | ||
55 | <attribute> | ||
56 | <name>title</name> | ||
57 | <string>Molweight</string> | ||
58 | </attribute> | ||
59 | <widget> | ||
60 | <class>QFrame</class> | ||
61 | <property stdset="1"> | ||
62 | <name>name</name> | ||
63 | <cstring>FrameSystemTime</cstring> | ||
64 | </property> | ||
65 | <property stdset="1"> | ||
66 | <name>geometry</name> | ||
67 | <rect> | ||
68 | <x>2</x> | ||
69 | <y>2</y> | ||
70 | <width>180</width> | ||
71 | <height>220</height> | ||
72 | </rect> | ||
73 | </property> | ||
74 | <property stdset="1"> | ||
75 | <name>frameShape</name> | ||
76 | <enum>StyledPanel</enum> | ||
77 | </property> | ||
78 | <property stdset="1"> | ||
79 | <name>frameShadow</name> | ||
80 | <enum>Raised</enum> | ||
81 | </property> | ||
82 | <widget> | ||
83 | <class>QLabel</class> | ||
84 | <property stdset="1"> | ||
85 | <name>name</name> | ||
86 | <cstring>TextLabel1_4</cstring> | ||
87 | </property> | ||
88 | <property stdset="1"> | ||
89 | <name>geometry</name> | ||
90 | <rect> | ||
91 | <x>1</x> | ||
92 | <y>1</y> | ||
93 | <width>298</width> | ||
94 | <height>16</height> | ||
95 | </rect> | ||
96 | </property> | ||
97 | <property stdset="1"> | ||
98 | <name>text</name> | ||
99 | <string>Formula:</string> | ||
100 | </property> | ||
101 | </widget> | ||
102 | <widget> | ||
103 | <class>QLayoutWidget</class> | ||
104 | <property stdset="1"> | ||
105 | <name>name</name> | ||
106 | <cstring>Layout7</cstring> | ||
107 | </property> | ||
108 | <property stdset="1"> | ||
109 | <name>geometry</name> | ||
110 | <rect> | ||
111 | <x>0</x> | ||
112 | <y>50</y> | ||
113 | <width>175</width> | ||
114 | <height>30</height> | ||
115 | </rect> | ||
116 | </property> | ||
117 | <hbox> | ||
118 | <property stdset="1"> | ||
119 | <name>margin</name> | ||
120 | <number>0</number> | ||
121 | </property> | ||
122 | <property stdset="1"> | ||
123 | <name>spacing</name> | ||
124 | <number>6</number> | ||
125 | </property> | ||
126 | <widget> | ||
127 | <class>QPushButton</class> | ||
128 | <property stdset="1"> | ||
129 | <name>name</name> | ||
130 | <cstring>calculate</cstring> | ||
131 | </property> | ||
132 | <property stdset="1"> | ||
133 | <name>text</name> | ||
134 | <string>Calculate</string> | ||
135 | </property> | ||
136 | </widget> | ||
137 | <widget> | ||
138 | <class>QPushButton</class> | ||
139 | <property stdset="1"> | ||
140 | <name>name</name> | ||
141 | <cstring>clear_fields</cstring> | ||
142 | </property> | ||
143 | <property stdset="1"> | ||
144 | <name>text</name> | ||
145 | <string>Clear</string> | ||
146 | </property> | ||
147 | </widget> | ||
148 | </hbox> | ||
149 | </widget> | ||
150 | <widget> | ||
151 | <class>QLineEdit</class> | ||
152 | <property stdset="1"> | ||
153 | <name>name</name> | ||
154 | <cstring>formula</cstring> | ||
155 | </property> | ||
156 | <property stdset="1"> | ||
157 | <name>geometry</name> | ||
158 | <rect> | ||
159 | <x>0</x> | ||
160 | <y>20</y> | ||
161 | <width>170</width> | ||
162 | <height>22</height> | ||
163 | </rect> | ||
164 | </property> | ||
165 | </widget> | ||
166 | <widget> | ||
167 | <class>QMultiLineEdit</class> | ||
168 | <property stdset="1"> | ||
169 | <name>name</name> | ||
170 | <cstring>anal_display</cstring> | ||
171 | </property> | ||
172 | <property stdset="1"> | ||
173 | <name>geometry</name> | ||
174 | <rect> | ||
175 | <x>0</x> | ||
176 | <y>130</y> | ||
177 | <width>170</width> | ||
178 | <height>80</height> | ||
179 | </rect> | ||
180 | </property> | ||
181 | </widget> | ||
182 | <widget> | ||
183 | <class>QLineEdit</class> | ||
184 | <property stdset="1"> | ||
185 | <name>name</name> | ||
186 | <cstring>result</cstring> | ||
187 | </property> | ||
188 | <property stdset="1"> | ||
189 | <name>geometry</name> | ||
190 | <rect> | ||
191 | <x>0</x> | ||
192 | <y>100</y> | ||
193 | <width>170</width> | ||
194 | <height>22</height> | ||
195 | </rect> | ||
196 | </property> | ||
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> | ||
219 | </widget> | ||
220 | <widget> | ||
221 | <class>QWidget</class> | ||
222 | <property stdset="1"> | ||
223 | <name>name</name> | ||
224 | <cstring>tabNtp</cstring> | ||
225 | </property> | ||
226 | <attribute> | ||
227 | <name>title</name> | ||
228 | <string>Nernst</string> | ||
229 | </attribute> | ||
230 | <grid> | ||
231 | <property stdset="1"> | ||
232 | <name>margin</name> | ||
233 | <number>1</number> | ||
234 | </property> | ||
235 | <property stdset="1"> | ||
236 | <name>spacing</name> | ||
237 | <number>2</number> | ||
238 | </property> | ||
239 | </grid> | ||
240 | </widget> | ||
241 | </widget> | ||
242 | </widget> | ||
243 | </UI> | ||
diff --git a/noncore/apps/checkbook/calcdlgui.cpp b/noncore/apps/checkbook/calcdlgui.cpp deleted file mode 100644 index e9b40d3..0000000 --- a/noncore/apps/checkbook/calcdlgui.cpp +++ b/dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * * | ||
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 * | ||
5 | * the Free Software Foundation; either version 2 of the License, or * | ||
6 | * ( at your option ) any later version. * | ||
7 | * * | ||
8 | **************************************************************************/ | ||
9 | #include "oxygen.h" | ||
10 | |||
11 | #include "calcdlgui.h" | ||
12 | #include "kmolcalc.h" | ||
13 | #include <qlineedit.h> | ||
14 | #include <qmultilineedit.h> | ||
15 | #include <qpushbutton.h> | ||
16 | |||
17 | calcDlgUI::calcDlgUI() : CalcDlg() | ||
18 | { | ||
19 | kmolcalc = new KMolCalc; | ||
20 | connect( calculate, SIGNAL( clicked() ), this, SLOT( calc() ) ); | ||
21 | connect( clear_fields, SIGNAL( clicked() ), this, SLOT( clear() ) ); | ||
22 | } | ||
23 | |||
24 | void calcDlgUI::calc() | ||
25 | { | ||
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 ); | ||
43 | } | ||
44 | |||
45 | /** | ||
46 | * * Clear all text entry / result fields. | ||
47 | * */ | ||
48 | void calcDlgUI::clear() | ||
49 | { | ||
50 | formula->clear(); | ||
51 | result->clear(); | ||
52 | anal_display->clear(); | ||
53 | } | ||
54 | |||
55 | |||
diff --git a/noncore/apps/checkbook/calcdlgui.h b/noncore/apps/checkbook/calcdlgui.h deleted file mode 100644 index 33a1ec1..0000000 --- a/noncore/apps/checkbook/calcdlgui.h +++ b/dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | |||
2 | /*************************************************************************** | ||
3 | * * | ||
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 | **************************************************************************/ | ||
10 | #include <qstring.h> | ||
11 | #include "calcdlg.h" | ||
12 | |||
13 | class QVBox; | ||
14 | class KMolCalc; | ||
15 | |||
16 | class calcDlgUI : public CalcDlg | ||
17 | { | ||
18 | Q_OBJECT | ||
19 | |||
20 | public: | ||
21 | calcDlgUI(); | ||
22 | KMolCalc *kmolcalc; | ||
23 | |||
24 | public slots: | ||
25 | void calc(); | ||
26 | void clear(); | ||
27 | }; | ||
diff --git a/noncore/apps/checkbook/checkbook.pro b/noncore/apps/checkbook/checkbook.pro new file mode 100644 index 0000000..e9e2167 --- a/dev/null +++ b/noncore/apps/checkbook/checkbook.pro | |||
@@ -0,0 +1,50 @@ | |||
1 | TEMPLATE= app | ||
2 | CONFIG = qt warn_on release | ||
3 | HEADERS = config.h \ | ||
4 | qcheckbook.h \ | ||
5 | qcheckdetails.h \ | ||
6 | qcheckentry.h \ | ||
7 | qcheckgraph.h \ | ||
8 | qcheckmainmenu.h \ | ||
9 | qcheckname.h \ | ||
10 | qcheckview.h \ | ||
11 | qrestrictedcombo.h \ | ||
12 | qrestrictedline.h | ||
13 | SOURCES = config.cpp \ | ||
14 | main.cpp \ | ||
15 | qcheckbook.cpp \ | ||
16 | qcheckdetails.cpp \ | ||
17 | qcheckentry.cpp \ | ||
18 | qcheckgraph.cpp \ | ||
19 | qcheckmainmenu.cpp \ | ||
20 | qcheckname.cpp \ | ||
21 | qcheckview.cpp \ | ||
22 | qrestrictedcombo.cpp \ | ||
23 | qrestrictedline.cpp | ||
24 | INTERFACES= qcheckdetailsbase.ui \ | ||
25 | qcheckentrybase.ui \ | ||
26 | qcheckgraphbase.ui \ | ||
27 | qcheckmmbase.ui \ | ||
28 | qchecknamebase.ui \ | ||
29 | qcheckviewbase.ui | ||
30 | INCLUDEPATH += $(OPIEDIR)/include | ||
31 | DEPENDPATH += $(OPIEDIR)/include | ||
32 | LIBS += -lqpe | ||
33 | TARGET = checkbook | ||
34 | DESTDIR = $(OPIEDIR)/bin | ||
35 | |||
36 | TRANSLATIONS = ../../../i18n/de/checkbook.ts \ | ||
37 | ../../../i18n/en/checkbook.ts \ | ||
38 | ../../../i18n/es/checkbook.ts \ | ||
39 | ../../../i18n/fr/checkbook.ts \ | ||
40 | ../../../i18n/hu/checkbook.ts \ | ||
41 | ../../../i18n/ja/checkbook.ts \ | ||
42 | ../../../i18n/ko/checkbook.ts \ | ||
43 | ../../../i18n/no/checkbook.ts \ | ||
44 | ../../../i18n/pl/checkbook.ts \ | ||
45 | ../../../i18n/pt/checkbook.ts \ | ||
46 | ../../../i18n/pt_BR/checkbook.ts \ | ||
47 | ../../../i18n/sl/checkbook.ts \ | ||
48 | ../../../i18n/zh_CN/checkbook.ts \ | ||
49 | ../../../i18n/zh_TW/checkbook.ts \ | ||
50 | ../../../i18n/it/checkbook.ts | ||
diff --git a/noncore/apps/checkbook/config.cpp b/noncore/apps/checkbook/config.cpp new file mode 100644 index 0000000..e6c6dcc --- a/dev/null +++ b/noncore/apps/checkbook/config.cpp | |||
@@ -0,0 +1,560 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #include <qdir.h> | ||
22 | #include <qfile.h> | ||
23 | #include <qfileinfo.h> | ||
24 | #include <qmessagebox.h> | ||
25 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | ||
26 | #include <qtextcodec.h> | ||
27 | #endif | ||
28 | #include <qtextstream.h> | ||
29 | |||
30 | #include <sys/stat.h> | ||
31 | #include <sys/types.h> | ||
32 | #include <fcntl.h> | ||
33 | #include <stdlib.h> | ||
34 | #include <unistd.h> | ||
35 | |||
36 | #include "config.h" | ||
37 | |||
38 | |||
39 | /*! | ||
40 | \internal | ||
41 | */ | ||
42 | QString Config::configFilename(const QString& name, Domain d) | ||
43 | { | ||
44 | switch (d) { | ||
45 | case File: | ||
46 | return name; | ||
47 | case User: { | ||
48 | QDir dir = (QString(getenv("HOME")) + "/Settings"); | ||
49 | if ( !dir.exists() ) | ||
50 | mkdir(dir.path().local8Bit(),0700); | ||
51 | return dir.path() + "/" + name + ".conf"; | ||
52 | } | ||
53 | } | ||
54 | return name; | ||
55 | } | ||
56 | |||
57 | /*! | ||
58 | \class Config config.h | ||
59 | \brief The Config class provides for saving application cofniguration state. | ||
60 | |||
61 | You should keep a Config in existence only while you do not want others | ||
62 | to be able to change the state. There is no locking currently, but there | ||
63 | may be in the future. | ||
64 | */ | ||
65 | |||
66 | /*! | ||
67 | \enum Config::ConfigGroup | ||
68 | \internal | ||
69 | */ | ||
70 | |||
71 | /*! | ||
72 | \enum Config::Domain | ||
73 | |||
74 | \value File | ||
75 | \value User | ||
76 | |||
77 | See Config for details. | ||
78 | */ | ||
79 | |||
80 | /*! | ||
81 | Constructs a config that will load or create a configuration with the | ||
82 | given \a name in the given \a domain. | ||
83 | |||
84 | You must call setGroup() before doing much else with the Config. | ||
85 | |||
86 | In the default Domain, \e User, | ||
87 | the configuration is user-specific. \a name should not contain "/" in | ||
88 | this case, and in general should be the name of the C++ class that is | ||
89 | primarily responsible for maintaining the configuration. | ||
90 | |||
91 | In the File Domain, \a name is an absolute filename. | ||
92 | */ | ||
93 | Config::Config( const QString &name, Domain domain ) | ||
94 | : filename( configFilename(name,domain) ) | ||
95 | { | ||
96 | git = groups.end(); | ||
97 | read(); | ||
98 | |||
99 | lang = getenv("LANG"); | ||
100 | int i = lang.find("."); | ||
101 | if ( i > 0 ) | ||
102 | lang = lang.left( i ); | ||
103 | i = lang.find( "_" ); | ||
104 | if ( i > 0 ) | ||
105 | glang = lang.left(i); | ||
106 | } | ||
107 | |||
108 | /*! | ||
109 | Writes any changes to disk and destroys the in-memory object. | ||
110 | */ | ||
111 | Config::~Config() | ||
112 | { | ||
113 | if ( changed ) | ||
114 | write(); | ||
115 | } | ||
116 | |||
117 | /*! | ||
118 | Returns whether the current group has an entry called \a key. | ||
119 | */ | ||
120 | bool Config::hasKey( const QString &key ) const | ||
121 | { | ||
122 | if ( groups.end() == git ) | ||
123 | return FALSE; | ||
124 | ConfigGroup::ConstIterator it = ( *git ).find( key ); | ||
125 | return it != ( *git ).end(); | ||
126 | } | ||
127 | |||
128 | /*! | ||
129 | Sets the current group for subsequent reading and writing of | ||
130 | entries to \a gname. Grouping allows the application to partition the namespace. | ||
131 | |||
132 | This function must be called prior to any reading or writing | ||
133 | of entries. | ||
134 | |||
135 | The \a gname must not be empty. | ||
136 | */ | ||
137 | void Config::setGroup( const QString &gname ) | ||
138 | { | ||
139 | QMap< QString, ConfigGroup>::Iterator it = groups.find( gname ); | ||
140 | if ( it == groups.end() ) { | ||
141 | git = groups.insert( gname, ConfigGroup() ); | ||
142 | changed = TRUE; | ||
143 | return; | ||
144 | } | ||
145 | git = it; | ||
146 | } | ||
147 | |||
148 | /*! | ||
149 | Writes a (\a key, \a value) entry to the current group. | ||
150 | |||
151 | \sa readEntry() | ||
152 | */ | ||
153 | void Config::writeEntry( const QString &key, const char* value ) | ||
154 | { | ||
155 | writeEntry(key,QString(value)); | ||
156 | } | ||
157 | |||
158 | /*! | ||
159 | Writes a (\a key, \a value) entry to the current group. | ||
160 | |||
161 | \sa readEntry() | ||
162 | */ | ||
163 | void Config::writeEntry( const QString &key, const QString &value ) | ||
164 | { | ||
165 | if ( git == groups.end() ) { | ||
166 | qWarning( "no group set" ); | ||
167 | return; | ||
168 | } | ||
169 | if ( (*git)[key] != value ) { | ||
170 | ( *git ).insert( key, value ); | ||
171 | changed = TRUE; | ||
172 | } | ||
173 | } | ||
174 | |||
175 | /* | ||
176 | Note that the degree of protection offered by the encryption here is | ||
177 | only sufficient to avoid the most casual observation of the configuration | ||
178 | files. People with access to the files can write down the contents and | ||
179 | decrypt it using this source code. | ||
180 | |||
181 | Conceivably, and at some burden to the user, this encryption could | ||
182 | be improved. | ||
183 | */ | ||
184 | static QString encipher(const QString& plain) | ||
185 | { | ||
186 | // mainly, we make it long | ||
187 | QString cipher; | ||
188 | int mix=28730492; | ||
189 | for (int i=0; i<(int)plain.length(); i++) { | ||
190 | int u = plain[i].unicode(); | ||
191 | int c = u ^ mix; | ||
192 | QString x = QString::number(c,36); | ||
193 | cipher.append(QChar('a'+x.length())); | ||
194 | cipher.append(x); | ||
195 | mix *= u; | ||
196 | } | ||
197 | return cipher; | ||
198 | } | ||
199 | |||
200 | static QString decipher(const QString& cipher) | ||
201 | { | ||
202 | QString plain; | ||
203 | int mix=28730492; | ||
204 | for (int i=0; i<(int)cipher.length();) { | ||
205 | int l = cipher[i].unicode()-'a'; | ||
206 | QString x = cipher.mid(i+1,l); i+=l+1; | ||
207 | int u = x.toInt(0,36) ^ mix; | ||
208 | plain.append(QChar(u)); | ||
209 | mix *= u; | ||
210 | } | ||
211 | return plain; | ||
212 | } | ||
213 | |||
214 | /*! | ||
215 | Writes an encrypted (\a key, \a value) entry to the current group. | ||
216 | |||
217 | Note that the degree of protection offered by the encryption is | ||
218 | only sufficient to avoid the most casual observation of the configuration | ||
219 | files. | ||
220 | |||
221 | \sa readEntry() | ||
222 | */ | ||
223 | void Config::writeEntryCrypt( const QString &key, const QString &value ) | ||
224 | { | ||
225 | if ( git == groups.end() ) { | ||
226 | qWarning( "no group set" ); | ||
227 | return; | ||
228 | } | ||
229 | QString evalue = encipher(value); | ||
230 | if ( (*git)[key] != evalue ) { | ||
231 | ( *git ).insert( key, evalue ); | ||
232 | changed = TRUE; | ||
233 | } | ||
234 | } | ||
235 | |||
236 | /*! | ||
237 | Writes a (\a key, \a num) entry to the current group. | ||
238 | |||
239 | \sa readNumEntry() | ||
240 | */ | ||
241 | void Config::writeEntry( const QString &key, int num ) | ||
242 | { | ||
243 | QString s; | ||
244 | s.setNum( num ); | ||
245 | writeEntry( key, s ); | ||
246 | } | ||
247 | |||
248 | #ifdef Q_HAS_BOOL_TYPE | ||
249 | /*! | ||
250 | Writes a (\a key, \a b) entry to the current group. This is equivalent | ||
251 | to writing a 0 or 1 as an integer entry. | ||
252 | |||
253 | \sa readBoolEntry() | ||
254 | */ | ||
255 | void Config::writeEntry( const QString &key, bool b ) | ||
256 | { | ||
257 | QString s; | ||
258 | s.setNum( ( int )b ); | ||
259 | writeEntry( key, s ); | ||
260 | } | ||
261 | #endif | ||
262 | |||
263 | /*! | ||
264 | Writes a (\a key, \a lst) entry to the current group. The list | ||
265 | is separated by \a sep, so the strings must not contain that character. | ||
266 | |||
267 | \sa readListEntry() | ||
268 | */ | ||
269 | void Config::writeEntry( const QString &key, const QStringList &lst, const QChar &sep ) | ||
270 | { | ||
271 | QString s; | ||
272 | QStringList::ConstIterator it = lst.begin(); | ||
273 | for ( ; it != lst.end(); ++it ) | ||
274 | s += *it + sep; | ||
275 | writeEntry( key, s ); | ||
276 | } | ||
277 | |||
278 | /*! | ||
279 | Removes the \a key entry from the current group. Does nothing if | ||
280 | there is no such entry. | ||
281 | */ | ||
282 | |||
283 | void Config::removeEntry( const QString &key ) | ||
284 | { | ||
285 | if ( git == groups.end() ) { | ||
286 | qWarning( "no group set" ); | ||
287 | return; | ||
288 | } | ||
289 | ( *git ).remove( key ); | ||
290 | changed = TRUE; | ||
291 | } | ||
292 | |||
293 | /*! | ||
294 | \fn bool Config::operator == ( const Config & other ) const | ||
295 | |||
296 | Tests for equality with \a other. Config objects are equal if they refer to the same filename. | ||
297 | */ | ||
298 | |||
299 | /*! | ||
300 | \fn bool Config::operator != ( const Config & other ) const | ||
301 | |||
302 | Tests for inequality with \a other. Config objects are equal if they refer to the same filename. | ||
303 | */ | ||
304 | |||
305 | /*! | ||
306 | \fn QString Config::readEntry( const QString &key, const QString &deflt ) const | ||
307 | |||
308 | Reads a string entry stored with \a key, defaulting to \a deflt if there is no entry. | ||
309 | */ | ||
310 | |||
311 | /*! | ||
312 | \internal | ||
313 | For compatibility, non-const version. | ||
314 | */ | ||
315 | QString Config::readEntry( const QString &key, const QString &deflt ) | ||
316 | { | ||
317 | QString res = readEntryDirect( key+"["+lang+"]" ); | ||
318 | if ( !res.isNull() ) | ||
319 | return res; | ||
320 | if ( !glang.isEmpty() ) { | ||
321 | res = readEntryDirect( key+"["+glang+"]" ); | ||
322 | if ( !res.isNull() ) | ||
323 | return res; | ||
324 | } | ||
325 | return readEntryDirect( key, deflt ); | ||
326 | } | ||
327 | |||
328 | /*! | ||
329 | \fn QString Config::readEntryCrypt( const QString &key, const QString &deflt ) const | ||
330 | |||
331 | Reads an encrypted string entry stored with \a key, defaulting to \a deflt if there is no entry. | ||
332 | */ | ||
333 | |||
334 | /*! | ||
335 | \internal | ||
336 | For compatibility, non-const version. | ||
337 | */ | ||
338 | QString Config::readEntryCrypt( const QString &key, const QString &deflt ) | ||
339 | { | ||
340 | QString res = readEntryDirect( key+"["+lang+"]" ); | ||
341 | if ( res.isNull() && glang.isEmpty() ) | ||
342 | res = readEntryDirect( key+"["+glang+"]" ); | ||
343 | if ( res.isNull() ) | ||
344 | res = readEntryDirect( key, QString::null ); | ||
345 | if ( res.isNull() ) | ||
346 | return deflt; | ||
347 | return decipher(res); | ||
348 | } | ||
349 | |||
350 | /*! | ||
351 | \fn QString Config::readEntryDirect( const QString &key, const QString &deflt ) const | ||
352 | \internal | ||
353 | */ | ||
354 | |||
355 | /*! | ||
356 | \internal | ||
357 | For compatibility, non-const version. | ||
358 | */ | ||
359 | QString Config::readEntryDirect( const QString &key, const QString &deflt ) | ||
360 | { | ||
361 | if ( git == groups.end() ) { | ||
362 | //qWarning( "no group set" ); | ||
363 | return deflt; | ||
364 | } | ||
365 | ConfigGroup::ConstIterator it = ( *git ).find( key ); | ||
366 | if ( it != ( *git ).end() ) | ||
367 | return *it; | ||
368 | else | ||
369 | return deflt; | ||
370 | } | ||
371 | |||
372 | /*! | ||
373 | \fn int Config::readNumEntry( const QString &key, int deflt ) const | ||
374 | Reads a numeric entry stored with \a key, defaulting to \a deflt if there is no entry. | ||
375 | */ | ||
376 | |||
377 | /*! | ||
378 | \internal | ||
379 | For compatibility, non-const version. | ||
380 | */ | ||
381 | int Config::readNumEntry( const QString &key, int deflt ) | ||
382 | { | ||
383 | QString s = readEntry( key ); | ||
384 | if ( s.isEmpty() ) | ||
385 | return deflt; | ||
386 | else | ||
387 | return s.toInt(); | ||
388 | } | ||
389 | |||
390 | /*! | ||
391 | \fn bool Config::readBoolEntry( const QString &key, bool deflt ) const | ||
392 | Reads a bool entry stored with \a key, defaulting to \a deflt if there is no entry. | ||
393 | */ | ||
394 | |||
395 | /*! | ||
396 | \internal | ||
397 | For compatibility, non-const version. | ||
398 | */ | ||
399 | bool Config::readBoolEntry( const QString &key, bool deflt ) | ||
400 | { | ||
401 | QString s = readEntry( key ); | ||
402 | if ( s.isEmpty() ) | ||
403 | return deflt; | ||
404 | else | ||
405 | return (bool)s.toInt(); | ||
406 | } | ||
407 | |||
408 | /*! | ||
409 | \fn QStringList Config::readListEntry( const QString &key, const QChar &sep ) const | ||
410 | Reads a string list entry stored with \a key, and with \a sep as the separator. | ||
411 | */ | ||
412 | |||
413 | /*! | ||
414 | \internal | ||
415 | For compatibility, non-const version. | ||
416 | */ | ||
417 | |||
418 | /*! | ||
419 | Removes all entries from the current group. | ||
420 | */ | ||
421 | void Config::clearGroup() | ||
422 | { | ||
423 | if ( git == groups.end() ) { | ||
424 | qWarning( "no group set" ); | ||
425 | return; | ||
426 | } | ||
427 | if ( !(*git).isEmpty() ) { | ||
428 | ( *git ).clear(); | ||
429 | changed = TRUE; | ||
430 | } | ||
431 | } | ||
432 | |||
433 | void Config::removeGroup() | ||
434 | { | ||
435 | if ( git == groups.end() ) { | ||
436 | qWarning( "no group set" ); | ||
437 | return; | ||
438 | } | ||
439 | |||
440 | groups.remove(git); | ||
441 | changed = TRUE; | ||
442 | } | ||
443 | |||
444 | /*! | ||
445 | \internal | ||
446 | */ | ||
447 | void Config::write( const QString &fn ) | ||
448 | { | ||
449 | QString strNewFile; | ||
450 | if ( !fn.isEmpty() ) | ||
451 | filename = fn; | ||
452 | strNewFile = filename + ".new"; | ||
453 | |||
454 | QFile f( strNewFile ); | ||
455 | if ( !f.open( IO_WriteOnly|IO_Raw ) ) { | ||
456 | qWarning( "could not open for writing `%s'", strNewFile.latin1() ); | ||
457 | git = groups.end(); | ||
458 | return; | ||
459 | } | ||
460 | |||
461 | QString str; | ||
462 | QCString cstr; | ||
463 | QMap< QString, ConfigGroup >::Iterator g_it = groups.begin(); | ||
464 | |||
465 | for ( ; g_it != groups.end(); ++g_it ) { | ||
466 | str += "[" + g_it.key() + "]\n"; | ||
467 | ConfigGroup::Iterator e_it = ( *g_it ).begin(); | ||
468 | for ( ; e_it != ( *g_it ).end(); ++e_it ) | ||
469 | str += e_it.key() + " = " + *e_it + "\n"; | ||
470 | } | ||
471 | cstr = str.utf8(); | ||
472 | |||
473 | int total_length; | ||
474 | total_length = f.writeBlock( cstr.data(), cstr.length() ); | ||
475 | if ( total_length != int(cstr.length()) ) { | ||
476 | QMessageBox::critical( 0, QObject::tr("Out of Space"), | ||
477 | QObject::tr("There was a problem creating\nConfiguration Information \nfor this program.\n\nPlease free up some space and\ntry again.") ); | ||
478 | f.close(); | ||
479 | QFile::remove( strNewFile ); | ||
480 | return; | ||
481 | } | ||
482 | |||
483 | f.close(); | ||
484 | // now rename the file... | ||
485 | if ( rename( strNewFile, filename ) < 0 ) { | ||
486 | qWarning( "problem renaming the file %s to %s", strNewFile.latin1(), | ||
487 | filename.latin1() ); | ||
488 | QFile::remove( strNewFile ); | ||
489 | } | ||
490 | } | ||
491 | |||
492 | /*! | ||
493 | Returns whether the Config is in a valid state. | ||
494 | */ | ||
495 | bool Config::isValid() const | ||
496 | { | ||
497 | return groups.end() != git; | ||
498 | } | ||
499 | |||
500 | /*! | ||
501 | \internal | ||
502 | */ | ||
503 | void Config::read() | ||
504 | { | ||
505 | changed = FALSE; | ||
506 | |||
507 | if ( !QFileInfo( filename ).exists() ) { | ||
508 | git = groups.end(); | ||
509 | return; | ||
510 | } | ||
511 | |||
512 | QFile f( filename ); | ||
513 | if ( !f.open( IO_ReadOnly ) ) { | ||
514 | git = groups.end(); | ||
515 | return; | ||
516 | } | ||
517 | |||
518 | QTextStream s( &f ); | ||
519 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | ||
520 | // The below should work, but doesn't in Qt 2.3.0 | ||
521 | s.setCodec( QTextCodec::codecForMib( 106 ) ); | ||
522 | #else | ||
523 | s.setEncoding( QTextStream::UnicodeUTF8 ); | ||
524 | #endif | ||
525 | |||
526 | QStringList list = QStringList::split('\n', s.read() ); | ||
527 | f.close(); | ||
528 | |||
529 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | ||
530 | if ( !parse( *it ) ) { | ||
531 | git = groups.end(); | ||
532 | return; | ||
533 | } | ||
534 | } | ||
535 | } | ||
536 | |||
537 | /*! | ||
538 | \internal | ||
539 | */ | ||
540 | bool Config::parse( const QString &l ) | ||
541 | { | ||
542 | QString line = l.stripWhiteSpace(); | ||
543 | if ( line[ 0 ] == QChar( '[' ) ) { | ||
544 | QString gname = line; | ||
545 | gname = gname.remove( 0, 1 ); | ||
546 | if ( gname[ (int)gname.length() - 1 ] == QChar( ']' ) ) | ||
547 | gname = gname.remove( gname.length() - 1, 1 ); | ||
548 | git = groups.insert( gname, ConfigGroup() ); | ||
549 | } else if ( !line.isEmpty() ) { | ||
550 | if ( git == groups.end() ) | ||
551 | return FALSE; | ||
552 | int eq = line.find( '=' ); | ||
553 | if ( eq == -1 ) | ||
554 | return FALSE; | ||
555 | QString key = line.left(eq).stripWhiteSpace(); | ||
556 | QString value = line.mid(eq+1).stripWhiteSpace(); | ||
557 | ( *git ).insert( key, value ); | ||
558 | } | ||
559 | return TRUE; | ||
560 | } | ||
diff --git a/noncore/apps/checkbook/config.h b/noncore/apps/checkbook/config.h new file mode 100644 index 0000000..b3a8561 --- a/dev/null +++ b/noncore/apps/checkbook/config.h | |||
@@ -0,0 +1,99 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #ifndef CONFIG_H | ||
22 | #define CONFIG_H | ||
23 | |||
24 | // ##### could use QSettings with Qt 3.0 | ||
25 | |||
26 | #include <qmap.h> | ||
27 | #include <qstringlist.h> | ||
28 | |||
29 | class ConfigPrivate; | ||
30 | class Config | ||
31 | { | ||
32 | public: | ||
33 | typedef QMap< QString, QString > ConfigGroup; | ||
34 | |||
35 | enum Domain { File, User }; | ||
36 | Config( const QString &name, Domain domain=User ); | ||
37 | ~Config(); | ||
38 | |||
39 | bool operator == ( const Config & other ) const { return (filename == other.filename); } | ||
40 | bool operator != ( const Config & other ) const { return (filename != other.filename); } | ||
41 | |||
42 | bool isValid() const; | ||
43 | bool hasKey( const QString &key ) const; | ||
44 | |||
45 | void setGroup( const QString &gname ); | ||
46 | void writeEntry( const QString &key, const char* value ); | ||
47 | void writeEntry( const QString &key, const QString &value ); | ||
48 | void writeEntryCrypt( const QString &key, const QString &value ); | ||
49 | void writeEntry( const QString &key, int num ); | ||
50 | #ifdef Q_HAS_BOOL_TYPE | ||
51 | void writeEntry( const QString &key, bool b ); | ||
52 | #endif | ||
53 | void writeEntry( const QString &key, const QStringList &lst, const QChar &sep ); | ||
54 | void removeEntry( const QString &key ); | ||
55 | |||
56 | QString readEntry( const QString &key, const QString &deflt = QString::null ) const; | ||
57 | QString readEntryCrypt( const QString &key, const QString &deflt = QString::null ) const; | ||
58 | QString readEntryDirect( const QString &key, const QString &deflt = QString::null ) const; | ||
59 | int readNumEntry( const QString &key, int deflt = -1 ) const; | ||
60 | bool readBoolEntry( const QString &key, bool deflt = FALSE ) const; | ||
61 | |||
62 | // For compatibility, non-const versions. | ||
63 | QString readEntry( const QString &key, const QString &deflt ); | ||
64 | QString readEntryCrypt( const QString &key, const QString &deflt ); | ||
65 | QString readEntryDirect( const QString &key, const QString &deflt ); | ||
66 | int readNumEntry( const QString &key, int deflt ); | ||
67 | bool readBoolEntry( const QString &key, bool deflt ); | ||
68 | |||
69 | void clearGroup(); | ||
70 | void removeGroup(); | ||
71 | |||
72 | void write( const QString &fn = QString::null ); | ||
73 | |||
74 | protected: | ||
75 | void read(); | ||
76 | bool parse( const QString &line ); | ||
77 | |||
78 | QMap< QString, ConfigGroup > groups; | ||
79 | QMap< QString, ConfigGroup >::Iterator git; | ||
80 | QString filename; | ||
81 | QString lang; | ||
82 | QString glang; | ||
83 | bool changed; | ||
84 | ConfigPrivate *d; | ||
85 | static QString configFilename(const QString& name, Domain); | ||
86 | }; | ||
87 | |||
88 | inline QString Config::readEntry( const QString &key, const QString &deflt ) const | ||
89 | { return ((Config*)this)->readEntry(key,deflt); } | ||
90 | inline QString Config::readEntryCrypt( const QString &key, const QString &deflt ) const | ||
91 | { return ((Config*)this)->readEntryCrypt(key,deflt); } | ||
92 | inline QString Config::readEntryDirect( const QString &key, const QString &deflt ) const | ||
93 | { return ((Config*)this)->readEntryDirect(key,deflt); } | ||
94 | inline int Config::readNumEntry( const QString &key, int deflt ) const | ||
95 | { return ((Config*)this)->readNumEntry(key,deflt); } | ||
96 | inline bool Config::readBoolEntry( const QString &key, bool deflt ) const | ||
97 | { return ((Config*)this)->readBoolEntry(key,deflt); } | ||
98 | |||
99 | #endif | ||
diff --git a/noncore/apps/checkbook/kmolcalc.cpp b/noncore/apps/checkbook/kmolcalc.cpp deleted file mode 100644 index 50e1375..0000000 --- a/noncore/apps/checkbook/kmolcalc.cpp +++ b/dev/null | |||
@@ -1,235 +0,0 @@ | |||
1 | /* | ||
2 | * kmolcalc.cpp | ||
3 | * | ||
4 | * Copyright (C) 2000 Tomislav Gountchev <tomi@idiom.com> | ||
5 | * Copyright (C) 2002 Carsten Niehaus <cniehaus@handhelds.org> | ||
6 | */ | ||
7 | |||
8 | /** | ||
9 | * KMOLCALC is the calculation engine. It knows about a hashtable of user defined atomic | ||
10 | * weights and group definitions ELSTABLE, and the currently processed formula, stored | ||
11 | * as a list of elements and their coefficients, ELEMENTS. | ||
12 | */ | ||
13 | |||
14 | #include "kmolcalc.h" | ||
15 | #include <qdict.h> | ||
16 | #include <qdir.h> | ||
17 | #include <qfile.h> | ||
18 | #include <iostream.h> | ||
19 | |||
20 | |||
21 | /** | ||
22 | * Construct a new calculator object. | ||
23 | */ | ||
24 | KMolCalc::KMolCalc() { | ||
25 | elements = new ElementList; | ||
26 | elstable = NULL; | ||
27 | readElstable(); | ||
28 | } | ||
29 | |||
30 | KMolCalc::~KMolCalc() { | ||
31 | delete elements; | ||
32 | } | ||
33 | |||
34 | void KMolCalc::readElstable() { | ||
35 | weight = -1; // not calculated yet | ||
36 | if (elstable) delete elstable; | ||
37 | elstable = new QDict<SubUnit> (197, TRUE); | ||
38 | elstable->setAutoDelete(TRUE); | ||
39 | QStringList files;// = // KGlobal::dirs()->findAllResources("appdata", "kmolweights"); | ||
40 | mwfile = "/home/opie/opie/noncore/apps/oxigen/kmolweights"; | ||
41 | QFile f(mwfile); | ||
42 | QString* latest_f = &mwfile; | ||
43 | for (uint i=0; i<files.count(); i++) { | ||
44 | if (QFileInfo(QFile(files[i])).lastModified() > QFileInfo(QFile(*latest_f)).lastModified()) { | ||
45 | latest_f = &files[i]; | ||
46 | } | ||
47 | } | ||
48 | QFile lf(*latest_f); | ||
49 | if (f.exists()) readMwfile(f); | ||
50 | if (!f.exists()) { | ||
51 | readMwfile(lf); | ||
52 | writeElstable(); | ||
53 | } else if (QFileInfo(f).lastModified() < QFileInfo(lf).lastModified()) { | ||
54 | // announce | ||
55 | QMessageBox::information | ||
56 | (0, "Warning:", "Found new global Mw file.\nLocal definitions will be updated.", QMessageBox::Ok); | ||
57 | readMwfile(lf); | ||
58 | writeElstable(); | ||
59 | } | ||
60 | |||
61 | } | ||
62 | |||
63 | |||
64 | /** | ||
65 | * Parse a string S and construct the ElementList this->ELEMENTS, representing the | ||
66 | * composition of S. Returns 0 if successful, or an error code (currently -1) if | ||
67 | * parsing failed. | ||
68 | * The elements is S must be valid element or group symbols, as stored in this->ELSTABLE. | ||
69 | * See help files for correct formula syntax. | ||
70 | */ | ||
71 | QString KMolCalc::readFormula(const QString& s) { | ||
72 | weight = -1; | ||
73 | if (elements) delete elements; | ||
74 | elements = new ElementList; | ||
75 | return KMolCalc::readGroup(s, elements); | ||
76 | } | ||
77 | |||
78 | // read a formula group recursively. Called by readFormula. | ||
79 | QString KMolCalc::readGroup(const QString& s, ElementList* els) { | ||
80 | if (s.isEmpty()) return QString ("Enter a formula."); //ERROR | ||
81 | int sl = s.length(); | ||
82 | int i = 0; | ||
83 | QString errors ("OK"); | ||
84 | bool ok = TRUE; | ||
85 | while (i < sl && ((s[i] <= '9' && s[i] >= '0') || s[i] == '.')) i++; | ||
86 | double prefix = (i == 0 ? 1 : s.left(i).toDouble(&ok)); | ||
87 | if (! ok || i == sl || prefix == 0) return QString ("Bad formula."); // ERROR | ||
88 | ElementList* elstemp = new ElementList; | ||
89 | while (i < sl) { | ||
90 | int j = i; | ||
91 | if (s[i] == '(') { | ||
92 | ElementList* inner = new ElementList; | ||
93 | int level = 1; // count levels of nested ( ). | ||
94 | while (1) { | ||
95 | if (i++ == sl) { | ||
96 | delete inner; | ||
97 | delete elstemp; | ||
98 | return QString ("Bad formula."); //ERROR | ||
99 | } | ||
100 | if (s[i] == '(') level++; | ||
101 | if (s[i] == ')') level--; | ||
102 | if (level == 0) break; | ||
103 | } | ||
104 | errors = KMolCalc::readGroup(s.mid(j+1, i-j-1), inner); | ||
105 | j = ++i; | ||
106 | while (i < sl && ((s[i] <= '9' && s[i] >= '0') || s[i] == '.')) i++; | ||
107 | double suffix = (i == j ? 1 : s.mid(j, i-j).toDouble(&ok)); | ||
108 | if (! ok || suffix == 0) { | ||
109 | delete inner; | ||
110 | delete elstemp; | ||
111 | return QString ("Bad formula."); // ERROR | ||
112 | } | ||
113 | inner->addTo(*elstemp, suffix); | ||
114 | delete inner; | ||
115 | inner = NULL; | ||
116 | } else if ((s[i] >= 'A' && s[i] <= 'Z') || (s[i] >= 'a' && s[i] <= 'z')) { | ||
117 | while (++i < sl && ((s[i] >= 'a' && s[i] <= 'z') || s[i] == '*' || | ||
118 | s[i] == '\'')); | ||
119 | QString elname = s.mid(j, i-j); | ||
120 | j = i; | ||
121 | while (i < sl && ((s[i] <= '9' && s[i] >= '0') || s[i] == '.')) i++; | ||
122 | double suffix = (i == j ? 1 : s.mid(j, i-j).toDouble(&ok)); | ||
123 | if (! ok || suffix == 0) { | ||
124 | delete elstemp; | ||
125 | return QString ("Bad formula."); // ERROR | ||
126 | } | ||
127 | SubUnit* group = elstable->find(elname); | ||
128 | if (group == 0) { | ||
129 | delete elstemp; | ||
130 | return QString ("Undefined symbol: ") + elname; //ERROR | ||
131 | } | ||
132 | group->addTo(*elstemp, suffix); | ||
133 | } else if (s[i] == '+') { | ||
134 | if (elstemp->isEmpty()) { | ||
135 | delete elstemp; | ||
136 | return QString ("Bad formula."); //ERROR | ||
137 | } | ||
138 | elstemp->addTo(*els, prefix); | ||
139 | delete elstemp; | ||
140 | errors = KMolCalc::readGroup(s.mid(i+1, sl-i-1), els); | ||
141 | return errors; | ||
142 | } else { | ||
143 | delete elstemp; | ||
144 | return QString ("Bad formula."); //ERROR | ||
145 | } | ||
146 | } | ||
147 | elstemp->addTo(*els, prefix); | ||
148 | delete elstemp; | ||
149 | return errors; | ||
150 | } | ||
151 | |||
152 | /** | ||
153 | * Calculate and return the molecular weight of the current chemical formula. | ||
154 | */ | ||
155 | double KMolCalc::getWeight() { | ||
156 | if (weight == -1) weight = elements->getWeight(elstable); | ||
157 | return weight; | ||
158 | } | ||
159 | |||
160 | /** | ||
161 | * Return the elemental composition of the current formula, as a string of tab-separated | ||
162 | * element - percentage pairs, separated by newlines. | ||
163 | */ | ||
164 | QString KMolCalc::getEA() { | ||
165 | if (weight == -1) weight = elements->getWeight(elstable); | ||
166 | if (weight == -1) return QString("ERROR: Couldn't get Mw..."); // ERROR | ||
167 | return elements->getEA(elstable, weight); | ||
168 | } | ||
169 | |||
170 | /** | ||
171 | * Return the empirical formula of the current compound as a QString. | ||
172 | */ | ||
173 | QString KMolCalc::getEmpFormula() { | ||
174 | return elements->getEmpFormula(); | ||
175 | } | ||
176 | |||
177 | // Read the element definition file. | ||
178 | void KMolCalc::readMwfile(QFile& f) { | ||
179 | if (! f.open(IO_ReadOnly)) return; //ERROR | ||
180 | QTextStream fs (&f); | ||
181 | QString line; | ||
182 | while (! fs.eof()) { | ||
183 | line = fs.readLine(); | ||
184 | SubUnit* s = SubUnit::makeSubUnit(line); | ||
185 | elstable->replace(s->getName(), s); | ||
186 | } | ||
187 | f.close(); | ||
188 | } | ||
189 | |||
190 | /** | ||
191 | * Save the element definitions file. | ||
192 | */ | ||
193 | void KMolCalc::writeElstable() { | ||
194 | QFile f(mwfile); | ||
195 | if (! f.open(IO_WriteOnly)) return; //ERROR | ||
196 | QTextStream fs (&f); | ||
197 | QString line; | ||
198 | QDictIterator<SubUnit> it(*elstable); | ||
199 | while (it.current()) { | ||
200 | it.current()->writeOut(line); | ||
201 | fs << line << endl; | ||
202 | ++it; | ||
203 | } | ||
204 | f.close(); | ||
205 | } | ||
206 | |||
207 | /** | ||
208 | * Remove a group or element definition from ELSTABLE. | ||
209 | */ | ||
210 | void KMolCalc::undefineGroup (const QString& name) { | ||
211 | elstable->remove (name); | ||
212 | } | ||
213 | |||
214 | /** | ||
215 | * Add a new element name - atomic weight record to the ELSTABLE hashtable. Assumes | ||
216 | * NAME has valid syntax. | ||
217 | |||
218 | */ | ||
219 | void KMolCalc::defineElement (const QString& name, double weight) { | ||
220 | Element* el = new Element(name, weight); | ||
221 | elstable->replace(name, el); | ||
222 | } | ||
223 | |||
224 | /** | ||
225 | * Add a new group definition to the ELSTABLE. Returns 0 if OK, -1 if parsing FORMULA | ||
226 | * fails. Assumes the syntax of grpname is correct. | ||
227 | */ | ||
228 | QString KMolCalc::defineGroup (const QString& grpname, const QString& formula) { | ||
229 | ElementList* els = new ElementList(grpname); | ||
230 | QString error = readGroup(formula, els); | ||
231 | if (error != "OK") return error; | ||
232 | if (els->contains(grpname)) return QString("Can't define a group recursively!\n"); | ||
233 | elstable->replace(grpname, els); | ||
234 | return QString("OK"); | ||
235 | } | ||
diff --git a/noncore/apps/checkbook/kmolcalc.h b/noncore/apps/checkbook/kmolcalc.h deleted file mode 100644 index c3e02f3..0000000 --- a/noncore/apps/checkbook/kmolcalc.h +++ b/dev/null | |||
@@ -1,110 +0,0 @@ | |||
1 | /* | ||
2 | * kmolcalc.h | ||
3 | * | ||
4 | * Copyright (C) 2000 Tomislav Gountchev <tomi@idiom.com> | ||
5 | */ | ||
6 | |||
7 | |||
8 | #ifndef KMOLCALC_H | ||
9 | #define KMOLCALC_H | ||
10 | |||
11 | #ifdef HAVE_CONFIG_H | ||
12 | #include <config.h> | ||
13 | #endif | ||
14 | |||
15 | |||
16 | #include "kmolelements.h" | ||
17 | #include <qdict.h> | ||
18 | #include <qlist.h> | ||
19 | #include <qstring.h> | ||
20 | #include <qfile.h> | ||
21 | #include <qfileinfo.h> | ||
22 | #include <qmessagebox.h> | ||
23 | #include <qtextstream.h> | ||
24 | |||
25 | |||
26 | /** | ||
27 | * KMOLCALC is the calculation engine. It knows about a hashtable of user defined atomic | ||
28 | * weights and group definitions ELSTABLE, and the currently processed formula, stored | ||
29 | * as a list of elements and their coefficients, ELEMENTS. | ||
30 | */ | ||
31 | class KMolCalc { | ||
32 | |||
33 | public: | ||
34 | |||
35 | KMolCalc(); | ||
36 | ~KMolCalc(); | ||
37 | |||
38 | /** | ||
39 | * Parse a string S and construct the ElementList ELEMENTS, representing the composition | ||
40 | * of S. Returns "OK" if successful, or an error message if parsing failed. | ||
41 | * The elements is S must be valid element or group symbols, as stored in ELSTABLE. | ||
42 | * See help files for correct formula syntax. | ||
43 | */ | ||
44 | QString readFormula(const QString& s); | ||
45 | |||
46 | /** | ||
47 | * Calculate and return the molecular weight of the current chemical formula. | ||
48 | */ | ||
49 | double getWeight(); | ||
50 | |||
51 | /** | ||
52 | * Return the elemental composition of the current formula, as a string of tab-separated | ||
53 | * element - percentage pairs, separated by newlines. | ||
54 | */ | ||
55 | QString getEA(); | ||
56 | |||
57 | |||
58 | /** | ||
59 | * Return the empirical formula of the current compound as a QString. | ||
60 | */ | ||
61 | QString getEmpFormula(); | ||
62 | |||
63 | /** | ||
64 | * Add a new element name - atomic weight record to the ELSTABLE hashtable. | ||
65 | * Assumes NAME has valid syntax. | ||
66 | */ | ||
67 | void defineElement(const QString& name, double weight); | ||
68 | |||
69 | /** | ||
70 | * Add a new group definition to the ELSTABLE. Returns "OK" if OK, error message | ||
71 | * if parsing FORMULA fails. Assumes the syntax of NAME is correct. | ||
72 | */ | ||
73 | QString defineGroup(const QString& name, const QString& formula); | ||
74 | |||
75 | /** | ||
76 | * Remove a group or element definition from ELSTABLE. | ||
77 | */ | ||
78 | void undefineGroup(const QString& name); | ||
79 | |||
80 | /** | ||
81 | * Save the element definitions file. | ||
82 | */ | ||
83 | void writeElstable(); | ||
84 | |||
85 | /** | ||
86 | * Read the element definitions file and construct ELSTABLE. | ||
87 | */ | ||
88 | void readElstable(); | ||
89 | |||
90 | /** | ||
91 | * The element dictionary. | ||
92 | */ | ||
93 | QDict<SubUnit>* elstable; | ||
94 | |||
95 | QString mwfile; | ||
96 | |||
97 | private: | ||
98 | double weight; | ||
99 | |||
100 | QString readGroup(const QString& s, ElementList* els); | ||
101 | void readMwfile(QFile& f); | ||
102 | ElementList* elements; | ||
103 | }; | ||
104 | |||
105 | #endif | ||
106 | |||
107 | |||
108 | |||
109 | |||
110 | |||
diff --git a/noncore/apps/checkbook/kmolelements.cpp b/noncore/apps/checkbook/kmolelements.cpp deleted file mode 100644 index ce8f9c1..0000000 --- a/noncore/apps/checkbook/kmolelements.cpp +++ b/dev/null | |||
@@ -1,238 +0,0 @@ | |||
1 | /* | ||
2 | * kmolelements.cpp | ||
3 | * | ||
4 | * Copyright (C) 2000 Tomislav Gountchev <tomi@idiom.com> | ||
5 | */ | ||
6 | |||
7 | // classes that store and manipulate chemical formulas represented as | ||
8 | // lists of elements | ||
9 | |||
10 | #include <stdio.h> | ||
11 | #include "kmolelements.h" | ||
12 | |||
13 | /** | ||
14 | * A generic chemical entity. Can be an element or a group. | ||
15 | */ | ||
16 | SubUnit::SubUnit () {} | ||
17 | |||
18 | SubUnit::~SubUnit () {} | ||
19 | |||
20 | /** | ||
21 | * Construct a subunit and return a pointer to it. The syntax of LINE is | ||
22 | * the one used in the element definition file. | ||
23 | */ | ||
24 | SubUnit* SubUnit::makeSubUnit(QString line) { | ||
25 | QString name, grpname, weight, coef; | ||
26 | QTextStream str (line, IO_ReadOnly); | ||
27 | str >> name; | ||
28 | if (name != "-group") { // not a group - must be represented as Element | ||
29 | str >> weight >> ws; | ||
30 | return new Element(name, weight.toDouble()); | ||
31 | } | ||
32 | else { | ||
33 | str >> grpname; | ||
34 | ElementList* els = new ElementList(grpname); // group - make an ElementList | ||
35 | while (!str.eof()) { | ||
36 | str >> name >> ws; | ||
37 | str >> coef >> ws; | ||
38 | els->addElement(name, coef.toDouble()); | ||
39 | } | ||
40 | return els; | ||
41 | } | ||
42 | } | ||
43 | |||
44 | QString SubUnit::getName() const { | ||
45 | return QString("None"); | ||
46 | } | ||
47 | |||
48 | /** | ||
49 | * Get the molecular weight of THIS, based on the data from ELSTABLE. | ||
50 | */ | ||
51 | double SubUnit::getWeight(QDict<SubUnit>* elstable) const { | ||
52 | return -1; | ||
53 | } | ||
54 | |||
55 | /** | ||
56 | * A group of elements. | ||
57 | */ | ||
58 | ElementList::ElementList () { | ||
59 | elements = new QList<ElementCoef>; | ||
60 | } | ||
61 | |||
62 | ElementList::~ElementList () { | ||
63 | delete elements; | ||
64 | } | ||
65 | |||
66 | |||
67 | /** | ||
68 | * A group of elements. | ||
69 | */ | ||
70 | ElementList::ElementList (QString name) { | ||
71 | this->name = name; | ||
72 | elements = new QList<ElementCoef>; | ||
73 | } | ||
74 | |||
75 | /** | ||
76 | * Write THIS to LINE, in a format suitable for the element definition file. | ||
77 | */ | ||
78 | void ElementList::writeOut(QString& line) { | ||
79 | QString coef; | ||
80 | line = "-group " + name; | ||
81 | ElementCoef* current = elements->first(); | ||
82 | while (current != 0) { | ||
83 | line += " " + current->name + " " + coef.setNum(current->coef, 'g', 10); | ||
84 | // precision set to 10 digits | ||
85 | current = elements->next(); | ||
86 | } | ||
87 | } | ||
88 | |||
89 | /** | ||
90 | * Get the molecular weight of THIS, based on the data from ELSTABLE. | ||
91 | */ | ||
92 | double ElementList::getWeight(QDict<SubUnit>* elstable) const { | ||
93 | double weight = 0; | ||
94 | ElementCoef* current = elements->first(); | ||
95 | while (current != 0) { | ||
96 | SubUnit* e = elstable->find(current->name); | ||
97 | if (e != 0) { | ||
98 | weight += (current->coef) * (e->getWeight(elstable)); | ||
99 | } else return -1; //ERROR | ||
100 | current = elements->next(); | ||
101 | } | ||
102 | return weight; | ||
103 | } | ||
104 | |||
105 | /** | ||
106 | * Return a string representing the elemental composition of THIS, as | ||
107 | * a tab-separated element - percentage pairs, separated by newlines. | ||
108 | */ | ||
109 | QString ElementList::getEA(QDict<SubUnit>* elstable, double mw) const { | ||
110 | if (mw == 0) mw = getWeight(elstable); | ||
111 | QString ea; | ||
112 | QString temp; | ||
113 | ElementCoef* current = elements->first(); | ||
114 | while (current != 0) { | ||
115 | SubUnit* e = elstable->find(current->name); | ||
116 | if (e != 0) { | ||
117 | double current_percent = 100 * (current->coef) * | ||
118 | (e->getWeight(elstable)) | ||
119 | / mw; | ||
120 | ea += current->name + "\t" + | ||
121 | temp.setNum(current_percent) + "\n"; | ||
122 | } else return QString("ERROR!\n"); //ERROR | ||
123 | current = elements->next(); | ||
124 | } | ||
125 | return ea; | ||
126 | } | ||
127 | |||
128 | /** | ||
129 | * Return a string representing THIS as an empirical chemical formula. | ||
130 | */ | ||
131 | QString ElementList::getEmpFormula() const { | ||
132 | QString ef; | ||
133 | QString temp; | ||
134 | ElementCoef* current = elements->first(); | ||
135 | while (current != 0) { | ||
136 | ef += current->name + temp.setNum(current->coef); | ||
137 | current = elements->next(); | ||
138 | } | ||
139 | return ef; | ||
140 | } | ||
141 | |||
142 | /** | ||
143 | * Multiply THIS (i.e. the coefficient of each element) by coef. | ||
144 | */ | ||
145 | void ElementList::multiplyBy(double coef) { | ||
146 | ElementCoef* current = elements->first(); | ||
147 | while (current != 0) { | ||
148 | (current->coef) *= coef; | ||
149 | current = elements->next(); | ||
150 | } | ||
151 | } | ||
152 | |||
153 | /** | ||
154 | * Add THIS to ELS. THIS is not modified; ELS is. | ||
155 | */ | ||
156 | void ElementList::addTo(ElementList& els, double coef) { | ||
157 | ElementCoef* current = elements->first(); | ||
158 | while (current != 0) { | ||
159 | els.addElement(current->name, (current->coef) * coef); | ||
160 | current = elements->next(); | ||
161 | } | ||
162 | } | ||
163 | |||
164 | /** | ||
165 | * Add an element to THIS, with a coefficient COEF. If THIS already contains | ||
166 | * an element with the same name, adjust its coefficient only; if not, create | ||
167 | * a new ElementCoef pair and add to THIS. | ||
168 | */ | ||
169 | void ElementList::addElement(const QString& name, double coef) { | ||
170 | ElementCoef* current = elements->first(); | ||
171 | while (current != 0) { | ||
172 | if (current->name == name) { | ||
173 | current->coef += coef; | ||
174 | return; | ||
175 | } | ||
176 | current = elements->next(); | ||
177 | } | ||
178 | elements->append(new ElementCoef(name, coef)); | ||
179 | } | ||
180 | |||
181 | /** | ||
182 | * True iff THIS contains element named NAME. | ||
183 | */ | ||
184 | bool ElementList::contains(const QString& name) { | ||
185 | ElementCoef* current = elements->first(); | ||
186 | while (current != 0) { | ||
187 | if (current->name == name) | ||
188 | return true; | ||
189 | current = elements->next(); | ||
190 | } | ||
191 | return false; | ||
192 | } | ||
193 | |||
194 | bool ElementList::isEmpty() { | ||
195 | return elements->isEmpty(); | ||
196 | } | ||
197 | |||
198 | QString ElementList::getName() const { | ||
199 | return name; | ||
200 | } | ||
201 | |||
202 | /** | ||
203 | * A chemical element. | ||
204 | */ | ||
205 | Element::Element(const QString& n, double w) | ||
206 | : weight(w), name(n) { } | ||
207 | |||
208 | |||
209 | Element::~Element() { | ||
210 | } | ||
211 | |||
212 | |||
213 | /** | ||
214 | * Write THIS to LINE, in a format suitable for the element definition file. | ||
215 | */ | ||
216 | void Element::writeOut(QString& line) { | ||
217 | line.setNum(weight); | ||
218 | line = name + " " + line; | ||
219 | } | ||
220 | |||
221 | double Element::getWeight(QDict<SubUnit>* elstable) const { | ||
222 | return weight; | ||
223 | } | ||
224 | |||
225 | void Element::addTo(ElementList& els, double coef) { | ||
226 | els.addElement(name, coef); | ||
227 | } | ||
228 | |||
229 | QString Element::getName() const { | ||
230 | return name; | ||
231 | } | ||
232 | |||
233 | /** | ||
234 | * An element - coefficient pair. Used to represent elements within an | ||
235 | * element list. | ||
236 | */ | ||
237 | ElementCoef::ElementCoef(const QString& n, double c) : name(n), coef(c) {} | ||
238 | |||
diff --git a/noncore/apps/checkbook/kmolelements.h b/noncore/apps/checkbook/kmolelements.h deleted file mode 100644 index 06d1469..0000000 --- a/noncore/apps/checkbook/kmolelements.h +++ b/dev/null | |||
@@ -1,161 +0,0 @@ | |||
1 | /* | ||
2 | * kmolelements.h | ||
3 | * | ||
4 | * Copyright (C) 2000 Tomislav Gountchev <tomi@idiom.com> | ||
5 | */ | ||
6 | |||
7 | // classes that store and manipulate chemical formulas represented as | ||
8 | // lists of elements | ||
9 | |||
10 | #ifndef KMOLELEMENTS_H | ||
11 | #define KMOLELEMENTS_H | ||
12 | |||
13 | |||
14 | #ifdef HAVE_CONFIG_H | ||
15 | #include <config.h> | ||
16 | #endif | ||
17 | |||
18 | |||
19 | #include <qlist.h> | ||
20 | #include <qdict.h> | ||
21 | #include <qstring.h> | ||
22 | #include <qtextstream.h> | ||
23 | |||
24 | class ElementCoef; | ||
25 | class ElementList; | ||
26 | |||
27 | /** | ||
28 | * A generic chemical entity. Can be an element or a group. | ||
29 | */ | ||
30 | class SubUnit { | ||
31 | public: | ||
32 | |||
33 | SubUnit(); | ||
34 | |||
35 | virtual ~SubUnit(); | ||
36 | |||
37 | /** | ||
38 | * Construct a subunit and return a pointer to it. The syntax of LINE is | ||
39 | * the one used in the element definition file. | ||
40 | */ | ||
41 | static SubUnit* makeSubUnit(QString line); | ||
42 | |||
43 | /** | ||
44 | * Get the molecular weight of THIS, based on the data from ELSTABLE. | ||
45 | */ | ||
46 | virtual double getWeight(QDict<SubUnit>* elstable) const; | ||
47 | |||
48 | /** | ||
49 | * Add THIS to ELS. | ||
50 | */ | ||
51 | virtual void addTo(ElementList& els, double coef) = 0; | ||
52 | |||
53 | virtual QString getName() const; | ||
54 | |||
55 | /** | ||
56 | * Write THIS to LINE, in the format used in the definition file. | ||
57 | */ | ||
58 | virtual void writeOut(QString& line) = 0; | ||
59 | }; | ||
60 | |||
61 | |||
62 | /** | ||
63 | * A group of elements. | ||
64 | */ | ||
65 | class ElementList : public SubUnit { | ||
66 | public: | ||
67 | ElementList (); | ||
68 | ElementList (QString name); | ||
69 | virtual ~ElementList(); | ||
70 | double getWeight(QDict<SubUnit>* elstable) const; | ||
71 | |||
72 | /** | ||
73 | * Return a string representing the elemental composition of THIS, as | ||
74 | * a tab-separated element - percentage pairs, separated by newlines. | ||
75 | */ | ||
76 | QString getEA(QDict<SubUnit>* elstable, double mw = 0) const; | ||
77 | |||
78 | /** | ||
79 | * Return a string representing THIS as an empirical chemical formula. | ||
80 | */ | ||
81 | QString getEmpFormula() const; | ||
82 | |||
83 | /** | ||
84 | * Multiply THIS (i.e. the coefficient of each element) by coef. | ||
85 | */ | ||
86 | void multiplyBy(double coef); | ||
87 | |||
88 | /** | ||
89 | * Add THIS to ELS. THIS is not modified; ELS is. | ||
90 | */ | ||
91 | void addTo(ElementList& els, double coef); | ||
92 | |||
93 | /** | ||
94 | * Add an element to THIS, with a coefficient COEF. | ||
95 | */ | ||
96 | void addElement(const QString& name, double coef); | ||
97 | |||
98 | /** | ||
99 | * True iff THIS contains element named NAME. | ||
100 | */ | ||
101 | bool contains(const QString& name); | ||
102 | |||
103 | |||
104 | bool isEmpty(); | ||
105 | |||
106 | /** | ||
107 | * The name of THIS, as a chemical group. | ||
108 | */ | ||
109 | QString getName() const; | ||
110 | |||
111 | /** | ||
112 | * Write THIS to LINE, in a format suitable for the element definition file. | ||
113 | */ | ||
114 | void writeOut(QString& line); | ||
115 | |||
116 | private: | ||
117 | QString name; | ||
118 | QList<ElementCoef>* elements; | ||
119 | }; | ||
120 | |||
121 | /** | ||
122 | * A chemical element. | ||
123 | */ | ||
124 | class Element : public SubUnit { | ||
125 | public: | ||
126 | Element(const QString& name, double weight); | ||
127 | virtual ~Element(); | ||
128 | double getWeight(QDict<SubUnit>* elstable) const; | ||
129 | |||
130 | /** | ||
131 | * Add THIS to ELS, with a coefficient COEF. | ||
132 | */ | ||
133 | void addTo(ElementList& els, double coef); | ||
134 | |||
135 | QString getName() const; | ||
136 | |||
137 | void writeOut(QString& line); | ||
138 | |||
139 | private: | ||
140 | double weight; | ||
141 | QString name; | ||
142 | }; | ||
143 | |||
144 | |||
145 | /** | ||
146 | * An element - coefficient pair. Used to represent elements within an | ||
147 | * element list. | ||
148 | */ | ||
149 | class ElementCoef { | ||
150 | friend class ElementList; | ||
151 | public: | ||
152 | ElementCoef(const QString& name, double coef = 1.0); | ||
153 | private: | ||
154 | QString name; | ||
155 | double coef; | ||
156 | }; | ||
157 | |||
158 | |||
159 | #endif | ||
160 | |||
161 | |||
diff --git a/noncore/apps/checkbook/main.cpp b/noncore/apps/checkbook/main.cpp index 328b61f..68f00e6 100644 --- a/noncore/apps/checkbook/main.cpp +++ b/noncore/apps/checkbook/main.cpp | |||
@@ -1,21 +1,11 @@ | |||
1 | /*************************************************************************** | ||
2 | * * | ||
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 * | ||
5 | * the Free Software Foundation; either version 2 of the License, or * | ||
6 | * ( at your option ) any later version. * | ||
7 | * * | ||
8 | * ***********************************************************************/ | ||
9 | |||
10 | |||
11 | #include <qpe/qpeapplication.h> | 1 | #include <qpe/qpeapplication.h> |
12 | #include "oxygen.h" | 2 | #include "qcheckbook.h" |
13 | 3 | ||
14 | int main(int argc, char **argv) | 4 | int main(int argc, char **argv) |
15 | { | 5 | { |
16 | QPEApplication app(argc, argv); | 6 | QPEApplication app(argc, argv); |
17 | Oxygen *oxi = new Oxygen(); | 7 | QCheckBook *qcb = new QCheckBook(); |
18 | app.setMainWidget(oxi); | 8 | app.setMainWidget(qcb); |
19 | oxi->showMaximized(); | 9 | qcb->showMaximized(); |
20 | return app.exec(); | 10 | return app.exec(); |
21 | } | 11 | } |
diff --git a/noncore/apps/checkbook/moc_kmoledit.cpp b/noncore/apps/checkbook/moc_kmoledit.cpp deleted file mode 100644 index a94e93b..0000000 --- a/noncore/apps/checkbook/moc_kmoledit.cpp +++ b/dev/null | |||
@@ -1,95 +0,0 @@ | |||
1 | /**************************************************************************** | ||
2 | ** KMolEdit meta object code from reading C++ file 'kmoledit.h' | ||
3 | ** | ||
4 | ** Created: Sun Sep 15 15:21:49 2002 | ||
5 | ** by: The Qt MOC ($Id$) | ||
6 | ** | ||
7 | ** WARNING! All changes made in this file will be lost! | ||
8 | *****************************************************************************/ | ||
9 | |||
10 | #if !defined(Q_MOC_OUTPUT_REVISION) | ||
11 | #define Q_MOC_OUTPUT_REVISION 9 | ||
12 | #elif Q_MOC_OUTPUT_REVISION != 9 | ||
13 | #error "Moc format conflict - please regenerate all moc files" | ||
14 | #endif | ||
15 | |||
16 | #include "kmoledit.h" | ||
17 | #include <qmetaobject.h> | ||
18 | #include <qapplication.h> | ||
19 | |||
20 | |||
21 | |||
22 | const char *KMolEdit::className() const | ||
23 | { | ||
24 | return "KMolEdit"; | ||
25 | } | ||
26 | |||
27 | QMetaObject *KMolEdit::metaObj = 0; | ||
28 | |||
29 | void KMolEdit::initMetaObject() | ||
30 | { | ||
31 | if ( metaObj ) | ||
32 | return; | ||
33 | if ( qstrcmp(QDialog::className(), "QDialog") != 0 ) | ||
34 | badSuperclassWarning("KMolEdit","QDialog"); | ||
35 | (void) staticMetaObject(); | ||
36 | } | ||
37 | |||
38 | #ifndef QT_NO_TRANSLATION | ||
39 | |||
40 | QString KMolEdit::tr(const char* s) | ||
41 | { | ||
42 | return qApp->translate( "KMolEdit", s, 0 ); | ||
43 | } | ||
44 | |||
45 | QString KMolEdit::tr(const char* s, const char * c) | ||
46 | { | ||
47 | return qApp->translate( "KMolEdit", s, c ); | ||
48 | } | ||
49 | |||
50 | #endif // QT_NO_TRANSLATION | ||
51 | |||
52 | QMetaObject* KMolEdit::staticMetaObject() | ||
53 | { | ||
54 | if ( metaObj ) | ||
55 | return metaObj; | ||
56 | (void) QDialog::staticMetaObject(); | ||
57 | #ifndef QT_NO_PROPERTIES | ||
58 | #endif // QT_NO_PROPERTIES | ||
59 | typedef bool (KMolEdit::*m1_t0)(); | ||
60 | typedef bool (QObject::*om1_t0)(); | ||
61 | typedef void (KMolEdit::*m1_t1)(); | ||
62 | typedef void (QObject::*om1_t1)(); | ||
63 | typedef void (KMolEdit::*m1_t2)(); | ||
64 | typedef void (QObject::*om1_t2)(); | ||
65 | m1_t0 v1_0 = &KMolEdit::edit; | ||
66 | om1_t0 ov1_0 = (om1_t0)v1_0; | ||
67 | m1_t1 v1_1 = &KMolEdit::save; | ||
68 | om1_t1 ov1_1 = (om1_t1)v1_1; | ||
69 | m1_t2 v1_2 = &KMolEdit::undo; | ||
70 | om1_t2 ov1_2 = (om1_t2)v1_2; | ||
71 | QMetaData *slot_tbl = QMetaObject::new_metadata(3); | ||
72 | QMetaData::Access *slot_tbl_access = QMetaObject::new_metaaccess(3); | ||
73 | slot_tbl[0].name = "edit()"; | ||
74 | slot_tbl[0].ptr = (QMember)ov1_0; | ||
75 | slot_tbl_access[0] = QMetaData::Private; | ||
76 | slot_tbl[1].name = "save()"; | ||
77 | slot_tbl[1].ptr = (QMember)ov1_1; | ||
78 | slot_tbl_access[1] = QMetaData::Private; | ||
79 | slot_tbl[2].name = "undo()"; | ||
80 | slot_tbl[2].ptr = (QMember)ov1_2; | ||
81 | slot_tbl_access[2] = QMetaData::Private; | ||
82 | metaObj = QMetaObject::new_metaobject( | ||
83 | "KMolEdit", "QDialog", | ||
84 | slot_tbl, 3, | ||
85 | 0, 0, | ||
86 | #ifndef QT_NO_PROPERTIES | ||
87 | 0, 0, | ||
88 | 0, 0, | ||
89 | #endif // QT_NO_PROPERTIES | ||
90 | 0, 0 ); | ||
91 | metaObj->set_slot_access( slot_tbl_access ); | ||
92 | #ifndef QT_NO_PROPERTIES | ||
93 | #endif // QT_NO_PROPERTIES | ||
94 | return metaObj; | ||
95 | } | ||
diff --git a/noncore/apps/checkbook/opie-checkbook.control b/noncore/apps/checkbook/opie-checkbook.control index 9784206..23e21da 100644 --- a/noncore/apps/checkbook/opie-checkbook.control +++ b/noncore/apps/checkbook/opie-checkbook.control | |||
@@ -6,4 +6,4 @@ Architecture: arm | |||
6 | Version: $QPE_VERSION-$SUB_VERSION | 6 | Version: $QPE_VERSION-$SUB_VERSION |
7 | Depends: opie-base ($QPE_VERSION) | 7 | Depends: opie-base ($QPE_VERSION) |
8 | Description: Checkbook keeping program. | 8 | Description: Checkbook keeping program. |
9 | The checkbook accounting program for the Opie environment. | 9 | The checbook accounting program for the Opie environment. |
diff --git a/noncore/apps/checkbook/opie-oxygen.control b/noncore/apps/checkbook/opie-oxygen.control deleted file mode 100644 index 4f84158..0000000 --- a/noncore/apps/checkbook/opie-oxygen.control +++ b/dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | Files: bin/oxygen apps/Applications/oxygencheckbook.desktop pics/oxygen/oxygen.png | ||
2 | Priority: optional | ||
3 | Section: applications | ||
4 | Maintainer: Carsten Niehaus <cniehaus@handhelds.org> | ||
5 | Architecture: arm | ||
6 | Version: $QPE_VERSION-$SUB_VERSION | ||
7 | Depends: opie-base ($QPE_VERSION) | ||
8 | Description: Periodic System of the Elements | ||
9 | The chemistry application for the Opie-environment | ||
diff --git a/noncore/apps/checkbook/oxygen.cpp b/noncore/apps/checkbook/oxygen.cpp deleted file mode 100644 index 81897e9..0000000 --- a/noncore/apps/checkbook/oxygen.cpp +++ b/dev/null | |||
@@ -1,53 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * * | ||
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 * | ||
5 | * the Free Software Foundation; either version 2 of the License, or * | ||
6 | * ( at your option ) any later version. * | ||
7 | * * | ||
8 | * ***********************************************************************/ | ||
9 | #include "oxygen.h" | ||
10 | |||
11 | #include <qmenubar.h> | ||
12 | #include <qstatusbar.h> | ||
13 | #include <qpopupmenu.h> | ||
14 | #include <qlabel.h> | ||
15 | #include <qapplication.h> | ||
16 | #include <qpushbutton.h> | ||
17 | #include <qfile.h> | ||
18 | #include <qdir.h> | ||
19 | #include <qvbox.h> | ||
20 | #include "calcdlg.h" | ||
21 | #include "calcdlgui.h" | ||
22 | |||
23 | Oxygen::Oxygen() | ||
24 | : QMainWindow() | ||
25 | { | ||
26 | this->setCaption( "Oxygen" ); | ||
27 | vbox = new QVBox( this ); | ||
28 | QPushButton *setButton = new QPushButton( "Settings", vbox ); | ||
29 | connect ( setButton, SIGNAL( clicked() ), this, SLOT( slotSettings() ) ); | ||
30 | QPushButton *calcButton = new QPushButton( "Calculations", vbox ); | ||
31 | connect ( calcButton, SIGNAL( clicked() ), this, SLOT( slotCalculations() ) ); | ||
32 | QPushButton *pseButton = new QPushButton( "PSE", vbox ); | ||
33 | connect ( pseButton, SIGNAL( clicked() ), this, SLOT( slotPSE() ) ); | ||
34 | |||
35 | setCentralWidget( vbox ); | ||
36 | } | ||
37 | |||
38 | |||
39 | void Oxygen::close() | ||
40 | { | ||
41 | QApplication::exit(); | ||
42 | } | ||
43 | |||
44 | //SLOTS | ||
45 | |||
46 | void Oxygen::slotCalculations(){ | ||
47 | calcDlgUI *CalcDlgUI = new calcDlgUI(); | ||
48 | CalcDlgUI->show(); | ||
49 | }; | ||
50 | |||
51 | void Oxygen::slotSettings(){ }; | ||
52 | void Oxygen::slotPSE(){ }; | ||
53 | |||
diff --git a/noncore/apps/checkbook/oxygen.h b/noncore/apps/checkbook/oxygen.h deleted file mode 100644 index 1e923ee..0000000 --- a/noncore/apps/checkbook/oxygen.h +++ b/dev/null | |||
@@ -1,22 +0,0 @@ | |||
1 | |||
2 | #include <qpe/resource.h> | ||
3 | #include <qmainwindow.h> | ||
4 | #include <qtoolbar.h> | ||
5 | #include <qstring.h> | ||
6 | #include <qpopupmenu.h> | ||
7 | |||
8 | class QVBox; | ||
9 | |||
10 | class Oxygen : public QMainWindow | ||
11 | { | ||
12 | Q_OBJECT | ||
13 | |||
14 | public: | ||
15 | Oxygen(); | ||
16 | QVBox *vbox; | ||
17 | private slots: | ||
18 | void slotCalculations(); | ||
19 | void slotSettings(); | ||
20 | void slotPSE(); | ||
21 | void close(); | ||
22 | }; | ||
diff --git a/noncore/apps/checkbook/oxygen.pro b/noncore/apps/checkbook/oxygen.pro deleted file mode 100644 index c5448e7..0000000 --- a/noncore/apps/checkbook/oxygen.pro +++ b/dev/null | |||
@@ -1,20 +0,0 @@ | |||
1 | TEMPLATE= app | ||
2 | CONFIG = qt warn_on release | ||
3 | HEADERS = oxygen.h \ | ||
4 | kmolcalc.h \ | ||
5 | kmolelements.h \ | ||
6 | calcdlgui.h | ||
7 | |||
8 | SOURCES = main.cpp \ | ||
9 | oxygen.cpp \ | ||
10 | kmolcalc.cpp \ | ||
11 | calcdlgui.cpp \ | ||
12 | kmolelements.cpp | ||
13 | INCLUDEPATH += $(OPIEDIR)/include | ||
14 | DEPENDPATH += $(OPIEDIR)/include | ||
15 | LIBS += -lqpe | ||
16 | INTERFACES= calcdlg.ui | ||
17 | TARGET = oxygen | ||
18 | DESTDIR = $(OPIEDIR)/bin | ||
19 | |||
20 | TRANSLATIONS = ../../../i18n/de/oxygen.ts | ||
diff --git a/noncore/apps/checkbook/qcheckbook.cpp b/noncore/apps/checkbook/qcheckbook.cpp new file mode 100644 index 0000000..bb7a5ac --- a/dev/null +++ b/noncore/apps/checkbook/qcheckbook.cpp | |||
@@ -0,0 +1,147 @@ | |||
1 | #include "qcheckbook.h" | ||
2 | |||
3 | #include <qmenubar.h> | ||
4 | #include <qstatusbar.h> | ||
5 | #include <qpopupmenu.h> | ||
6 | #include <qapplication.h> | ||
7 | #include <qfile.h> | ||
8 | #include <qdir.h> | ||
9 | |||
10 | QCheckBook::QCheckBook() | ||
11 | : QMainWindow(), | ||
12 | m_view(), | ||
13 | m_view2(), | ||
14 | m_view3() | ||
15 | { | ||
16 | initCheck = false; | ||
17 | initMM = false; | ||
18 | setCaption("Checking"); | ||
19 | statusBar()->hide(); | ||
20 | menuBar()->hide(); | ||
21 | |||
22 | bar = new QToolBar(this); | ||
23 | bar->setHorizontalStretchable( TRUE ); | ||
24 | |||
25 | addToolBar(bar); | ||
26 | |||
27 | Config config("qcheckbook"); | ||
28 | config.setGroup("Global"); | ||
29 | QString lastCheck = config.readEntry("LastCheckBook", QString("")); | ||
30 | |||
31 | QString checkdirname = QDir::homeDirPath(); | ||
32 | checkdirname.append("/.checkbooks/"); | ||
33 | checkdirname.append(lastCheck); | ||
34 | QFile f(checkdirname); | ||
35 | |||
36 | |||
37 | if (lastCheck.isEmpty() == false && lastCheck != "" && f.exists() == true) | ||
38 | { | ||
39 | newCheck(lastCheck); | ||
40 | } else { | ||
41 | initMainMenus(); | ||
42 | } | ||
43 | |||
44 | setToolBarsMovable( FALSE ); | ||
45 | } | ||
46 | |||
47 | void QCheckBook::newCheck(const QString &filename) | ||
48 | { | ||
49 | if (filename.isEmpty() == false) | ||
50 | { | ||
51 | initCheck = true; | ||
52 | if (m_view != 0) | ||
53 | { | ||
54 | m_view=0; | ||
55 | delete m_view; | ||
56 | } | ||
57 | m_view = new QCheckView(this, filename); | ||
58 | m_view->hide(); | ||
59 | connect(m_view, SIGNAL(reload(const QString &)), this, SLOT(newCheck(const QString &))); | ||
60 | if (initMM == true) | ||
61 | { | ||
62 | delete nb1; | ||
63 | } | ||
64 | bar->clear(); | ||
65 | mbar = new QMenuBar(bar); | ||
66 | mbar->setMargin(0); | ||
67 | |||
68 | QPixmap newIcon = Resource::loadPixmap( "new" ); | ||
69 | nb2 = new QToolButton( newIcon, "New", QString::null, m_view, SLOT(newClicked()), bar, "new item" ); | ||
70 | QPixmap pixmap = Resource::loadPixmap( "pixmap" ); | ||
71 | m_filename = filename; | ||
72 | nb3 = new QToolButton( pixmap, "Graph", QString::null, this, SLOT(newGraph()), bar, "new graph" ); | ||
73 | |||
74 | QPixmap closeIcon = Resource::loadPixmap( "close" ); | ||
75 | nb4 = new QToolButton( closeIcon, "Close", QString::null, this, SLOT(initMainMenus()), bar, "close graph" ); | ||
76 | |||
77 | popup = new QPopupMenu(m_view); | ||
78 | popup->insertItem("&New Entry", m_view, SLOT(newClicked())); | ||
79 | popup->insertItem("&Graph Checkbook", this, SLOT(newGraph())); | ||
80 | popup->insertItem("&Close Checkbook", this, SLOT(initMainMenus())); | ||
81 | popup->insertItem("&Exit", this, SLOT(close())); | ||
82 | mbar->insertItem("&File", popup); | ||
83 | |||
84 | setCentralWidget(m_view); | ||
85 | m_view->show(); | ||
86 | |||
87 | Config config("qcheckbook"); | ||
88 | config.setGroup("Global"); | ||
89 | config.writeEntry("LastCheckBook", filename); | ||
90 | initMM = false; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | void QCheckBook::close() | ||
95 | { | ||
96 | QApplication::exit(); | ||
97 | } | ||
98 | |||
99 | void QCheckBook::newGraph() | ||
100 | { | ||
101 | if (m_filename.isEmpty() == false) | ||
102 | { | ||
103 | m_view2 = new QCheckGraph(m_filename); | ||
104 | m_view2->showMaximized(); | ||
105 | } | ||
106 | } | ||
107 | |||
108 | void QCheckBook::initMainMenus() | ||
109 | { | ||
110 | Config config("qcheckbook"); | ||
111 | config.setGroup("Global"); | ||
112 | config.writeEntry("LastCheckBook", QString("")); | ||
113 | initMM = true; | ||
114 | m_filename = ""; | ||
115 | if (m_view3 != 0) | ||
116 | { | ||
117 | delete m_view3; | ||
118 | } | ||
119 | m_view3 = new QCheckMainMenu(this); | ||
120 | m_view3->hide(); | ||
121 | |||
122 | if (initCheck == true) | ||
123 | { | ||
124 | delete nb2; | ||
125 | delete nb3; | ||
126 | delete nb4; | ||
127 | } | ||
128 | |||
129 | bar->clear(); | ||
130 | |||
131 | mbar = new QMenuBar(bar); | ||
132 | mbar->setMargin(0); | ||
133 | |||
134 | QPixmap newIcon = Resource::loadPixmap( "new" ); | ||
135 | nb1 = new QToolButton( newIcon, "New", QString::null, m_view3, SLOT(newClicked()), bar, "new book" ); | ||
136 | |||
137 | popup = new QPopupMenu(); | ||
138 | popup->insertItem("&New", m_view3, SLOT(newClicked())); | ||
139 | popup->insertItem("&Exit", this, SLOT(close())); | ||
140 | mbar->insertItem("&File", popup); | ||
141 | |||
142 | setCentralWidget(m_view3); | ||
143 | m_view3->show(); | ||
144 | |||
145 | connect(m_view3, SIGNAL(itemSelected(const QString &)), this, SLOT(newCheck(const QString &))); | ||
146 | initCheck = false; | ||
147 | } | ||
diff --git a/noncore/apps/checkbook/qcheckbook.h b/noncore/apps/checkbook/qcheckbook.h new file mode 100644 index 0000000..52c0d40 --- a/dev/null +++ b/noncore/apps/checkbook/qcheckbook.h | |||
@@ -0,0 +1,37 @@ | |||
1 | #include "qcheckview.h" | ||
2 | #include "qcheckgraph.h" | ||
3 | #include "qcheckmainmenu.h" | ||
4 | |||
5 | #include <qpe/resource.h> | ||
6 | #include <qmainwindow.h> | ||
7 | #include <qtoolbar.h> | ||
8 | #include <qstring.h> | ||
9 | #include "config.h" | ||
10 | #include <qpopupmenu.h> | ||
11 | |||
12 | class QCheckBook : public QMainWindow | ||
13 | { | ||
14 | Q_OBJECT | ||
15 | public: | ||
16 | QCheckBook(); | ||
17 | private slots: | ||
18 | void newCheck(const QString &filename); | ||
19 | void newGraph(); | ||
20 | void close(); | ||
21 | void initMainMenus(); | ||
22 | private: | ||
23 | QCheckView *m_view; | ||
24 | QCheckGraph *m_view2; | ||
25 | QCheckMainMenu *m_view3; | ||
26 | QToolBar *bar; | ||
27 | QMenuBar *mbar; | ||
28 | int filemenuid; | ||
29 | QString m_filename; | ||
30 | QToolButton *nb1; | ||
31 | QToolButton *nb2; | ||
32 | QToolButton *nb3; | ||
33 | QToolButton *nb4; | ||
34 | bool initCheck; | ||
35 | bool initMM; | ||
36 | QPopupMenu *popup; | ||
37 | }; | ||
diff --git a/noncore/apps/checkbook/qcheckdetails.cpp b/noncore/apps/checkbook/qcheckdetails.cpp new file mode 100644 index 0000000..19a5e82 --- a/dev/null +++ b/noncore/apps/checkbook/qcheckdetails.cpp | |||
@@ -0,0 +1,119 @@ | |||
1 | #include "qcheckdetails.h" | ||
2 | |||
3 | QCheckDetails::QCheckDetails(int row, int col, const QStringList item) | ||
4 | : QMainWindow(), | ||
5 | m_view() | ||
6 | { | ||
7 | m_view = new QCheckDetailsBase(this); | ||
8 | setCentralWidget(m_view); | ||
9 | |||
10 | m_row = row; | ||
11 | m_col = col; | ||
12 | |||
13 | QToolBar *bar = new QToolBar(this); | ||
14 | bar->setHorizontalStretchable( TRUE ); | ||
15 | |||
16 | QPixmap newIcon = Resource::loadPixmap( "edit" ); | ||
17 | QPixmap trashIcon = Resource::loadPixmap( "trash" ); | ||
18 | QToolButton *nb1 = new QToolButton( newIcon, "Edit", QString::null, this, SLOT(editCheck()), bar, "edit transaction" ); | ||
19 | QToolButton *nb2 = new QToolButton( trashIcon, "Delete", QString::null, this, SLOT(deleteCheck()), bar, "delete transaction" ); | ||
20 | addToolBar(bar); | ||
21 | |||
22 | QString text = ""; | ||
23 | if (item[0] == "true") | ||
24 | { | ||
25 | text.append("<b>Payment</b> to <b>"); | ||
26 | text.append(item[1]); | ||
27 | } | ||
28 | if (item[0] == "false") | ||
29 | { | ||
30 | text.append("<b>Deposit</b> from <b>"); | ||
31 | text.append(item[1]); | ||
32 | } | ||
33 | text.append("</b> on <b>"); | ||
34 | text.append(item[7]); | ||
35 | text.append("</b> for <b>"); | ||
36 | text.append(QString("$" + item[5])); | ||
37 | |||
38 | text.append("</b>, to make your balance <b>$"); | ||
39 | text.append(item[9]); | ||
40 | text.append("</b>."); | ||
41 | |||
42 | text.append("<br><br>"); | ||
43 | text.append("<b>Category: </b>"); | ||
44 | text.append(item[2]); | ||
45 | text.append("<br>"); | ||
46 | text.append("<b>Type: </b>"); | ||
47 | |||
48 | QString type = "No Type"; | ||
49 | if (item[0] == "true") | ||
50 | { | ||
51 | if(item[3] == "0") | ||
52 | { | ||
53 | type = "Debit Charge"; | ||
54 | } | ||
55 | if(item[3] == "1") | ||
56 | { | ||
57 | type = "Written Check"; | ||
58 | } | ||
59 | if(item[3] == "2") | ||
60 | { | ||
61 | type = "Transfer"; | ||
62 | } | ||
63 | if(item[3] == "3") | ||
64 | { | ||
65 | type = "Credit Card"; | ||
66 | } | ||
67 | } | ||
68 | |||
69 | if (item[0] == "false") | ||
70 | { | ||
71 | if(item[3] == "0") | ||
72 | { | ||
73 | type = "Written Check"; | ||
74 | } | ||
75 | if(item[3] == "1") | ||
76 | { | ||
77 | type = "Automatic Payment"; | ||
78 | } | ||
79 | if(item[3] == "2") | ||
80 | { | ||
81 | type = "Transfer"; | ||
82 | } | ||
83 | if(item[3] == "3") | ||
84 | { | ||
85 | type = "Cash"; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | text.append(type); | ||
90 | text.append("<br>"); | ||
91 | if (item[4] != "0") | ||
92 | { | ||
93 | text.append("<b>Check Number: </b>"); | ||
94 | text.append(item[4]); | ||
95 | text.append("<br>"); | ||
96 | } | ||
97 | if (item[6] != ".00") | ||
98 | { | ||
99 | text.append("<b>Extra Fee: </b>"); | ||
100 | text.append(QString("$" + item[6])); | ||
101 | m_view->checkDetails->setText(text); | ||
102 | } | ||
103 | if (item[8] != "") | ||
104 | { | ||
105 | text.append("<br><b>Additional Comments: </b>"); | ||
106 | text.append(item[8]); | ||
107 | } | ||
108 | m_view->checkDetails->setText(text); | ||
109 | } | ||
110 | |||
111 | void QCheckDetails::editCheck() | ||
112 | { | ||
113 | emit editClicked(m_row, m_col); | ||
114 | } | ||
115 | |||
116 | void QCheckDetails::deleteCheck() | ||
117 | { | ||
118 | emit deleteClicked(m_row, m_col); | ||
119 | } | ||
diff --git a/noncore/apps/checkbook/qcheckdetails.h b/noncore/apps/checkbook/qcheckdetails.h new file mode 100644 index 0000000..fe5fe1a --- a/dev/null +++ b/noncore/apps/checkbook/qcheckdetails.h | |||
@@ -0,0 +1,27 @@ | |||
1 | #include "qcheckdetailsbase.h" | ||
2 | #include <qstring.h> | ||
3 | #include <qtextview.h> | ||
4 | #include <qtoolbar.h> | ||
5 | #include <qpe/resource.h> | ||
6 | #include <qpixmap.h> | ||
7 | #include <qdialog.h> | ||
8 | #include <qmainwindow.h> | ||
9 | #include <qtoolbutton.h> | ||
10 | #include <qwidget.h> | ||
11 | |||
12 | class QCheckDetails : public QMainWindow | ||
13 | { | ||
14 | Q_OBJECT | ||
15 | public: | ||
16 | QCheckDetails(int row, int col, const QStringList item); | ||
17 | signals: | ||
18 | void editClicked(int, int); | ||
19 | void deleteClicked(int, int); | ||
20 | public slots: | ||
21 | void editCheck(); | ||
22 | void deleteCheck(); | ||
23 | private: | ||
24 | int m_row; | ||
25 | int m_col; | ||
26 | QCheckDetailsBase *m_view; | ||
27 | }; | ||
diff --git a/noncore/apps/checkbook/qcheckdetailsbase.ui b/noncore/apps/checkbook/qcheckdetailsbase.ui new file mode 100644 index 0000000..d94ba5e --- a/dev/null +++ b/noncore/apps/checkbook/qcheckdetailsbase.ui | |||
@@ -0,0 +1,62 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>QCheckDetailsBase</class> | ||
3 | <widget> | ||
4 | <class>QWidget</class> | ||
5 | <property stdset="1"> | ||
6 | <name>name</name> | ||
7 | <cstring>QCheckDetailsBase</cstring> | ||
8 | </property> | ||
9 | <property stdset="1"> | ||
10 | <name>geometry</name> | ||
11 | <rect> | ||
12 | <x>0</x> | ||
13 | <y>0</y> | ||
14 | <width>240</width> | ||
15 | <height>265</height> | ||
16 | </rect> | ||
17 | </property> | ||
18 | <property stdset="1"> | ||
19 | <name>caption</name> | ||
20 | <string>Transaction Details</string> | ||
21 | </property> | ||
22 | <grid> | ||
23 | <property stdset="1"> | ||
24 | <name>margin</name> | ||
25 | <number>4</number> | ||
26 | </property> | ||
27 | <property stdset="1"> | ||
28 | <name>spacing</name> | ||
29 | <number>0</number> | ||
30 | </property> | ||
31 | <widget row="0" column="0" > | ||
32 | <class>QTextView</class> | ||
33 | <property stdset="1"> | ||
34 | <name>name</name> | ||
35 | <cstring>checkDetails</cstring> | ||
36 | </property> | ||
37 | </widget> | ||
38 | </grid> | ||
39 | </widget> | ||
40 | <customwidgets> | ||
41 | <customwidget> | ||
42 | <class>QWidget</class> | ||
43 | <header location="global">qwidget.h</header> | ||
44 | <sizehint> | ||
45 | <width>-1</width> | ||
46 | <height>-1</height> | ||
47 | </sizehint> | ||
48 | <container>0</container> | ||
49 | <sizepolicy> | ||
50 | <hordata>5</hordata> | ||
51 | <verdata>5</verdata> | ||
52 | </sizepolicy> | ||
53 | <pixmap>image0</pixmap> | ||
54 | </customwidget> | ||
55 | </customwidgets> | ||
56 | <images> | ||
57 | <image> | ||
58 | <name>image0</name> | ||
59 | <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data> | ||
60 | </image> | ||
61 | </images> | ||
62 | </UI> | ||
diff --git a/noncore/apps/checkbook/qcheckentry.cpp b/noncore/apps/checkbook/qcheckentry.cpp new file mode 100644 index 0000000..2e8da1c --- a/dev/null +++ b/noncore/apps/checkbook/qcheckentry.cpp | |||
@@ -0,0 +1,256 @@ | |||
1 | #include "qcheckentry.h" | ||
2 | |||
3 | QCheckEntry::QCheckEntry() | ||
4 | : QCheckEntryBase() | ||
5 | { | ||
6 | connect(transAmount, SIGNAL(textChanged(const QString &)), this, SLOT(amountChanged(const QString &))); | ||
7 | connect(transFee, SIGNAL(textChanged(const QString &)), this, SLOT(transFeeChanged(const QString &))); | ||
8 | connect(payment, SIGNAL(clicked()), this, SLOT(paymentClicked())); | ||
9 | connect(deposit, SIGNAL(clicked()), this, SLOT(depositClicked())); | ||
10 | |||
11 | QString todaysdate = QString::number(QDate::currentDate().month()); | ||
12 | todaysdate.append("/"); | ||
13 | todaysdate.append(QString::number(QDate::currentDate().day())); | ||
14 | todaysdate.append("/"); | ||
15 | todaysdate.append(QString::number(QDate::currentDate().year())); | ||
16 | dateEdit->setText(todaysdate); | ||
17 | |||
18 | descriptionCombo->setFocus(); | ||
19 | |||
20 | dateEdit->setValidChars("0123456789./-"); | ||
21 | dateEdit->setMaxLength(10); | ||
22 | |||
23 | descriptionCombo->lineEdit()->setMaxLength(30); | ||
24 | |||
25 | checkNumber->setValidChars("0123456789-"); | ||
26 | checkNumber->setMaxLength(10); | ||
27 | |||
28 | transAmount->setValidChars("0123456789."); | ||
29 | |||
30 | transFee->setMaxLength(5); | ||
31 | transFee->setValidChars("0123456789."); | ||
32 | setTabOrder(transType,checkNumber); | ||
33 | setTabOrder(checkNumber,transAmount); | ||
34 | setTabOrder(transAmount,transFee); | ||
35 | setTabOrder(transFee,dateEdit); | ||
36 | setTabOrder(dateEdit, additionalNotes ); | ||
37 | } | ||
38 | |||
39 | void QCheckEntry::paymentClicked() | ||
40 | { | ||
41 | cmbCategory->clear(); | ||
42 | cmbCategory->insertItem( tr( "Automobile" ) ); | ||
43 | cmbCategory->insertItem( tr( "Bills" ) ); | ||
44 | cmbCategory->insertItem( tr( "CDs" ) ); | ||
45 | cmbCategory->insertItem( tr( "Clothing" ) ); | ||
46 | cmbCategory->insertItem( tr( "Computer" ) ); | ||
47 | cmbCategory->insertItem( tr( "DVDs" ) ); | ||
48 | cmbCategory->insertItem( tr( "Eletronics" ) ); | ||
49 | cmbCategory->insertItem( tr( "Entertainment" ) ); | ||
50 | cmbCategory->insertItem( tr( "Food" ) ); | ||
51 | cmbCategory->insertItem( tr( "Gasoline" ) ); | ||
52 | cmbCategory->insertItem( tr( "Misc" ) ); | ||
53 | cmbCategory->insertItem( tr( "Movies" ) ); | ||
54 | cmbCategory->insertItem( tr( "Rent" ) ); | ||
55 | cmbCategory->insertItem( tr( "Travel" ) ); | ||
56 | cmbCategory->setCurrentItem( 0 ); | ||
57 | transType->clear(); | ||
58 | transType->insertItem( tr( "Debit Charge" ) ); | ||
59 | transType->insertItem( tr( "Written Check" ) ); | ||
60 | transType->insertItem( tr( "Transfer" ) ); | ||
61 | transType->insertItem( tr( "Credit Card" ) ); | ||
62 | } | ||
63 | |||
64 | void QCheckEntry::depositClicked() | ||
65 | { | ||
66 | cmbCategory->clear(); | ||
67 | cmbCategory->insertItem( tr( "Work" ) ); | ||
68 | cmbCategory->insertItem( tr( "Family Member" ) ); | ||
69 | cmbCategory->insertItem( tr( "Misc. Credit" ) ); | ||
70 | cmbCategory->setCurrentItem( 0 ); | ||
71 | transType->clear(); | ||
72 | transType->insertItem( tr( "Written Check" ) ); | ||
73 | transType->insertItem( tr( "Automatic Payment" ) ); | ||
74 | transType->insertItem( tr( "Transfer" ) ); | ||
75 | transType->insertItem( tr( "Cash" ) ); | ||
76 | } | ||
77 | |||
78 | QStringList QCheckEntry::popupEntry(const QStringList &originaldata) | ||
79 | { | ||
80 | QCheckEntry qce; | ||
81 | |||
82 | // This is how the list looks: | ||
83 | // 0: true or false, true == payment, false == deposit | ||
84 | // 1: description of the transaction | ||
85 | // 2: category name | ||
86 | // 3: transaction type (stores the integer value of the index of the combobox) | ||
87 | // 4: check number of the transaction (if any) | ||
88 | // 5: transaction amount | ||
89 | // 6: transaction fee (e.g. service charge, or ATM charge). | ||
90 | // 7: date of the transaction | ||
91 | // 8: additional notes | ||
92 | // 9: recently used descriptions | ||
93 | if (originaldata.count() > 1) | ||
94 | { | ||
95 | if (originaldata[0] == "true") | ||
96 | { | ||
97 | qce.payment->setChecked(true); | ||
98 | qce.paymentClicked(); | ||
99 | } else { | ||
100 | if (originaldata[0] == "false") | ||
101 | { | ||
102 | qce.deposit->setChecked(true); | ||
103 | qce.depositClicked(); | ||
104 | } | ||
105 | } | ||
106 | qce.descriptionCombo->lineEdit()->setText(originaldata[1]); | ||
107 | qce.cmbCategory->lineEdit()->setText(originaldata[2]); | ||
108 | qce.transType->setCurrentItem(originaldata[3].toInt()); | ||
109 | qce.checkNumber->setText(originaldata[4]); | ||
110 | qce.transAmount->setText(originaldata[5]); | ||
111 | qce.transFee->setText(originaldata[6]); | ||
112 | qce.dateEdit->setText(originaldata[7]); | ||
113 | qce.additionalNotes->setText(originaldata[8]); | ||
114 | QStringList recentlist; | ||
115 | if (!originaldata[9].isEmpty()) | ||
116 | { | ||
117 | recentlist = QStringList::split(',', originaldata[9], false); | ||
118 | } | ||
119 | if (!recentlist.isEmpty()) | ||
120 | { | ||
121 | qce.descriptionCombo->insertStringList(recentlist); | ||
122 | } | ||
123 | } else { | ||
124 | QStringList recentlist; | ||
125 | if (!originaldata[0].isEmpty()) | ||
126 | { | ||
127 | recentlist = QStringList::split(',', originaldata[0], false); | ||
128 | } | ||
129 | if (!recentlist.isEmpty()) | ||
130 | { | ||
131 | qce.descriptionCombo->insertStringList(recentlist); | ||
132 | } | ||
133 | } | ||
134 | |||
135 | qce.setWFlags(Qt::WType_Modal); | ||
136 | qce.showMaximized(); | ||
137 | |||
138 | qce.descriptionCombo->lineEdit()->clear(); | ||
139 | |||
140 | if (qce.exec() == QDialog::Accepted) | ||
141 | { | ||
142 | // Validate that the user has inputed a valid dollar amount | ||
143 | if (qce.transFee->text().contains('.') == 0) | ||
144 | { | ||
145 | QString text = qce.transFee->text(); | ||
146 | text.append(".00"); | ||
147 | qce.transFee->setText(text); | ||
148 | } else { | ||
149 | QString tmp = qce.transFee->text(); | ||
150 | if (tmp.mid(tmp.find('.'), tmp.length()).length() == 1) | ||
151 | { | ||
152 | tmp.append("00"); | ||
153 | qce.transFee->setText(tmp); | ||
154 | } else { | ||
155 | if (tmp.mid(tmp.find('.'), tmp.length()).length() == 2) | ||
156 | { | ||
157 | tmp.append("0"); | ||
158 | qce.transFee->setText(tmp); | ||
159 | } | ||
160 | } | ||
161 | } | ||
162 | if (qce.transAmount->text().contains('.') == 0) | ||
163 | { | ||
164 | QString text = qce.transAmount->text(); | ||
165 | text.append(".00"); | ||
166 | qce.transAmount->setText(text); | ||
167 | } else { | ||
168 | QString tmp = qce.transAmount->text(); | ||
169 | if (tmp.mid(tmp.find('.'), tmp.length()).length() == 1) | ||
170 | { | ||
171 | tmp.append("00"); | ||
172 | qce.transAmount->setText(tmp); | ||
173 | } else { | ||
174 | if (tmp.mid(tmp.find('.'), tmp.length()).length() == 2) | ||
175 | { | ||
176 | tmp.append("0"); | ||
177 | qce.transAmount->setText(tmp); | ||
178 | } | ||
179 | } | ||
180 | } | ||
181 | |||
182 | QString recent; | ||
183 | if (qce.descriptionCombo->count() != 0) | ||
184 | { | ||
185 | QStringList recentlist = QStringList::split(',', originaldata[9], false); | ||
186 | if (recentlist.count() >= 10) | ||
187 | { | ||
188 | recentlist.remove(recentlist.last()); | ||
189 | } | ||
190 | recentlist.prepend(qce.descriptionCombo->lineEdit()->text()); | ||
191 | recent = recentlist.join(","); | ||
192 | } else { | ||
193 | recent = qce.descriptionCombo->lineEdit()->text(); | ||
194 | } | ||
195 | |||
196 | QString checkNumberString = qce.checkNumber->text(); | ||
197 | if (checkNumberString.isEmpty() == true) | ||
198 | { | ||
199 | checkNumberString = "0"; | ||
200 | } | ||
201 | |||
202 | QString paymentChecked = "true"; | ||
203 | if (qce.payment->isChecked() == false) | ||
204 | { | ||
205 | paymentChecked = "false"; | ||
206 | } | ||
207 | QStringList returnvalue; | ||
208 | returnvalue << paymentChecked << qce.descriptionCombo->lineEdit()->text() << qce.cmbCategory->lineEdit()->text() << QString::number(qce.transType->currentItem()) << checkNumberString << qce.transAmount->text() << qce.transFee->text() << qce.dateEdit->text() << qce.additionalNotes->text() << recent; | ||
209 | return returnvalue; | ||
210 | } else { | ||
211 | QStringList blank; | ||
212 | return blank; | ||
213 | } | ||
214 | } | ||
215 | |||
216 | void QCheckEntry::transFeeChanged(const QString &input) | ||
217 | { | ||
218 | QString tmpinput = input; | ||
219 | if (tmpinput.contains('.') > 1) | ||
220 | { | ||
221 | int first = tmpinput.find('.'); | ||
222 | tmpinput = tmpinput.remove(tmpinput.find('.', (first + 1)), 1); | ||
223 | } | ||
224 | if (tmpinput.contains(QRegExp("\\.[0-9][0-9]{2}$")) >= 1) | ||
225 | { | ||
226 | tmpinput = tmpinput.remove((tmpinput.length() - 1), 1); | ||
227 | } | ||
228 | transFee->setText(tmpinput); | ||
229 | } | ||
230 | |||
231 | void QCheckEntry::amountChanged(const QString &input) | ||
232 | { | ||
233 | QString tmpinput = input; | ||
234 | if (tmpinput.contains('.') > 1) | ||
235 | { | ||
236 | int first = tmpinput.find('.'); | ||
237 | tmpinput = tmpinput.remove(tmpinput.find('.', (first + 1)), 1); | ||
238 | } | ||
239 | if (tmpinput.contains(QRegExp("\\.[0-9][0-9]{2}$")) >= 1) | ||
240 | { | ||
241 | tmpinput = tmpinput.remove((tmpinput.length() - 1), 1); | ||
242 | } | ||
243 | transAmount->setText(tmpinput); | ||
244 | } | ||
245 | |||
246 | void QCheckEntry::accept() | ||
247 | { | ||
248 | // Does the description combo not have any text in it? Do something if it doesn't! | ||
249 | if (descriptionCombo->lineEdit()->text().isEmpty() == true) | ||
250 | { | ||
251 | QMessageBox::critical(this, "Field Missing.", "<qt>You didn't enter a description for this transaction. Please fill out the \"Transaction Description\" field and try again.</qt>"); | ||
252 | descriptionCombo->setFocus(); | ||
253 | return; | ||
254 | } | ||
255 | QDialog::accept(); | ||
256 | } | ||
diff --git a/noncore/apps/checkbook/qcheckentry.h b/noncore/apps/checkbook/qcheckentry.h new file mode 100644 index 0000000..f361bbf --- a/dev/null +++ b/noncore/apps/checkbook/qcheckentry.h | |||
@@ -0,0 +1,31 @@ | |||
1 | #include <qstring.h> | ||
2 | #include <qcombobox.h> | ||
3 | #include "qrestrictedline.h" | ||
4 | #include <qcombobox.h> | ||
5 | #include <qstringlist.h> | ||
6 | #include <qlabel.h> | ||
7 | #include <qmultilineedit.h> | ||
8 | #include "qcheckentrybase.h" | ||
9 | #include <qdialog.h> | ||
10 | #include <qregexp.h> | ||
11 | #include <qmessagebox.h> | ||
12 | #include <qwidget.h> | ||
13 | #include <qevent.h> | ||
14 | #include <qdatetime.h> | ||
15 | #include <qradiobutton.h> | ||
16 | #include "config.h" | ||
17 | |||
18 | class QCheckEntry : public QCheckEntryBase | ||
19 | { | ||
20 | Q_OBJECT | ||
21 | public: | ||
22 | QCheckEntry(); | ||
23 | static QStringList popupEntry(const QStringList &originaldata); | ||
24 | private slots: | ||
25 | void amountChanged(const QString &); | ||
26 | void transFeeChanged(const QString &); | ||
27 | void paymentClicked(); | ||
28 | void depositClicked(); | ||
29 | protected slots: | ||
30 | virtual void accept(); | ||
31 | }; | ||
diff --git a/noncore/apps/checkbook/qcheckentrybase.ui b/noncore/apps/checkbook/qcheckentrybase.ui new file mode 100644 index 0000000..efc35ff --- a/dev/null +++ b/noncore/apps/checkbook/qcheckentrybase.ui | |||
@@ -0,0 +1,610 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>QCheckEntryBase</class> | ||
3 | <widget> | ||
4 | <class>QDialog</class> | ||
5 | <property stdset="1"> | ||
6 | <name>name</name> | ||
7 | <cstring>QCheckEntryBase</cstring> | ||
8 | </property> | ||
9 | <property stdset="1"> | ||
10 | <name>geometry</name> | ||
11 | <rect> | ||
12 | <x>0</x> | ||
13 | <y>0</y> | ||
14 | <width>224</width> | ||
15 | <height>291</height> | ||
16 | </rect> | ||
17 | </property> | ||
18 | <property stdset="1"> | ||
19 | <name>caption</name> | ||
20 | <string>Account Transaction</string> | ||
21 | </property> | ||
22 | <property> | ||
23 | <name>layoutMargin</name> | ||
24 | </property> | ||
25 | <property> | ||
26 | <name>layoutSpacing</name> | ||
27 | </property> | ||
28 | <grid> | ||
29 | <property stdset="1"> | ||
30 | <name>margin</name> | ||
31 | <number>5</number> | ||
32 | </property> | ||
33 | <property stdset="1"> | ||
34 | <name>spacing</name> | ||
35 | <number>2</number> | ||
36 | </property> | ||
37 | <spacer row="7" column="8" rowspan="1" colspan="4" > | ||
38 | <property> | ||
39 | <name>name</name> | ||
40 | <cstring>Spacer3</cstring> | ||
41 | </property> | ||
42 | <property stdset="1"> | ||
43 | <name>orientation</name> | ||
44 | <enum>Horizontal</enum> | ||
45 | </property> | ||
46 | <property stdset="1"> | ||
47 | <name>sizeType</name> | ||
48 | <enum>Expanding</enum> | ||
49 | </property> | ||
50 | <property> | ||
51 | <name>sizeHint</name> | ||
52 | <size> | ||
53 | <width>20</width> | ||
54 | <height>20</height> | ||
55 | </size> | ||
56 | </property> | ||
57 | </spacer> | ||
58 | <spacer row="3" column="1" rowspan="1" colspan="4" > | ||
59 | <property> | ||
60 | <name>name</name> | ||
61 | <cstring>Spacer5</cstring> | ||
62 | </property> | ||
63 | <property stdset="1"> | ||
64 | <name>orientation</name> | ||
65 | <enum>Horizontal</enum> | ||
66 | </property> | ||
67 | <property stdset="1"> | ||
68 | <name>sizeType</name> | ||
69 | <enum>Expanding</enum> | ||
70 | </property> | ||
71 | <property> | ||
72 | <name>sizeHint</name> | ||
73 | <size> | ||
74 | <width>20</width> | ||
75 | <height>20</height> | ||
76 | </size> | ||
77 | </property> | ||
78 | </spacer> | ||
79 | <widget row="5" column="5" > | ||
80 | <class>QLabel</class> | ||
81 | <property stdset="1"> | ||
82 | <name>name</name> | ||
83 | <cstring>TextLabel6</cstring> | ||
84 | </property> | ||
85 | <property stdset="1"> | ||
86 | <name>font</name> | ||
87 | <font> | ||
88 | <family>adobe-helvetica</family> | ||
89 | <bold>1</bold> | ||
90 | </font> | ||
91 | </property> | ||
92 | <property stdset="1"> | ||
93 | <name>text</name> | ||
94 | <string>$</string> | ||
95 | </property> | ||
96 | </widget> | ||
97 | <spacer row="4" column="6" > | ||
98 | <property> | ||
99 | <name>name</name> | ||
100 | <cstring>Spacer8</cstring> | ||
101 | </property> | ||
102 | <property stdset="1"> | ||
103 | <name>orientation</name> | ||
104 | <enum>Horizontal</enum> | ||
105 | </property> | ||
106 | <property stdset="1"> | ||
107 | <name>sizeType</name> | ||
108 | <enum>Expanding</enum> | ||
109 | </property> | ||
110 | <property> | ||
111 | <name>sizeHint</name> | ||
112 | <size> | ||
113 | <width>20</width> | ||
114 | <height>20</height> | ||
115 | </size> | ||
116 | </property> | ||
117 | </spacer> | ||
118 | <widget row="2" column="0" rowspan="1" colspan="3" > | ||
119 | <class>QLabel</class> | ||
120 | <property stdset="1"> | ||
121 | <name>name</name> | ||
122 | <cstring>TextLabel2</cstring> | ||
123 | </property> | ||
124 | <property stdset="1"> | ||
125 | <name>text</name> | ||
126 | <string>Category:</string> | ||
127 | </property> | ||
128 | </widget> | ||
129 | <spacer row="5" column="2" rowspan="1" colspan="3" > | ||
130 | <property> | ||
131 | <name>name</name> | ||
132 | <cstring>Spacer7</cstring> | ||
133 | </property> | ||
134 | <property stdset="1"> | ||
135 | <name>orientation</name> | ||
136 | <enum>Horizontal</enum> | ||
137 | </property> | ||
138 | <property stdset="1"> | ||
139 | <name>sizeType</name> | ||
140 | <enum>Expanding</enum> | ||
141 | </property> | ||
142 | <property> | ||
143 | <name>sizeHint</name> | ||
144 | <size> | ||
145 | <width>20</width> | ||
146 | <height>20</height> | ||
147 | </size> | ||
148 | </property> | ||
149 | </spacer> | ||
150 | <spacer row="5" column="11" > | ||
151 | <property> | ||
152 | <name>name</name> | ||
153 | <cstring>Spacer4</cstring> | ||
154 | </property> | ||
155 | <property stdset="1"> | ||
156 | <name>orientation</name> | ||
157 | <enum>Horizontal</enum> | ||
158 | </property> | ||
159 | <property stdset="1"> | ||
160 | <name>sizeType</name> | ||
161 | <enum>Expanding</enum> | ||
162 | </property> | ||
163 | <property> | ||
164 | <name>sizeHint</name> | ||
165 | <size> | ||
166 | <width>20</width> | ||
167 | <height>20</height> | ||
168 | </size> | ||
169 | </property> | ||
170 | </spacer> | ||
171 | <spacer row="2" column="3" rowspan="1" colspan="2" > | ||
172 | <property> | ||
173 | <name>name</name> | ||
174 | <cstring>Spacer6</cstring> | ||
175 | </property> | ||
176 | <property stdset="1"> | ||
177 | <name>orientation</name> | ||
178 | <enum>Horizontal</enum> | ||
179 | </property> | ||
180 | <property stdset="1"> | ||
181 | <name>sizeType</name> | ||
182 | <enum>Expanding</enum> | ||
183 | </property> | ||
184 | <property> | ||
185 | <name>sizeHint</name> | ||
186 | <size> | ||
187 | <width>20</width> | ||
188 | <height>20</height> | ||
189 | </size> | ||
190 | </property> | ||
191 | </spacer> | ||
192 | <widget row="5" column="6" rowspan="1" colspan="5" > | ||
193 | <class>QRestrictedLine</class> | ||
194 | <property stdset="1"> | ||
195 | <name>name</name> | ||
196 | <cstring>transAmount</cstring> | ||
197 | </property> | ||
198 | </widget> | ||
199 | <widget row="1" column="0" rowspan="1" colspan="5" > | ||
200 | <class>QLabel</class> | ||
201 | <property stdset="1"> | ||
202 | <name>name</name> | ||
203 | <cstring>TextLabel1</cstring> | ||
204 | </property> | ||
205 | <property stdset="1"> | ||
206 | <name>text</name> | ||
207 | <string>Description:</string> | ||
208 | </property> | ||
209 | </widget> | ||
210 | <widget row="3" column="0" > | ||
211 | <class>QLabel</class> | ||
212 | <property stdset="1"> | ||
213 | <name>name</name> | ||
214 | <cstring>TextLabel3</cstring> | ||
215 | </property> | ||
216 | <property stdset="1"> | ||
217 | <name>text</name> | ||
218 | <string>Type:</string> | ||
219 | </property> | ||
220 | </widget> | ||
221 | <widget row="5" column="0" rowspan="1" colspan="2" > | ||
222 | <class>QLabel</class> | ||
223 | <property stdset="1"> | ||
224 | <name>name</name> | ||
225 | <cstring>TextLabel5</cstring> | ||
226 | </property> | ||
227 | <property stdset="1"> | ||
228 | <name>text</name> | ||
229 | <string>Amount:</string> | ||
230 | </property> | ||
231 | </widget> | ||
232 | <widget row="2" column="5" rowspan="1" colspan="7" > | ||
233 | <class>QComboBox</class> | ||
234 | <item> | ||
235 | <property> | ||
236 | <name>text</name> | ||
237 | <string>Automobile</string> | ||
238 | </property> | ||
239 | </item> | ||
240 | <item> | ||
241 | <property> | ||
242 | <name>text</name> | ||
243 | <string>Bills</string> | ||
244 | </property> | ||
245 | </item> | ||
246 | <item> | ||
247 | <property> | ||
248 | <name>text</name> | ||
249 | <string>CDs</string> | ||
250 | </property> | ||
251 | </item> | ||
252 | <item> | ||
253 | <property> | ||
254 | <name>text</name> | ||
255 | <string>Clothing</string> | ||
256 | </property> | ||
257 | </item> | ||
258 | <item> | ||
259 | <property> | ||
260 | <name>text</name> | ||
261 | <string>Computer</string> | ||
262 | </property> | ||
263 | </item> | ||
264 | <item> | ||
265 | <property> | ||
266 | <name>text</name> | ||
267 | <string>DVDs</string> | ||
268 | </property> | ||
269 | </item> | ||
270 | <item> | ||
271 | <property> | ||
272 | <name>text</name> | ||
273 | <string>Eletronics</string> | ||
274 | </property> | ||
275 | </item> | ||
276 | <item> | ||
277 | <property> | ||
278 | <name>text</name> | ||
279 | <string>Entertainment</string> | ||
280 | </property> | ||
281 | </item> | ||
282 | <item> | ||
283 | <property> | ||
284 | <name>text</name> | ||
285 | <string>Food</string> | ||
286 | </property> | ||
287 | </item> | ||
288 | <item> | ||
289 | <property> | ||
290 | <name>text</name> | ||
291 | <string>Gasoline</string> | ||
292 | </property> | ||
293 | </item> | ||
294 | <item> | ||
295 | <property> | ||
296 | <name>text</name> | ||
297 | <string>Misc</string> | ||
298 | </property> | ||
299 | </item> | ||
300 | <item> | ||
301 | <property> | ||
302 | <name>text</name> | ||
303 | <string>Movies</string> | ||
304 | </property> | ||
305 | </item> | ||
306 | <item> | ||
307 | <property> | ||
308 | <name>text</name> | ||
309 | <string>Rent</string> | ||
310 | </property> | ||
311 | </item> | ||
312 | <item> | ||
313 | <property> | ||
314 | <name>text</name> | ||
315 | <string>Travel</string> | ||
316 | </property> | ||
317 | </item> | ||
318 | <property stdset="1"> | ||
319 | <name>name</name> | ||
320 | <cstring>cmbCategory</cstring> | ||
321 | </property> | ||
322 | <property stdset="1"> | ||
323 | <name>editable</name> | ||
324 | <bool>true</bool> | ||
325 | </property> | ||
326 | <property stdset="1"> | ||
327 | <name>currentItem</name> | ||
328 | <number>0</number> | ||
329 | </property> | ||
330 | <property stdset="1"> | ||
331 | <name>autoCompletion</name> | ||
332 | <bool>true</bool> | ||
333 | </property> | ||
334 | <property stdset="1"> | ||
335 | <name>duplicatesEnabled</name> | ||
336 | <bool>false</bool> | ||
337 | </property> | ||
338 | </widget> | ||
339 | <widget row="4" column="0" rowspan="1" colspan="6" > | ||
340 | <class>QLabel</class> | ||
341 | <property stdset="1"> | ||
342 | <name>name</name> | ||
343 | <cstring>TextLabel4</cstring> | ||
344 | </property> | ||
345 | <property stdset="1"> | ||
346 | <name>text</name> | ||
347 | <string>Check Number:</string> | ||
348 | </property> | ||
349 | </widget> | ||
350 | <widget row="6" column="4" > | ||
351 | <class>QLabel</class> | ||
352 | <property stdset="1"> | ||
353 | <name>name</name> | ||
354 | <cstring>TextLabel6_2</cstring> | ||
355 | </property> | ||
356 | <property stdset="1"> | ||
357 | <name>font</name> | ||
358 | <font> | ||
359 | <family>adobe-helvetica</family> | ||
360 | <bold>1</bold> | ||
361 | </font> | ||
362 | </property> | ||
363 | <property stdset="1"> | ||
364 | <name>text</name> | ||
365 | <string>$</string> | ||
366 | </property> | ||
367 | </widget> | ||
368 | <widget row="6" column="5" rowspan="1" colspan="4" > | ||
369 | <class>QRestrictedLine</class> | ||
370 | <property stdset="1"> | ||
371 | <name>name</name> | ||
372 | <cstring>transFee</cstring> | ||
373 | </property> | ||
374 | </widget> | ||
375 | <widget row="6" column="0" rowspan="1" colspan="4" > | ||
376 | <class>QLabel</class> | ||
377 | <property stdset="1"> | ||
378 | <name>name</name> | ||
379 | <cstring>TextLabel7</cstring> | ||
380 | </property> | ||
381 | <property stdset="1"> | ||
382 | <name>text</name> | ||
383 | <string>Extra Fee:</string> | ||
384 | </property> | ||
385 | </widget> | ||
386 | <widget row="7" column="0" rowspan="1" colspan="8" > | ||
387 | <class>QLabel</class> | ||
388 | <property stdset="1"> | ||
389 | <name>name</name> | ||
390 | <cstring>TextLabel8</cstring> | ||
391 | </property> | ||
392 | <property stdset="1"> | ||
393 | <name>text</name> | ||
394 | <string>Additional Notes:</string> | ||
395 | </property> | ||
396 | </widget> | ||
397 | <widget row="1" column="5" rowspan="1" colspan="7" > | ||
398 | <class>QComboBox</class> | ||
399 | <property stdset="1"> | ||
400 | <name>name</name> | ||
401 | <cstring>descriptionCombo</cstring> | ||
402 | </property> | ||
403 | <property stdset="1"> | ||
404 | <name>editable</name> | ||
405 | <bool>true</bool> | ||
406 | </property> | ||
407 | <property stdset="1"> | ||
408 | <name>maxCount</name> | ||
409 | <number>10</number> | ||
410 | </property> | ||
411 | <property stdset="1"> | ||
412 | <name>insertionPolicy</name> | ||
413 | <enum>BeforeCurrent</enum> | ||
414 | </property> | ||
415 | <property stdset="1"> | ||
416 | <name>autoCompletion</name> | ||
417 | <bool>true</bool> | ||
418 | </property> | ||
419 | <property stdset="1"> | ||
420 | <name>duplicatesEnabled</name> | ||
421 | <bool>false</bool> | ||
422 | </property> | ||
423 | </widget> | ||
424 | <widget row="6" column="9" > | ||
425 | <class>QLabel</class> | ||
426 | <property stdset="1"> | ||
427 | <name>name</name> | ||
428 | <cstring>TextLabel9</cstring> | ||
429 | </property> | ||
430 | <property stdset="1"> | ||
431 | <name>minimumSize</name> | ||
432 | <size> | ||
433 | <width>0</width> | ||
434 | <height>0</height> | ||
435 | </size> | ||
436 | </property> | ||
437 | <property stdset="1"> | ||
438 | <name>maximumSize</name> | ||
439 | <size> | ||
440 | <width>32767</width> | ||
441 | <height>32767</height> | ||
442 | </size> | ||
443 | </property> | ||
444 | <property stdset="1"> | ||
445 | <name>caption</name> | ||
446 | <string></string> | ||
447 | </property> | ||
448 | <property stdset="1"> | ||
449 | <name>text</name> | ||
450 | <string>Date:</string> | ||
451 | </property> | ||
452 | </widget> | ||
453 | <widget row="6" column="10" rowspan="1" colspan="2" > | ||
454 | <class>QRestrictedLine</class> | ||
455 | <property stdset="1"> | ||
456 | <name>name</name> | ||
457 | <cstring>dateEdit</cstring> | ||
458 | </property> | ||
459 | </widget> | ||
460 | <widget row="4" column="7" rowspan="1" colspan="5" > | ||
461 | <class>QRestrictedLine</class> | ||
462 | <property stdset="1"> | ||
463 | <name>name</name> | ||
464 | <cstring>checkNumber</cstring> | ||
465 | </property> | ||
466 | </widget> | ||
467 | <widget row="3" column="5" rowspan="1" colspan="7" > | ||
468 | <class>QComboBox</class> | ||
469 | <item> | ||
470 | <property> | ||
471 | <name>text</name> | ||
472 | <string>Debit Charge</string> | ||
473 | </property> | ||
474 | </item> | ||
475 | <item> | ||
476 | <property> | ||
477 | <name>text</name> | ||
478 | <string>Written Check</string> | ||
479 | </property> | ||
480 | </item> | ||
481 | <item> | ||
482 | <property> | ||
483 | <name>text</name> | ||
484 | <string>Transfer</string> | ||
485 | </property> | ||
486 | </item> | ||
487 | <item> | ||
488 | <property> | ||
489 | <name>text</name> | ||
490 | <string>Credit Card</string> | ||
491 | </property> | ||
492 | </item> | ||
493 | <property stdset="1"> | ||
494 | <name>name</name> | ||
495 | <cstring>transType</cstring> | ||
496 | </property> | ||
497 | </widget> | ||
498 | <widget row="8" column="0" rowspan="1" colspan="12" > | ||
499 | <class>QMultiLineEdit</class> | ||
500 | <property stdset="1"> | ||
501 | <name>name</name> | ||
502 | <cstring>additionalNotes</cstring> | ||
503 | </property> | ||
504 | </widget> | ||
505 | <widget row="0" column="0" rowspan="1" colspan="12" > | ||
506 | <class>QButtonGroup</class> | ||
507 | <property stdset="1"> | ||
508 | <name>name</name> | ||
509 | <cstring>ButtonGroup3</cstring> | ||
510 | </property> | ||
511 | <property stdset="1"> | ||
512 | <name>sizePolicy</name> | ||
513 | <sizepolicy> | ||
514 | <hsizetype>7</hsizetype> | ||
515 | <vsizetype>7</vsizetype> | ||
516 | </sizepolicy> | ||
517 | </property> | ||
518 | <property stdset="1"> | ||
519 | <name>title</name> | ||
520 | <string></string> | ||
521 | </property> | ||
522 | <property> | ||
523 | <name>layoutMargin</name> | ||
524 | </property> | ||
525 | <property> | ||
526 | <name>layoutSpacing</name> | ||
527 | </property> | ||
528 | <grid> | ||
529 | <property stdset="1"> | ||
530 | <name>margin</name> | ||
531 | <number>4</number> | ||
532 | </property> | ||
533 | <property stdset="1"> | ||
534 | <name>spacing</name> | ||
535 | <number>0</number> | ||
536 | </property> | ||
537 | <widget row="0" column="1" > | ||
538 | <class>QRadioButton</class> | ||
539 | <property stdset="1"> | ||
540 | <name>name</name> | ||
541 | <cstring>deposit</cstring> | ||
542 | </property> | ||
543 | <property stdset="1"> | ||
544 | <name>sizePolicy</name> | ||
545 | <sizepolicy> | ||
546 | <hsizetype>1</hsizetype> | ||
547 | <vsizetype>1</vsizetype> | ||
548 | </sizepolicy> | ||
549 | </property> | ||
550 | <property stdset="1"> | ||
551 | <name>text</name> | ||
552 | <string>Deposit</string> | ||
553 | </property> | ||
554 | </widget> | ||
555 | <widget row="0" column="0" > | ||
556 | <class>QRadioButton</class> | ||
557 | <property stdset="1"> | ||
558 | <name>name</name> | ||
559 | <cstring>payment</cstring> | ||
560 | </property> | ||
561 | <property stdset="1"> | ||
562 | <name>sizePolicy</name> | ||
563 | <sizepolicy> | ||
564 | <hsizetype>1</hsizetype> | ||
565 | <vsizetype>1</vsizetype> | ||
566 | </sizepolicy> | ||
567 | </property> | ||
568 | <property stdset="1"> | ||
569 | <name>text</name> | ||
570 | <string>Payment</string> | ||
571 | </property> | ||
572 | <property stdset="1"> | ||
573 | <name>checked</name> | ||
574 | <bool>true</bool> | ||
575 | </property> | ||
576 | </widget> | ||
577 | </grid> | ||
578 | </widget> | ||
579 | </grid> | ||
580 | </widget> | ||
581 | <customwidgets> | ||
582 | <customwidget> | ||
583 | <class>QRestrictedLine</class> | ||
584 | <header location="local">qrestrictedline.h</header> | ||
585 | <sizehint> | ||
586 | <width>-1</width> | ||
587 | <height>-1</height> | ||
588 | </sizehint> | ||
589 | <container>0</container> | ||
590 | <sizepolicy> | ||
591 | <hordata>5</hordata> | ||
592 | <verdata>5</verdata> | ||
593 | </sizepolicy> | ||
594 | <pixmap>image0</pixmap> | ||
595 | </customwidget> | ||
596 | </customwidgets> | ||
597 | <images> | ||
598 | <image> | ||
599 | <name>image0</name> | ||
600 | <data format="XPM.GZ" length="649">789c6dd23b0ec2300c00d03da7b0e22d42e9476c88232031222186c80c3074813220c4dd214dddd84dac0e759fe2386e1a07a7e3015c639e6318ef04740b0f70d7d730bccf97fdc7d8be87f8406737c62210606869dbb531f531a57f4a299d03a7e06c11cca1055508412c2889acc2ef425423b34840a645f28244936860d2c265d7923bae8b2f05cb35a91739002d2b5727d535cbe954a43ad1e22f700755caf7407cf4799fe286c47dbe3bf303014167a2</data> | ||
601 | </image> | ||
602 | </images> | ||
603 | <tabstops> | ||
604 | <tabstop>payment</tabstop> | ||
605 | <tabstop>descriptionCombo</tabstop> | ||
606 | <tabstop>cmbCategory</tabstop> | ||
607 | <tabstop>transType</tabstop> | ||
608 | <tabstop>additionalNotes</tabstop> | ||
609 | </tabstops> | ||
610 | </UI> | ||
diff --git a/noncore/apps/checkbook/qcheckgraph.cpp b/noncore/apps/checkbook/qcheckgraph.cpp new file mode 100644 index 0000000..5b21ad8 --- a/dev/null +++ b/noncore/apps/checkbook/qcheckgraph.cpp | |||
@@ -0,0 +1,258 @@ | |||
1 | #include "qcheckgraph.h" | ||
2 | |||
3 | #include <qpainter.h> | ||
4 | #include <qmessagebox.h> | ||
5 | #include <qfontmetrics.h> | ||
6 | #include <qdir.h> | ||
7 | #include <qfile.h> | ||
8 | #include <qstringlist.h> | ||
9 | #include <qdatetime.h> | ||
10 | #include <qmenubar.h> | ||
11 | #include <qpopupmenu.h> | ||
12 | |||
13 | QCheckGraph::QCheckGraph(const QString filename) | ||
14 | : QCheckGraphBase() | ||
15 | { | ||
16 | QMenuBar *bar = new QMenuBar(this); | ||
17 | bar->setMargin(0); | ||
18 | QPopupMenu *popup = new QPopupMenu; | ||
19 | popup->insertItem("&Save Graph...", this, SLOT(saveGraphAsPicture())); | ||
20 | bar->insertItem("&File", popup); | ||
21 | |||
22 | pixmapready = false; | ||
23 | config = new Config(filename, Config::File); | ||
24 | QString forresult = ""; | ||
25 | QString forresult2 = ""; | ||
26 | int i = 1; | ||
27 | for (; forresult != "Not Found"; i++) | ||
28 | { | ||
29 | config->setGroup(QString::number(i)); | ||
30 | forresult = config->readEntry("Description", QString("Not Found")); | ||
31 | forresult2 = config->readEntry("Category", QString("Not Found")); | ||
32 | if (forresult != "Not Found") | ||
33 | { | ||
34 | if (list.contains(forresult2) == 0) | ||
35 | { | ||
36 | config->setGroup("Totals"); | ||
37 | QString larger = config->readEntry("Spent", QString("no")); | ||
38 | QString smaller = config->readEntry(forresult2, QString("no")); | ||
39 | if (larger != "no" && smaller != "no") | ||
40 | { | ||
41 | list << forresult2; | ||
42 | QString percentage = calculator(smaller, larger, true); | ||
43 | |||
44 | // Here we calculate how many pixels tall it will be by multiplying it by 200. | ||
45 | QString pixels = calculator(percentage, QString("200"), false); | ||
46 | |||
47 | // This is done because it really doesn't need to have a decimal... just an int, and | ||
48 | // QString rounds doubles up to the nearest whole number in order to convert | ||
49 | // to an int (which is correct). | ||
50 | pixels = pixels.remove(pixels.find('.'), pixels.length()); | ||
51 | |||
52 | if (pixels.toInt() <= 5) | ||
53 | { | ||
54 | pixels = "6"; | ||
55 | } | ||
56 | |||
57 | list2 << pixels; | ||
58 | } | ||
59 | } | ||
60 | } else { | ||
61 | continue; | ||
62 | } | ||
63 | // We want to break this loop on the 7th (remember, starts at 0->6 == 7) item. | ||
64 | if (list.count() == 6) | ||
65 | { | ||
66 | break; | ||
67 | } | ||
68 | } | ||
69 | for (QStringList::Iterator it = list.begin(); it != list.end(); it++) | ||
70 | { | ||
71 | if ((*it).length() > 11) | ||
72 | { | ||
73 | (*it).truncate(8); | ||
74 | (*it).append("..."); | ||
75 | } | ||
76 | } | ||
77 | graphPixmap(); | ||
78 | } | ||
79 | |||
80 | void QCheckGraph::graphPixmap() | ||
81 | { | ||
82 | pixmapready = false; | ||
83 | graph = QPixmap(240,250); | ||
84 | QPainter p; | ||
85 | p.begin(&graph); | ||
86 | p.fillRect(0, 0, 240, 300, QColor(255,255,255)); | ||
87 | // Draw the graph lines | ||
88 | |||
89 | // Y | ||
90 | p.drawLine( 40, 50, 40, 252 ); | ||
91 | |||
92 | // X | ||
93 | p.drawLine( 40, 252, 203, 252 ); | ||
94 | |||
95 | // Y stepup lines | ||
96 | p.drawLine( 40, 50, 37, 50); | ||
97 | p.drawLine( 40, 70, 37, 70); | ||
98 | p.drawLine( 40, 90, 37, 90); | ||
99 | p.drawLine( 40, 110, 37, 110); | ||
100 | p.drawLine( 40, 130, 37, 130); | ||
101 | p.drawLine( 40, 150, 37, 150); | ||
102 | p.drawLine( 40, 170, 37, 170); | ||
103 | p.drawLine( 40, 190, 37, 190); | ||
104 | p.drawLine( 40, 210, 37, 210); | ||
105 | p.drawLine( 40, 230, 37, 230); | ||
106 | p.drawLine( 40, 245, 37, 245); | ||
107 | |||
108 | |||
109 | // Y stepup values | ||
110 | p.drawText((35 - p.fontMetrics().width("100")), (50 + (p.fontMetrics().height() / 2)), "100"); | ||
111 | p.drawText((35 - p.fontMetrics().width("90")), (70 + (p.fontMetrics().height() / 2)), "90"); | ||
112 | p.drawText((35 - p.fontMetrics().width("80")), (90 + (p.fontMetrics().height() / 2)), "80"); | ||
113 | p.drawText((35 - p.fontMetrics().width("70")), (110 + (p.fontMetrics().height() / 2)), "70"); | ||
114 | p.drawText((35 - p.fontMetrics().width("60")), (130 + (p.fontMetrics().height() / 2)), "60"); | ||
115 | p.drawText((35 - p.fontMetrics().width("50")), (150 + (p.fontMetrics().height() / 2)), "50"); | ||
116 | p.drawText((35 - p.fontMetrics().width("40")), (170 + (p.fontMetrics().height() / 2)), "40"); | ||
117 | p.drawText((35 - p.fontMetrics().width("30")), (190 + (p.fontMetrics().height() / 2)), "30"); | ||
118 | p.drawText((35 - p.fontMetrics().width("20")), (210 + (p.fontMetrics().height() / 2)), "20"); | ||
119 | p.drawText((35 - p.fontMetrics().width("10")), (230 + (p.fontMetrics().height() / 2)), "10"); | ||
120 | p.drawText((35 - p.fontMetrics().width("<10")), (245 + (p.fontMetrics().height() / 2)), "<10"); | ||
121 | |||
122 | // Draw the axis[sic?] labels | ||
123 | QString ylabel = "Percentage"; | ||
124 | int pixel = 100; | ||
125 | for (unsigned int i = 0; i != ylabel.length(); i++) | ||
126 | { | ||
127 | p.setBrush(QColor(0,0,0)); | ||
128 | p.drawText(5,pixel, QString(ylabel[i])); | ||
129 | pixel = pixel + p.fontMetrics().height(); | ||
130 | } | ||
131 | p.drawText(95, 265, "Category"); | ||
132 | |||
133 | int i = 0; | ||
134 | // Hack: Using if()'s... switch was acting all wierd :{ | ||
135 | QStringList::Iterator it2 = list2.begin(); | ||
136 | for (QStringList::Iterator it = list.begin(); it != list.end(); it++) | ||
137 | { | ||
138 | qWarning(QString::number(i)); | ||
139 | if (i ==0) | ||
140 | { | ||
141 | // For the color code: | ||
142 | p.setBrush(QColor(255,0,0)); | ||
143 | p.drawRect(8,12, 8, 8); | ||
144 | |||
145 | // Now the text: | ||
146 | p.setBrush(QColor(0,0,0)); | ||
147 | p.drawText(18,20, (*it)); | ||
148 | |||
149 | // Last, but not least, we have the actual bar graph height. | ||
150 | p.setBrush(QColor(255,0,0)); | ||
151 | p.drawRect(47, ((202 - (*it2).toInt()) + 50), 15, (*it2).toInt()); | ||
152 | } | ||
153 | if (i ==1) | ||
154 | { | ||
155 | p.setBrush(QColor(255,255,0)); | ||
156 | p.drawRect(78,12, 8, 8); | ||
157 | |||
158 | p.setBrush(QColor(0,0,0)); | ||
159 | p.drawText(88,20, (*it)); | ||
160 | |||
161 | p.setBrush(QColor(255,255,0)); | ||
162 | p.drawRect(70, ((202 - (*it2).toInt()) + 50), 15, (*it2).toInt()); | ||
163 | } | ||
164 | if (i==2) | ||
165 | { | ||
166 | p.setBrush(QColor(0,255,0)); | ||
167 | p.drawRect(153,12, 8, 8); | ||
168 | p.setBrush(QColor(0,0,0)); | ||
169 | p.drawText(163,20, (*it)); | ||
170 | |||
171 | p.setBrush(QColor(0,255,0)); | ||
172 | p.drawRect(98, ((202 - (*it2).toInt()) + 50), 15, (*it2).toInt()); | ||
173 | } | ||
174 | if (i==3) | ||
175 | { | ||
176 | p.setBrush(QColor(89,12,54)); | ||
177 | p.drawRect(8,27, 8, 8); | ||
178 | p.setBrush(QColor(0,0,0)); | ||
179 | p.drawText(18,35, (*it)); | ||
180 | |||
181 | p.setBrush(QColor(89,12,54)); | ||
182 | p.drawRect(126, ((202 - (*it2).toInt()) + 50), 15, (*it2).toInt()); | ||
183 | } | ||
184 | if (i==4) | ||
185 | { | ||
186 | p.setBrush(QColor(0,0,255)); | ||
187 | p.drawRect(78,27, 8, 8); | ||
188 | p.setBrush(QColor(0,0,0)); | ||
189 | p.drawText(88,35, (*it)); | ||
190 | p.setBrush(QColor(0,0,255)); | ||
191 | p.drawRect(154, ((202 - (*it2).toInt()) + 50), 15, (*it2).toInt()); | ||
192 | } | ||
193 | if (i==5) | ||
194 | { | ||
195 | p.setBrush(QColor(100,40,0)); | ||
196 | p.drawRect(153,27, 8, 8); | ||
197 | p.setBrush(QColor(0,0,0)); | ||
198 | p.drawText(163,35, (*it)); | ||
199 | p.setBrush(QColor(100,40,0)); | ||
200 | p.drawRect(182, ((202 - (*it2).toInt()) + 50), 15, (*it2).toInt()); | ||
201 | } | ||
202 | i++; | ||
203 | it2++; | ||
204 | } | ||
205 | |||
206 | p.end(); | ||
207 | pixmapready = true; | ||
208 | graphWidget->setBackgroundPixmap(graph); | ||
209 | } | ||
210 | |||
211 | QString QCheckGraph::calculator(QString largervalue, QString smallervalue, bool divide) | ||
212 | { | ||
213 | //largervalue = largervalue.remove(largervalue.find(".", 0, false), 1); | ||
214 | //smallervalue = smallervalue.remove(smallervalue.find(".", 0, false), 1); | ||
215 | |||
216 | double largercents = largervalue.toDouble(); | ||
217 | double smallercents = smallervalue.toDouble(); | ||
218 | |||
219 | double finalammount = 0; | ||
220 | |||
221 | if (divide == true) | ||
222 | { | ||
223 | finalammount = (largercents / smallercents); | ||
224 | } else { | ||
225 | finalammount = (largercents * smallercents); | ||
226 | } | ||
227 | |||
228 | qWarning(QString::number(finalammount)); | ||
229 | |||
230 | return QString::number(finalammount); | ||
231 | } | ||
232 | |||
233 | /*void QCheckGraph::paintEvent(QPaintEvent *e) | ||
234 | { | ||
235 | if (pixmapready == true) | ||
236 | { | ||
237 | bitBlt((QPaintDevice *)(graphWidget), 0, 0, graph, 0,0); | ||
238 | QWidget::paintEvent(e); | ||
239 | } | ||
240 | } | ||
241 | */ | ||
242 | void QCheckGraph::saveGraphAsPicture() | ||
243 | { | ||
244 | QString homedir = QDir::homeDirPath(); | ||
245 | QDate current = QDate::currentDate(); | ||
246 | QString datestring = QString::number(current.month()); | ||
247 | datestring.append(QString::number(current.day())); | ||
248 | datestring.append(QString::number(current.year())); | ||
249 | QString filename = homedir; | ||
250 | filename.append("/Documents/graph"); | ||
251 | filename.append(datestring); | ||
252 | filename.append(".png"); | ||
253 | graph.save(filename, "PNG", 85); | ||
254 | QString graphmessage = "<qt>The graph was saved as graph"; | ||
255 | graphmessage.append(datestring); | ||
256 | graphmessage.append(".png. You may access it by returning to your home screen and clicking on the \"Documents\" tab in the upper right hand screen</qt>"); | ||
257 | QMessageBox::information(0, "File Saved", graphmessage); | ||
258 | } | ||
diff --git a/noncore/apps/checkbook/qcheckgraph.h b/noncore/apps/checkbook/qcheckgraph.h new file mode 100644 index 0000000..1cafef8 --- a/dev/null +++ b/noncore/apps/checkbook/qcheckgraph.h | |||
@@ -0,0 +1,25 @@ | |||
1 | #include <qstring.h> | ||
2 | #include <qmainwindow.h> | ||
3 | #include <qwidget.h> | ||
4 | #include <qstringlist.h> | ||
5 | #include <qpixmap.h> | ||
6 | #include "config.h" | ||
7 | |||
8 | #include "qcheckgraphbase.h" | ||
9 | |||
10 | class QCheckGraph : public QCheckGraphBase | ||
11 | { | ||
12 | Q_OBJECT | ||
13 | public: | ||
14 | QCheckGraph(const QString); | ||
15 | private: | ||
16 | QStringList list; | ||
17 | QStringList list2; | ||
18 | QString calculator(QString larger, QString smaller, bool divide); | ||
19 | QPixmap graph; | ||
20 | void graphPixmap(); | ||
21 | bool pixmapready; | ||
22 | Config *config; | ||
23 | private slots: | ||
24 | void saveGraphAsPicture(); | ||
25 | }; | ||
diff --git a/noncore/apps/checkbook/qcheckgraphbase.ui b/noncore/apps/checkbook/qcheckgraphbase.ui new file mode 100644 index 0000000..2763839 --- a/dev/null +++ b/noncore/apps/checkbook/qcheckgraphbase.ui | |||
@@ -0,0 +1,62 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>QCheckGraphBase</class> | ||
3 | <widget> | ||
4 | <class>QDialog</class> | ||
5 | <property stdset="1"> | ||
6 | <name>name</name> | ||
7 | <cstring>QCheckGraphBase</cstring> | ||
8 | </property> | ||
9 | <property stdset="1"> | ||
10 | <name>geometry</name> | ||
11 | <rect> | ||
12 | <x>0</x> | ||
13 | <y>0</y> | ||
14 | <width>236</width> | ||
15 | <height>285</height> | ||
16 | </rect> | ||
17 | </property> | ||
18 | <property stdset="1"> | ||
19 | <name>caption</name> | ||
20 | <string>Account Graph</string> | ||
21 | </property> | ||
22 | <grid> | ||
23 | <property stdset="1"> | ||
24 | <name>margin</name> | ||
25 | <number>0</number> | ||
26 | </property> | ||
27 | <property stdset="1"> | ||
28 | <name>spacing</name> | ||
29 | <number>0</number> | ||
30 | </property> | ||
31 | <widget row="0" column="0" > | ||
32 | <class>QWidget</class> | ||
33 | <property stdset="1"> | ||
34 | <name>name</name> | ||
35 | <cstring>graphWidget</cstring> | ||
36 | </property> | ||
37 | </widget> | ||
38 | </grid> | ||
39 | </widget> | ||
40 | <customwidgets> | ||
41 | <customwidget> | ||
42 | <class>QWidget</class> | ||
43 | <header location="global">qwidget.h</header> | ||
44 | <sizehint> | ||
45 | <width>-1</width> | ||
46 | <height>-1</height> | ||
47 | </sizehint> | ||
48 | <container>0</container> | ||
49 | <sizepolicy> | ||
50 | <hordata>5</hordata> | ||
51 | <verdata>5</verdata> | ||
52 | </sizepolicy> | ||
53 | <pixmap>image0</pixmap> | ||
54 | </customwidget> | ||
55 | </customwidgets> | ||
56 | <images> | ||
57 | <image> | ||
58 | <name>image0</name> | ||
59 | <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data> | ||
60 | </image> | ||
61 | </images> | ||
62 | </UI> | ||
diff --git a/noncore/apps/checkbook/qcheckmainmenu.cpp b/noncore/apps/checkbook/qcheckmainmenu.cpp new file mode 100644 index 0000000..2382513 --- a/dev/null +++ b/noncore/apps/checkbook/qcheckmainmenu.cpp | |||
@@ -0,0 +1,74 @@ | |||
1 | #include "qcheckmainmenu.h" | ||
2 | #include "qcheckname.h" | ||
3 | |||
4 | QCheckMainMenu::QCheckMainMenu(QWidget *parent) | ||
5 | : QCheckMMBase(parent) | ||
6 | { | ||
7 | init(); | ||
8 | } | ||
9 | |||
10 | void QCheckMainMenu::init() | ||
11 | { | ||
12 | lstCheckBooks->clear(); | ||
13 | QString checkdirname = QDir::homeDirPath(); | ||
14 | checkdirname.append("/.checkbooks"); | ||
15 | QDir checkdir(checkdirname); | ||
16 | if (checkdir.exists() == true) | ||
17 | { | ||
18 | QStringList checkbooks = checkdir.entryList("*.qcb", QDir::Files|QDir::Readable|QDir::Writable, QDir::Time); | ||
19 | for (QStringList::Iterator it = checkbooks.begin(); it != checkbooks.end(); it++) | ||
20 | { | ||
21 | (*it) = (*it).remove((*it).find('.'), (*it).length()); | ||
22 | } | ||
23 | lstCheckBooks->insertStringList(checkbooks); | ||
24 | } | ||
25 | lstCheckBooks->clearSelection(); | ||
26 | connect(lstCheckBooks, SIGNAL(clicked(QListBoxItem *)), this, SLOT(slotSelected(QListBoxItem *))); | ||
27 | lstCheckBooks->clearSelection(); | ||
28 | } | ||
29 | |||
30 | void QCheckMainMenu::slotSelected(QListBoxItem *item) | ||
31 | { | ||
32 | if (item != 0) | ||
33 | { | ||
34 | QString text = item->text(); | ||
35 | if (text.isEmpty() == false) | ||
36 | { | ||
37 | text.append(".qcb"); | ||
38 | QString checkdirname = QDir::homeDirPath(); | ||
39 | checkdirname.append("/.checkbooks/"); | ||
40 | text.prepend(checkdirname); | ||
41 | emit itemSelected(text); | ||
42 | } | ||
43 | } | ||
44 | } | ||
45 | |||
46 | void QCheckMainMenu::newClicked() | ||
47 | { | ||
48 | QString checkname = QCheckName::getName(); | ||
49 | if (checkname.isEmpty() == false) | ||
50 | { | ||
51 | QString checkdirname = QDir::homeDirPath(); | ||
52 | checkdirname.append("/.checkbooks"); | ||
53 | QDir checkdir(checkdirname); | ||
54 | if (checkdir.exists() == false) | ||
55 | { | ||
56 | checkdir.mkdir(checkdirname); | ||
57 | } | ||
58 | checkdirname.append("/"); | ||
59 | checkdirname.append(checkname); | ||
60 | checkdirname.append(".qcb"); | ||
61 | QFile file(checkdirname); | ||
62 | if (file.exists() == false) | ||
63 | { | ||
64 | file.open(IO_WriteOnly); | ||
65 | QTextStream os(&file); | ||
66 | os << ""; | ||
67 | file.close(); | ||
68 | } | ||
69 | QFileInfo fi(file); | ||
70 | QString noextension = fi.fileName(); | ||
71 | noextension = noextension.remove(noextension.find('.'), noextension.length()); | ||
72 | lstCheckBooks->insertItem(noextension); | ||
73 | } | ||
74 | } | ||
diff --git a/noncore/apps/checkbook/qcheckmainmenu.h b/noncore/apps/checkbook/qcheckmainmenu.h new file mode 100644 index 0000000..456d3df --- a/dev/null +++ b/noncore/apps/checkbook/qcheckmainmenu.h | |||
@@ -0,0 +1,27 @@ | |||
1 | #include <qwidget.h> | ||
2 | #include <qtoolbutton.h> | ||
3 | #include <qpopupmenu.h> | ||
4 | #include <qfile.h> | ||
5 | #include <qdir.h> | ||
6 | #include <qtextstream.h> | ||
7 | #include <qstring.h> | ||
8 | #include <qlistbox.h> | ||
9 | #include <qmessagebox.h> | ||
10 | |||
11 | #include "qcheckmmbase.h" | ||
12 | |||
13 | class QCheckMainMenu : public QCheckMMBase | ||
14 | { | ||
15 | Q_OBJECT | ||
16 | public: | ||
17 | QCheckMainMenu(QWidget *); | ||
18 | signals: | ||
19 | void itemSelected(const QString &); | ||
20 | private: | ||
21 | void init(); | ||
22 | private slots: | ||
23 | void slotSelected(QListBoxItem *); | ||
24 | public slots: | ||
25 | void newClicked(); | ||
26 | }; | ||
27 | |||
diff --git a/noncore/apps/checkbook/qcheckmmbase.ui b/noncore/apps/checkbook/qcheckmmbase.ui new file mode 100644 index 0000000..efde990 --- a/dev/null +++ b/noncore/apps/checkbook/qcheckmmbase.ui | |||
@@ -0,0 +1,80 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>QCheckMMBase</class> | ||
3 | <widget> | ||
4 | <class>QWidget</class> | ||
5 | <property stdset="1"> | ||
6 | <name>name</name> | ||
7 | <cstring>QCheckMMBase</cstring> | ||
8 | </property> | ||
9 | <property stdset="1"> | ||
10 | <name>geometry</name> | ||
11 | <rect> | ||
12 | <x>0</x> | ||
13 | <y>0</y> | ||
14 | <width>256</width> | ||
15 | <height>311</height> | ||
16 | </rect> | ||
17 | </property> | ||
18 | <property stdset="1"> | ||
19 | <name>caption</name> | ||
20 | <string>Main Menu</string> | ||
21 | </property> | ||
22 | <grid> | ||
23 | <property stdset="1"> | ||
24 | <name>margin</name> | ||
25 | <number>7</number> | ||
26 | </property> | ||
27 | <property stdset="1"> | ||
28 | <name>spacing</name> | ||
29 | <number>3</number> | ||
30 | </property> | ||
31 | <widget row="0" column="0" > | ||
32 | <class>QLabel</class> | ||
33 | <property stdset="1"> | ||
34 | <name>name</name> | ||
35 | <cstring>TextLabel2</cstring> | ||
36 | </property> | ||
37 | <property stdset="1"> | ||
38 | <name>text</name> | ||
39 | <string>Select from the check books below or click the "New" icon in the toolbar.</string> | ||
40 | </property> | ||
41 | <property stdset="1"> | ||
42 | <name>alignment</name> | ||
43 | <set>WordBreak|AlignVCenter|AlignLeft</set> | ||
44 | </property> | ||
45 | <property> | ||
46 | <name>wordwrap</name> | ||
47 | </property> | ||
48 | </widget> | ||
49 | <widget row="1" column="0" > | ||
50 | <class>QListBox</class> | ||
51 | <property stdset="1"> | ||
52 | <name>name</name> | ||
53 | <cstring>lstCheckBooks</cstring> | ||
54 | </property> | ||
55 | </widget> | ||
56 | </grid> | ||
57 | </widget> | ||
58 | <customwidgets> | ||
59 | <customwidget> | ||
60 | <class>QWidget</class> | ||
61 | <header location="global">qwidget.h</header> | ||
62 | <sizehint> | ||
63 | <width>-1</width> | ||
64 | <height>-1</height> | ||
65 | </sizehint> | ||
66 | <container>0</container> | ||
67 | <sizepolicy> | ||
68 | <hordata>5</hordata> | ||
69 | <verdata>5</verdata> | ||
70 | </sizepolicy> | ||
71 | <pixmap>image0</pixmap> | ||
72 | </customwidget> | ||
73 | </customwidgets> | ||
74 | <images> | ||
75 | <image> | ||
76 | <name>image0</name> | ||
77 | <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data> | ||
78 | </image> | ||
79 | </images> | ||
80 | </UI> | ||
diff --git a/noncore/apps/checkbook/qcheckname.cpp b/noncore/apps/checkbook/qcheckname.cpp new file mode 100644 index 0000000..0e4d71c --- a/dev/null +++ b/noncore/apps/checkbook/qcheckname.cpp | |||
@@ -0,0 +1,36 @@ | |||
1 | #include "qcheckname.h" | ||
2 | #include <qmessagebox.h> | ||
3 | #include <qdialog.h> | ||
4 | #include <qpushbutton.h> | ||
5 | #include <qlineedit.h> | ||
6 | #include "qrestrictedline.h" | ||
7 | |||
8 | QCheckName::QCheckName() | ||
9 | : QCheckNameBase() | ||
10 | { | ||
11 | connect(cmdDone, SIGNAL(clicked()), this, SLOT(clicked())); | ||
12 | } | ||
13 | |||
14 | QString QCheckName::getName() | ||
15 | { | ||
16 | QCheckName qcn; | ||
17 | qcn.setWFlags(Qt::WType_Modal); | ||
18 | qcn.leText->setValidChars("abcdefghijklmnopqrstuvwxyz0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"); | ||
19 | if (qcn.exec() == QDialog::Accepted) | ||
20 | { | ||
21 | return qcn.leText->text(); | ||
22 | } else { | ||
23 | return QString(""); | ||
24 | } | ||
25 | } | ||
26 | |||
27 | void QCheckName::clicked() | ||
28 | { | ||
29 | if (leText->text().isEmpty() == false) | ||
30 | { | ||
31 | hide(); | ||
32 | accept(); | ||
33 | } else { | ||
34 | QMessageBox::critical(this, "Missing Information", "<qt>Please enter the name of your Check Book and try again.</qt>"); | ||
35 | } | ||
36 | } | ||
diff --git a/noncore/apps/checkbook/qcheckname.h b/noncore/apps/checkbook/qcheckname.h new file mode 100644 index 0000000..c47c4f9 --- a/dev/null +++ b/noncore/apps/checkbook/qcheckname.h | |||
@@ -0,0 +1,15 @@ | |||
1 | #include "qchecknamebase.h" | ||
2 | #include <qstring.h> | ||
3 | #include <qwidget.h> | ||
4 | |||
5 | class QCheckName : public QCheckNameBase | ||
6 | { | ||
7 | Q_OBJECT | ||
8 | public: | ||
9 | QCheckName(); | ||
10 | static QString getName(); | ||
11 | private: | ||
12 | QWidget *m_parent; | ||
13 | private slots: | ||
14 | void clicked(); | ||
15 | }; | ||
diff --git a/noncore/apps/checkbook/qchecknamebase.ui b/noncore/apps/checkbook/qchecknamebase.ui new file mode 100644 index 0000000..b9bda19 --- a/dev/null +++ b/noncore/apps/checkbook/qchecknamebase.ui | |||
@@ -0,0 +1,136 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>QCheckNameBase</class> | ||
3 | <widget> | ||
4 | <class>QDialog</class> | ||
5 | <property stdset="1"> | ||
6 | <name>name</name> | ||
7 | <cstring>QCheckNameBase</cstring> | ||
8 | </property> | ||
9 | <property stdset="1"> | ||
10 | <name>geometry</name> | ||
11 | <rect> | ||
12 | <x>0</x> | ||
13 | <y>0</y> | ||
14 | <width>228</width> | ||
15 | <height>108</height> | ||
16 | </rect> | ||
17 | </property> | ||
18 | <property stdset="1"> | ||
19 | <name>caption</name> | ||
20 | <string>Check Book Name</string> | ||
21 | </property> | ||
22 | <widget> | ||
23 | <class>QLabel</class> | ||
24 | <property stdset="1"> | ||
25 | <name>name</name> | ||
26 | <cstring>TextLabel3</cstring> | ||
27 | </property> | ||
28 | <property stdset="1"> | ||
29 | <name>geometry</name> | ||
30 | <rect> | ||
31 | <x>10</x> | ||
32 | <y>5</y> | ||
33 | <width>70</width> | ||
34 | <height>16</height> | ||
35 | </rect> | ||
36 | </property> | ||
37 | <property stdset="1"> | ||
38 | <name>font</name> | ||
39 | <font> | ||
40 | <family>BDF-helvetica</family> | ||
41 | <pointsize>19</pointsize> | ||
42 | <bold>1</bold> | ||
43 | </font> | ||
44 | </property> | ||
45 | <property stdset="1"> | ||
46 | <name>text</name> | ||
47 | <string>Name...</string> | ||
48 | </property> | ||
49 | </widget> | ||
50 | <widget> | ||
51 | <class>QLabel</class> | ||
52 | <property stdset="1"> | ||
53 | <name>name</name> | ||
54 | <cstring>TextLabel4</cstring> | ||
55 | </property> | ||
56 | <property stdset="1"> | ||
57 | <name>geometry</name> | ||
58 | <rect> | ||
59 | <x>10</x> | ||
60 | <y>25</y> | ||
61 | <width>210</width> | ||
62 | <height>25</height> | ||
63 | </rect> | ||
64 | </property> | ||
65 | <property stdset="1"> | ||
66 | <name>text</name> | ||
67 | <string>Please name your check book (limit: 15 characters):</string> | ||
68 | </property> | ||
69 | <property stdset="1"> | ||
70 | <name>alignment</name> | ||
71 | <set>WordBreak|AlignVCenter|AlignLeft</set> | ||
72 | </property> | ||
73 | <property> | ||
74 | <name>wordwrap</name> | ||
75 | </property> | ||
76 | </widget> | ||
77 | <widget> | ||
78 | <class>QPushButton</class> | ||
79 | <property stdset="1"> | ||
80 | <name>name</name> | ||
81 | <cstring>cmdDone</cstring> | ||
82 | </property> | ||
83 | <property stdset="1"> | ||
84 | <name>geometry</name> | ||
85 | <rect> | ||
86 | <x>75</x> | ||
87 | <y>80</y> | ||
88 | <width>75</width> | ||
89 | <height>25</height> | ||
90 | </rect> | ||
91 | </property> | ||
92 | <property stdset="1"> | ||
93 | <name>text</name> | ||
94 | <string>&Done</string> | ||
95 | </property> | ||
96 | </widget> | ||
97 | <widget> | ||
98 | <class>QRestrictedLine</class> | ||
99 | <property stdset="1"> | ||
100 | <name>name</name> | ||
101 | <cstring>leText</cstring> | ||
102 | </property> | ||
103 | <property stdset="1"> | ||
104 | <name>geometry</name> | ||
105 | <rect> | ||
106 | <x>5</x> | ||
107 | <y>51</y> | ||
108 | <width>216</width> | ||
109 | <height>25</height> | ||
110 | </rect> | ||
111 | </property> | ||
112 | </widget> | ||
113 | </widget> | ||
114 | <customwidgets> | ||
115 | <customwidget> | ||
116 | <class>QRestrictedLine</class> | ||
117 | <header location="local">qrestrictedline.h</header> | ||
118 | <sizehint> | ||
119 | <width>-1</width> | ||
120 | <height>-1</height> | ||
121 | </sizehint> | ||
122 | <container>0</container> | ||
123 | <sizepolicy> | ||
124 | <hordata>5</hordata> | ||
125 | <verdata>5</verdata> | ||
126 | </sizepolicy> | ||
127 | <pixmap>image0</pixmap> | ||
128 | </customwidget> | ||
129 | </customwidgets> | ||
130 | <images> | ||
131 | <image> | ||
132 | <name>image0</name> | ||
133 | <data format="XPM.GZ" length="649">789c6dd23b0ec2300c00d03da7b0e22d42e9476c88232031222186c80c3074813220c4dd214dddd84dac0e759fe2386e1a07a7e3015c639e6318ef04740b0f70d7d730bccf97fdc7d8be87f8406737c62210606869dbb531f531a57f4a299d03a7e06c11cca1055508412c2889acc2ef425423b34840a645f28244936860d2c265d7923bae8b2f05cb35a91739002d2b5727d535cbe954a43ad1e22f700755caf7407cf4799fe286c47dbe3bf303014167a2</data> | ||
134 | </image> | ||
135 | </images> | ||
136 | </UI> | ||
diff --git a/noncore/apps/checkbook/qcheckview.cpp b/noncore/apps/checkbook/qcheckview.cpp new file mode 100644 index 0000000..ddc3fa9 --- a/dev/null +++ b/noncore/apps/checkbook/qcheckview.cpp | |||
@@ -0,0 +1,458 @@ | |||
1 | #include "qcheckview.h" | ||
2 | |||
3 | #include <qpe/resource.h> | ||
4 | #include <qregexp.h> | ||
5 | #include <qlineedit.h> | ||
6 | #include <qradiobutton.h> | ||
7 | #include <qcombobox.h> | ||
8 | #include <qapplication.h> | ||
9 | #include <qpushbutton.h> | ||
10 | #include <qdir.h> | ||
11 | #include <qlabel.h> | ||
12 | #include <qdatetime.h> | ||
13 | #include <qmessagebox.h> | ||
14 | #include <qcheckbox.h> | ||
15 | #include <qfile.h> | ||
16 | #include <qtextstream.h> | ||
17 | #include <qbuttongroup.h> | ||
18 | #include <qradiobutton.h> | ||
19 | #include <qheader.h> | ||
20 | |||
21 | QCheckView::QCheckView(QWidget *parent, QString filename) | ||
22 | : QCheckViewBase(parent) | ||
23 | { | ||
24 | tblTransactions->setHScrollBarMode( QTable::AlwaysOff ); | ||
25 | tblTransactions->setNumRows( 0 ); | ||
26 | tblTransactions->setNumCols( 4 ); | ||
27 | tblTransactions->setShowGrid( FALSE ); | ||
28 | tblTransactions->horizontalHeader()->setLabel(0, "Num", 29); | ||
29 | tblTransactions->horizontalHeader()->setLabel(1, "Description", 81); | ||
30 | tblTransactions->horizontalHeader()->setLabel(2, "Date", 57); | ||
31 | tblTransactions->horizontalHeader()->setLabel(3, "Amount", 59); | ||
32 | tblTransactions->verticalHeader()->hide(); | ||
33 | tblTransactions->setLeftMargin( 0 ); | ||
34 | tblTransactions->setSelectionMode(QTable::NoSelection); | ||
35 | |||
36 | m_filename = filename; | ||
37 | load(filename); | ||
38 | } | ||
39 | |||
40 | void QCheckView::deleteClicked(int row, int col) | ||
41 | { | ||
42 | QStringList existing; | ||
43 | QString rowText = tblTransactions->text(row, 0); | ||
44 | config->setGroup(rowText); | ||
45 | QString originalamount = config->readEntry("Amount", "0.00"); | ||
46 | |||
47 | config->setGroup("Data"); | ||
48 | int lastCheck = config->readNumEntry("LastCheck", 0); | ||
49 | |||
50 | qWarning(rowText); | ||
51 | config->setGroup(rowText); | ||
52 | QString payment = config->readEntry("Payment", "true"); | ||
53 | if ( payment == QString("true") && rowText.toInt() <= lastCheck) | ||
54 | { | ||
55 | for(int i = row; i != (lastCheck); i++) | ||
56 | { | ||
57 | config->setGroup(tblTransactions->text(i, 0)); | ||
58 | QString ibalance = config->readEntry("Balance", "0.00"); | ||
59 | // this adds the old amount on to the transaction and then takes the new amount away | ||
60 | QString newbalance = calculator(ibalance, originalamount, false); | ||
61 | config->writeEntry("Balance", newbalance); | ||
62 | |||
63 | if (i == (lastCheck - 1)) | ||
64 | { | ||
65 | config->setGroup("Totals"); | ||
66 | config->writeEntry("Balance", newbalance); | ||
67 | break; | ||
68 | } | ||
69 | } | ||
70 | QString category = config->readEntry("Category", "Error"); | ||
71 | if (category != QString("Error")) | ||
72 | { | ||
73 | config->setGroup("Totals"); | ||
74 | config->writeEntry("Spent", calculator(config->readEntry("Spent", QString("0")), originalamount, true)); | ||
75 | QString categorytotal = config->readEntry(category, QString("0")); | ||
76 | categorytotal = calculator(categorytotal, originalamount, true); | ||
77 | config->writeEntry(category, categorytotal); | ||
78 | } | ||
79 | } | ||
80 | if ( payment == QString("false") && rowText.toInt() <= lastCheck) | ||
81 | { | ||
82 | for(int i = row; i != (lastCheck); i++) | ||
83 | { | ||
84 | config->setGroup(tblTransactions->text(i, 0)); | ||
85 | QString ibalance = config->readEntry("Balance", "0.00"); | ||
86 | // this subtracts the old amount on to the transaction and then adds the new amount on | ||
87 | QString newbalance = calculator(ibalance, originalamount, true); | ||
88 | config->writeEntry("Balance", newbalance); | ||
89 | |||
90 | if (i == lastCheck - 1) | ||
91 | { | ||
92 | config->setGroup("Totals"); | ||
93 | config->writeEntry("Balance", newbalance); | ||
94 | break; | ||
95 | } | ||
96 | } | ||
97 | config->setGroup("Totals"); | ||
98 | config->writeEntry("Deposited", calculator(config->readEntry("Deposited", QString("0")), originalamount, true)); | ||
99 | } | ||
100 | for (int i = rowText.toInt(); i != lastCheck; i++) | ||
101 | { | ||
102 | qWarning(QString::number(i +1)); | ||
103 | config->setGroup(QString::number(i +1)); | ||
104 | QString origamount = config->readEntry("Amount", "0"); | ||
105 | qWarning(origamount); | ||
106 | QString origbalance = config->readEntry("Balance", "0"); | ||
107 | QString origchecknumber = config->readEntry("CheckNumber", "0"); | ||
108 | QString origcomments = config->readEntry("Comments", ""); | ||
109 | QString origdate = config->readEntry("Date", "01/01/2000"); | ||
110 | QString origdescription = config->readEntry("Description", "No Description"); | ||
111 | QString origpayment = config->readEntry("Payment", "true"); | ||
112 | QString origtransactionfee = config->readEntry("TransactionFee", "0"); | ||
113 | QString origtype = config->readEntry("Type", "0"); | ||
114 | |||
115 | if (config->hasKey("Category")) | ||
116 | { | ||
117 | QString origcategory = config->readEntry("Category", "No Category"); | ||
118 | config->removeGroup(); | ||
119 | config->setGroup(QString::number(i)); | ||
120 | config->clearGroup(); | ||
121 | config->writeEntry("Category", origcategory); | ||
122 | } else { | ||
123 | config->removeGroup(); | ||
124 | config->setGroup(QString::number(i)); | ||
125 | config->clearGroup(); | ||
126 | } | ||
127 | config->writeEntry("Amount", origamount); | ||
128 | config->writeEntry("Balance", origbalance); | ||
129 | config->writeEntry("CheckNumber", origchecknumber); | ||
130 | config->writeEntry("Comments", origcomments); | ||
131 | config->writeEntry("Date", origdate); | ||
132 | config->writeEntry("Description", origdescription); | ||
133 | config->writeEntry("Payment", origpayment); | ||
134 | config->writeEntry("TransactionFee", origtransactionfee); | ||
135 | config->writeEntry("Type", origtype); | ||
136 | } | ||
137 | tblTransactions->clearCell(row, col); | ||
138 | labelBalance->setText(QString("$" + config->readEntry("Balance", QString("0.00")))); | ||
139 | config->setGroup("Data"); | ||
140 | config->writeEntry("LastCheck", QString::number(QString(config->readEntry("LastCheck", 0)).toInt() -1)); | ||
141 | config->write(); | ||
142 | delete qcd; | ||
143 | emit reload(m_filename); | ||
144 | |||
145 | } | ||
146 | |||
147 | void QCheckView::load(const QString filename) | ||
148 | { | ||
149 | config = new Config(filename, Config::File); | ||
150 | |||
151 | connect(tblTransactions, SIGNAL(clicked(int, int, int, const QPoint &)), this, SLOT(tableClicked(int, int, int, const QPoint &))); | ||
152 | |||
153 | config->setGroup("Totals"); | ||
154 | labelBalance->setText(QString("$" + config->readEntry("Balance", QString("0.00")))); | ||
155 | |||
156 | config->setGroup("Data"); | ||
157 | int lastCheck = config->readNumEntry("LastCheck", 1); | ||
158 | for (int i = 1; i != (lastCheck + 1); i++) | ||
159 | { | ||
160 | config->setGroup(QString::number(i)); | ||
161 | QString item = config->readEntry("Description", QString("Not Found")); | ||
162 | if (item != "Not Found") | ||
163 | { | ||
164 | QTableItem *qti = new QTableItem(tblTransactions, QTableItem::Never, QString::number(i)); | ||
165 | QTableItem *qti1 = new QTableItem(tblTransactions, QTableItem::Never, config->readEntry("Description", QString("None"))); | ||
166 | QTableItem *qti2 = new QTableItem(tblTransactions, QTableItem::Never, config->readEntry("Date", QString("None"))); | ||
167 | QTableItem *qti3 = new QTableItem(tblTransactions, QTableItem::Never, QString("$" + config->readEntry("Amount", QString("0.00")))); | ||
168 | int row = tblTransactions->numRows(); | ||
169 | tblTransactions->setNumRows(row + 1); | ||
170 | tblTransactions->setItem(row,0, qti); | ||
171 | tblTransactions->setItem(row,1, qti1); | ||
172 | tblTransactions->setItem(row,2, qti2); | ||
173 | tblTransactions->setItem(row,3, qti3); | ||
174 | tblTransactions->updateCell(row, 0); | ||
175 | tblTransactions->updateCell(row, 1); | ||
176 | tblTransactions->updateCell(row, 2); | ||
177 | tblTransactions->updateCell(row, 3); | ||
178 | } | ||
179 | } | ||
180 | } | ||
181 | |||
182 | void QCheckView::editClicked(int row, int col) | ||
183 | { | ||
184 | delete qcd; | ||
185 | QStringList existing; | ||
186 | QString rowText = tblTransactions->text(row, 0); | ||
187 | config->setGroup("Data"); | ||
188 | QString recent = config->readEntry("Recent", ""); | ||
189 | |||
190 | config->setGroup(rowText); | ||
191 | //We need the original amount to add or subtract to check's blanaces written after this edited check | ||
192 | QString originalamount = config->readEntry("Amount", "0.00"); | ||
193 | QString originalcategory = config->readEntry("Category", "None"); | ||
194 | |||
195 | existing << config->readEntry("Payment", "true") << config->readEntry("Description", "No Description Found") << config->readEntry("Category", "Misc.") << config->readEntry("Type", "0") << config->readEntry("CheckNumber", "0") << originalamount << config->readEntry("TransactionFee", "") << config->readEntry("Date", "01/01/2001") << config->readEntry("Comments", "") << recent; | ||
196 | QStringList result = QCheckEntry::popupEntry(existing); | ||
197 | if (result.isEmpty() == false) | ||
198 | { | ||
199 | config->setGroup("Data"); | ||
200 | int lastCheck = config->readNumEntry("LastCheck", 0); | ||
201 | config->writeEntry("Recent", result[9]); | ||
202 | |||
203 | config->setGroup(rowText); | ||
204 | |||
205 | tblTransactions->setText(row, 1, result[1]); | ||
206 | tblTransactions->updateCell(row, 1); | ||
207 | |||
208 | tblTransactions->setText(row, 2, result[7]); | ||
209 | tblTransactions->updateCell(row, 2); | ||
210 | |||
211 | tblTransactions->setText(row, 3, QString("$" + result[5])); | ||
212 | tblTransactions->updateCell(row, 3); | ||
213 | |||
214 | // This is how the list looks: | ||
215 | // 0: true or false, true == payment, false == deposit | ||
216 | // 1: description of the transaction | ||
217 | // 2: category name | ||
218 | // 3: transaction type (stores the integer value of the index of the combobox) | ||
219 | // 4: check number of the transaction (if any) | ||
220 | // 5: transaction amount | ||
221 | // 6: transaction fee (e.g. service charge, or ATM charge). | ||
222 | // 7: date of the transaction | ||
223 | // 8: additional comments | ||
224 | config->writeEntry("Payment", result[0]); | ||
225 | config->writeEntry("Description", result[1]); | ||
226 | if (result[0] == QString("true")) | ||
227 | { | ||
228 | config->writeEntry("Category", result[2]); | ||
229 | } | ||
230 | config->writeEntry("Type", result[3]); | ||
231 | config->writeEntry("CheckNumber", result[4]); | ||
232 | config->writeEntry("Amount", result[5]); | ||
233 | config->writeEntry("TransactionFee", result[6]); | ||
234 | config->writeEntry("Date", result[7]); | ||
235 | config->writeEntry("Comments", result[8]); | ||
236 | if (result[0] == QString("true")) | ||
237 | { | ||
238 | if (rowText.toInt() <= lastCheck) | ||
239 | { | ||
240 | for(int i = (rowText.toInt() - 1); i != (lastCheck); i++) | ||
241 | { | ||
242 | config->setGroup(tblTransactions->text(i, 0)); | ||
243 | QString ibalance = config->readEntry("Balance", "0.00"); | ||
244 | |||
245 | // this adds the old amount on to the transaction and then takes the new amount away | ||
246 | QString newbalance = calculator(calculator(ibalance, originalamount, false), result[5], true); | ||
247 | config->writeEntry("Balance", newbalance); | ||
248 | if (i == (lastCheck - 1)) | ||
249 | { | ||
250 | config->setGroup("Totals"); | ||
251 | config->writeEntry("Balance", newbalance); | ||
252 | break; | ||
253 | } | ||
254 | } | ||
255 | } | ||
256 | config->setGroup("Totals"); | ||
257 | config->writeEntry("Spent", calculator(config->readEntry("Spent", QString("0")), originalamount, true)); | ||
258 | config->writeEntry("Spent", calculator(config->readEntry("Spent", QString("0")), result[5], false)); | ||
259 | |||
260 | if (result[2] == originalcategory) | ||
261 | { | ||
262 | QString categorytotal = config->readEntry(result[2], QString("0")); | ||
263 | categorytotal = calculator(categorytotal, originalamount, true); | ||
264 | categorytotal = calculator(categorytotal, result[5], false); | ||
265 | config->writeEntry(result[2], categorytotal); | ||
266 | } else { | ||
267 | QString origtotal = config->readEntry(originalcategory, QString("0")); | ||
268 | QString origfinal = calculator(origtotal, result[5], true); | ||
269 | if (origfinal == "0" || origfinal == "0.00") | ||
270 | { | ||
271 | config->removeEntry(originalcategory); | ||
272 | } else { | ||
273 | config->writeEntry(originalcategory, origfinal); | ||
274 | } | ||
275 | QString categorytotal = config->readEntry(result[2], QString("0")); | ||
276 | categorytotal = calculator(categorytotal, originalamount, false); | ||
277 | config->writeEntry(result[2],categorytotal); | ||
278 | } | ||
279 | } | ||
280 | if (result[0] == QString("false")) | ||
281 | { | ||
282 | if (rowText.toInt() <= lastCheck) | ||
283 | { | ||
284 | for(int i = (rowText.toInt() - 1 ); i != (lastCheck); i++) | ||
285 | { | ||
286 | config->setGroup(tblTransactions->text(i, 0)); | ||
287 | QString ibalance = config->readEntry("Balance", "0.00"); | ||
288 | |||
289 | // this subtracts the old amount on to the transaction and then adds the new amount on | ||
290 | QString newbalance = calculator(calculator(ibalance, originalamount, true), result[5], false); | ||
291 | config->writeEntry("Balance", newbalance); | ||
292 | if (i == lastCheck - 1) | ||
293 | { | ||
294 | config->setGroup("Totals"); | ||
295 | config->writeEntry("Balance", newbalance); | ||
296 | break; | ||
297 | } | ||
298 | } | ||
299 | } | ||
300 | config->setGroup("Totals"); | ||
301 | config->writeEntry("Deposited", calculator(config->readEntry("Deposited", QString("0")), originalamount, true)); | ||
302 | config->writeEntry("Deposited", calculator(config->readEntry("Deposited", QString("0")), result[5], false)); | ||
303 | } | ||
304 | labelBalance->setText(QString("$" + config->readEntry("Balance", QString("0.00")))); | ||
305 | config->write(); | ||
306 | } | ||
307 | } | ||
308 | void QCheckView::tableClicked(int row, int col, int mouseButton, const QPoint &mousePos) | ||
309 | { | ||
310 | if (tblTransactions->text(row, col).isEmpty() == false) | ||
311 | { | ||
312 | QStringList existing; | ||
313 | config->setGroup(tblTransactions->text(row, 0)); | ||
314 | existing << config->readEntry("Payment", "true") << config->readEntry("Description", "No Description Found") << config->readEntry("Category", "Misc.") << config->readEntry("Type", "0") << config->readEntry("CheckNumber", "0") << config->readEntry("Amount", "0.00") << config->readEntry("TransactionFee", "0.00") << config->readEntry("Date", "01/01/2001") << config->readEntry("Comments", "") << config->readEntry("Balance", "0.00"); | ||
315 | qcd = new QCheckDetails(row, col, existing); | ||
316 | qcd->showMaximized(); | ||
317 | connect(qcd, SIGNAL(editClicked(int, int)), this, SLOT(editClicked(int, int))); | ||
318 | connect(qcd, SIGNAL(deleteClicked(int, int)), this, SLOT(deleteClicked(int, int))); | ||
319 | } | ||
320 | } | ||
321 | |||
322 | void QCheckView::newClicked() | ||
323 | { | ||
324 | config->setGroup("Data"); | ||
325 | QString recent = config->readEntry("Recent", ""); | ||
326 | QStringList kindablank; | ||
327 | kindablank << recent; | ||
328 | QStringList result = QCheckEntry::popupEntry(kindablank); | ||
329 | if (result.count() > 1) | ||
330 | { | ||
331 | QTableItem *qti = new QTableItem(tblTransactions, QTableItem::Never, result[1]); | ||
332 | int row = tblTransactions->numRows(); | ||
333 | tblTransactions->setNumRows(row + 1); | ||
334 | tblTransactions->setItem(row,1, qti); | ||
335 | tblTransactions->updateCell(row, 1); | ||
336 | config->setGroup("Data"); | ||
337 | config->writeEntry("Recent", result[9]); | ||
338 | int lastCheck = config->readNumEntry("LastCheck", 0); | ||
339 | if (lastCheck == 0) | ||
340 | { | ||
341 | config->writeEntry("LastCheck", 1); | ||
342 | } else { | ||
343 | config->writeEntry("LastCheck", (lastCheck + 1)); | ||
344 | } | ||
345 | QString number = QString::number(lastCheck + 1); | ||
346 | config->setGroup(number); | ||
347 | |||
348 | QTableItem *qti1 = new QTableItem(tblTransactions, QTableItem::Never, number); | ||
349 | tblTransactions->setItem(row, 0, qti1); | ||
350 | tblTransactions->updateCell(row, 0); | ||
351 | |||
352 | QTableItem *qti2 = new QTableItem(tblTransactions, QTableItem::Never, result[7]); | ||
353 | tblTransactions->setItem(row, 2, qti2); | ||
354 | tblTransactions->updateCell(row, 2); | ||
355 | |||
356 | QTableItem *qti3 = new QTableItem(tblTransactions, QTableItem::Never, QString("$" + result[5])); | ||
357 | tblTransactions->setItem(row, 3, qti3); | ||
358 | tblTransactions->updateCell(row, 3); | ||
359 | |||
360 | // This is how the list looks: | ||
361 | // 0: true or false, true == payment, false == deposit | ||
362 | // 1: description of the transaction | ||
363 | // 2: category name | ||
364 | // 3: transaction type (stores the integer value of the index of the combobox) | ||
365 | // 4: check number of the transaction (if any) | ||
366 | // 5: transaction amount | ||
367 | // 6: transaction fee (e.g. service charge, or ATM charge). | ||
368 | // 7: date of the transaction | ||
369 | config->writeEntry("Payment", result[0]); | ||
370 | config->writeEntry("Description", result[1]); | ||
371 | if (result[0] == QString("true")) | ||
372 | { | ||
373 | config->writeEntry("Category", result[2]); | ||
374 | } | ||
375 | config->writeEntry("Type", result[3]); | ||
376 | config->writeEntry("CheckNumber", result[4]); | ||
377 | config->writeEntry("Amount", result[5]); | ||
378 | config->writeEntry("TransactionFee", result[6]); | ||
379 | config->writeEntry("Date", result[7]); | ||
380 | config->writeEntry("Comments", result[8]); | ||
381 | config->setGroup("Totals"); | ||
382 | if (result[0] == QString("true")) | ||
383 | { | ||
384 | QString totalspent = config->readEntry("Spent", QString("0")); | ||
385 | totalspent = calculator(totalspent, result[5], false); | ||
386 | config->writeEntry("Spent", totalspent); | ||
387 | QString balance = config->readEntry("Balance", QString("0")); | ||
388 | balance = calculator(balance, result[5], true); | ||
389 | |||
390 | // Make sure to add the fee on, if any | ||
391 | balance = calculator(balance, result[6], true); | ||
392 | |||
393 | config->writeEntry("Balance", balance); | ||
394 | |||
395 | config->setGroup(number); | ||
396 | config->writeEntry("Balance", balance); | ||
397 | |||
398 | config->setGroup("Totals"); | ||
399 | QString categorytotal = config->readEntry(result[2], QString("0")); | ||
400 | categorytotal = calculator(categorytotal, result[5], false); | ||
401 | config->writeEntry(result[2], categorytotal); | ||
402 | } | ||
403 | if (result[0] == QString("false")) | ||
404 | { | ||
405 | QString totaldeposited = config->readEntry("Deposited", QString("0")); | ||
406 | totaldeposited = calculator(totaldeposited, result[5], false); | ||
407 | config->writeEntry("Deposited", totaldeposited); | ||
408 | QString balance = config->readEntry("Balance", QString("0")); | ||
409 | balance = calculator(balance, result[5], false); | ||
410 | |||
411 | // Make sure to add the fee on, if any | ||
412 | balance = calculator(balance, result[6], true); | ||
413 | |||
414 | config->writeEntry("Balance", balance); | ||
415 | |||
416 | config->setGroup(number); | ||
417 | config->writeEntry("Balance", balance); | ||
418 | } | ||
419 | } | ||
420 | config->setGroup("Totals"); | ||
421 | labelBalance->setText(QString("$" + config->readEntry("Balance", QString("0.00")))); | ||
422 | config->write(); | ||
423 | } | ||
424 | |||
425 | QString QCheckView::calculator(QString largervalue, QString smallervalue, bool subtract) | ||
426 | { | ||
427 | // This class provides a way to eliminate the ARM processor problem of not being able to handle | ||
428 | // decimals. I just take the two QString'ed numbers and find the decimal point, then I remove the decimal | ||
429 | // point seperating the number into two. Then I convert it to cents (times it times 100) and add/ | ||
430 | // substract the two together. Put the decimals back in, and return. | ||
431 | |||
432 | largervalue = largervalue.remove(largervalue.find(".", 0, false), 1); | ||
433 | smallervalue = smallervalue.remove(smallervalue.find(".", 0, false), 1); | ||
434 | |||
435 | int largercents = largervalue.toInt(); | ||
436 | int smallercents = smallervalue.toInt(); | ||
437 | |||
438 | int finalammount = 0; | ||
439 | |||
440 | if (subtract == true) | ||
441 | { | ||
442 | finalammount = largercents - smallercents; | ||
443 | } else { | ||
444 | finalammount = largercents + smallercents; | ||
445 | } | ||
446 | |||
447 | QString returnvalue = QString::number(finalammount); | ||
448 | if (returnvalue.length() >= 2) | ||
449 | { | ||
450 | returnvalue.insert((returnvalue.length() - 2), "."); | ||
451 | } else { | ||
452 | if (returnvalue.length() == 1) | ||
453 | { | ||
454 | returnvalue.prepend("0.0"); | ||
455 | } | ||
456 | } | ||
457 | return returnvalue; | ||
458 | } | ||
diff --git a/noncore/apps/checkbook/qcheckview.h b/noncore/apps/checkbook/qcheckview.h new file mode 100644 index 0000000..840dc8b --- a/dev/null +++ b/noncore/apps/checkbook/qcheckview.h | |||
@@ -0,0 +1,33 @@ | |||
1 | #include "qcheckviewbase.h" | ||
2 | #include "qrestrictedline.h" | ||
3 | #include "qcheckentry.h" | ||
4 | #include "qcheckdetails.h" | ||
5 | |||
6 | #include <qstring.h> | ||
7 | #include "config.h" | ||
8 | #include <qtable.h> | ||
9 | #include <qpoint.h> | ||
10 | #include <qlayout.h> | ||
11 | |||
12 | class QCheckView : public QCheckViewBase | ||
13 | { | ||
14 | Q_OBJECT | ||
15 | public: | ||
16 | QCheckView(QWidget *, QString filename); | ||
17 | void load(const QString filename); | ||
18 | private: | ||
19 | Config *config; | ||
20 | QString calculator(QString largervalue, QString smallervalue, bool subtract); | ||
21 | int lastSortCol; | ||
22 | bool ascend; | ||
23 | QCheckDetails *qcd; | ||
24 | QString m_filename; | ||
25 | private slots: | ||
26 | // void entryActivated(int); | ||
27 | void newClicked(); | ||
28 | void tableClicked(int, int, int, const QPoint &mousePos); | ||
29 | void editClicked(int, int); | ||
30 | void deleteClicked(int, int); | ||
31 | signals: | ||
32 | void reload(const QString &filename); | ||
33 | }; | ||
diff --git a/noncore/apps/checkbook/qcheckviewbase.ui b/noncore/apps/checkbook/qcheckviewbase.ui new file mode 100644 index 0000000..00ed7dd --- a/dev/null +++ b/noncore/apps/checkbook/qcheckviewbase.ui | |||
@@ -0,0 +1,122 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>QCheckViewBase</class> | ||
3 | <widget> | ||
4 | <class>QWidget</class> | ||
5 | <property stdset="1"> | ||
6 | <name>name</name> | ||
7 | <cstring>QCheckViewBase</cstring> | ||
8 | </property> | ||
9 | <property stdset="1"> | ||
10 | <name>geometry</name> | ||
11 | <rect> | ||
12 | <x>0</x> | ||
13 | <y>0</y> | ||
14 | <width>242</width> | ||
15 | <height>312</height> | ||
16 | </rect> | ||
17 | </property> | ||
18 | <property stdset="1"> | ||
19 | <name>caption</name> | ||
20 | <string>Account Transactions</string> | ||
21 | </property> | ||
22 | <grid> | ||
23 | <property stdset="1"> | ||
24 | <name>margin</name> | ||
25 | <number>5</number> | ||
26 | </property> | ||
27 | <property stdset="1"> | ||
28 | <name>spacing</name> | ||
29 | <number>1</number> | ||
30 | </property> | ||
31 | <widget row="0" column="1" > | ||
32 | <class>QLabel</class> | ||
33 | <property stdset="1"> | ||
34 | <name>name</name> | ||
35 | <cstring>labelBalance</cstring> | ||
36 | </property> | ||
37 | <property stdset="1"> | ||
38 | <name>frameShape</name> | ||
39 | <enum>MShape</enum> | ||
40 | </property> | ||
41 | <property stdset="1"> | ||
42 | <name>frameShadow</name> | ||
43 | <enum>MShadow</enum> | ||
44 | </property> | ||
45 | <property stdset="1"> | ||
46 | <name>text</name> | ||
47 | <string>$0.00</string> | ||
48 | </property> | ||
49 | <property stdset="1"> | ||
50 | <name>alignment</name> | ||
51 | <set>AlignCenter</set> | ||
52 | </property> | ||
53 | <property> | ||
54 | <name>hAlign</name> | ||
55 | </property> | ||
56 | </widget> | ||
57 | <widget row="1" column="0" rowspan="1" colspan="2" > | ||
58 | <class>QTable</class> | ||
59 | <property stdset="1"> | ||
60 | <name>name</name> | ||
61 | <cstring>tblTransactions</cstring> | ||
62 | </property> | ||
63 | <property stdset="1"> | ||
64 | <name>hScrollBarMode</name> | ||
65 | <enum>AlwaysOff</enum> | ||
66 | </property> | ||
67 | <property stdset="1"> | ||
68 | <name>numRows</name> | ||
69 | <number>0</number> | ||
70 | </property> | ||
71 | <property stdset="1"> | ||
72 | <name>numCols</name> | ||
73 | <number>4</number> | ||
74 | </property> | ||
75 | <property stdset="1"> | ||
76 | <name>showGrid</name> | ||
77 | <bool>false</bool> | ||
78 | </property> | ||
79 | </widget> | ||
80 | <widget row="0" column="0" > | ||
81 | <class>QLabel</class> | ||
82 | <property stdset="1"> | ||
83 | <name>name</name> | ||
84 | <cstring>TextLabel3</cstring> | ||
85 | </property> | ||
86 | <property stdset="1"> | ||
87 | <name>text</name> | ||
88 | <string>Balance:</string> | ||
89 | </property> | ||
90 | <property stdset="1"> | ||
91 | <name>alignment</name> | ||
92 | <set>AlignVCenter|AlignRight</set> | ||
93 | </property> | ||
94 | <property> | ||
95 | <name>hAlign</name> | ||
96 | </property> | ||
97 | </widget> | ||
98 | </grid> | ||
99 | </widget> | ||
100 | <customwidgets> | ||
101 | <customwidget> | ||
102 | <class>QWidget</class> | ||
103 | <header location="global">qwidget.h</header> | ||
104 | <sizehint> | ||
105 | <width>-1</width> | ||
106 | <height>-1</height> | ||
107 | </sizehint> | ||
108 | <container>0</container> | ||
109 | <sizepolicy> | ||
110 | <hordata>5</hordata> | ||
111 | <verdata>5</verdata> | ||
112 | </sizepolicy> | ||
113 | <pixmap>image0</pixmap> | ||
114 | </customwidget> | ||
115 | </customwidgets> | ||
116 | <images> | ||
117 | <image> | ||
118 | <name>image0</name> | ||
119 | <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data> | ||
120 | </image> | ||
121 | </images> | ||
122 | </UI> | ||
diff --git a/noncore/apps/checkbook/qrestrictedcombo.cpp b/noncore/apps/checkbook/qrestrictedcombo.cpp new file mode 100644 index 0000000..e1533f6 --- a/dev/null +++ b/noncore/apps/checkbook/qrestrictedcombo.cpp | |||
@@ -0,0 +1,78 @@ | |||
1 | /* | ||
2 | * | ||
3 | * $Id$ | ||
4 | * | ||
5 | * Implementation of QRestrictedCombo | ||
6 | * | ||
7 | * Copyright (C) 1997 Michael Wiedmann, <mw@miwie.in-berlin.de> | ||
8 | * | ||
9 | * This library is free software; you can redistribute it and/or | ||
10 | * modify it under the terms of the GNU Library General Public | ||
11 | * License as published by the Free Software Foundation; either | ||
12 | * version 2 of the License, or (at your option) any later version. | ||
13 | * | ||
14 | * This library is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * Library General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU Library General Public | ||
20 | * License along with this library; if not, write to the Free | ||
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
22 | * | ||
23 | */ | ||
24 | |||
25 | #include <qkeycode.h> | ||
26 | |||
27 | #include "qrestrictedcombo.h" | ||
28 | |||
29 | QRestrictedCombo::QRestrictedCombo( QWidget *parent, | ||
30 | const char *name, | ||
31 | const QString& valid ) | ||
32 | : QComboBox( parent, name ) | ||
33 | { | ||
34 | qsValidChars = valid; | ||
35 | } | ||
36 | |||
37 | QRestrictedCombo::~QRestrictedCombo() | ||
38 | { | ||
39 | ; | ||
40 | } | ||
41 | |||
42 | |||
43 | void QRestrictedCombo::keyPressEvent( QKeyEvent *e ) | ||
44 | { | ||
45 | // let QLineEdit process "special" keys and return/enter | ||
46 | // so that we still can use the default key binding | ||
47 | if (e->key() == Key_Enter || e->key() == Key_Return || e->key() == Key_Delete || e->ascii() < 32) | ||
48 | { | ||
49 | QComboBox::keyPressEvent(e); | ||
50 | return; | ||
51 | } | ||
52 | |||
53 | // do we have a list of valid chars && | ||
54 | // is the pressed key in the list of valid chars? | ||
55 | if (!qsValidChars.isEmpty() && !qsValidChars.contains(e->ascii())) | ||
56 | { | ||
57 | // invalid char, emit signal and return | ||
58 | emit (invalidChar(e->key())); | ||
59 | return; | ||
60 | } | ||
61 | else | ||
62 | // valid char: let QLineEdit process this key as usual | ||
63 | QComboBox::keyPressEvent(e); | ||
64 | |||
65 | return; | ||
66 | } | ||
67 | |||
68 | |||
69 | void QRestrictedCombo::setValidChars( const QString& valid) | ||
70 | { | ||
71 | qsValidChars = valid; | ||
72 | } | ||
73 | |||
74 | QString QRestrictedCombo::validChars() const | ||
75 | { | ||
76 | return qsValidChars; | ||
77 | } | ||
78 | |||
diff --git a/noncore/apps/checkbook/qrestrictedcombo.h b/noncore/apps/checkbook/qrestrictedcombo.h new file mode 100644 index 0000000..50ea59f --- a/dev/null +++ b/noncore/apps/checkbook/qrestrictedcombo.h | |||
@@ -0,0 +1,96 @@ | |||
1 | /* | ||
2 | * | ||
3 | * Definition of QRestrictedCombo | ||
4 | * | ||
5 | * Copyright (C) 1997 Michael Wiedmann, <mw@miwie.in-berlin.de> | ||
6 | * | ||
7 | * Edited 2001 by Nick Betcher <nbetcher@usinternet.com> to work | ||
8 | * with Qt-only. Changed class name from LRestrictedLine to | ||
9 | * QRestrictedCombo in order to accomidate Combo Boxes. | ||
10 | * | ||
11 | * This library is free software; you can redistribute it and/or | ||
12 | * modify it under the terms of the GNU Library General Public | ||
13 | * License as published by the Free Software Foundation; either | ||
14 | * version 2 of the License, or (at your option) any later version. | ||
15 | * | ||
16 | * This library is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
19 | * Library General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU Library General Public | ||
22 | * License along with this library; if not, write to the Free | ||
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
24 | * | ||
25 | */ | ||
26 | |||
27 | #ifndef QRESTRICTEDCOMBO_H | ||
28 | #define QRESTRICTEDCOMBO_H | ||
29 | |||
30 | #include <qcombobox.h> | ||
31 | |||
32 | /** | ||
33 | * The QRestrictedCombo widget is a variant of @ref QComboBox which | ||
34 | * accepts only a restricted set of characters as input. | ||
35 | * All other characters will be discarded and the signal @ref #invalidChar() | ||
36 | * will be emitted for each of them. | ||
37 | * | ||
38 | * Valid characters can be passed as a QString to the constructor | ||
39 | * or set afterwards via @ref #setValidChars(). | ||
40 | * The default key bindings of @ref QComboBox are still in effect. | ||
41 | * | ||
42 | * @short A line editor for restricted character sets. | ||
43 | * @author Michael Wiedmann <mw@miwie.in-berlin.de> | ||
44 | * @version 0.0.1 | ||
45 | */ | ||
46 | class QRestrictedCombo : public QComboBox | ||
47 | { | ||
48 | Q_OBJECT | ||
49 | Q_PROPERTY( QString validChars READ validChars WRITE setValidChars ) | ||
50 | |||
51 | public: | ||
52 | |||
53 | /** | ||
54 | * Constructor: This contructor takes three - optional - arguments. | ||
55 | * The first two parameters are simply passed on to @ref QLineEdit. | ||
56 | * @param parent pointer to the parent widget | ||
57 | * @param name pointer to the name of this widget | ||
58 | * @param valid pointer to set of valid characters | ||
59 | */ | ||
60 | QRestrictedCombo( QWidget *parent=0, const char *name=0, | ||
61 | const QString& valid = QString::null); | ||
62 | |||
63 | /** | ||
64 | * Destructs the restricted line editor. | ||
65 | */ | ||
66 | ~QRestrictedCombo(); | ||
67 | |||
68 | /** | ||
69 | * All characters in the string valid are treated as | ||
70 | * acceptable characters. | ||
71 | */ | ||
72 | void setValidChars(const QString& valid); | ||
73 | /** | ||
74 | * @return the string of acceptable characters. | ||
75 | */ | ||
76 | QString validChars() const; | ||
77 | |||
78 | signals: | ||
79 | |||
80 | /** | ||
81 | * Emitted when an invalid character was typed. | ||
82 | */ | ||
83 | voidinvalidChar(int); | ||
84 | |||
85 | protected: | ||
86 | /** | ||
87 | * @reimplemented | ||
88 | */ | ||
89 | voidkeyPressEvent( QKeyEvent *e ); | ||
90 | |||
91 | private: | ||
92 | /// QString of valid characters for this line | ||
93 | QStringqsValidChars; | ||
94 | }; | ||
95 | |||
96 | #endif // QRESTRICTEDCOMBO_H | ||
diff --git a/noncore/apps/checkbook/qrestrictedline.cpp b/noncore/apps/checkbook/qrestrictedline.cpp new file mode 100644 index 0000000..8508c33 --- a/dev/null +++ b/noncore/apps/checkbook/qrestrictedline.cpp | |||
@@ -0,0 +1,78 @@ | |||
1 | /* | ||
2 | * | ||
3 | * $Id$ | ||
4 | * | ||
5 | * Implementation of QRestrictedLine | ||
6 | * | ||
7 | * Copyright (C) 1997 Michael Wiedmann, <mw@miwie.in-berlin.de> | ||
8 | * | ||
9 | * This library is free software; you can redistribute it and/or | ||
10 | * modify it under the terms of the GNU Library General Public | ||
11 | * License as published by the Free Software Foundation; either | ||
12 | * version 2 of the License, or (at your option) any later version. | ||
13 | * | ||
14 | * This library is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * Library General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU Library General Public | ||
20 | * License along with this library; if not, write to the Free | ||
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
22 | * | ||
23 | */ | ||
24 | |||
25 | #include <qkeycode.h> | ||
26 | |||
27 | #include "qrestrictedline.h" | ||
28 | |||
29 | QRestrictedLine::QRestrictedLine( QWidget *parent, | ||
30 | const char *name, | ||
31 | const QString& valid ) | ||
32 | : QLineEdit( parent, name ) | ||
33 | { | ||
34 | qsValidChars = valid; | ||
35 | } | ||
36 | |||
37 | QRestrictedLine::~QRestrictedLine() | ||
38 | { | ||
39 | ; | ||
40 | } | ||
41 | |||
42 | |||
43 | void QRestrictedLine::keyPressEvent( QKeyEvent *e ) | ||
44 | { | ||
45 | // let QLineEdit process "special" keys and return/enter | ||
46 | // so that we still can use the default key binding | ||
47 | if (e->key() == Key_Enter || e->key() == Key_Return || e->key() == Key_Delete || e->ascii() < 32) | ||
48 | { | ||
49 | QLineEdit::keyPressEvent(e); | ||
50 | return; | ||
51 | } | ||
52 | |||
53 | // do we have a list of valid chars && | ||
54 | // is the pressed key in the list of valid chars? | ||
55 | if (!qsValidChars.isEmpty() && !qsValidChars.contains(e->ascii())) | ||
56 | { | ||
57 | // invalid char, emit signal and return | ||
58 | emit (invalidChar(e->key())); | ||
59 | return; | ||
60 | } | ||
61 | else | ||
62 | // valid char: let QLineEdit process this key as usual | ||
63 | QLineEdit::keyPressEvent(e); | ||
64 | |||
65 | return; | ||
66 | } | ||
67 | |||
68 | |||
69 | void QRestrictedLine::setValidChars( const QString& valid) | ||
70 | { | ||
71 | qsValidChars = valid; | ||
72 | } | ||
73 | |||
74 | QString QRestrictedLine::validChars() const | ||
75 | { | ||
76 | return qsValidChars; | ||
77 | } | ||
78 | |||
diff --git a/noncore/apps/checkbook/qrestrictedline.h b/noncore/apps/checkbook/qrestrictedline.h new file mode 100644 index 0000000..7e41cd9 --- a/dev/null +++ b/noncore/apps/checkbook/qrestrictedline.h | |||
@@ -0,0 +1,96 @@ | |||
1 | /* | ||
2 | * | ||
3 | * Definition of QRestrictedLine | ||
4 | * | ||
5 | * Copyright (C) 1997 Michael Wiedmann, <mw@miwie.in-berlin.de> | ||
6 | * | ||
7 | * Edited 2001 by Nick Betcher <nbetcher@usinternet.com> to work | ||
8 | * with Qt-only. Changed class name from QRestrictedLine to | ||
9 | * QRestrictedLine. | ||
10 | * | ||
11 | * This library is free software; you can redistribute it and/or | ||
12 | * modify it under the terms of the GNU Library General Public | ||
13 | * License as published by the Free Software Foundation; either | ||
14 | * version 2 of the License, or (at your option) any later version. | ||
15 | * | ||
16 | * This library is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
19 | * Library General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU Library General Public | ||
22 | * License along with this library; if not, write to the Free | ||
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
24 | * | ||
25 | */ | ||
26 | |||
27 | #ifndef QRESTRICTEDLINE_H | ||
28 | #define QRESTRICTEDLINE_H | ||
29 | |||
30 | #include <qlineedit.h> | ||
31 | |||
32 | /** | ||
33 | * The QRestrictedLine widget is a variant of @ref QLineEdit which | ||
34 | * accepts only a restricted set of characters as input. | ||
35 | * All other characters will be discarded and the signal @ref #invalidChar() | ||
36 | * will be emitted for each of them. | ||
37 | * | ||
38 | * Valid characters can be passed as a QString to the constructor | ||
39 | * or set afterwards via @ref #setValidChars(). | ||
40 | * The default key bindings of @ref QLineEdit are still in effect. | ||
41 | * | ||
42 | * @short A line editor for restricted character sets. | ||
43 | * @author Michael Wiedmann <mw@miwie.in-berlin.de> | ||
44 | * @version 0.0.1 | ||
45 | */ | ||
46 | class QRestrictedLine : public QLineEdit | ||
47 | { | ||
48 | Q_OBJECT | ||
49 | Q_PROPERTY( QString validChars READ validChars WRITE setValidChars ) | ||
50 | |||
51 | public: | ||
52 | |||
53 | /** | ||
54 | * Constructor: This contructor takes three - optional - arguments. | ||
55 | * The first two parameters are simply passed on to @ref QLineEdit. | ||
56 | * @param parent pointer to the parent widget | ||
57 | * @param name pointer to the name of this widget | ||
58 | * @param valid pointer to set of valid characters | ||
59 | */ | ||
60 | QRestrictedLine( QWidget *parent=0, const char *name=0, | ||
61 | const QString& valid = QString::null); | ||
62 | |||
63 | /** | ||
64 | * Destructs the restricted line editor. | ||
65 | */ | ||
66 | ~QRestrictedLine(); | ||
67 | |||
68 | /** | ||
69 | * All characters in the string valid are treated as | ||
70 | * acceptable characters. | ||
71 | */ | ||
72 | void setValidChars(const QString& valid); | ||
73 | /** | ||
74 | * @return the string of acceptable characters. | ||
75 | */ | ||
76 | QString validChars() const; | ||
77 | |||
78 | signals: | ||
79 | |||
80 | /** | ||
81 | * Emitted when an invalid character was typed. | ||
82 | */ | ||
83 | voidinvalidChar(int); | ||
84 | |||
85 | protected: | ||
86 | /** | ||
87 | * @reimplemented | ||
88 | */ | ||
89 | voidkeyPressEvent( QKeyEvent *e ); | ||
90 | |||
91 | private: | ||
92 | /// QString of valid characters for this line | ||
93 | QStringqsValidChars; | ||
94 | }; | ||
95 | |||
96 | #endif // QRESTRICTEDLINE_H | ||