summaryrefslogtreecommitdiff
path: root/noncore/unsupported
authormickeyl <mickeyl>2004-11-04 10:33:04 (UTC)
committer mickeyl <mickeyl>2004-11-04 10:33:04 (UTC)
commit7855b19ce0241a7b7b4fc72e3a8ddd9bf73b0a77 (patch) (unidiff)
treee76604c6af3da9c19b69dcdcf8105d58bac63f71 /noncore/unsupported
parentcd2d50799e087fad5b56df9d7fe9aa572a313e64 (diff)
downloadopie-7855b19ce0241a7b7b4fc72e3a8ddd9bf73b0a77.zip
opie-7855b19ce0241a7b7b4fc72e3a8ddd9bf73b0a77.tar.gz
opie-7855b19ce0241a7b7b4fc72e3a8ddd9bf73b0a77.tar.bz2
opie-qashmoney is now unsupported
Diffstat (limited to 'noncore/unsupported') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/qashmoney/.cvsignore3
-rwxr-xr-xnoncore/unsupported/qashmoney/CHANGES32
-rwxr-xr-xnoncore/unsupported/qashmoney/LICENSE348
-rwxr-xr-xnoncore/unsupported/qashmoney/README71
-rwxr-xr-xnoncore/unsupported/qashmoney/TODO15
-rwxr-xr-xnoncore/unsupported/qashmoney/account.cpp374
-rwxr-xr-xnoncore/unsupported/qashmoney/account.h100
-rwxr-xr-xnoncore/unsupported/qashmoney/accountdisplay.cpp451
-rwxr-xr-xnoncore/unsupported/qashmoney/accountdisplay.h54
-rwxr-xr-xnoncore/unsupported/qashmoney/budget.cpp221
-rwxr-xr-xnoncore/unsupported/qashmoney/budget.h45
-rwxr-xr-xnoncore/unsupported/qashmoney/budgetdisplay.cpp417
-rwxr-xr-xnoncore/unsupported/qashmoney/budgetdisplay.h86
-rwxr-xr-xnoncore/unsupported/qashmoney/calculator.cpp113
-rwxr-xr-xnoncore/unsupported/qashmoney/calculator.h50
-rwxr-xr-xnoncore/unsupported/qashmoney/currency.cpp80
-rwxr-xr-xnoncore/unsupported/qashmoney/currency.h23
-rwxr-xr-xnoncore/unsupported/qashmoney/datepicker.cpp95
-rwxr-xr-xnoncore/unsupported/qashmoney/datepicker.h60
-rwxr-xr-xnoncore/unsupported/qashmoney/main.cpp13
-rwxr-xr-xnoncore/unsupported/qashmoney/memory.cpp62
-rwxr-xr-xnoncore/unsupported/qashmoney/memory.h45
-rwxr-xr-xnoncore/unsupported/qashmoney/memorydialog.cpp86
-rwxr-xr-xnoncore/unsupported/qashmoney/memorydialog.h40
-rwxr-xr-xnoncore/unsupported/qashmoney/newaccount.cpp206
-rwxr-xr-xnoncore/unsupported/qashmoney/newaccount.h87
-rwxr-xr-xnoncore/unsupported/qashmoney/newtransaction.cpp274
-rwxr-xr-xnoncore/unsupported/qashmoney/newtransaction.h96
-rwxr-xr-xnoncore/unsupported/qashmoney/preferencedialogs.cpp216
-rwxr-xr-xnoncore/unsupported/qashmoney/preferencedialogs.h90
-rwxr-xr-xnoncore/unsupported/qashmoney/preferences.cpp352
-rwxr-xr-xnoncore/unsupported/qashmoney/preferences.h53
-rwxr-xr-xnoncore/unsupported/qashmoney/qashmoney.cpp402
-rwxr-xr-xnoncore/unsupported/qashmoney/qashmoney.h64
-rwxr-xr-xnoncore/unsupported/qashmoney/qashmoney.pro55
-rwxr-xr-xnoncore/unsupported/qashmoney/transaction.cpp345
-rwxr-xr-xnoncore/unsupported/qashmoney/transaction.h73
-rwxr-xr-xnoncore/unsupported/qashmoney/transactiondisplay.cpp625
-rwxr-xr-xnoncore/unsupported/qashmoney/transactiondisplay.h83
-rwxr-xr-xnoncore/unsupported/qashmoney/transfer.cpp259
-rwxr-xr-xnoncore/unsupported/qashmoney/transfer.h52
-rwxr-xr-xnoncore/unsupported/qashmoney/transferdialog.cpp112
-rwxr-xr-xnoncore/unsupported/qashmoney/transferdialog.h62
43 files changed, 6390 insertions, 0 deletions
diff --git a/noncore/unsupported/qashmoney/.cvsignore b/noncore/unsupported/qashmoney/.cvsignore
new file mode 100644
index 0000000..e737538
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/.cvsignore
@@ -0,0 +1,3 @@
1Makefile*
2.moc
3.obj
diff --git a/noncore/unsupported/qashmoney/CHANGES b/noncore/unsupported/qashmoney/CHANGES
new file mode 100755
index 0000000..a3ac224
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/CHANGES
@@ -0,0 +1,32 @@
1QashMoney - Budget Software for the Sharp Zaurus
2
3CHANGES
4
50.76 - 5/21/03
6
7 Updated postinst file so app will install on new Sharp ROM 3.1
8 Improved algorithm for selecting cleared transaction
9 Fixed budget display bug
10
11----------------------------------------------------------------------------------
12
1311/1/02 - Initial release of 0.2 version. Considered stable beta version.
1411/16/02 - Release of version 0.3. This is a stable version adding function to
15 transfer money between accounts. Several bugs fixes and speed enhancements
16 have been done.
1711/21/02 - 0.31 news tabs working but not yet displaying accounts
1812/15/02 - QashMoney gets a complete face lift and now has a date picker.
1912/29/02 - Version 0.41 released. This release fixes more bugs and adds a
20 function to manage transaction memory items.
2112/31/02 - Version 0.42 released. Maintenance release fixing soem rather nasty
22 bugs that screw up account, transaction, and transfer displays.
2303/03/03 - Version 0.60 released. QashMoney has undergone quite a transformation.
24 A new GUI that incorporates all of Qts excellent layout capabilities should
25 display nicely in all formats. A new embedded SQL database should make QashMoney
26very extensible.
274/25/03 - Version 0.70 released. This version includes many new features over 0.60 including
28currency support for accounts, a function to limit transaction views, and an all new budgeting
29tab that allows multiple budgets and currency support.
305/7/03 - Version 0.73 released. Few minor bugfixes and feature enhancements. QashMoney now
31right justifies all numbers and remembers the sate in which you leave the account window. So, if you
32collapse a parent account, it will stay collapsed (even between QashMoney restarts).
diff --git a/noncore/unsupported/qashmoney/LICENSE b/noncore/unsupported/qashmoney/LICENSE
new file mode 100755
index 0000000..421cfb2
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/LICENSE
@@ -0,0 +1,348 @@
1QashMoney - Budget/Finance Software for the Sharp Zaurus Copyright (C) 2002 Allen Forsythe
2
3 You may use, distribute and copy the this software under the terms of
4 GNU General Public License version 2, which is displayed below.
5
6-------------------------------------------------------------------------
7
8 GNU GENERAL PUBLIC LICENSE
9 Version 2, June 1991
10
11 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
12 675 Mass Ave, Cambridge, MA 02139, USA
13 Everyone is permitted to copy and distribute verbatim copies
14 of this license document, but changing it is not allowed.
15
16 Preamble
17
18 The licenses for most software are designed to take away your
19freedom to share and change it. By contrast, the GNU General Public
20License is intended to guarantee your freedom to share and change free
21software--to make sure the software is free for all its users. This
22General Public License applies to most of the Free Software
23Foundation's software and to any other program whose authors commit to
24using it. (Some other Free Software Foundation software is covered by
25the GNU Library General Public License instead.) You can apply it to
26your programs, too.
27
28 When we speak of free software, we are referring to freedom, not
29price. Our General Public Licenses are designed to make sure that you
30have the freedom to distribute copies of free software (and charge for
31this service if you wish), that you receive source code or can get it
32if you want it, that you can change the software or use pieces of it
33in new free programs; and that you know you can do these things.
34
35 To protect your rights, we need to make restrictions that forbid
36anyone to deny you these rights or to ask you to surrender the rights.
37These restrictions translate to certain responsibilities for you if you
38distribute copies of the software, or if you modify it.
39
40 For example, if you distribute copies of such a program, whether
41gratis or for a fee, you must give the recipients all the rights that
42you have. You must make sure that they, too, receive or can get the
43source code. And you must show them these terms so they know their
44rights.
45
46 We protect your rights with two steps: (1) copyright the software, and
47(2) offer you this license which gives you legal permission to copy,
48distribute and/or modify the software.
49
50 Also, for each author's protection and ours, we want to make certain
51that everyone understands that there is no warranty for this free
52software. If the software is modified by someone else and passed on, we
53want its recipients to know that what they have is not the original, so
54that any problems introduced by others will not reflect on the original
55authors' reputations.
56
57 Finally, any free program is threatened constantly by software
58patents. We wish to avoid the danger that redistributors of a free
59program will individually obtain patent licenses, in effect making the
60program proprietary. To prevent this, we have made it clear that any
61patent must be licensed for everyone's free use or not licensed at all.
62
63 The precise terms and conditions for copying, distribution and
64modification follow.
65
66 GNU GENERAL PUBLIC LICENSE
67 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
68
69 0. This License applies to any program or other work which contains
70a notice placed by the copyright holder saying it may be distributed
71under the terms of this General Public License. The "Program", below,
72refers to any such program or work, and a "work based on the Program"
73means either the Program or any derivative work under copyright law:
74that is to say, a work containing the Program or a portion of it,
75either verbatim or with modifications and/or translated into another
76language. (Hereinafter, translation is included without limitation in
77the term "modification".) Each licensee is addressed as "you".
78
79Activities other than copying, distribution and modification are not
80covered by this License; they are outside its scope. The act of
81running the Program is not restricted, and the output from the Program
82is covered only if its contents constitute a work based on the
83Program (independent of having been made by running the Program).
84Whether that is true depends on what the Program does.
85
86 1. You may copy and distribute verbatim copies of the Program's
87source code as you receive it, in any medium, provided that you
88conspicuously and appropriately publish on each copy an appropriate
89copyright notice and disclaimer of warranty; keep intact all the
90notices that refer to this License and to the absence of any warranty;
91and give any other recipients of the Program a copy of this License
92along with the Program.
93
94You may charge a fee for the physical act of transferring a copy, and
95you may at your option offer warranty protection in exchange for a fee.
96
97 2. You may modify your copy or copies of the Program or any portion
98of it, thus forming a work based on the Program, and copy and
99distribute such modifications or work under the terms of Section 1
100above, provided that you also meet all of these conditions:
101
102 a) You must cause the modified files to carry prominent notices
103 stating that you changed the files and the date of any change.
104
105 b) You must cause any work that you distribute or publish, that in
106 whole or in part contains or is derived from the Program or any
107 part thereof, to be licensed as a whole at no charge to all third
108 parties under the terms of this License.
109
110 c) If the modified program normally reads commands interactively
111 when run, you must cause it, when started running for such
112 interactive use in the most ordinary way, to print or display an
113 announcement including an appropriate copyright notice and a
114 notice that there is no warranty (or else, saying that you provide
115 a warranty) and that users may redistribute the program under
116 these conditions, and telling the user how to view a copy of this
117 License. (Exception: if the Program itself is interactive but
118 does not normally print such an announcement, your work based on
119 the Program is not required to print an announcement.)
120
121These requirements apply to the modified work as a whole. If
122identifiable sections of that work are not derived from the Program,
123and can be reasonably considered independent and separate works in
124themselves, then this License, and its terms, do not apply to those
125sections when you distribute them as separate works. But when you
126distribute the same sections as part of a whole which is a work based
127on the Program, the distribution of the whole must be on the terms of
128this License, whose permissions for other licensees extend to the
129entire whole, and thus to each and every part regardless of who wrote it.
130
131Thus, it is not the intent of this section to claim rights or contest
132your rights to work written entirely by you; rather, the intent is to
133exercise the right to control the distribution of derivative or
134collective works based on the Program.
135
136In addition, mere aggregation of another work not based on the Program
137with the Program (or with a work based on the Program) on a volume of
138a storage or distribution medium does not bring the other work under
139the scope of this License.
140
141 3. You may copy and distribute the Program (or a work based on it,
142under Section 2) in object code or executable form under the terms of
143Sections 1 and 2 above provided that you also do one of the following:
144
145 a) Accompany it with the complete corresponding machine-readable
146 source code, which must be distributed under the terms of Sections
147 1 and 2 above on a medium customarily used for software interchange; or,
148
149 b) Accompany it with a written offer, valid for at least three
150 years, to give any third party, for a charge no more than your
151 cost of physically performing source distribution, a complete
152 machine-readable copy of the corresponding source code, to be
153 distributed under the terms of Sections 1 and 2 above on a medium
154 customarily used for software interchange; or,
155
156 c) Accompany it with the information you received as to the offer
157 to distribute corresponding source code. (This alternative is
158 allowed only for noncommercial distribution and only if you
159 received the program in object code or executable form with such
160 an offer, in accord with Subsection b above.)
161
162The source code for a work means the preferred form of the work for
163making modifications to it. For an executable work, complete source
164code means all the source code for all modules it contains, plus any
165associated interface definition files, plus the scripts used to
166control compilation and installation of the executable. However, as a
167special exception, the source code distributed need not include
168anything that is normally distributed (in either source or binary
169form) with the major components (compiler, kernel, and so on) of the
170operating system on which the executable runs, unless that component
171itself accompanies the executable.
172
173If distribution of executable or object code is made by offering
174access to copy from a designated place, then offering equivalent
175access to copy the source code from the same place counts as
176distribution of the source code, even though third parties are not
177compelled to copy the source along with the object code.
178
179 4. You may not copy, modify, sublicense, or distribute the Program
180except as expressly provided under this License. Any attempt
181otherwise to copy, modify, sublicense or distribute the Program is
182void, and will automatically terminate your rights under this License.
183However, parties who have received copies, or rights, from you under
184this License will not have their licenses terminated so long as such
185parties remain in full compliance.
186
187 5. You are not required to accept this License, since you have not
188signed it. However, nothing else grants you permission to modify or
189distribute the Program or its derivative works. These actions are
190prohibited by law if you do not accept this License. Therefore, by
191modifying or distributing the Program (or any work based on the
192Program), you indicate your acceptance of this License to do so, and
193all its terms and conditions for copying, distributing or modifying
194the Program or works based on it.
195
196 6. Each time you redistribute the Program (or any work based on the
197Program), the recipient automatically receives a license from the
198original licensor to copy, distribute or modify the Program subject to
199these terms and conditions. You may not impose any further
200restrictions on the recipients' exercise of the rights granted herein.
201You are not responsible for enforcing compliance by third parties to
202this License.
203
204 7. If, as a consequence of a court judgment or allegation of patent
205infringement or for any other reason (not limited to patent issues),
206conditions are imposed on you (whether by court order, agreement or
207otherwise) that contradict the conditions of this License, they do not
208excuse you from the conditions of this License. If you cannot
209distribute so as to satisfy simultaneously your obligations under this
210License and any other pertinent obligations, then as a consequence you
211may not distribute the Program at all. For example, if a patent
212license would not permit royalty-free redistribution of the Program by
213all those who receive copies directly or indirectly through you, then
214the only way you could satisfy both it and this License would be to
215refrain entirely from distribution of the Program.
216
217If any portion of this section is held invalid or unenforceable under
218any particular circumstance, the balance of the section is intended to
219apply and the section as a whole is intended to apply in other
220circumstances.
221
222It is not the purpose of this section to induce you to infringe any
223patents or other property right claims or to contest validity of any
224such claims; this section has the sole purpose of protecting the
225integrity of the free software distribution system, which is
226implemented by public license practices. Many people have made
227generous contributions to the wide range of software distributed
228through that system in reliance on consistent application of that
229system; it is up to the author/donor to decide if he or she is willing
230to distribute software through any other system and a licensee cannot
231impose that choice.
232
233This section is intended to make thoroughly clear what is believed to
234be a consequence of the rest of this License.
235
236 8. If the distribution and/or use of the Program is restricted in
237certain countries either by patents or by copyrighted interfaces, the
238original copyright holder who places the Program under this License
239may add an explicit geographical distribution limitation excluding
240those countries, so that distribution is permitted only in or among
241countries not thus excluded. In such case, this License incorporates
242the limitation as if written in the body of this License.
243
244 9. The Free Software Foundation may publish revised and/or new versions
245of the General Public License from time to time. Such new versions will
246be similar in spirit to the present version, but may differ in detail to
247address new problems or concerns.
248
249Each version is given a distinguishing version number. If the Program
250specifies a version number of this License which applies to it and "any
251later version", you have the option of following the terms and conditions
252either of that version or of any later version published by the Free
253Software Foundation. If the Program does not specify a version number of
254this License, you may choose any version ever published by the Free Software
255Foundation.
256
257 10. If you wish to incorporate parts of the Program into other free
258programs whose distribution conditions are different, write to the author
259to ask for permission. For software which is copyrighted by the Free
260Software Foundation, write to the Free Software Foundation; we sometimes
261make exceptions for this. Our decision will be guided by the two goals
262of preserving the free status of all derivatives of our free software and
263of promoting the sharing and reuse of software generally.
264
265 NO WARRANTY
266
267 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
268FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
269OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
270PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
271OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
272MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
273TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
274PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
275REPAIR OR CORRECTION.
276
277 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
278WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
279REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
280INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
281OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
282TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
283YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
284PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
285POSSIBILITY OF SUCH DAMAGES.
286
287 END OF TERMS AND CONDITIONS
288
289 Appendix: How to Apply These Terms to Your New Programs
290
291 If you develop a new program, and you want it to be of the greatest
292possible use to the public, the best way to achieve this is to make it
293free software which everyone can redistribute and change under these terms.
294
295 To do so, attach the following notices to the program. It is safest
296to attach them to the start of each source file to most effectively
297convey the exclusion of warranty; and each file should have at least
298the "copyright" line and a pointer to where the full notice is found.
299
300 <one line to give the program's name and a brief idea of what it does.>
301 Copyright (C) 19yy <name of author>
302
303 This program is free software; you can redistribute it and/or modify
304 it under the terms of the GNU General Public License as published by
305 the Free Software Foundation; either version 2 of the License, or
306 (at your option) any later version.
307
308 This program is distributed in the hope that it will be useful,
309 but WITHOUT ANY WARRANTY; without even the implied warranty of
310 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
311 GNU General Public License for more details.
312
313 You should have received a copy of the GNU General Public License
314 along with this program; if not, write to the Free Software
315 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
316
317Also add information on how to contact you by electronic and paper mail.
318
319If the program is interactive, make it output a short notice like this
320when it starts in an interactive mode:
321
322 Gnomovision version 69, Copyright (C) 19yy name of author
323 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
324 This is free software, and you are welcome to redistribute it
325 under certain conditions; type `show c' for details.
326
327The hypothetical commands `show w' and `show c' should show the appropriate
328parts of the General Public License. Of course, the commands you use may
329be called something other than `show w' and `show c'; they could even be
330mouse-clicks or menu items--whatever suits your program.
331
332You should also get your employer (if you work as a programmer) or your
333school, if any, to sign a "copyright disclaimer" for the program, if
334necessary. Here is a sample; alter the names:
335
336 Yoyodyne, Inc., hereby disclaims all copyright interest in the program
337 `Gnomovision' (which makes passes at compilers) written by James Hacker.
338
339 <signature of Ty Coon>, 1 April 1989
340 Ty Coon, President of Vice
341
342This General Public License does not permit incorporating your program into
343proprietary programs. If your program is a subroutine library, you may
344consider it more useful to permit linking proprietary applications with the
345library. If this is what you want to do, use the GNU Library General
346Public License instead of this License.
347
348-------------------------------------------------------------------------
diff --git a/noncore/unsupported/qashmoney/README b/noncore/unsupported/qashmoney/README
new file mode 100755
index 0000000..ef004f7
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/README
@@ -0,0 +1,71 @@
1QashMoney - Budget Software for the Sharp Zaurus
2
3README
4
5This file lists all the important files in the qashmoney CVS directory and how
6to make the IPK file that goes on the Zaurus. When you checkout the
7qashmoney-source module from CVS, it will create a directory on your hard drive called
8qashmoney-source. These instructions assume you are in this directory.
9
10The first thing you need to do is have all the necessary cross-compile software
11and Qtopia installed on your system. I assume you have already done this since
12you are downloading CVS, but if not, go to:
13
14http://docs.zaurus.com
15
16and download the RPMS that you need for development.
17
18You also must have sqlite installed on your system to successfully compile
19QashMoney. Go to:
20
21http://www.sqlite.org
22
23to download this progam.
24
25After that, set the correct environment variables for the package you
26are developing. Two scripts in the qashmoney-source directory are used for that purpose: x86.sh
27and arm.sh. If you are building for x86 type:
28
29source x86.sh
30
31and press enter. To make binaries that run on the Zaurus, type:
32
33source arm.sh
34
35Next, construct the makefile by typing:
36
37tmake -o Makefile qashmoney.pro
38
39tmake is Trolltech's program for constructing a typical GNU Makefile from the
40project file (qashmoney.pro for this application). If you get an "error: tmake
41command not found", you either don't have all the correct RPMS installed or your
42environment variables are not correctly set. If all is well type:
43
44make
45
46and the program should be constructed and you will be left with a qashmoney
47binary in this directory. If you compiled for x86, you can see the application
48by using the Qt Virtual Frame Buffer which emulates the Qtopia environment on
49your computer. First, copy all the files from the databasefiles directory within the
50qashmoney directory. Otherwise, the program will not function.
51
52To run QashMoney in the Qtopia Virtual Frame Buffer, type:
53
54qvfb &
55./qashmoney -qws
56
57and QashMoney should appear in the frambuffer. You can use and test qashmoney
58here as you would on the Zaurus.
59
60If you want to compile the app and make the IPK file, check out the qashmoney-build module and see the README file in that module.
61
62I hope the program can be useful. If you have any questions or comments, please
63contact me at qashmoneyman@attbi.com
64
65Thanks!
66
67Allen
68
69Disclaimer: Altough I've tried to make this application tight and well
70functioning, it comes with absolutely no warranty and I will not be liable for
71any damage it may cause.
diff --git a/noncore/unsupported/qashmoney/TODO b/noncore/unsupported/qashmoney/TODO
new file mode 100755
index 0000000..c85b0d2
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/TODO
@@ -0,0 +1,15 @@
1QashMoney Budget Software for the Sharp Zaurus
2
3TODO
4
5Planned features for QashtMoney include:
6
7- Go to another account from within the transactionwindow
8- Move a transaction from one account to another
9- Purge transactions (remove them without effecting the account balances).
10- Add difference account types such as stocks, etc. Basically I want it to
11 becoming a full featured money app, hence the name!!
12- Open Financial Exchange protocol support
13- Allow limiting the number of transactions that are displayed when showing cleared transactions.
14 This will become important when a database becomes very large as the program will
15 slow greatly if it retrieves serveral hundred transactions to view.
diff --git a/noncore/unsupported/qashmoney/account.cpp b/noncore/unsupported/qashmoney/account.cpp
new file mode 100755
index 0000000..f21598e
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/account.cpp
@@ -0,0 +1,374 @@
1#include "account.h"
2#include "preferences.h"
3
4#include <qpixmap.h>
5#include <stdlib.h>
6
7extern Preferences *preferences;
8
9Account::Account ()
10 {
11 adb = sqlite_open ( "qmaccounts.db", 0, NULL );
12 }
13
14Account::~Account ()
15 {
16 sqlite_close ( adb );
17 }
18
19void Account::addAccount ( QString name, int parentid, float balance, int type, QString description, float creditlimit,
20 int statementyear, int statementmonth, int statementday, float statementbalance, const char *currency )
21 {
22 sqlite_exec_printf ( adb, "insert into accounts2 values ( '%q', %i, %.2f, %i, '%q', %.2f, %i, %i, %i, %.2f, '%q', 0, 0, 0, 0, 0, NULL );", 0, 0, 0,
23 (const char *) name, parentid, balance, type, (const char *) description, creditlimit, statementyear, statementmonth, statementday, statementbalance, currency );
24 }
25
26void Account::updateAccount ( QString name, QString description, QString currencycode, int accountid )
27 {
28 sqlite_exec_printf ( adb, "update accounts2 set name = '%q', description = '%q', currency = '%q' where accountid = %i;", 0, 0, 0, ( const char * ) name, ( const char * ) description, ( const char * ) currencycode, accountid );
29 }
30
31void Account::deleteAccount ( int accountid )
32 {
33 sqlite_exec_printf ( adb, "delete from accounts2 where accountid = %i;", 0, 0, 0, accountid );
34 }
35
36void Account::setAccountExpanded ( int expanded, int accountid )
37 {
38 sqlite_exec_printf ( adb, "update accounts2 set r1 = %i where accountid = %i;", 0, 0, 0, expanded, accountid );
39 }
40
41int Account::getAccountExpanded ( int id )
42 {
43 char **results;
44 sqlite_get_table_printf ( adb, "select r1 from accounts2 where accountid = %i;", &results, 0, 0, 0, id );
45 if ( strlen ( results [1] ) == 0 )
46 return 0;
47 else
48 return atoi ( results [ 1 ] );
49 }
50
51int Account::getNumberOfAccounts ()
52 {
53 char **results;
54 sqlite_get_table ( adb, "select count() from accounts2;", &results, NULL, NULL, NULL );
55 return atoi ( results [ 1 ] );
56 }
57
58int Account::getNumberOfChildAccounts ( int id )
59 {
60 char **results;
61 sqlite_get_table_printf ( adb, "select count() from accounts2 where parent = %i;", &results, NULL, NULL, NULL, id );
62 return atoi ( results [ 1 ] );
63 }
64
65void Account::updateAccountBalance ( int accountid )
66 {
67 // Here, we'll get a balance for the transactions in an account
68 sqlite *tdb = sqlite_open ( "qmtransactions.db", 0, NULL );
69 int rows, columns;
70 char **results;
71 sqlite_get_table_printf ( tdb, "select sum (amount) from transactions where accountid= %i;", &results, &rows, &columns, NULL, accountid );
72 float transactionsbalance = strtod ( results [ 1 ], 0 );
73 sqlite_close ( tdb );
74
75 // next, we'll get a balance for all the transfers from the account
76 sqlite *trdb = sqlite_open ( "qmtransfers.db", 0, NULL );
77 rows = 0;
78 columns = 0;
79 char **results2;
80 sqlite_get_table_printf ( trdb, "select sum (amount) from transfers where fromaccount = %i;", &results2, &rows, &columns, NULL, accountid );
81 float fromtransfersbalance = ( strtod ( results2 [ 1 ], 0 ) * -1 );
82
83 // finally, we'll get a balance for all the transfers into the account
84 rows = 0;
85 columns= 0;
86 char **results3;
87 sqlite_get_table_printf ( trdb, "select sum (amount) from transfers where toaccount = %i;", &results3, &rows, &columns, NULL, accountid );
88 float totransfersbalance = strtod ( results3 [ 1 ], 0 );
89
90 sqlite_close ( trdb );
91
92 // calculate and update new balance
93 sqlite_exec_printf ( adb, "update accounts2 set balance = %.2f where accountid = %i;", 0, 0, 0,
94 ( transactionsbalance + fromtransfersbalance + totransfersbalance + getStatementBalance ( accountid ) ), accountid );
95 }
96
97void Account::changeParentAccountBalance ( int parentid )
98 {
99 // select all child balances that share the parent of the current child account
100 char **results;
101 int rows;
102 sqlite_get_table_printf ( adb, "select sum ( balance ) from accounts2 where parent = %i;", &results, &rows, NULL, NULL, parentid );
103 sqlite_exec_printf ( adb, "update accounts2 set balance = %.2f where accountid = %i;", 0, 0, 0, strtod ( results[ 1 ], NULL ), parentid );
104 }
105
106int Account::getParentAccountID ( int id )
107 {
108 char **results;
109 sqlite_get_table_printf ( adb, "select parent from accounts2 where accountid = %i;", &results, NULL, NULL, NULL, id );
110 return atoi ( results [ 1 ] );
111 }
112
113int Account::getParentAccountID ( QString accountname )
114 {
115 char **results;
116 sqlite_get_table_printf ( adb, "select parent from accounts2 where name= '%q';", &results, NULL, NULL, NULL, ( const char * ) accountname );
117 return atoi ( results [ 1 ] );
118 }
119
120void Account::displayAccounts ( QListView *listview )
121 {
122 char **results;
123 int rows, columns;
124 sqlite_get_table ( adb, "select name, parent, balance, accountid, currency from accounts2;", &results, &rows, &columns, 0 );
125
126 // determine if we are using currency support
127 int currency = preferences->getPreference ( 4 );
128
129 // remove all columns from the account display
130 int counter;
131 for ( counter = 0; counter <= columns; counter++ )
132 listview->removeColumn ( 0 );
133
134 // add columns to the account display
135 listview->addColumn ( "Account", 0 );
136 int columntoalign = 1;
137 if ( preferences->getPreference ( 4 ) == 1 ) // add the currency column if the user wants it
138 {
139 listview->addColumn ( "C", 0 );
140 columntoalign = 2;
141 }
142 listview->addColumn ( "Balance", 0 );
143 listview->addColumn ( "", 0 );
144 listview->setColumnAlignment ( columntoalign, Qt::AlignRight );
145 counter = 5;
146 int total = ( rows + 1 ) * columns;
147 while ( counter < total )
148 {
149 int accountid = atoi ( results [ counter + 3 ] );
150 if ( atoi ( results [ counter + 1 ] ) == -1 )
151 {
152 QListViewItem *parent = new QListViewItem ( listview );
153 parent->setText ( 0, results [ counter ] );
154 if ( currency == 0 )
155 {
156 parent->setText ( 1, results [ counter + 2 ] );
157 parent->setText ( 2, results [ counter + 3 ] );
158 }
159 else
160 {
161 if ( getNumberOfChildAccounts ( accountid ) == 0 ) // add the currency flag if this is a parent with no children
162 {
163 // create the string we'll use to set the currency pixmap
164 QString filename = "/opt/QtPalmtop/pics/flags/";
165 QString flag = results [ counter + 4 ];
166 filename.append ( flag );
167 filename.append ( ".png" );
168 parent->setPixmap ( 1, QPixmap ( filename ) );
169 parent->setText ( 1, flag );
170 }
171 parent->setText ( 2, results [ counter + 2 ] );
172 parent->setText ( 3, results [ counter + 3 ] );
173 }
174
175 if ( getAccountExpanded ( accountid ) == 1 )
176 parent->setOpen ( TRUE );
177
178 //Start display child accounts for this parent
179 int childcounter = 5;
180 while ( childcounter < total )
181 {
182 if ( atoi ( results [ childcounter + 1 ] ) == accountid )
183 {
184 if ( currency == 0 )
185 QListViewItem *child = new QListViewItem ( parent, results [ childcounter ], results [ childcounter + 2 ], results [ childcounter + 3 ] );
186 else
187 {
188 // create the string we'll use to set the currency pixmap
189 QString filename = "/opt/QtPalmtop/pics/flags/";
190 QString flag = results [ childcounter + 4 ];
191 filename.append ( flag );
192 filename.append ( ".png" );
193 QListViewItem *child = new QListViewItem ( parent, results [ childcounter ], "", results [ childcounter + 2 ], results [ childcounter + 3 ] );
194 child->setPixmap ( 1, QPixmap ( filename ) );
195 child->setText ( 1, flag );
196 }
197 }
198 childcounter = childcounter + 5;
199 }
200 //End display child accounts
201 }
202 counter = counter + 5;
203 }
204
205 // resize all columns appropriately
206 if ( preferences->getPreference ( 4 ) == 0 )
207 {
208 listview->setColumnWidth ( 0, preferences->getColumnPreference ( 1 ) );
209 listview->setColumnWidthMode ( 0, QListView::Manual );
210 listview->setColumnWidth ( 1, preferences->getColumnPreference ( 2 ) );
211 listview->setColumnWidthMode ( 1, QListView::Manual );
212 listview->setColumnWidthMode ( 2, QListView::Manual );
213 }
214 else
215 {
216 listview->setColumnWidth ( 0, preferences->getColumnPreference ( 10 ) );
217 listview->setColumnWidthMode ( 0, QListView::Manual );
218 listview->setColumnWidth ( 1, preferences->getColumnPreference ( 11 ) );
219 listview->setColumnWidthMode ( 1, QListView::Manual );
220 listview->setColumnWidth ( 2, preferences->getColumnPreference ( 12 ) );
221 listview->setColumnWidthMode ( 2, QListView::Manual );
222 listview->setColumnWidthMode ( 3, QListView::Manual );
223 }
224
225 // Now reset the column sorting to user preference
226 int column = 0;
227 int direction = 0;
228 preferences->getSortingPreference ( 1, &column, &direction );
229 listview->setSorting ( column, direction );
230 }
231
232int Account::displayParentAccountNames ( QComboBox *combobox, QString indexstring )
233 {
234 char **results;
235 int rows, columns, index;
236 index = 0;
237 sqlite_get_table ( adb, "select name from accounts2 order by name asc;", &results, &rows, &columns, NULL );
238 int counter = 1;
239 int indexcounter = 1;
240 int total = ( rows + 1 ) * columns;
241 while ( counter < total )
242 {
243 if ( getParentAccountID ( results [ counter ] ) == -1 )
244 {
245 combobox->insertItem ( results [ counter ], -1 );
246 if ( strcmp ( results [ counter ], indexstring ) == 0 )
247 index = indexcounter;
248 indexcounter++;
249 }
250 counter ++;
251 }
252 return index;
253 }
254
255int Account::getAccountType ( int accountid )
256 {
257 char **results;
258 sqlite_get_table_printf ( adb, "select type from accounts2 where accountid= %i;", &results, NULL, NULL, NULL, accountid );
259 return atoi ( results [ 1 ] );
260 }
261
262int Account::getStatementDay ( int accountid )
263 {
264 char **results;
265 sqlite_get_table_printf ( adb, "select statementday from accounts2 where accountid= %i;", &results, NULL, NULL, NULL, accountid );
266 return atoi ( results [ 1 ] );
267 }
268
269int Account::getStatementMonth ( int accountid )
270 {
271 char **results;
272 sqlite_get_table_printf ( adb, "select statementmonth from accounts2 where accountid= %i;", &results, NULL, NULL, NULL, accountid );
273 return atoi ( results [ 1 ] );
274 }
275
276int Account::getStatementYear ( int accountid )
277 {
278 char **results;
279 sqlite_get_table_printf ( adb, "select statementyear from accounts2 where accountid= %i;", &results, NULL, NULL, NULL, accountid );
280 return atoi ( results [ 1 ] );
281 }
282
283QString Account::getAccountDescription ( int accountid )
284 {
285 char **results;
286 sqlite_get_table_printf ( adb, "select description from accounts2 where accountid= %i;", &results, NULL, NULL, NULL, accountid );
287 return ( QString ) results [ 1 ];
288 }
289
290QString Account::getCurrencyCode ( int accountid )
291 {
292 char **results;
293 sqlite_get_table_printf ( adb, "select currency from accounts2 where accountid= %i;", &results, NULL, NULL, NULL, accountid );
294 return ( QString ) results [ 1 ];
295 }
296
297QString Account::getAccountName ( int accountid )
298 {
299 char **results;
300 sqlite_get_table_printf ( adb, "select name from accounts2 where accountid= %i;", &results, NULL, NULL, NULL, accountid );
301 return ( QString ) results [ 1 ];
302 }
303
304QString Account::getAccountBalance ( int accountid )
305 {
306 char **results;
307 sqlite_get_table_printf ( adb, "select balance from accounts2 where accountid= %i;", &results, NULL, NULL, NULL, accountid );
308 return ( QString ) results [ 1 ];
309 }
310
311float Account::getAccountCreditLimit ( int accountid )
312 {
313 char **results;
314 sqlite_get_table_printf ( adb, "select creditlimit from accounts2 where accountid = %i;", &results, NULL, NULL, NULL, accountid );
315 return strtod ( results [ 1 ], NULL );
316 }
317
318float Account::getStatementBalance ( int accountid )
319 {
320 char **results;
321 sqlite_get_table_printf ( adb, "select statementbalance from accounts2 where accountid = %i;", &results, NULL, NULL, NULL, accountid );
322 return strtod ( results [ 1 ], NULL );
323 }
324
325GreyBackgroundItem::GreyBackgroundItem ( QListView *parent )
326 : QListViewItem ( parent )
327 {
328 }
329
330GreyBackgroundItem::GreyBackgroundItem ( QListView *parent, QString label1, QString label2, QString label3 )
331 : QListViewItem ( parent, label1, label2, label3 )
332 {
333 }
334
335GreyBackgroundItem::GreyBackgroundItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4 )
336 : QListViewItem ( parent, label1, label2, label3, label4 )
337 {
338 }
339
340GreyBackgroundItem::GreyBackgroundItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4, QString label5 )
341 : QListViewItem ( parent, label1, label2, label3, label4, label5 )
342 {
343 }
344
345void GreyBackgroundItem::paintCell ( QPainter *p, const QColorGroup &cg, int column, int width, int alignment )
346 {
347 QColorGroup _cg ( cg );
348 _cg.setColor ( QColorGroup::Base, Qt::lightGray );
349 QListViewItem::paintCell ( p, _cg, column, width, alignment );
350 }
351
352QStringList Account::getAccountNames ()
353 {
354 QStringList accountnames;
355 char **results;
356 int rows, counter;
357 sqlite_get_table ( adb, "select name from accounts2;", &results, &rows, 0, 0 );
358 for ( counter = 0; counter < rows; counter++ )
359 accountnames.append ( results [ counter+1 ] );
360 return accountnames;
361 }
362
363QStringList Account::getAccountIDs ()
364 {
365 QStringList accountids;
366 char **results;
367 int rows, counter;
368 sqlite_get_table ( adb, "select accountid from accounts2;", &results, &rows, 0, 0 );
369 for ( counter = 0; counter < rows; counter++ )
370 accountids.append ( results [ counter+1 ] );
371 return accountids;
372 }
373
374
diff --git a/noncore/unsupported/qashmoney/account.h b/noncore/unsupported/qashmoney/account.h
new file mode 100755
index 0000000..5bad4a1
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/account.h
@@ -0,0 +1,100 @@
1#ifndef ACCOUNT_H
2#define ACCOUNT_H
3
4#include <qstring.h>
5#include <qlistview.h>
6#include <qcombobox.h>
7#include <sqlite3.h>
8
9class Account
10 {
11 public:
12
13 Account ();
14 ~Account ();
15
16 // This function adds a new account to the database. It takes the account name, parent,
17 // initial balance and the account type, description, credit limit, statementbalancedate
18 // as three integers, and the statementbalance amount
19 // The parent is an integer account id. Its -1 if there is no parent
20 // The account types (so far) are 0=not defined 1=parent checking 2=child checking
21 void addAccount ( QString, int, float, int, QString, float, int, int, int, float, const char * );
22
23 // updates certain parts of an account
24 void updateAccount ( QString name, QString description, QString currencycode, int accountid );
25
26 void setAccountExpanded ( int expanded, int accountid );
27 int getAccountExpanded ( int id );
28
29 // Deletes an account
30 // Takes the accountid as its parameter
31 void deleteAccount ( int );
32
33 // Returns the number of accounts
34 int getNumberOfAccounts ();
35
36 // returns number of child accounts for a given parent
37 // this function is useless for child accounts. It will
38 // always return 0
39 int getNumberOfChildAccounts ( int );
40
41 // This function retrieves all transactions for an account and updates the
42 // account balance based on the transactions
43 void updateAccountBalance ( int accountid );
44 //void changeAccountBalance ( int accountid, float amount );
45
46 // updates a parent account
47 void changeParentAccountBalance ( int parentid );
48
49 // Returns the parent account ID for an account
50 // Takes the account name as its parameter or the account id
51 int getParentAccountID ( QString accountname );
52 int getParentAccountID ( int id );
53
54 // This takes a QListView and puts parents and children memorys
55 // into the list view
56 void displayAccounts ( QListView * );
57
58 // This function displays a sorted list of account names in a combobox
59 // Takes the combobox address for its parameter
60 int displayParentAccountNames ( QComboBox *, QString );
61
62 int getAccountType ( int ); // returns account type for given account id
63
64 // The next three collectively return a date or balance
65 // They take the accountid as their parameters
66 int getStatementDay ( int );
67 int getStatementMonth ( int );
68 int getStatementYear ( int );
69 float getStatementBalance ( int );
70
71 // Returns account description and name
72 QString getAccountDescription ( int accountid );
73 QString getCurrencyCode ( int accountid );
74 QString getAccountName ( int accountid );
75 QStringList getAccountNames ();
76 QStringList getAccountIDs ();
77 QString getAccountBalance ( int accountid );
78
79 // returns account credit limit
80 float getAccountCreditLimit ( int );
81
82 // The primary database that stores all our data
83 sqlite3 *adb;
84 };
85
86class GreyBackgroundItem : public QListViewItem
87 {
88 public:
89
90 GreyBackgroundItem ( QListView *parent );
91 GreyBackgroundItem ( QListView *parent, QString label1, QString label2, QString label3 );
92 GreyBackgroundItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4 );
93 GreyBackgroundItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4, QString label5 );
94
95 virtual void paintCell ( QPainter *p, const QColorGroup &cg, int column, int width, int alignment );
96
97 };
98
99#endif
100
diff --git a/noncore/unsupported/qashmoney/accountdisplay.cpp b/noncore/unsupported/qashmoney/accountdisplay.cpp
new file mode 100755
index 0000000..046d997
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/accountdisplay.cpp
@@ -0,0 +1,451 @@
1#include "accountdisplay.h"
2#include "newaccount.h"
3#include "transaction.h"
4#include "transferdialog.h"
5#include "transfer.h"
6
7/* OPIE */
8#include <opie2/odebug.h>
9using namespace Opie::Core;
10
11/* QT */
12#include <qmessagebox.h>
13#include <qheader.h>
14
15extern Account *account;
16extern Transaction *transaction;
17extern Transfer *transfer;
18extern Preferences *preferences;
19
20AccountDisplay::AccountDisplay ( QWidget *parent ) : QWidget ( parent )
21 {
22 cleared = 0;
23
24 firstline = new QHBox ( this );
25 firstline->setSpacing ( 2 );
26
27 newaccount = new QPushButton ( firstline );
28 newaccount->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/new.png") );
29 connect ( newaccount, SIGNAL ( released() ), this, SLOT ( addAccount() ) );
30
31 editaccount = new QPushButton ( firstline );
32 editaccount->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/edit.png") );
33 connect ( editaccount, SIGNAL ( released() ), this, SLOT ( editAccount() ) );
34
35 deleteaccount = new QPushButton ( firstline );
36 deleteaccount->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/delete.png") );
37 connect ( deleteaccount, SIGNAL ( released() ), this, SLOT ( deleteAccount() ) );
38
39 transferbutton = new QPushButton ( firstline );
40 transferbutton->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/transfer.png") );
41 transferbutton->setToggleButton ( TRUE );
42 connect ( transferbutton, SIGNAL ( toggled(bool) ), this, SLOT ( accountTransfer(bool) ) );
43
44 listview = new QListView ( this );
45 listview->setAllColumnsShowFocus ( TRUE );
46 listview->setShowSortIndicator ( TRUE );
47 listview->setRootIsDecorated ( TRUE );
48 listview->setMultiSelection ( FALSE );
49 connect ( listview, SIGNAL ( expanded(QListViewItem*) ), this, SLOT ( setAccountExpanded(QListViewItem*) ) );
50 connect ( listview, SIGNAL ( collapsed(QListViewItem*) ), this, SLOT ( setAccountCollapsed(QListViewItem*) ) );
51
52 listview->header()->setTracking ( FALSE );
53 connect ( listview->header(), SIGNAL ( sizeChange(int,int,int) ), this, SLOT ( saveColumnSize(int,int,int) ) );
54 connect ( listview->header(), SIGNAL ( clicked(int) ), this, SLOT ( saveSortingPreference(int) ) );
55
56 layout = new QVBoxLayout ( this, 2, 5 );
57 layout->addWidget ( firstline );
58 layout->addWidget ( listview );
59 }
60
61void AccountDisplay::setTabs ( QWidget *newtab2, QTabWidget *newtabs )
62 {
63 tab2 = newtab2;
64 maintabs = newtabs;
65 }
66
67void AccountDisplay::addAccount ()
68 {
69 // initialize local variables
70 int parentid = 0;
71 type = 0;
72 QString parentlist [ listview->childCount() + 1 ] [ 3 ] ;
73
74 // create new account window for entering data
75 NewAccount *newaccount = new NewAccount ( this );
76 int width = this->width();
77 newaccount->accountbox->setMaximumWidth ( ( int ) ( width * 0.5 ) );
78 newaccount->datebox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
79 newaccount->childbox->setMaximumWidth ( ( int ) ( width * 0.5 ) );
80 newaccount->balancebox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
81 newaccount->creditlimitbox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
82
83 // if there are no accounts, disable the child check box
84 if ( account->getNumberOfAccounts () == 0 )
85 newaccount->childcheckbox->setEnabled ( FALSE );
86
87 // if there are accounts, fill up the pulldown menu for
88 // selecting a parent account. We should only add those parents without transactions
89 else
90 {
91 int c = 0;
92 QListViewItemIterator it ( listview );
93 for ( ; it.current(); ++it )
94 {
95 int id = it.current()->text ( getIDColumn() ).toInt();
96 // iterate through accountdisplay listview and add parents with no transactions
97 // add this item to the list box only if it is a parent and has no transactions
98 if ( transfer->getNumberOfTransfers ( id ) == 0 && transaction->getNumberOfTransactions ( id ) == 0 && it.current()->parent() == 0 )
99 {
100 newaccount->childbox->insertItem ( it.current()->text ( 0 ) );
101 parentlist [ c ] [ 0 ] = it.current()->text ( 0 );
102 parentlist [ c ] [ 1 ] = it.current()->text ( getIDColumn() );
103 parentlist [ c ] [ 2 ] = QString::number ( c );
104 c++;
105 }
106 }
107 }
108
109 if ( preferences->getPreference ( 4 ) == 0 )
110 newaccount->currencybox->setEnabled ( FALSE );
111
112 // enter today's date in the date box as default
113 QDate today = QDate::currentDate ();
114 int defaultday = today.day();
115 int defaultmonth = today.month();
116 int defaultyear = today.year();
117 newaccount->startdate->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) );
118
119 //add account information if user pushes OK button
120 if ( newaccount->exec() == QDialog::Accepted )
121 {
122 if ( newaccount->childcheckbox->isChecked () == TRUE ) // set a parent id and type for a child account
123 {
124 // go through the parentlist we created and determine the parent accountid
125 // we can't use the name of the account because there may be two accounts
126 // with the same name. This function does it all by accountid
127 int counter;
128 for ( counter = 0; counter < listview->childCount() + 1; counter++ )
129 if ( ( parentlist [ counter ] [ 2 ].toInt() ) == newaccount->childbox->currentItem() )
130 {
131 parentid = parentlist [ counter ] [ 1 ].toInt();
132 break;
133 }
134 type = ( newaccount->accounttype->currentItem() ) + 6; // sets account ids for child accounts. See accountdisplay.h for types
135 }
136 else
137 {
138 parentid = -1;
139 type = newaccount->accounttype->currentItem(); // sets account ids for parent accounts
140 }
141
142 // add the new account
143 if ( newaccount->getDateEdited () == TRUE )
144 account->addAccount ( newaccount->accountname->text(), parentid, newaccount->accountbalance->text().toFloat(), type,
145 newaccount->getDescription(), newaccount->creditlimit->text().toFloat(), newaccount->getYear(),
146 newaccount->getMonth(), newaccount->getDay(), newaccount->accountbalance->text().toFloat(), newaccount->currencybox->currencybox->currentText() );
147 else
148 account->addAccount ( newaccount->accountname->text (), parentid, newaccount->accountbalance->text().toFloat(), type,
149 newaccount->getDescription(), newaccount->creditlimit->text().toFloat(), defaultyear,
150 defaultmonth, defaultday, newaccount->accountbalance->text().toFloat(), newaccount->currencybox->currencybox->currentText() );
151
152 if ( parentid != -1 )
153 account->changeParentAccountBalance ( parentid );
154
155 // redisplay accounts
156 // this function clears the account display first
157 account->displayAccounts ( listview );
158 setToggleButton();
159 }
160 maintabs->setTabEnabled ( tab2, FALSE );
161 }
162
163void AccountDisplay::deleteAccount ()
164 {
165 if ( listview->selectedItem() == 0 )
166 QMessageBox::warning ( this, "QashMoney", "Please select an account\nto delete.");
167 else if ( listview->selectedItem()->parent() == 0 && listview->selectedItem()->childCount() != 0 )
168 QMessageBox::warning ( this, "QashMoney", "Can't delete parent accounts\nwith children");
169 else
170 {
171 QMessageBox mb ( "Delete Account", "This will delete all transactions\nand transfers for this account.", QMessageBox::Information, QMessageBox::Ok, QMessageBox::Cancel, QMessageBox::NoButton );
172 if ( mb.exec() == QMessageBox::Ok )
173 {
174 int accountid = listview->selectedItem()->text ( getIDColumn() ).toInt ();
175 int parentid = account->getParentAccountID ( accountid );
176
177 // delete all the transactions and transfers for the account
178 transaction->deleteAllTransactions ( accountid );
179 transfer->deleteAllTransfers ( accountid );
180
181 // delete the account
182 account->deleteAccount ( accountid );
183
184 // update account balances
185 if ( parentid != -1 )
186 account->changeParentAccountBalance ( parentid );
187
188 //redisplay accounts
189 account->displayAccounts ( listview );
190
191 //remove all the columns from the accountdisplay if there are not any accounts
192 if ( account->getNumberOfAccounts() == 0 )
193 {
194 int columns = listview->columns();
195 int counter;
196 for ( counter = 0; counter <= columns; counter++ )
197 listview->removeColumn ( 0 );
198 }
199
200 setToggleButton();
201 }
202 }
203 maintabs->setTabEnabled ( tab2, FALSE );
204 }
205
206void AccountDisplay::setToggleButton ()
207 {
208 // iterate through account display and determine how many "transferable" accounts we have
209 // if there are less than two, disable the transfer button
210 QListViewItemIterator it ( listview );
211 int counter = 0;
212 for ( ; it.current(); ++it )
213 {
214 // add one to counter if we find a transferable account
215 if ( it.current()->parent() != 0 || ( it.current()->childCount() ) == 0 )
216 counter++;
217 }
218 if ( counter > 1 )
219 transferbutton->show();
220 else
221 transferbutton->hide();
222 }
223
224void AccountDisplay::accountTransfer ( bool state )
225 {
226 if ( state == TRUE )
227 {
228 firstaccountid = -1;
229 secondaccountid = -1;
230 listview->clearSelection ();
231 listview->setMultiSelection ( TRUE );
232 disableParentsWithChildren ();
233 connect ( listview, SIGNAL ( clicked(QListViewItem*) ), this, SLOT ( getTransferAccounts(QListViewItem*) ) );
234 }
235 else
236 {
237 firstaccountid = -1;
238 secondaccountid = -1;
239 listview->clearSelection ();
240 listview->setMultiSelection ( FALSE );
241 enableAccounts ();
242 disconnect ( listview, SIGNAL ( clicked(QListViewItem*) ), this, SLOT ( getTransferAccounts(QListViewItem*) ) );
243 }
244 }
245
246void AccountDisplay::getTransferAccounts ( QListViewItem * item )
247 {
248 if ( item->parent() != 0 || item->childCount() == 0 ) // only set an account for transfer if its a child or parent with no children
249 {
250 if ( firstaccountid == -1 )
251 firstaccountid = item->text ( getIDColumn() ).toInt(); // set first account if we've selected a valid account
252 else
253 if ( item->text ( getIDColumn() ).toInt() != firstaccountid ) // set the second account if its not equal to the first
254 secondaccountid = item->text ( getIDColumn() ).toInt();
255 }
256
257 // open transfer window if both accounts are set
258 if ( firstaccountid != -1 && secondaccountid != -1 )
259 {
260 // construct the transferdialog window
261 TransferDialog *td = new TransferDialog ( this, firstaccountid, secondaccountid );
262
263 // enter today's date in the date box as default
264 QDate today = QDate::currentDate ();
265 int defaultday = today.day();
266 int defaultmonth = today.month();
267 int defaultyear = today.year();
268 td->date->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) );
269
270 if ( td->exec() == QDialog::Accepted )
271 {
272 // set the cleared integer if the checkbox is checked
273 if ( td->clearedcheckbox->isChecked() == TRUE )
274 cleared = 1;
275 odebug << "Year from transferdialog = " << td->getYear() << "" << oendl;
276 // add the transfer with a new date if its been edited or use the default date
277 if ( td->getDateEdited () == TRUE )
278 transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, account->getParentAccountID ( secondaccountid ), td->getDay(), td->getMonth(), td->getYear(), td->amount->text().toFloat(), cleared );
279 else
280 transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, account->getParentAccountID ( secondaccountid ), defaultday, defaultmonth, defaultyear, td->amount->text().toFloat(), cleared );
281
282 // update account balances of both accounts and parents if necessary
283 account->updateAccountBalance ( firstaccountid );
284 if ( account->getParentAccountID ( firstaccountid ) != -1 )
285 account->changeParentAccountBalance ( account->getParentAccountID ( firstaccountid ) );
286 account->updateAccountBalance ( secondaccountid );
287 if ( account->getParentAccountID ( secondaccountid ) != -1 )
288 account->changeParentAccountBalance ( account->getParentAccountID ( secondaccountid ) );
289
290 // redisplay accounts
291 account->displayAccounts ( listview );
292 }
293 else
294 {
295 firstaccountid = -1;
296 secondaccountid = -1;
297 listview->clearSelection ();
298 listview->setMultiSelection ( FALSE );
299 disconnect ( listview, SIGNAL ( clicked(QListViewItem*) ), this, SLOT ( getTransferAccounts(QListViewItem*) ) );
300 }
301
302 // reset the accounts display window
303 transferbutton->toggle(); // toggling this button with clear the window as well
304
305 // reenable all the accounts so the transaction tab will be properly set
306 enableAccounts ();
307 }
308 }
309
310void AccountDisplay::disableParentsWithChildren ()
311 {
312 // iterate through accountdisplay listview and disable all the parents that have children
313 QListViewItemIterator it ( listview );
314 for ( ; it.current(); ++it )
315 {
316 if ( it.current()->parent() == 0 && it.current()->childCount() != 0 )
317 it.current()->setSelectable ( FALSE );
318 }
319 }
320
321void AccountDisplay::enableAccounts ()
322 {
323 // iterate through accountdisplay listview and enable all accounts
324 QListViewItemIterator it ( listview );
325 for ( ; it.current(); ++it )
326 it.current()->setSelectable ( TRUE );
327 }
328
329void AccountDisplay::saveColumnSize ( int column, int oldsize, int newsize )
330 {
331 switch ( column )
332 {
333 case 0:
334 if ( listview->columns() == 3 )
335 preferences->changeColumnPreference ( 1, newsize );
336 else
337 preferences->changeColumnPreference ( 10, newsize );
338 break;
339 case 1:
340 if ( listview->columns() == 3 )
341 preferences->changeColumnPreference ( 2, newsize );
342 else
343 preferences->changeColumnPreference ( 11, newsize );
344 break;
345 case 2:
346 preferences->changeColumnPreference ( 12, newsize );
347 break;
348 }
349
350 }
351
352void AccountDisplay::saveSortingPreference ( int column )
353 {
354 preferences->changeSortingPreference ( 1, column );
355 }
356
357int AccountDisplay::getIDColumn ()
358 {
359 int counter;
360 int columns = listview->columns();
361 for ( counter = 0; counter <= columns; counter++ )
362 if ( listview->header()->label ( counter ).length() == 0 )
363 return counter;
364 }
365
366void AccountDisplay::editAccount ()
367 {
368 if ( listview->selectedItem() == 0 )
369 QMessageBox::warning ( this, "QashMoney", "Please select an account\nto edit.");
370 else
371 {
372 // set the accountid
373 int accountid = listview->selectedItem()->text ( getIDColumn() ).toInt();
374
375 //construct new dialog box
376 QDialog *editaccountwindow = new QDialog ( this, 0, TRUE );
377 editaccountwindow->setCaption ( "Edit Account" );
378
379 // construct the items which will go in the dialog bix
380 QLabel *namelabel = new QLabel ( "Account Name", editaccountwindow );
381 QLineEdit *accountname = new QLineEdit ( editaccountwindow );
382 QLabel *descriptionlabel = new QLabel ( "Account Description", editaccountwindow );
383 QLineEdit *accountdescription = new QLineEdit ( editaccountwindow );
384 Currency *currencybox = new Currency ( editaccountwindow );
385
386 QVBoxLayout *layout = new QVBoxLayout ( editaccountwindow, 5, 2 );
387 layout->addWidget ( namelabel );
388 layout->addWidget ( accountname );
389 layout->addWidget ( descriptionlabel );
390 layout->addWidget ( accountdescription );
391 layout->addWidget ( currencybox );
392
393 //set the account name
394 accountname->setText ( listview->selectedItem()->text ( 0 ) );
395
396 //set the account description
397 accountdescription->setText ( account->getAccountDescription ( accountid ) );
398
399 if ( preferences->getPreference ( 4 ) == 1 )
400 {
401 // get currency code for this account then iterate through the currency box
402 // to find the one we want
403 int count = currencybox->currencybox->count();
404 QString code = account->getCurrencyCode ( accountid );
405 for ( int counter = 0; count - 1; counter++ )
406 {
407 if ( QString::compare ( currencybox->currencybox->text ( counter ), code ) == 0 )
408 {
409 currencybox->currencybox->setCurrentItem ( counter );
410 break;
411 }
412 }
413 }
414 else
415 currencybox->setEnabled ( FALSE );
416
417 //execute the dialog box
418 int response = editaccountwindow->exec();
419 if ( response == 1 )
420 {
421 account->updateAccount ( accountname->text(), accountdescription->text(), currencybox->currencybox->currentText(), accountid );
422 account->displayAccounts ( listview );
423
424 // Try and select the same account that was just edited
425 QListViewItemIterator it ( listview );
426 for ( ; it.current(); ++it )
427 {
428 if ( it.current()->text ( 0 ) == accountname->text() )
429 {
430 listview->setSelected ( it.current(), TRUE );
431 return;
432 }
433 }
434 maintabs->setTabEnabled ( tab2, FALSE );
435 }
436 }
437 }
438
439void AccountDisplay::setAccountExpanded ( QListViewItem *item )
440 {
441 int accountid = item->text ( getIDColumn() ).toInt();
442 account->setAccountExpanded ( 1, accountid );
443 }
444
445void AccountDisplay::setAccountCollapsed ( QListViewItem *item )
446 {
447 int accountid = item->text ( getIDColumn() ).toInt();
448 account->setAccountExpanded ( 0, accountid );
449 }
450
451
diff --git a/noncore/unsupported/qashmoney/accountdisplay.h b/noncore/unsupported/qashmoney/accountdisplay.h
new file mode 100755
index 0000000..6d67b9b
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/accountdisplay.h
@@ -0,0 +1,54 @@
1#ifndef ACCOUNTDISPLAY_H
2#define ACCOUNTDISPLAY_H
3
4#include <qlistview.h>
5#include <qpushbutton.h>
6#include <qlayout.h>
7#include <qtabwidget.h>
8#include <qhbox.h>
9
10class AccountDisplay : public QWidget
11 {
12 Q_OBJECT
13
14 public:
15 AccountDisplay ( QWidget *parent );
16
17 QHBox *firstline;
18
19 QPushButton* newaccount;
20 QPushButton* editaccount;
21 QPushButton* deleteaccount;
22 QPushButton* transferbutton;
23
24 QListView* listview;
25
26 QBoxLayout *layout;
27
28 void setTabs ( QWidget *newtab2, QTabWidget *newtabs );
29 int getIDColumn ();
30 void setToggleButton ();
31
32 public slots:
33 void addAccount ();
34 void editAccount ();
35 void deleteAccount ();
36 void accountTransfer ( bool state );
37 void getTransferAccounts ( QListViewItem * item );
38 void disableParentsWithChildren ();
39 void enableAccounts ();
40
41 private slots:
42 void saveColumnSize ( int column, int oldsize, int newsize );
43 void setAccountExpanded ( QListViewItem *item );
44 void setAccountCollapsed ( QListViewItem *item );
45 void saveSortingPreference ( int column );
46
47 private:
48 int type, firstaccountid, secondaccountid, cleared;
49 QWidget *tab2;
50 QTabWidget *maintabs;
51};
52
53#endif // ACCOUNTDISPLAY_H
54
diff --git a/noncore/unsupported/qashmoney/budget.cpp b/noncore/unsupported/qashmoney/budget.cpp
new file mode 100755
index 0000000..2cec329
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/budget.cpp
@@ -0,0 +1,221 @@
1#include "budget.h"
2#include "transaction.h"
3#include <stdlib.h>
4
5extern Transaction *transaction;
6
7Budget::Budget ()
8 {
9 bdb = sqlite_open ( "qmbudgets.db", 0, NULL );
10 }
11
12Budget::~Budget ()
13 {
14 sqlite_close ( bdb );
15 }
16
17int Budget::addBudget ( QString name, int type, QString description, QString currency, int startday, int startmonth, int startyear, int endday, int endmonth, int endyear, int defaultview )
18 {
19 sqlite_exec_printf ( bdb, "insert into budgets values ( '%q', %i, '%q', '%q', %i, %i, %i, %i, %i, %i, %i, NULL );", 0, 0, 0, ( const char * ) name, type, ( const char * ) description, ( const char * ) currency, startday, startmonth, startyear, endday, endmonth, endyear, defaultview );
20 char **results;
21 sqlite_get_table ( bdb, "select last_insert_rowid() from budgets;", &results, NULL, NULL, NULL );
22 QString tablename = "table";
23 tablename.append ( results [ 1 ] );
24 sqlite_exec_printf ( bdb, "create table '%q' ( name, lineitemamount, type, lineitemid integer primary key );", 0, 0, 0, ( const char* ) tablename );
25 return atoi ( results [ 1 ] );
26 }
27
28void Budget::updateBudget ( QString name, QString description, QString currency, int budgetid )
29 {
30 sqlite_exec_printf ( bdb, "update budgets set name = '%q', description = '%q', currency = '%q' where budgetid = %i;", 0, 0, 0, ( const char * ) name, ( const char * ) description, ( const char * ) currency, budgetid );
31 }
32
33void Budget::deleteBudget ( int budgetid )
34 {
35 if ( getNumberOfBudgets() != 0 )
36 {
37 QString tablename = "table";
38 tablename.append ( QString::number ( budgetid ) );
39 sqlite_exec_printf ( bdb, "delete from budgets where budgetid = %i;", 0, 0, 0, budgetid );
40 sqlite_exec_printf ( bdb, "drop table '%q';", 0, 0, 0, ( const char* ) tablename );
41 }
42 }
43
44int Budget::getNumberOfBudgets ()
45 {
46 char **results;
47 sqlite_get_table ( bdb, "select count() from budgets;", &results, NULL, NULL, NULL );
48 return atoi ( results [ 1 ] );
49 }
50
51int Budget::getNumberOfLineItems ( int budgetid )
52 {
53 QString tablename = "table";
54 tablename.append ( QString::number ( budgetid ) );
55 char **results;
56 sqlite_get_table_printf ( bdb, "select count() from '%q';", &results, NULL, NULL, NULL, ( const char * ) tablename );
57 return atoi ( results [ 1 ] );
58 }
59
60QStringList* Budget::getBudgetNames ()
61 {
62 QStringList *names = new QStringList ();
63 char **results;
64 int rows, counter;
65 sqlite_get_table ( bdb, "select name from budgets;", &results, &rows, NULL, NULL );
66 names->append ( "None" );
67 for ( counter = 0; counter < rows; counter++ )
68 names->append ( results [ counter+1 ] );
69 return names;
70 }
71
72QString Budget::getBudgetName ( int budgetid )
73 {
74 char **results;
75 sqlite_get_table_printf ( bdb, "select name from budgets where budgetid= %i;", &results, NULL, NULL, NULL, budgetid );
76 return ( QString ) results [ 1 ];
77 }
78
79QString Budget::getBudgetDescription ( int budgetid )
80 {
81 char **results;
82 sqlite_get_table_printf ( bdb, "select description from budgets where budgetid= %i;", &results, NULL, NULL, NULL, budgetid );
83 return ( QString ) results [ 1 ];
84 }
85
86QString Budget::getCurrency ( int budgetid )
87 {
88 char **results;
89 sqlite_get_table_printf ( bdb, "select currency from budgets where budgetid= %i;", &results, NULL, NULL, NULL, budgetid );
90 return ( QString ) results [ 1 ];
91 }
92
93QStringList* Budget::getBudgetIDs ()
94 {
95 QStringList *ids = new QStringList ();
96 char **results;
97 int rows, counter;
98 sqlite_get_table ( bdb, "select budgetid from budgets;", &results, &rows, NULL, NULL );
99 for ( counter = 0; counter < rows; counter++ )
100 ids->append ( results [ counter+1 ] );
101 return ids;
102 }
103
104int Budget::addLineItem ( int budgetid, QString lineitemname, float lineitemamount, int lineitemtype )
105 {
106 QString tablename = "table";
107 tablename.append ( QString::number ( budgetid ) );
108 sqlite_exec_printf ( bdb, "insert into '%q' values ( '%q', %.2f, %i, NULL );", 0, 0, 0, ( const char* ) tablename, ( const char* ) lineitemname, lineitemamount, lineitemtype );
109 char **results;
110 sqlite_get_table_printf ( bdb, "select last_insert_rowid() from '%q';", &results, NULL, NULL, NULL, ( const char* ) tablename );
111 return atoi ( results [ 1 ] );
112 }
113
114void Budget::updateLineItem ( QString lineitemname, float lineitemamount, int lineitemtype, int budgetid, int lineitemid )
115 {
116 QString tablename = "table";
117 tablename.append ( QString::number ( budgetid ) );
118 sqlite_exec_printf ( bdb, "update '%q' set name = '%q', lineitemamount = %f, type = %i where lineitemid = %i;", 0, 0, 0, ( const char* ) tablename, ( const char * ) lineitemname, lineitemamount, lineitemtype, lineitemid );
119 }
120
121void Budget::deleteLineItem ( int budgetid, int lineitemid )
122 {
123 QString tablename = "table";
124 tablename.append ( QString::number ( budgetid ) );
125 sqlite_exec_printf ( bdb, "delete from '%q' where lineitemid = %i;", 0, 0, 0, ( const char * ) tablename, lineitemid );
126 }
127
128void Budget::displayLineItems ( int budgetid, QListView *listview, int month, int year, int viewtype )
129 {
130 QString tablename = "table";
131 tablename.append ( QString::number ( budgetid ) );
132 char **results;
133 int rows, columns, counter;
134 sqlite_get_table_printf ( bdb, "select name, lineitemamount, lineitemid from '%q';", &results, &rows, &columns, NULL, ( const char * ) tablename );
135 int total = ( ( rows + 1 ) * columns );
136 for ( counter = 3; counter < total; counter = counter + 3 )
137 {
138 float amount = 0;
139 if ( viewtype == 0 )
140 {
141 QString lineitemamount = results [ counter + 1 ];
142 amount = lineitemamount.toFloat() / 12;
143 }
144 else
145 {
146 QString lineitemamount = results [ counter + 1 ];
147 amount = lineitemamount.toFloat();
148 }
149 QListViewItem *item = new QListViewItem ( listview, results [ counter ], QString::number ( amount, 'f', 2 ), transaction->getBudgetTotal ( budgetid, atoi ( results [ counter + 2 ] ), year, month, viewtype ), results [ counter + 2 ] );
150 }
151 }
152
153QStringList Budget::getLineItems ( int budgetid )
154 {
155 QString tablename = "table";
156 tablename.append ( QString::number ( budgetid ) );
157 QStringList lineitems;
158 char **results;
159 int rows, counter;
160 sqlite_get_table_printf ( bdb, "select name from '%q';", &results, &rows, NULL, NULL, (const char*) tablename );
161 for ( counter = 0; counter < rows; counter++ )
162 lineitems.append ( results [ counter + 1 ] );
163 return lineitems;
164 }
165
166QStringList Budget::getLineItemIDs ( int budgetid )
167 {
168 QString tablename = "table";
169 tablename.append ( QString::number ( budgetid ) );
170 QStringList lineitemids;
171 char **results;
172 int rows, counter;
173 sqlite_get_table_printf ( bdb, "select lineitemid from '%q';", &results, &rows, NULL, NULL, (const char*) tablename );
174 for ( counter = 0; counter < rows; counter++ )
175 lineitemids.append ( results [ counter + 1 ] );
176 return lineitemids;
177 }
178
179int Budget::getLineItemTime ( int budgetid, int lineitemid )
180 {
181 QString tablename = "table";
182 tablename.append ( QString::number ( budgetid ) );
183 char **results;
184 sqlite_get_table_printf ( bdb, "select type from '%q' where lineitemid= %i;", &results, NULL, NULL, NULL, ( const char * ) tablename, lineitemid );
185 return atoi ( results [ 1 ] );
186 }
187
188float Budget::getLineItemAmount ( int budgetid, int lineitemid )
189 {
190 QString tablename = "table";
191 tablename.append ( QString::number ( budgetid ) );
192 char **results;
193 sqlite_get_table_printf ( bdb, "select lineitemamount from '%q' where lineitemid= %i;", &results, NULL, NULL, NULL, ( const char* ) tablename, lineitemid );
194 return strtod ( results [ 1 ], 0 );
195 }
196
197QString Budget::getBudgetTotal ( int budgetid, int viewtype )
198 {
199 QString tablename = "table";
200 tablename.append ( QString::number ( budgetid ) );
201 // determine if we are viewing a years, months, or days budget
202 // we have to pick a different sum for each
203 char **results;
204 sqlite_get_table_printf ( bdb, "select sum ( lineitemamount ) from '%q';", &results, NULL, NULL, NULL, ( const char * ) tablename );
205 QString amount = results [ 1 ];
206 float total = amount.toFloat();
207 if ( viewtype == 0 )
208 total = total / 12;
209 amount.setNum ( total, 'f', 2 );
210 return amount;
211 }
212
213int Budget::getLastAdded ()
214 {
215 char **results;
216 sqlite_get_table ( bdb, "select last_insert_rowid() from budgets;", &results, NULL, NULL, NULL );
217 return atoi ( results [ 1 ] );
218 }
219
220
221
diff --git a/noncore/unsupported/qashmoney/budget.h b/noncore/unsupported/qashmoney/budget.h
new file mode 100755
index 0000000..f82e048
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/budget.h
@@ -0,0 +1,45 @@
1#ifndef BUDGET_H
2#define BUDGET_H
3
4#include <qstring.h>
5#include <qstringlist.h>
6#include <qlistview.h>
7#include <sqlite3.h>
8
9class Budget
10 {
11 public:
12
13 Budget ();
14 ~Budget ();
15
16 int addBudget ( QString name, int type, QString description, QString currency, int startday, int startmonth, int startyear, int endday, int endmonth, int endyear, int defaultview );
17 void updateBudget ( QString name, QString description, QString currency, int budgetid );
18 void deleteBudget ( int budgetid );
19 int getNumberOfBudgets ();
20 int getNumberOfLineItems ( int budgetid );
21
22 QStringList* getBudgetNames ();
23 QStringList* getBudgetIDs ();
24 QStringList getLineItems ( int budgetid );
25 QStringList getLineItemIDs ( int budgetid );
26 QString getBudgetName ( int budgetid );
27 QString getBudgetDescription ( int budgetid );
28 QString getCurrency ( int budgetid );
29 QString getBudgetTotal ( int budgetid, int viewtype );
30
31 int getLastAdded ();
32
33 int addLineItem ( int budgetid, QString lineitemname, float lineitemamount, int lineitemtype );
34 void updateLineItem ( QString lineitemname, float lineitemamount, int lineitemtype, int budgetid, int lineitemid );
35 void displayLineItems ( int budgetid, QListView *listview, int month, int year, int viewtype );
36 void deleteLineItem ( int budgetid, int lineitemid );
37 int getLineItemTime ( int budgetid, int lineitemid );
38 float getLineItemAmount ( int budgetid, int lineitemid );
39
40 private:
41 sqlite3 *bdb;
42 };
43
44#endif
45
diff --git a/noncore/unsupported/qashmoney/budgetdisplay.cpp b/noncore/unsupported/qashmoney/budgetdisplay.cpp
new file mode 100755
index 0000000..b83eb46
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/budgetdisplay.cpp
@@ -0,0 +1,417 @@
1#include <qmessagebox.h>
2#include <qheader.h>
3#include <sqlite3.h>
4
5#include "budgetdisplay.h"
6#include "budget.h"
7#include "datepicker.h"
8#include "transaction.h"
9
10extern Preferences *preferences;
11extern Budget *budget;
12extern Transaction *transaction;
13
14BudgetDisplay::BudgetDisplay ( QWidget *parent ) : QWidget ( parent )
15 {
16 QFont font = this->font();
17 font.setWeight ( QFont::Bold );
18
19 //set the default date to today
20 newDate = QDate::currentDate ();
21 year = newDate.year();
22 month = newDate.month();
23 day = newDate.day();
24 datelabel = preferences->getDate ( year, month );
25
26 setCaption ( "Budget" );
27
28 firstline = new QHBox ( this );
29 firstline->setSpacing ( 2 );
30 secondline = new QHBox ( this );
31 secondline->setSpacing ( 10 );
32
33 menu = new QMenuBar ( this );
34 menu->setFrameStyle ( QFrame::Box | QFrame::Sunken );
35 budgetmenu = new QPopupMenu ( this );
36 lineitemsmenu = new QPopupMenu ( this );
37 datemenu = new QPopupMenu ( this );
38 menu->insertItem ( "Budget", budgetmenu );
39 menu->insertItem ( "Line Item", lineitemsmenu );
40 menu->insertItem ( "Date", datemenu );
41 budgetmenu->insertItem ( "New", this, SLOT ( newBudget() ), 0, 1 );
42 budgetmenu->insertItem ( "Edit", this, SLOT ( editBudget() ), 0, 2 );
43 budgetmenu->insertItem ( "Delete", this, SLOT ( deleteBudget() ), 0, 3 );
44 lineitemsmenu->insertItem ( "New", this, SLOT ( newLineItem() ), 0, 1 );
45 lineitemsmenu->insertItem ( "Edit", this, SLOT ( editLineItem() ), 0, 2 );
46 lineitemsmenu->insertItem ( "Delete", this, SLOT ( deleteLineItem() ), 0, 3 );
47 datemenu->insertItem ( "Change", this, SLOT ( showCalendar() ) );
48
49 budgetbox = new QComboBox ( firstline );
50 connect ( budgetbox, SIGNAL ( activated(int) ), this, SLOT ( setCurrentBudget(int) ) );
51
52 budgetview = new QComboBox ( firstline );
53 budgetview->insertItem ( "Month" );
54 budgetview->insertItem ( "Year" );
55 connect ( budgetview, SIGNAL ( activated(int) ), this, SLOT ( setCurrentView(int) ) );
56
57 budgeted = new QLabel ( secondline );
58 budgeted->setFont ( font );
59 actual = new QLabel ( secondline );
60 actual->setFont ( font );
61 date = new QLabel ( secondline );
62 date->setFont ( font );
63
64 listview = new QListView ( this );
65 listview->setAllColumnsShowFocus ( TRUE );
66 listview->setShowSortIndicator ( TRUE );
67 listview->setRootIsDecorated ( TRUE );
68 listview->setMultiSelection ( FALSE );
69 listview->addColumn ( "Line Item", preferences->getColumnPreference ( 13 ) ); // column id 13
70 listview->addColumn ( "Budget", preferences->getColumnPreference ( 14 ) ); // column id 14
71 listview->addColumn ( "Actual", preferences->getColumnPreference ( 15 ) ); // column id 15
72 listview->addColumn ( "", 0 ); // line item ids
73 listview->setColumnWidthMode ( 0, QListView::Manual );
74 listview->setColumnWidthMode ( 1, QListView::Manual );
75 listview->setColumnWidthMode ( 2, QListView::Manual );
76 listview->setColumnAlignment ( 1, Qt::AlignRight );
77 listview->setColumnAlignment ( 2, Qt::AlignRight );
78 listview->setColumnWidthMode ( 3, QListView::Manual );
79
80 listview->header()->setTracking ( FALSE );
81 connect ( listview->header(), SIGNAL ( sizeChange(int,int,int) ), this, SLOT ( saveColumnSize(int,int,int) ) );
82 connect ( listview->header(), SIGNAL ( clicked(int) ), this, SLOT ( saveSortingPreference(int) ) );
83
84 // pull the column sorting preference from the preferences table, and configure the listview accordingly
85 int column = 0;
86 int direction = 0;
87 preferences->getSortingPreference ( 3, &column, &direction );
88 listview->setSorting ( column, direction );
89
90 displayBudgetNames();
91
92 layout = new QVBoxLayout ( this, 2, 2 );
93 layout->setMenuBar ( menu );
94 layout->addWidget ( firstline );
95 layout->addWidget ( secondline );
96 layout->addWidget ( listview );
97 }
98
99void BudgetDisplay::deleteBudget ()
100 {
101 listview->clear();
102 transaction->clearBudgetIDs ( currentbudget );
103 budget->deleteBudget ( currentbudget );
104 if ( budgetbox->count() != 0 )
105 displayBudgetNames();
106 checkBudgets();
107 }
108
109void BudgetDisplay::saveColumnSize ( int column, int oldsize, int newsize )
110 {
111 switch ( column )
112 {
113 case 0:
114 preferences->changeColumnPreference ( 13, newsize );
115 break;
116 case 1:
117 preferences->changeColumnPreference ( 14, newsize );
118 break;
119 case 2:
120 preferences->changeColumnPreference ( 15, newsize );
121 break;
122 }
123 }
124
125void BudgetDisplay::saveSortingPreference ( int column )
126 {
127 preferences->changeSortingPreference ( 3, column );
128 }
129
130int BudgetDisplay::getIDColumn ()
131 {
132 int counter;
133 int columns = listview->columns();
134 for ( counter = 0; counter <= columns; counter++ )
135 if ( listview->header()->label ( counter ).length() == 0 )
136 return counter;
137 }
138
139void BudgetDisplay::newBudget ()
140 {
141 constructBudgetWindow();
142 int response = nb->exec();
143 if ( response == 1 )
144 {
145 // open a new budget object
146 int addedbudget = budget->addBudget ( budgetname->text(), 0, description->text(), currencybox->currencybox->currentText(), day, month, year, day, month, year, 0 );
147 transaction->clearBudgetIDs ( addedbudget );
148 displayBudgetNames();
149 }
150 checkBudgets();
151 }
152
153void BudgetDisplay::constructBudgetWindow ()
154 {
155 //construct and format the new budget window
156 nb = new QDialog ( this, 0, TRUE );
157 nb->setCaption ( "Budget" );
158 QLabel *namelabel = new QLabel ( "Budget Name", nb );
159 budgetname = new QLineEdit ( nb );
160 QLabel *descriptionlabel = new QLabel ( "Description", nb );
161 description = new QLineEdit ( nb );
162 currencybox = new Currency ( nb );
163 QBoxLayout *layout = new QVBoxLayout ( nb, 2, 2 );
164 layout->addWidget ( namelabel );
165 layout->addWidget ( budgetname );
166 layout->addWidget ( descriptionlabel );
167 layout->addWidget ( description );
168 layout->addWidget ( currencybox );
169 }
170
171void BudgetDisplay::displayBudgetNames ()
172 {
173 budgetbox->clear();
174 if ( budget->getNumberOfBudgets() != 0 )
175 {
176 ids = budget->getBudgetIDs();
177 for ( QStringList::Iterator it = ids->begin(); it != ids->end(); ++it )
178 {
179 QString flag = "/opt/QtPalmtop/pics/flags/";
180 flag.append ( budget->getCurrency ( (*it).toInt() ) );
181 flag.append ( ".png" );
182 budgetbox->insertItem ( QPixmap ( flag ), budget->getBudgetName ( (*it).toInt() ) );
183 }
184 setCurrentBudget ( 0 );
185 }
186 else
187 checkBudgets();
188 }
189
190void BudgetDisplay::setCurrentBudget ( int index )
191 {
192 currentbudget = ( ids->operator[] ( index ).toInt() );
193 displayLineItems();
194 }
195
196void BudgetDisplay::setCurrentView ( int index )
197 {
198 displayLineItems();
199 }
200
201void BudgetDisplay::showCalendar ()
202 {
203 // create new calendar object and show it
204 DatePicker *dp = new DatePicker ( QDate ( year, month, day ) );
205 dp->daylabel->hide();
206 dp->daybox->hide();
207 if ( budgetview->currentItem() == 1 )
208 {
209 dp->monthlabel->hide();
210 dp->monthbox->hide();
211 }
212 dp->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) );
213
214 int response = dp->exec();
215 if ( response == 1 )
216 {
217 // Set date integers
218 year = dp->getYear();
219 if ( budgetview->currentItem() == 0 )
220 month = dp->getMonth();
221 else
222 month = newDate.month();
223 datelabel = preferences->getDate ( year, month );
224 displayLineItems();
225 }
226 }
227
228void BudgetDisplay::newLineItem ()
229 {
230 //construct and format the new line item window
231 constructLineItemWindow ();
232
233 int response = newlineitem->exec();
234 if ( response == 1 )
235 {
236 float amount;
237 if ( lineitemtime->currentItem() == 0 )
238 amount = lineitemamount->text().toFloat();
239 else if ( lineitemtime->currentItem() == 1 )
240 amount = lineitemamount->text().toFloat() * 12;
241 else
242 amount = lineitemamount->text().toFloat() * 52;
243 int lineitemadded = budget->addLineItem ( currentbudget, lineitemname->text(), amount, lineitemtime->currentItem() );
244 transaction->clearBudgetIDs ( currentbudget, lineitemadded );
245 displayLineItems();
246 }
247 checkBudgets();
248 }
249
250void BudgetDisplay::constructLineItemWindow ()
251 {
252 //construct and format the new budget window
253 newlineitem = new QDialog ( this, 0, TRUE );
254 newlineitem->setCaption ( "Line Item" );
255 QLabel *namelabel = new QLabel ( "Line Item Name", newlineitem );
256 lineitemname = new QLineEdit ( newlineitem );
257 QLabel *budgetamountlabel = new QLabel ( "Budget Amount", newlineitem );
258 lineitemamount = new QLineEdit ( newlineitem );
259 QLabel *lineitemtimelabel = new QLabel ( "Per:", newlineitem );
260 lineitemtime = new QComboBox ( newlineitem );
261 lineitemtime->insertItem ( "Year" ); // type 0
262 lineitemtime->insertItem ( "Month" ); // type 1
263 lineitemtime->insertItem ( "Week" ); // type 2
264 QBoxLayout *layout = new QVBoxLayout ( newlineitem, 2, 2 );
265 layout->addWidget ( namelabel );
266 layout->addWidget ( lineitemname );
267 layout->addWidget ( budgetamountlabel );
268 layout->addWidget ( lineitemamount );
269 layout->addWidget ( lineitemtimelabel );
270 layout->addWidget ( lineitemtime );
271 }
272
273void BudgetDisplay::deleteLineItem ()
274 {
275 if ( listview->selectedItem() != 0 )
276 {
277 int lineitemid = listview->selectedItem()->text ( getIDColumn() ).toInt();
278 transaction->clearBudgetIDs ( currentbudget, lineitemid );
279 budget->deleteLineItem ( currentbudget, lineitemid );
280 displayBudgetNames();
281 }
282 else
283 QMessageBox::warning ( this, "QashMoney", "Please select a line item to delete." );
284 checkBudgets();
285 }
286
287void BudgetDisplay::displayLineItems ()
288 {
289 listview->clear();
290 if ( budget->getNumberOfBudgets() != 0 )
291 {
292 QString budgettable = budgetbox->currentText();
293 budgettable.append ( QString::number ( currentbudget ) );
294 budget->displayLineItems ( currentbudget, listview, month, year, budgetview->currentItem() );
295 totalactual = transaction->getActualTotal ( currentbudget, year, month, budgetview->currentItem() );
296 totalbudget = budget->getBudgetTotal ( currentbudget, budgetview->currentItem() );
297 updateBudgetInformation();
298 }
299 }
300
301void BudgetDisplay::checkBudgets ()
302 {
303 if ( budget->getNumberOfBudgets() == 0 )
304 {
305 budgetview->setEnabled ( FALSE );
306 budgetmenu->setItemEnabled ( 2, FALSE );
307 budgetmenu->setItemEnabled ( 3, FALSE );
308 lineitemsmenu->setItemEnabled ( 1, FALSE );
309 lineitemsmenu->setItemEnabled ( 2, FALSE );
310 lineitemsmenu->setItemEnabled ( 3, FALSE );
311 }
312 else
313 {
314 budgetview->setEnabled ( TRUE );
315 budgetmenu->setItemEnabled ( 2, TRUE );
316 budgetmenu->setItemEnabled ( 3, TRUE );
317 lineitemsmenu->setItemEnabled ( 1, TRUE );
318 lineitemsmenu->setItemEnabled ( 2, FALSE );
319 lineitemsmenu->setItemEnabled ( 3, FALSE );
320
321 if ( budget->getNumberOfLineItems ( currentbudget ) != 0 )
322 {
323 lineitemsmenu->setItemEnabled ( 2, TRUE );
324 lineitemsmenu->setItemEnabled ( 3, TRUE );
325 }
326 }
327 }
328
329void BudgetDisplay::updateBudgetInformation ()
330 {
331 if ( budgetview->currentItem() == 0 )
332 {
333 datelabel = preferences->getDate ( year, month );
334 datelabel.prepend ( "Date: " );
335 date->setText ( datelabel );
336 }
337 else
338 date->setText ( QString::number ( year ) );
339
340 QString budget = "Budget: ";
341 budget.append ( totalbudget );
342 budgeted->setText ( budget );
343
344 QString actualamount = "Actual: ";
345 actualamount.append ( totalactual );
346 actual->setText ( actualamount );
347 }
348
349void BudgetDisplay::editBudget ()
350 {
351 constructBudgetWindow();
352
353 //set the title
354 budgetname->setText ( budget->getBudgetName ( currentbudget ) );
355 //set the description
356 description->setText ( budget->getBudgetDescription ( currentbudget ) );
357 // retrieve the two character currency code then
358 // go through the currencty box and find the code
359 //set the currency box to that index number
360 int count = currencybox->currencybox->count();
361 QString code = budget->getCurrency ( currentbudget );
362 for ( int counter = 0; count - 1; counter++ )
363 {
364 if ( QString::compare (currencybox->currencybox->text ( counter ), code ) == 0 )
365 {
366 currencybox->currencybox->setCurrentItem ( counter );
367 break;
368 }
369 }
370 int response = nb->exec();
371 if ( response == 1 )
372 {
373 budget->updateBudget ( budgetname->text(), description->text(), currencybox->currencybox->currentText(), currentbudget );
374 displayBudgetNames();
375 }
376 }
377
378void BudgetDisplay::editLineItem ()
379 {
380 if ( listview->selectedItem() != 0 )
381 {
382 constructLineItemWindow();
383
384 // set the line item name
385 lineitemname->setText ( listview->selectedItem()->text( 0 ) );
386
387 // set the line item time combobox
388 int lineitemtype = budget->getLineItemTime ( currentbudget, listview->selectedItem()->text ( 3 ).toInt() );
389 lineitemtime->setCurrentItem ( lineitemtype );
390
391 // set the line item amount
392 float amount = budget->getLineItemAmount ( currentbudget, listview->selectedItem()->text ( 3 ).toInt() );
393 if ( lineitemtype == 1 )
394 amount = amount / 12;
395 else if ( lineitemtype == 2 )
396 amount = amount / 52;
397 lineitemamount->setText ( QString::number ( amount ) );
398
399 int response = newlineitem->exec();
400 if ( response == 1 )
401 {
402 float amount;
403 if ( lineitemtime->currentItem() == 0 )
404 amount = lineitemamount->text().toFloat();
405 else if ( lineitemtime->currentItem() == 1 )
406 amount = lineitemamount->text().toFloat() * 12;
407 else
408 amount = lineitemamount->text().toFloat() * 52;
409 budget->updateLineItem ( lineitemname->text(), amount, lineitemtime->currentItem(), currentbudget, listview->selectedItem()->text ( 3 ).toInt() );
410 displayLineItems();
411 }
412 }
413 else
414 QMessageBox::warning ( this, "QashMoney", "Please select a line item to edit." );
415 }
416
417
diff --git a/noncore/unsupported/qashmoney/budgetdisplay.h b/noncore/unsupported/qashmoney/budgetdisplay.h
new file mode 100755
index 0000000..a4e806c
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/budgetdisplay.h
@@ -0,0 +1,86 @@
1#ifndef BUDGETDISPLAY_H
2#define BUDGETDISPLAY_H
3
4#include <qlistview.h>
5#include <qlineedit.h>
6#include <qpushbutton.h>
7#include <qcombobox.h>
8#include <qlayout.h>
9#include <qlabel.h>
10#include <qstringlist.h>
11#include <qdatetime.h>
12#include <qmenubar.h>
13#include <qpopupmenu.h>
14#include <qhbox.h>
15
16#include "currency.h"
17
18class BudgetDisplay : public QWidget
19 {
20 Q_OBJECT
21
22 public:
23 BudgetDisplay ( QWidget *parent );
24
25 QMenuBar *menu;
26 QPopupMenu *budgetmenu;
27 QPopupMenu *lineitemsmenu;
28 QPopupMenu *datemenu;
29
30 QHBox *firstline;
31 QHBox *secondline;
32
33 QLabel *budgeted;
34 QLabel *actual;
35 QLabel *date;
36
37 QLineEdit *budgetname;
38 QLineEdit *description;
39 Currency *currencybox;
40
41 QLineEdit *lineitemname;
42 QLineEdit *lineitemamount;
43 QComboBox *lineitemtime;
44
45 QListView *listview;
46 QComboBox *budgetbox;
47 QComboBox *budgetview;
48
49 QBoxLayout *layout;
50
51 int getIDColumn ();
52
53 public slots:
54 void displayBudgetNames ();
55 void displayLineItems ();
56 void updateBudgetInformation ();
57
58 private slots:
59 void saveColumnSize ( int column, int oldsize, int newsize );
60 void newBudget ();
61 void deleteBudget ();
62 void setCurrentBudget ( int );
63 void setCurrentView ( int );
64 void showCalendar ();
65 void newLineItem ();
66 void deleteLineItem ();
67 void checkBudgets ();
68 void editBudget ();
69 void editLineItem ();
70 void constructBudgetWindow ();
71 void constructLineItemWindow ();
72 void saveSortingPreference ( int column );
73
74 private:
75 QStringList *names;
76 QStringList *ids;
77 int currentbudget, year, month, day;
78 QDate newDate;
79 QString totalbudget, totalactual;
80 QString datelabel;
81 QDialog *nb;
82 QDialog *newlineitem;
83};
84
85#endif // BUDGETDISPLAY_H
86
diff --git a/noncore/unsupported/qashmoney/calculator.cpp b/noncore/unsupported/qashmoney/calculator.cpp
new file mode 100755
index 0000000..2c92103
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/calculator.cpp
@@ -0,0 +1,113 @@
1#include "calculator.h"
2
3#include <qpushbutton.h>
4
5Calculator::Calculator ( QWidget* parent ) : QDialog ( parent, 0, TRUE )
6 {
7
8 display = new QLineEdit ( this, "display" );
9 display->setFrame ( FALSE );
10 display->setAlignment ( Qt::AlignRight );
11
12 QPushButton *one = new QPushButton ( "1", this, "one" ); // make buttons for first row
13 one->setFlat ( TRUE );
14 connect ( one, SIGNAL ( released() ), this, SLOT ( displayOne() ) );
15
16 QPushButton *two = new QPushButton ( "2", this, "two" );
17 two->setFlat ( TRUE );
18 connect ( two, SIGNAL ( released() ), this, SLOT ( displayTwo() ) );
19
20 QPushButton *three = new QPushButton ( "3", this, "three" );
21 three->setFlat ( TRUE );
22 connect ( three, SIGNAL ( released() ), this, SLOT ( displayThree() ) );
23
24 QPushButton *four = new QPushButton ( "4", this, "four" ); // make buttons for second row
25 four->setFlat ( TRUE );
26 connect ( four, SIGNAL ( released() ), this, SLOT ( displayFour() ) );
27
28 QPushButton *five = new QPushButton ( "5", this, "five" );
29 five->setFlat ( TRUE );
30 connect ( five, SIGNAL ( released() ), this, SLOT ( displayFive() ) );
31
32 QPushButton *six = new QPushButton ( "6", this, "six" );
33 six->setFlat ( TRUE );
34 connect ( six, SIGNAL ( released() ), this, SLOT ( displaySix() ) );
35
36 QPushButton *seven = new QPushButton ( "7", this, "seven" ); // make buttons for third row
37 seven->setFlat ( TRUE );
38 connect ( seven, SIGNAL ( released() ), this, SLOT ( displaySeven() ) );
39
40 QPushButton *eight = new QPushButton ( "8", this, "eight" );
41 eight->setFlat ( TRUE );
42 connect ( eight, SIGNAL ( released() ), this, SLOT ( displayEight() ) );
43
44 QPushButton *nine = new QPushButton ( "9", this, "nine" );
45 nine->setFlat ( TRUE );
46 connect ( nine, SIGNAL ( released() ), this, SLOT ( displayNine() ) );
47
48 QPushButton *zero = new QPushButton ( "0", this, "zero" );
49 zero->setFlat ( TRUE );
50 connect ( zero, SIGNAL ( released() ), this, SLOT ( displayZero() ) );
51
52 QPushButton *dp = new QPushButton ( ".", this, "dp" );
53 dp->setFlat ( TRUE );
54 connect ( dp, SIGNAL ( released() ), this, SLOT ( displayPoint() ) );
55
56 QPushButton *back = new QPushButton ( "<-", this, "back" );
57 back->setFlat ( TRUE );
58 connect ( back, SIGNAL ( released() ), this, SLOT ( back() ) );
59
60 layout = new QGridLayout ( this, 5, 3, 5, 1, "calculatorlayout" );
61 layout->addMultiCellWidget ( display, 0, 0, 0, 2 );
62 layout->addWidget ( one, 1, 0 );
63 layout->addWidget ( two, 1, 1 );
64 layout->addWidget ( three, 1, 2 );
65 layout->addWidget ( four, 2, 0 );
66 layout->addWidget ( five, 2, 1 );
67 layout->addWidget ( six, 2, 2 );
68 layout->addWidget ( seven, 3, 0 );
69 layout->addWidget ( eight, 3, 1 );
70 layout->addWidget ( nine, 3, 2 );
71 layout->addWidget ( zero, 4, 0 );
72 layout->addWidget ( dp, 4, 1 );
73 layout->addWidget ( back, 4, 2 );
74
75 }
76
77void Calculator::displayOne ()
78 { display->insert ( "1" ); }
79
80void Calculator::displayTwo ()
81 { display->insert ( "2" ); }
82
83void Calculator::displayThree ()
84 { display->insert ( "3" ); }
85
86void Calculator::displayFour ()
87 { display->insert ( "4" ); }
88
89void Calculator::displayFive ()
90 { display->insert ( "5" ); }
91
92void Calculator::displaySix ()
93 { display->insert ( "6" ); }
94
95void Calculator::displaySeven ()
96 { display->insert ( "7" ); }
97
98void Calculator::displayEight ()
99 { display->insert ( "8" ); }
100
101void Calculator::displayNine ()
102 { display->insert ( "9" ); }
103
104void Calculator::displayZero ()
105 { display->insert ( "0" ); }
106
107void Calculator::displayPoint ()
108 { display->insert ( "." ); }
109
110void Calculator::back ()
111 { display->backspace(); }
112
113
diff --git a/noncore/unsupported/qashmoney/calculator.h b/noncore/unsupported/qashmoney/calculator.h
new file mode 100755
index 0000000..56dc1bc
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/calculator.h
@@ -0,0 +1,50 @@
1#ifndef CALCULATOR_H
2#define CALCULATOR_H
3
4#include <qdialog.h>
5#include <qlayout.h>
6#include <qlineedit.h>
7
8class Calculator : public QDialog
9{
10 Q_OBJECT
11
12 public:
13
14 Calculator ( QWidget* parent );
15
16 QLineEdit* display;
17
18 private slots:
19
20 void displayOne ();
21 void displayTwo ();
22 void displayThree ();
23 void displayFour ();
24 void displayFive ();
25 void displaySix ();
26 void displaySeven ();
27 void displayEight ();
28 void displayNine ();
29 void displayZero ();
30 void displayPoint ();
31 void back ();
32
33 private:
34
35 QGridLayout *layout;
36
37};
38
39#endif
40
41
42
43
44
45
46
47
48
49
50
diff --git a/noncore/unsupported/qashmoney/currency.cpp b/noncore/unsupported/qashmoney/currency.cpp
new file mode 100755
index 0000000..20412a7
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/currency.cpp
@@ -0,0 +1,80 @@
1#include "currency.h"
2
3Currency::Currency ( QWidget *parent ) : QWidget ( parent )
4 {
5 currencylabel = new QLabel ( "Currency", this );
6 currencybox = new QComboBox ( this );
7 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/AE.png"), "AE" );
8 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/AR.png"), "AR" );
9 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/AT.png"), "AT" );
10 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/AU.png"), "AU" );
11 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/BD.png"), "BD" );
12 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/BE.png"), "BE" );
13 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/BH.png"), "BH" );
14 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/BR.png"), "BR" );
15 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/BW.png"), "BW" );
16 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/CA.png"), "CA" );
17 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/CH.png"), "CH" );
18 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/CL.png"), "CL" );
19 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/CN.png"), "CN" );
20 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/CO.png"), "CO" );
21 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/CZ.png"), "CZ" );
22 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/DE.png"), "DE" );
23 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/DK.png"), "DK" );
24 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/DO.png"), "DO" );
25 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/EG.png"), "EG" );
26 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/ES.png"), "ES" );
27 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/EU.png"), "EU" );
28 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/FL.png"), "FL" );
29 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/FR.png"), "FR" );
30 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/GB.png"), "GB" );
31 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/GR.png"), "GR" );
32 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/HK.png"), "HK" );
33 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/HU.png"), "HU" );
34 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/ID.png"), "ID" );
35 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/IE.png"), "IE" );
36 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/IL.png"), "IL" );
37 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/IN.png"), "IN" );
38 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/IQ.png"), "IQ" );
39 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/IS.png"), "IS" );
40 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/IT.png"), "IT" );
41 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/JO.png"), "JO" );
42 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/JP.png"), "JP" );
43 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/KR.png"), "KR" );
44 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/LB.png"), "LB" );
45 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/LK.png"), "LK" );
46 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/LU.png"), "LU" );
47 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/MX.png"), "MX" );
48 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/MY.png"), "MY" );
49 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/NL.png"), "NL" );
50 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/NO.png"), "NO" );
51 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/NP.png"), "NP" );
52 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/NZ.png"), "NZ" );
53 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/OM.png"), "OM" );
54 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/PE.png"), "PE" );
55 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/PH.png"), "PH" );
56 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/PK.png"), "PK" );
57 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/PL.png"), "PL" );
58 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/PT.png"), "PT" );
59 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/QA.png"), "QA" );
60 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/SA.png"), "SA" );
61 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/SE.png"), "SE" );
62 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/SG.png"), "SG" );
63 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/SI.png"), "SK" );
64 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/TH.png"), "TH" );
65 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/TR.png"), "TR" );
66 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/TW.png"), "TW" );
67 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/US.png"), "US" );
68 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/UY.png"), "UY" );
69 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/VE.png"), "VE" );
70 currencybox->insertItem ( QPixmap ( "/opt/QtPalmtop/pics/flags/ZA.png"), "ZA" );
71
72 layout = new QVBoxLayout ( this );
73 layout->addWidget ( currencylabel );
74 layout->addWidget ( currencybox );
75 }
76
77
78
79
80
diff --git a/noncore/unsupported/qashmoney/currency.h b/noncore/unsupported/qashmoney/currency.h
new file mode 100755
index 0000000..08bb3c1
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/currency.h
@@ -0,0 +1,23 @@
1#ifndef CURRENCY_H
2#define CURRENCY_H
3
4#include <qgroupbox.h>
5#include <qlabel.h>
6#include <qcombobox.h>
7#include <qpixmap.h>
8#include <qlayout.h>
9
10class Currency : public QWidget
11 {
12 Q_OBJECT
13
14 public:
15
16 Currency ( QWidget *parent );
17 QLabel *currencylabel;
18 QComboBox *currencybox;
19 QBoxLayout *layout;
20 };
21
22#endif
23
diff --git a/noncore/unsupported/qashmoney/datepicker.cpp b/noncore/unsupported/qashmoney/datepicker.cpp
new file mode 100755
index 0000000..7997c0b
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/datepicker.cpp
@@ -0,0 +1,95 @@
1#include "datepicker.h"
2
3DatePicker::DatePicker ( QDate entrydate ) : QDialog ( 0, 0, TRUE )
4 {
5 setCaption ( "Select Date" );
6 date = entrydate;
7 day = date.day();
8 month = date.month();
9 year = date.year();
10
11 daylabel = new QLabel ( "Day", this );
12 monthlabel = new QLabel ( "Month", this );
13 yearlabel = new QLabel ( "Year", this );
14
15 daybox = new QComboBox ( this, "daybox" );
16 connect ( daybox, SIGNAL ( activated(int) ), this, SLOT ( setDay(int) ) );
17 displayDays ( daybox );
18 monthbox = new QComboBox ( this, "monthbox" );
19 connect ( monthbox, SIGNAL ( activated(int) ), this, SLOT ( setMonth(int) ) );
20 displayMonths ( monthbox );
21 yearbox = new QComboBox ( this, "yearbox" );
22 connect ( yearbox, SIGNAL ( activated(int) ), this, SLOT ( setYear(int) ) );
23 displayYears ( yearbox );
24
25 layout = new QGridLayout ( this, 2, 3, 5, 5, "datepickerlayout" );
26 layout->addWidget ( daylabel, 0, 2 );
27 layout->addWidget ( monthlabel, 0, 1 );
28 layout->addWidget ( yearlabel, 0, 0 );
29 layout->addWidget ( daybox, 1, 2 );
30 layout->addWidget ( monthbox, 1, 1 );
31 layout->addWidget ( yearbox, 1, 0 );
32 }
33
34void DatePicker::displayDays ( QComboBox *daybox )
35 {
36 int counter;
37 int days = date.daysInMonth();
38 for ( counter = 1; counter <= days; counter++ )
39 daybox->insertItem ( QString::number ( counter ) );
40 daybox->setCurrentItem ( ( date.day() ) - 1 );
41 }
42
43void DatePicker::displayMonths ( QComboBox *monthbox )
44 {
45 int counter;
46 for ( counter = 1; counter <= 12; counter++ )
47 monthbox->insertItem ( QString::number ( counter ) );
48 monthbox->setCurrentItem ( ( date.month() ) - 1 );
49 }
50
51void DatePicker::displayYears ( QComboBox *yearbox )
52 {
53 int counter;
54 int indexcounter = 0;
55 int yearindex = 0;
56 int year = date.year();
57 for ( counter = ( year - 1 ); counter <= ( year + 1 ); counter++ )
58 {
59 yearbox->insertItem ( QString::number ( counter ) );
60 if ( date.year() == counter )
61 yearindex = indexcounter;
62 indexcounter ++;
63 }
64 yearbox->setCurrentItem ( yearindex );
65 }
66
67void DatePicker::setDay ( int index )
68 {
69 day = daybox->text ( index ).toInt();
70 }
71
72void DatePicker::setMonth ( int index )
73 {
74 month = monthbox->text( index ).toInt();
75 }
76
77void DatePicker::setYear ( int index )
78 {
79 year = yearbox->text ( index ).toInt();
80 }
81
82int DatePicker::getDay ()
83 { return day; }
84
85int DatePicker::getMonth ()
86 { return month; }
87
88int DatePicker::getYear ()
89 { return year; }
90
91
92
93
94
95
diff --git a/noncore/unsupported/qashmoney/datepicker.h b/noncore/unsupported/qashmoney/datepicker.h
new file mode 100755
index 0000000..67e63e9
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/datepicker.h
@@ -0,0 +1,60 @@
1#ifndef DATEPICKER_H
2#define DATEPICKER_H
3
4#include <qdialog.h>
5#include <qlabel.h>
6#include <qdatetime.h>
7#include <qcombobox.h>
8#include <qlayout.h>
9
10class DatePicker : public QDialog
11
12 {
13 Q_OBJECT
14
15 public:
16 QLabel *daylabel;
17 QComboBox *daybox;
18
19 QLabel *monthlabel;
20 QComboBox *monthbox;
21
22 DatePicker ( QDate entrydate );
23 int getDay ();
24 int getMonth ();
25 int getYear ();
26
27 private slots:
28 void setDay ( int );
29 void setMonth ( int );
30 void setYear ( int );
31
32 private:
33 void displayDays ( QComboBox *daybox );
34 void displayMonths ( QComboBox *monthbox );
35 void displayYears ( QComboBox *yearbox );
36
37 QDate date;
38
39 QLabel *yearlabel;
40 QComboBox *yearbox;
41
42 QGridLayout *layout;
43
44 int day, month, year;
45
46 };
47
48#endif
49
50
51
52
53
54
55
56
57
58
59
60
diff --git a/noncore/unsupported/qashmoney/main.cpp b/noncore/unsupported/qashmoney/main.cpp
new file mode 100755
index 0000000..f86be89
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/main.cpp
@@ -0,0 +1,13 @@
1#include <qpe/qpeapplication.h>
2#include "qashmoney.h"
3
4int main( int argc, char **argv )
5 {
6 QPEApplication a ( argc, argv );
7 QashMoney qashmoney;
8 a.showMainWidget ( &qashmoney );
9 return a.exec();
10 }
11
12
13
diff --git a/noncore/unsupported/qashmoney/memory.cpp b/noncore/unsupported/qashmoney/memory.cpp
new file mode 100755
index 0000000..b5155b3
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/memory.cpp
@@ -0,0 +1,62 @@
1#include "memory.h"
2
3#include <stdlib.h>
4
5Memory::Memory ()
6 {
7 db = sqlite_open ( "qmmemory.db", 0, NULL );
8 }
9
10Memory::~Memory ()
11 {
12 sqlite_close ( db );
13 }
14
15void Memory::addMemoryItem ( QString item )
16 {
17 sqlite_exec_printf ( db, "insert into memory values ( '%q', 0, 0 );", 0, 0, 0, ( const char * ) item );
18 }
19
20void Memory::deleteMemoryItem ( QString item )
21 {
22 sqlite_exec_printf ( db, "delete from memory where item = '%q';", 0, 0, 0, ( const char * ) item );
23 }
24
25int Memory::getNumberOfMemoryItems ()
26 {
27 char **results;
28 sqlite_get_table ( db, "select count() from memory;", &results, NULL, NULL, NULL );
29 return atoi ( results [ 1 ] );
30 }
31
32void Memory::changeMemoryName ( QString item )
33 {
34 sqlite_exec_printf ( db, "update memory set item = '%q' where item = '%q';", 0, 0, 0, ( const char * ) item );
35 }
36
37void Memory::displayMemoryItems ( QListBox *listbox )
38 {
39 char **results;
40 int rows;
41 sqlite_get_table ( db, "select item from memory order by item asc;", &results, &rows, NULL, NULL );
42 int counter = 1;
43 while ( counter < ( rows + 1 ) )
44 {
45 listbox->insertItem ( results [ counter ] );
46 counter ++;
47 }
48 }
49
50void Memory::displayMemoryItems ( QComboBox *box )
51 {
52 char **results;
53 int rows;
54 sqlite_get_table ( db, "select item from memory order by item asc;", &results, &rows, NULL, NULL );
55 int counter = 1;
56 while ( counter < ( rows + 1 ) )
57 {
58 box->insertItem ( results [ counter ] );
59 counter ++;
60 }
61 }
62
diff --git a/noncore/unsupported/qashmoney/memory.h b/noncore/unsupported/qashmoney/memory.h
new file mode 100755
index 0000000..6e8ae46
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/memory.h
@@ -0,0 +1,45 @@
1#ifndef MEMORY_H
2#define MEMORY_H
3
4#include <qstring.h>
5#include <qlistbox.h>
6#include <qcombobox.h>
7#include <sqlite3.h>
8
9class Memory : public QObject
10 {
11
12 Q_OBJECT
13
14 public:
15
16 Memory ();
17 ~Memory ();
18
19 // This function adds a new memory to the database. It takes the memory name, parent,
20 // initial balance, a displayed variable, and the memory type
21 // The parent is an integer memory id. Its -1 if there is not parent
22 // The memory types are 0=not defined 1=parent 2=child
23 void addMemoryItem ( QString );
24
25 // Returns the number of checking memorys
26 int getNumberOfMemoryItems ();
27
28 void changeMemoryName ( QString );
29
30 // This takes a QListView and puts parents and children memorys
31 // into the list view
32 void displayMemoryItems ( QListBox * );
33 void displayMemoryItems ( QComboBox * );
34
35 // The primary database that stores all our data
36 sqlite3 *db;
37
38 public slots:
39
40 // Deletes a memory item. Takes the memoryid as its parameter
41 void deleteMemoryItem ( QString );
42 };
43
44#endif
45
diff --git a/noncore/unsupported/qashmoney/memorydialog.cpp b/noncore/unsupported/qashmoney/memorydialog.cpp
new file mode 100755
index 0000000..ba11540
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/memorydialog.cpp
@@ -0,0 +1,86 @@
1#include "memorydialog.h"
2#include "memory.h"
3#include <qmessagebox.h>
4
5extern Memory *memory;
6
7MemoryDialog::MemoryDialog () : QDialog ( 0, 0, TRUE )
8{
9 setCaption ( tr ( "Edit Memory" ) );
10
11 listbox = new QListBox ( this, "listbox" );
12 memory->displayMemoryItems ( listbox );
13 listbox->clearSelection();
14
15 secondline = new QHBox ( this );
16
17 newbutton = new QPushButton ( secondline );
18 newbutton->setPixmap( QPixmap ("/opt/QtPalmtop/pics/new.png") );
19 connect ( newbutton, SIGNAL ( released() ), this, SLOT ( addItem() ) );
20
21 editbutton = new QPushButton ( secondline );
22 editbutton->setPixmap( QPixmap ("/opt/QtPalmtop/pics/edit.png") );
23 connect ( editbutton, SIGNAL ( released() ), this, SLOT ( editItem() ) );
24
25 deletebutton = new QPushButton( secondline );
26 deletebutton->setPixmap( QPixmap ("/opt/QtPalmtop/pics/delete.png") );
27 connect ( deletebutton, SIGNAL ( released() ), this, SLOT ( deleteItem() ) );
28
29 lineedit = new QLineEdit ( this );
30
31 layout = new QVBoxLayout ( this, 2, 2 );
32 layout->addWidget ( listbox );
33 layout->addWidget ( secondline );
34 layout->addWidget ( lineedit );
35}
36
37MemoryDialog::~MemoryDialog()
38 {
39 }
40
41void MemoryDialog::addItem ()
42 {
43 if ( lineedit->text().length() != 0 )
44 {
45 memory->addMemoryItem ( lineedit->text() );
46 listbox->clear ();
47 memory->displayMemoryItems ( listbox );
48 listbox->clearFocus();
49 listbox->clearSelection ();
50 lineedit->clear();
51 }
52 }
53
54void MemoryDialog::editItem ()
55 {
56 if ( listbox->currentItem() != -1 )
57 {
58 lineedit->setText ( listbox->currentText() );
59 memory->deleteMemoryItem ( listbox->currentText() );
60 listbox->clear ();
61 memory->displayMemoryItems ( listbox );
62 listbox->clearSelection();
63 }
64 else
65 QMessageBox::warning ( this, "QashMoney", "Please select an item to edit." );
66 }
67
68void MemoryDialog::deleteItem ()
69 {
70 if ( listbox->currentItem() != -1 )
71 {
72 memory->deleteMemoryItem ( listbox->currentText() );
73 listbox->clear ();
74 memory->displayMemoryItems ( listbox );
75 listbox->clearSelection();
76 }
77 else
78 QMessageBox::warning ( this, "QashMoney", "Please select an item to delete." );
79 }
80
81
82
83
84
85
86
diff --git a/noncore/unsupported/qashmoney/memorydialog.h b/noncore/unsupported/qashmoney/memorydialog.h
new file mode 100755
index 0000000..3491823
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/memorydialog.h
@@ -0,0 +1,40 @@
1#ifndef MEMORYDIALOG_H
2#define MEMORYDIALOG_H
3
4#include <qdialog.h>
5#include <qlistbox.h>
6#include <qlineedit.h>
7#include <qpushbutton.h>
8#include <qlayout.h>
9#include <qstring.h>
10#include <qhbox.h>
11
12class MemoryDialog : public QDialog
13 {
14 Q_OBJECT
15
16 public:
17 MemoryDialog();
18 ~MemoryDialog();
19
20 private slots:
21 void addItem();
22 void editItem();
23 void deleteItem();
24
25 private:
26
27 QHBox *secondline;
28
29 QListBox* listbox;
30
31 QLineEdit* lineedit;
32
33 QPushButton* newbutton;
34 QPushButton* editbutton;
35 QPushButton* deletebutton;
36
37 QBoxLayout *layout;
38};
39
40#endif
diff --git a/noncore/unsupported/qashmoney/newaccount.cpp b/noncore/unsupported/qashmoney/newaccount.cpp
new file mode 100755
index 0000000..5932182
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/newaccount.cpp
@@ -0,0 +1,206 @@
1#include "newaccount.h"
2#include "calculator.h"
3#include "datepicker.h"
4#include <qmultilineedit.h>
5
6extern Preferences *preferences;
7
8NewAccount::NewAccount ( QWidget *parent, const char *name, bool modal ) : QDialog ( parent, name, modal )
9 {
10 accountdescription = "";
11 dateedited = FALSE;
12 setCaption( tr( "Account" ) );
13
14 namelabel = new QLabel ( "Account Name", this );
15
16 accountbox = new QHBox ( this );
17 accountname = new QLineEdit ( accountbox );
18 descriptionbutton = new QPushButton ( accountbox );
19 descriptionbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/info.png" ) );
20
21 datelabel = new QLabel ( "Date", this );
22
23 datebox = new QHBox ( this );
24 startdate = new QLineEdit ( datebox );
25 startdate->setDisabled ( TRUE );
26 datebutton = new QPushButton ( datebox );
27 datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) );
28
29 childcheckbox = new QCheckBox ( this );
30 childcheckbox->setText( tr ( "Child Account" ) );
31
32 childlabel = new QLabel ( "Child of", this );
33 childbox = new QComboBox ( FALSE, this );
34 hideChildPulldownMenu ();
35
36 balancelabel = new QLabel ( "Balance", this );
37
38 balancebox = new QHBox ( this );
39 accountbalance = new QLineEdit ( balancebox );
40 accountbalance->setText ( "0.00" );
41 balancecalculator = new QPushButton( balancebox );
42 balancecalculator->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) );
43
44 creditlimitlabel = new QLabel ( "Credit Limit", this );
45
46 creditlimitbox = new QHBox ( this );
47 creditlimit = new QLineEdit ( creditlimitbox );
48 creditlimitbox->setEnabled ( FALSE );
49 creditlimitcalculator = new QPushButton( creditlimitbox );
50 creditlimitcalculator->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) );
51
52 currencybox = new Currency ( this );
53
54 typelabel = new QLabel ( "Type", this );
55 accounttype = new QComboBox ( FALSE, this );
56 accounttype->insertItem( tr( "Bank" ) );
57 accounttype->insertItem( tr( "Cash" ) );
58 accounttype->insertItem( tr( "Credit Card" ) );
59 accounttype->insertItem( tr( "Equity" ) );
60 accounttype->insertItem( tr( "Asset" ) );
61 accounttype->insertItem( tr( "Liability" ) );
62
63 layout = new QGridLayout ( this, 7, 2, 4, 2 );
64 layout->addWidget ( namelabel , 0, 0, Qt::AlignLeft );
65 layout->addWidget ( accountbox, 1, 0, Qt::AlignLeft );
66 layout->addWidget ( datelabel, 2, 0, Qt::AlignLeft );
67 layout->addWidget ( datebox, 3, 0, Qt::AlignLeft );
68 layout->addWidget ( childcheckbox, 4, 0, Qt::AlignLeft );
69 layout->addWidget ( childlabel, 5, 0, Qt::AlignLeft );
70 layout->addWidget ( childbox, 6, 0, Qt::AlignLeft );
71 layout->addWidget ( balancelabel, 0, 1, Qt::AlignLeft );
72 layout->addWidget ( balancebox, 1, 1, Qt::AlignLeft );
73 layout->addWidget ( creditlimitlabel, 2, 1, Qt::AlignLeft );
74 layout->addWidget ( creditlimitbox, 3, 1, Qt::AlignLeft );
75 layout->addWidget ( currencybox, 4, 1, Qt::AlignLeft );
76 layout->addWidget ( typelabel, 5, 1, Qt::AlignLeft );
77 layout->addWidget ( accounttype, 6, 1, Qt::AlignLeft );
78
79 connect ( childcheckbox, SIGNAL ( clicked() ), this, SLOT ( showChildPulldownMenu() ) );
80 connect ( balancecalculator, SIGNAL ( released() ), this, SLOT ( showCalculator() ) );
81 connect ( creditlimitcalculator, SIGNAL ( released() ), this, SLOT ( showCreditLimitCalculator() ) );
82 connect ( accounttype, SIGNAL ( activated(int) ), this, SLOT ( activateCreditLimit(int) ) );
83 connect ( datebutton, SIGNAL ( released() ), this, SLOT ( showCalendar() ) );
84 connect ( descriptionbutton, SIGNAL ( released() ), this, SLOT ( addAccountDescription() ) );
85}
86
87NewAccount::~NewAccount ()
88 {
89 }
90
91void NewAccount::showChildPulldownMenu ()
92 {
93 if ( childcheckbox->isChecked() == TRUE )
94 {
95 childlabel->setEnabled ( TRUE );
96 childbox->setEnabled ( TRUE );
97 }
98 else
99 hideChildPulldownMenu();
100 }
101
102void NewAccount::hideChildPulldownMenu ()
103 {
104 childlabel->setEnabled ( FALSE );
105 childbox->setEnabled ( FALSE );
106 }
107
108void NewAccount::showCalculator ()
109 {
110 Calculator *calculator = new Calculator ( this );
111 calculator->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) );
112 if ( calculator->exec () == QDialog::Accepted )
113 accountbalance->setText ( calculator->display->text() );
114 }
115
116void NewAccount::showCreditLimitCalculator ()
117 {
118 Calculator *calculator = new Calculator ( this );
119 calculator->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) );
120 if ( calculator->exec () == QDialog::Accepted )
121 creditlimit->setText ( calculator->display->text() );
122 }
123
124void NewAccount::activateCreditLimit ( int index )
125 {
126 if ( index == 2 || index == 5 )
127 creditlimitbox->setEnabled ( TRUE );
128 else
129 {
130 creditlimit->clear ();
131 creditlimitbox->setEnabled ( FALSE );
132 }
133 }
134
135void NewAccount::showCalendar ()
136 {
137 QDate newDate = QDate::currentDate ();
138 DatePicker *dp = new DatePicker ( newDate );
139 dp->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) );
140
141 int response = dp->exec();
142 if ( response == QDialog::Accepted )
143 {
144 // Set date integers
145 year = dp->getYear();
146 month = dp->getMonth();
147 day = dp->getDay();
148
149 // Set dateedited to TRUE
150 // This tells the accountdisplay object that the user edited an account
151 // and did change the date
152 dateedited = TRUE;
153
154 // Display date with our selected format
155 startdate->setText ( preferences->getDate ( year, month, day ) );
156 }
157 }
158
159bool NewAccount::getDateEdited ()
160 {
161 return dateedited;
162 }
163
164int NewAccount::getDay ()
165 {
166 return day;
167 }
168
169int NewAccount::getMonth ()
170 {
171 return month;
172 }
173
174int NewAccount::getYear ()
175 {
176 return year;
177 }
178
179QString NewAccount::getDescription ()
180 {
181 return accountdescription;
182 }
183
184void NewAccount::setDescription ( QString description )
185 {
186 accountdescription = description;
187 }
188
189void NewAccount::addAccountDescription ()
190 {
191 // Function for adding or editing an account description.
192 QDialog *description = new QDialog ( this, "description", TRUE );
193 description->setCaption ( "Notes" );
194 QMultiLineEdit *enter = new QMultiLineEdit ( description );
195 enter->setFixedSize ( ( int ) (this->width() * 0.75 ), ( int ) ( this->height() * 0.5 ) );
196 enter->setWrapColumnOrWidth ( ( int ) (this->width() * 0.75 ) );
197 enter->setWordWrap ( QMultiLineEdit::WidgetWidth );
198 if ( accountdescription != "(NULL)" )
199 enter->setText ( accountdescription );
200 if ( description->exec () == QDialog::Accepted )
201 accountdescription = enter->text ();
202 }
203
204
205
206
diff --git a/noncore/unsupported/qashmoney/newaccount.h b/noncore/unsupported/qashmoney/newaccount.h
new file mode 100755
index 0000000..f8235d5
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/newaccount.h
@@ -0,0 +1,87 @@
1#ifndef NEWACCOUNT_H
2#define NEWACCOUNT_H
3
4#include <qbuttongroup.h>
5#include <qcombobox.h>
6#include <qlineedit.h>
7#include <qpushbutton.h>
8#include <qradiobutton.h>
9#include <qlayout.h>
10#include <qdialog.h>
11#include <qlabel.h>
12#include <qhbox.h>
13#include <qcheckbox.h>
14
15#include "account.h"
16#include "preferences.h"
17#include "currency.h"
18
19class NewAccount : public QDialog
20 {
21 Q_OBJECT
22
23 public:
24 NewAccount ( QWidget *parent = 0, const char *name = 0, bool modal = TRUE );
25 ~NewAccount();
26
27 QLabel *namelabel;
28 QHBox *accountbox;
29 QLineEdit* accountname;
30 QPushButton* descriptionbutton;
31
32 QHBox *datebox;
33 QLabel *datelabel;
34 QLineEdit* startdate;
35 QPushButton* datebutton;
36
37 QCheckBox* childcheckbox;
38
39 QLabel *childlabel;
40 QComboBox *childbox;
41
42 QLabel *balancelabel;
43 QHBox *balancebox;
44 QLineEdit* accountbalance;
45 QPushButton* balancecalculator;
46
47 QLabel *creditlimitlabel;
48 QHBox *creditlimitbox;
49 QLineEdit* creditlimit;
50 QPushButton* creditlimitcalculator;
51
52 Currency *currencybox;
53
54 QLabel *typelabel;
55 QComboBox* accounttype;
56
57 QGridLayout *layout;
58
59 int getDay ();
60 int getMonth ();
61 int getYear ();
62 QString getDescription ();
63 void setDescription ( QString );
64
65 // When a user edits an account and edits the date, this flag
66 // is set to TRUE adding the new date to the account. Otherwise,
67 // the old date is used for the edited account. This prevents a date
68 // from reverting to 0/0/0 if the date is not edited
69 bool getDateEdited ();
70
71 public slots:
72 void showChildPulldownMenu();
73 void hideChildPulldownMenu();
74 void showCalculator();
75 void showCreditLimitCalculator ();
76 void activateCreditLimit ( int );
77 void showCalendar ();
78 void addAccountDescription ();
79
80 private:
81 int index, year, month, day, currencypreference;
82 QString accountdescription;
83 bool dateedited;
84};
85
86#endif
87
diff --git a/noncore/unsupported/qashmoney/newtransaction.cpp b/noncore/unsupported/qashmoney/newtransaction.cpp
new file mode 100755
index 0000000..87b7f7e
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/newtransaction.cpp
@@ -0,0 +1,274 @@
1#include "newtransaction.h"
2#include "calculator.h"
3#include "datepicker.h"
4#include "budget.h"
5
6#include <qmultilineedit.h>
7
8extern Budget *budget;
9extern Preferences *preferences;
10
11NewTransaction::NewTransaction ( QWidget* parent ) : QDialog ( parent, 0, TRUE )
12 {
13 transactiondescription = "";
14 currentlineitem = -1;
15 currentbudget = -1;
16 dateedited = FALSE;
17 setCaption( tr( "Transaction" ) );
18
19 // START FIRST COLUMN
20
21 namelabel = new QLabel ( "Transaction", this );
22
23 transactionnamebox = new QHBox ( this );
24 transactionname = new QComboBox ( transactionnamebox );
25 transactionname->setEditable ( TRUE );
26 descriptionbutton = new QPushButton ( transactionnamebox );
27 descriptionbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/info.png" ) );
28 connect ( descriptionbutton, SIGNAL ( released() ), this, SLOT ( addTransactionDescription() ) );
29
30 amountlabel = new QLabel ( "Amount", this );
31
32 transactionamountbox = new QHBox ( this );
33 transactionamount = new QLineEdit ( transactionamountbox );
34 transactionamount->setAlignment ( Qt::AlignRight );
35 transactionamount->setText ( "0.00" );
36 calculatorbutton = new QPushButton( transactionamountbox );
37 calculatorbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) );
38 connect ( calculatorbutton, SIGNAL ( released() ), this, SLOT ( showCalculator() ) );
39
40 datelabel = new QLabel ( "Date", this );
41
42 transactiondatebox = new QHBox ( this );
43 transactiondate = new QLineEdit ( transactiondatebox );
44 transactiondate->setAlignment ( Qt::AlignRight );
45 transactiondate->setDisabled ( TRUE );
46 datebutton = new QPushButton( transactiondatebox );
47 datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) );
48 connect ( datebutton, SIGNAL ( released() ), this, SLOT ( showCalendar() ) );
49
50 clearedcheckbox = new QCheckBox ( "Cleared", this );
51 depositbox = new QCheckBox ( "Credit", this );
52
53 // START SECOND COLUMN
54
55 numberlabel = new QLabel ( "Number", this );
56 transactionnumber = new QLineEdit ( this );
57
58 budgetlabel = new QLabel ( "Budget", this );
59 budgetbox = new QComboBox ( FALSE, this );
60
61 lineitemlabel = new QLabel ( "LineItem", this );
62 lineitembox = new QComboBox ( FALSE, this );
63
64 layout = new QGridLayout ( this, 7, 2, 2, 2 );
65 layout->addWidget ( namelabel, 0, 0, Qt::AlignLeft );
66 layout->addWidget ( transactionnamebox, 1, 0, Qt::AlignLeft );
67 layout->addWidget ( amountlabel, 2, 0, Qt::AlignLeft );
68 layout->addWidget ( transactionamountbox, 3, 0, Qt::AlignLeft );
69 layout->addWidget ( datelabel, 4, 0, Qt::AlignLeft );
70 layout->addWidget ( transactiondatebox, 5, 0, Qt::AlignLeft );
71 layout->addWidget ( clearedcheckbox, 6, 0, Qt::AlignLeft );
72 layout->addWidget ( numberlabel, 0, 1, Qt::AlignLeft );
73 layout->addWidget ( transactionnumber, 1, 1, Qt::AlignLeft );
74 layout->addWidget ( budgetlabel, 2, 1, Qt::AlignLeft );
75 layout->addWidget ( budgetbox, 3, 1, Qt::AlignLeft );
76 layout->addWidget ( lineitemlabel, 4, 1, Qt::AlignLeft );
77 layout->addWidget ( lineitembox, 5, 1, Qt::AlignLeft );
78 layout->addWidget ( depositbox, 6, 1, Qt::AlignLeft );
79
80 if ( budget->getNumberOfBudgets() != 0 )
81 {
82 budgetnameslist = budget->getBudgetNames();
83 budgetidslist = budget->getBudgetIDs();
84 budgetbox->insertStringList ( *budgetnameslist );
85 lineitemlabel->setEnabled ( FALSE );
86 lineitembox->setEnabled ( FALSE );
87 connect ( budgetbox, SIGNAL ( activated(int) ), this, SLOT ( setCurrentBudget(int) ) );
88 connect ( lineitembox, SIGNAL ( activated(int) ), this, SLOT ( setCurrentLineItem(int) ) );
89 }
90 else
91 {
92 budgetlabel->setEnabled ( FALSE );
93 budgetbox->setEnabled ( FALSE );
94 lineitemlabel->setEnabled ( FALSE );
95 lineitembox->setEnabled ( FALSE );
96 }
97
98}
99
100NewTransaction::~NewTransaction ()
101 {
102 }
103
104void NewTransaction::showCalculator ()
105{
106 Calculator *calculator = new Calculator ( this );
107 calculator->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) );
108 if ( calculator->exec () == QDialog::Accepted )
109 transactionamount->setText ( calculator->display->text() );
110}
111
112void NewTransaction::showCalendar ()
113 {
114 QDate newDate = QDate::currentDate ();
115 DatePicker *dp = new DatePicker ( newDate );
116 dp->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) );
117
118 int response = dp->exec();
119 if ( response == QDialog::Accepted )
120 {
121 // Set date integers
122 year = dp->getYear();
123 month = dp->getMonth();
124 day = dp->getDay();
125
126 // Set dateedited to TRUE
127 // This tells the transactiondisplay object that the user edited an transaction
128 // and did change the date3
129 dateedited = TRUE;
130
131 // Display date with our selected format
132 transactiondate->setText ( preferences->getDate ( year, month, day ) );
133 }
134 }
135
136bool NewTransaction::getDateEdited ()
137 {
138 return dateedited;
139 }
140
141int NewTransaction::getDay ()
142 {
143 return day;
144 }
145
146int NewTransaction::getMonth ()
147 {
148 return month;
149 }
150
151int NewTransaction::getYear ()
152 {
153 return year;
154 }
155
156QString NewTransaction::getDescription ()
157 {
158 return transactiondescription;
159 }
160
161void NewTransaction::setDescription ( QString description )
162 {
163 transactiondescription = description;
164 }
165
166void NewTransaction::addTransactionDescription ()
167 {
168 // Function for adding or editing an transaction description.
169 QDialog *description = new QDialog ( this, "description", TRUE );
170 description->setCaption ( "Notes" );
171 QMultiLineEdit *enter = new QMultiLineEdit ( description );
172 enter->setFixedSize ( ( int ) (this->width() * 0.75 ), ( int ) ( this->height() * 0.5 ) );
173 enter->setWrapColumnOrWidth ( ( int ) (this->width() * 0.75 ) );
174 enter->setWordWrap ( QMultiLineEdit::WidgetWidth );
175 if ( transactiondescription != "(NULL)" )
176 enter->setText ( transactiondescription );
177 if ( description->exec () == QDialog::Accepted )
178 transactiondescription = enter->text ();
179 }
180
181int NewTransaction::getNameIndex ( QString name )
182 {
183 int counter;
184 int items = transactionname->count();
185 for ( counter = 0; ( items - 1 ); counter++ )
186 {
187 if ( name == transactionname->text ( counter ) )
188 {
189 return counter;
190 break;
191 }
192 }
193 return 0;
194 }
195
196void NewTransaction::setCurrentBudget ( int index )
197 {
198 if ( index != 0 )
199 {
200 currentbudget = budgetidslist->operator[] ( index - 1 ).toInt();
201 lineitemslist = budget->getLineItems ( currentbudget );
202 lineitemidslist = budget->getLineItemIDs ( currentbudget );
203 lineitemlabel->setEnabled ( TRUE );
204 lineitembox->setEnabled ( TRUE );
205 lineitembox->clear();
206 lineitembox->insertStringList ( lineitemslist );
207 setCurrentLineItem ( 0 );
208 }
209 else
210 {
211 lineitembox->clear();
212 lineitemlabel->setEnabled ( FALSE );
213 lineitembox->setEnabled ( FALSE );
214 currentlineitem = -1;
215 currentbudget = -1;
216 }
217 }
218
219void NewTransaction::setCurrentLineItem ( int index )
220 {
221 currentlineitem = ( lineitemidslist.operator[] ( index ).toInt() );
222 }
223
224int NewTransaction::getCurrentBudget ()
225 {
226 return currentbudget;
227 }
228
229int NewTransaction::getBudgetIndex ( int budgetid )
230 {
231 currentbudget = budgetid;
232 const QString budget = QString::number ( budgetid );
233 return budgetidslist->findIndex ( budget );
234 }
235
236int NewTransaction::getLineItemIndex ( int lineitemid )
237 {
238 currentlineitem = lineitemid;
239 const QString lineitem = QString::number ( lineitemid );
240 return lineitemidslist.findIndex ( lineitem );
241 }
242
243void NewTransaction::setLineItems ()
244 {
245 lineitemslist = budget->getLineItems ( currentbudget );
246 lineitemidslist = budget->getLineItemIDs ( currentbudget );
247 lineitemlabel->setEnabled ( TRUE );
248 lineitembox->setEnabled ( TRUE );
249 lineitembox->clear();
250 lineitembox->insertStringList ( lineitemslist );
251 }
252
253int NewTransaction::getCurrentLineItem ()
254 {
255 return currentlineitem;
256 }
257
258void NewTransaction::setComboBoxes ( int budgetid, int lineitemid )
259 {
260 const QString budgetname = QString::number ( budgetid );
261 budgetbox->setCurrentItem ( ( budgetidslist->findIndex ( budgetname ) ) );
262 currentbudget = budgetidslist->operator[] ( budgetbox->currentItem() - 1 ).toInt();
263
264 lineitemslist = budget->getLineItems ( currentbudget );
265 lineitemidslist = budget->getLineItemIDs ( currentbudget );
266 lineitemlabel->setEnabled ( TRUE );
267 lineitembox->setEnabled ( TRUE );
268 lineitembox->clear();
269 lineitembox->insertStringList ( lineitemslist );
270
271 const QString lineitem = QString::number ( lineitemid );
272 lineitembox->setCurrentItem ( lineitemidslist.findIndex ( lineitem ) );
273 currentlineitem = ( lineitemidslist.operator[] ( lineitembox->currentItem() ).toInt() );
274 }
diff --git a/noncore/unsupported/qashmoney/newtransaction.h b/noncore/unsupported/qashmoney/newtransaction.h
new file mode 100755
index 0000000..db3a5ad
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/newtransaction.h
@@ -0,0 +1,96 @@
1#ifndef NEWTRANSACTION_H
2#define NEWTRANSACTION_H
3
4#include <qlineedit.h>
5#include <qpushbutton.h>
6#include <qlayout.h>
7#include <qcheckbox.h>
8#include <qdialog.h>
9#include <qlabel.h>
10#include <qstringlist.h>
11#include <qhbox.h>
12#include <qcombobox.h>
13
14#include "transaction.h"
15#include "preferences.h"
16
17class NewTransaction : public QDialog
18{
19 Q_OBJECT
20
21 public:
22
23 int year, month, day;
24
25 NewTransaction ( QWidget* parent );
26 ~NewTransaction();
27
28 QLabel *namelabel;
29 QHBox *transactionnamebox;
30 QComboBox* transactionname;
31 QPushButton* descriptionbutton;
32
33 QLabel *amountlabel;
34 QHBox *transactionamountbox;
35 QLineEdit* transactionamount;
36 QPushButton* calculatorbutton;
37
38 QLabel *datelabel;
39 QHBox *transactiondatebox;
40 QLineEdit* transactiondate;
41 QPushButton* datebutton;
42
43 QCheckBox *clearedcheckbox;
44
45 QLabel *numberlabel;
46 QLineEdit *transactionnumber;
47
48 QLabel *budgetlabel;
49 QComboBox *budgetbox;
50
51 QLabel *lineitemlabel;
52 QComboBox *lineitembox;
53
54 QCheckBox *depositbox;
55
56 QGridLayout *layout;
57
58 int getDay ();
59 int getMonth ();
60 int getYear ();
61 QString getDescription ();
62 void setDescription ( QString );
63 void setComboBoxes ( int, int );
64
65 // When a user edits an transaction and edits the date, this flag
66 // is set to TRUE adding the new date to the transaction. Otherwise,
67 // the old date is used for the edited transaction. This prevents a date
68 // from reverting to 0/0/0 if the date is not edited
69 bool getDateEdited ();
70
71 public slots:
72
73 void showCalculator();
74 void showCalendar ();
75 void addTransactionDescription ();
76 int getNameIndex ( QString name );
77 int getCurrentBudget ();
78 int getCurrentLineItem ();
79 int getBudgetIndex ( int budgetid );
80 int getLineItemIndex ( int lineitemid );
81 void setLineItems ();
82
83 private slots:
84 void setCurrentBudget ( int index );
85 void setCurrentLineItem ( int index );
86
87 private:
88 bool dateedited;
89 int index, currentbudget, currentlineitem;
90 QString transactiondescription;
91 QStringList *budgetnameslist, *budgetidslist;
92 QStringList lineitemslist, lineitemidslist;
93
94};
95
96#endif
diff --git a/noncore/unsupported/qashmoney/preferencedialogs.cpp b/noncore/unsupported/qashmoney/preferencedialogs.cpp
new file mode 100755
index 0000000..b83c957
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/preferencedialogs.cpp
@@ -0,0 +1,216 @@
1#include "preferencedialogs.h"
2#include "preferences.h"
3
4extern Preferences *preferences;
5
6DatePreferences::DatePreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE )
7 {
8 setCaption( tr( "Date" ) );
9
10 QLabel *datelabel = new QLabel ( "Format", this );
11 dateformat = new QComboBox ( this );
12 dateformat->setEditable ( FALSE );
13 dateformat->insertItem ( "yyyymmdd" );
14 dateformat->insertItem ( "yymmdd" );
15 dateformat->insertItem ( "mmddyyyy" );
16 dateformat->insertItem ( "mmddyy" );
17 dateformat->insertItem ( "yyyyddmm" );
18 dateformat->insertItem ( "yyddmm" );
19 dateformat->insertItem ( "ddmmyyyy" );
20 dateformat->insertItem ( "ddmmyy" );
21 connect ( dateformat, SIGNAL ( activated(int) ), this, SLOT ( changeDateFormat(int) ) );
22
23 QLabel *dateseparatorlabel = new QLabel ( "Separator", this );
24 dateseparator = new QComboBox ( this );
25 dateseparator->insertItem ( "/" );
26 dateseparator->insertItem ( "-" );
27 dateseparator->insertItem ( "." );
28 connect ( dateseparator, SIGNAL ( activated(int) ), this, SLOT ( changeDateSeparator(int) ) );
29
30 defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this );
31 connect ( defaults, SIGNAL ( released() ), this, SLOT ( setDefaultDatePreferences() ) );
32
33 dateformat->setCurrentItem ( ( preferences->getPreference ( 1 ) ) - 1 );
34 dateseparator->setCurrentItem ( ( preferences->getPreference ( 2 ) ) - 1 );
35
36 layout = new QVBoxLayout ( this, 2, 2 );
37 layout->addWidget ( datelabel );
38 layout->addWidget ( dateformat );
39 layout->addWidget ( dateseparatorlabel );
40 layout->addWidget ( dateseparator );
41 layout->insertSpacing ( 4, 5 );
42 layout->addWidget ( defaults );
43
44 }
45
46DatePreferences::~DatePreferences ()
47 {
48 }
49
50void DatePreferences::changeDateFormat ( int index )
51 {
52 index ++;
53 preferences->changePreference ( 1, index );
54 }
55
56void DatePreferences::changeDateSeparator ( int index )
57 {
58 index ++;
59 preferences->changePreference ( 2, index );
60 }
61
62void DatePreferences::setDefaultDatePreferences ()
63 {
64 preferences->setDefaultDatePreferences ();
65 dateformat->setCurrentItem ( ( preferences->getPreference ( 1 ) ) - 1 );
66 dateseparator->setCurrentItem ( ( preferences->getPreference ( 2 ) ) - 1 );
67 }
68
69// START TRANSACTION PREFERENCES
70
71TransactionPreferences::TransactionPreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE )
72{
73 setCaption( tr ( "Transaction" ) );
74
75 showclearedtransactions = new QCheckBox ( this );
76 showclearedtransactions->setText ( "Show Cleared Transactions" );
77
78 limittransactionsbox = new QHBox ( this );
79 limittransactionsbox->setSpacing ( 2 );
80 limittransactionslabel = new QLabel ( "Show ", limittransactionsbox );
81 limittransactions = new QComboBox ( limittransactionsbox );
82 QLabel *limittransactionslabel2 = new QLabel ( "of cleared transactions. ", limittransactionsbox );
83 limittransactions->insertItem ( "14 days" );
84 limittransactions->insertItem ( "30 days" );
85 limittransactions->insertItem ( "90 days" );
86 limittransactions->insertItem ( "180 days" );
87 limittransactions->insertItem ( "365 days" );
88 limittransactions->insertItem ( "All" );
89 limittransactions->setCurrentItem ( preferences->getPreference ( 7 ) );
90
91 excludetransfers = new QCheckBox ( this );
92 excludetransfers->setText ( "Include Transfers In Limit View" );
93
94 if ( preferences->getPreference ( 3 ) == 1 )
95 showclearedtransactions->setChecked ( TRUE );
96 else
97 showclearedtransactions->setChecked ( FALSE );
98
99 if ( preferences->getPreference ( 6 ) == 1 )
100 excludetransfers->setChecked ( TRUE );
101 else
102 excludetransfers->setChecked ( FALSE );
103
104 defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this );
105 connect ( defaults, SIGNAL ( released() ), this, SLOT ( setDefaultTransactionPreferences() ) );
106
107 layout = new QVBoxLayout ( this, 2, 2 );
108 layout->addWidget ( showclearedtransactions );
109 layout->addWidget ( limittransactionsbox );
110 layout->addWidget ( excludetransfers );
111 layout->insertSpacing ( 3, 5 );
112 layout->addWidget ( defaults );
113
114 connect ( showclearedtransactions, SIGNAL ( toggled(bool) ), this, SLOT ( changeShowClearedPreference(bool) ) );
115 connect ( excludetransfers, SIGNAL ( toggled(bool) ), this, SLOT ( changeExcludeTranfersPreference(bool) ) );
116 connect ( limittransactions, SIGNAL ( activated(int) ), this, SLOT ( changeLimitTransactionsPreference(int) ) );
117}
118
119TransactionPreferences::~TransactionPreferences ()
120 {
121 }
122
123void TransactionPreferences::changeLimitTransactionsPreference ( int pref )
124 {
125 preferences->changePreference ( 7, pref );
126 }
127
128void TransactionPreferences::changeShowClearedPreference ( bool state )
129 {
130 if ( state == TRUE )
131 preferences->changePreference ( 3, 1 );
132 else
133 preferences->changePreference ( 3, 0 );
134 }
135
136void TransactionPreferences::changeExcludeTranfersPreference ( bool state )
137 {
138 if ( state == TRUE )
139 preferences->changePreference ( 6, 1 );
140 else
141 preferences->changePreference ( 6, 0 );
142 }
143
144void TransactionPreferences::setDefaultTransactionPreferences ()
145 {
146 preferences->changePreference ( 3, 0 );
147 preferences->changePreference ( 6, 0 );
148 preferences->changePreference ( 7, 0 );
149 showclearedtransactions->setChecked ( FALSE );
150 limittransactions->setCurrentItem ( 0 );
151 }
152
153// START ACCOUNT PREFERNCES
154
155AccountPreferences::AccountPreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE )
156{
157
158 setCaption( tr ( "Account" ) );
159
160 currencysupport = new QCheckBox ( this );
161 currencysupport->setText ( "Enable Currency Support" );
162
163 onetouch = new QCheckBox ( this );
164 onetouch->setText ( "One Touch Account Viewing" );
165
166 if ( preferences->getPreference ( 4 ) == 1 )
167 currencysupport->setChecked ( TRUE );
168 else
169 currencysupport->setChecked ( FALSE );
170
171 if ( preferences->getPreference ( 5 ) == 1 )
172 onetouch->setChecked ( TRUE );
173 else
174 onetouch->setChecked ( FALSE );
175
176 defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this );
177 connect ( defaults, SIGNAL ( released() ), this, SLOT ( setDefaultAccountPreferences() ) );
178
179 layout = new QVBoxLayout ( this, 2, 2 );
180 layout->addWidget ( currencysupport );
181 layout->addWidget ( onetouch );
182 layout->insertSpacing ( 2, 5 );
183 layout->addWidget ( defaults );
184
185 connect ( currencysupport, SIGNAL ( toggled(bool) ), this, SLOT ( changeCurrencySupport(bool) ) );
186 connect ( onetouch, SIGNAL ( toggled(bool) ), this, SLOT ( changeOneTouchViewing(bool) ) );
187}
188
189AccountPreferences::~AccountPreferences ()
190 {
191 }
192
193void AccountPreferences::changeCurrencySupport ( bool state )
194 {
195 if ( state == TRUE )
196 preferences->changePreference ( 4, 1 );
197 else
198 preferences->changePreference ( 4, 0 );
199 }
200
201void AccountPreferences::changeOneTouchViewing ( bool state )
202 {
203 if ( state == TRUE )
204 preferences->changePreference ( 5, 1 );
205 else
206 preferences->changePreference ( 5, 0 );
207 }
208
209void AccountPreferences::setDefaultAccountPreferences ()
210 {
211 preferences->changePreference ( 4, 0 );
212 preferences->changePreference ( 5, 0 );
213 currencysupport->setChecked ( FALSE );
214 onetouch->setChecked ( FALSE );
215 }
216
diff --git a/noncore/unsupported/qashmoney/preferencedialogs.h b/noncore/unsupported/qashmoney/preferencedialogs.h
new file mode 100755
index 0000000..88281b8
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/preferencedialogs.h
@@ -0,0 +1,90 @@
1#include <qcombobox.h>
2#include <qdialog.h>
3#include <qpushbutton.h>
4#include <qpixmap.h>
5#include <qgroupbox.h>
6#include <qhbuttongroup.h>
7#include <qcheckbox.h>
8#include <qlayout.h>
9#include <qlabel.h>
10#include <qhbox.h>
11
12#ifndef DATEPREFERENCES_H
13#define DATEPREFERENCES_H
14
15class DatePreferences : public QDialog
16 {
17 Q_OBJECT
18
19 public:
20 DatePreferences ( QWidget * parent );
21 ~DatePreferences();
22
23 QPushButton *defaults;
24 QComboBox *dateformat;
25 QComboBox *dateseparator;
26 QBoxLayout *layout;
27
28 public slots:
29 void changeDateFormat ( int );
30 void changeDateSeparator ( int );
31 void setDefaultDatePreferences ();
32};
33
34#endif
35
36#ifndef TRANSACTIONPREFERENCES_H
37#define TRANSACTIONPREFERENCES_H
38
39class TransactionPreferences : public QDialog
40 {
41 Q_OBJECT
42
43 public:
44 TransactionPreferences ( QWidget * parent );
45 ~TransactionPreferences();
46
47 QCheckBox *showclearedtransactions;
48 QCheckBox *excludetransfers;
49 QHBox *limittransactionsbox;
50 QLabel *limittransactionslabel;
51 QComboBox *limittransactions;
52 QPushButton *defaults;
53 QBoxLayout *layout;
54
55 public slots:
56 void changeShowClearedPreference ( bool );
57 void changeExcludeTranfersPreference ( bool );
58 void setDefaultTransactionPreferences ();
59 void changeLimitTransactionsPreference ( int );
60};
61
62#endif
63
64#ifndef ACCOUNTPREFERENCES_H
65#define ACCOUNTPREFERENCES_H
66
67class AccountPreferences : public QDialog
68 {
69 Q_OBJECT
70
71 public:
72 AccountPreferences ( QWidget * parent );
73 ~AccountPreferences();
74
75 QCheckBox *currencysupport;
76 QCheckBox *onetouch;
77 QPushButton *defaults;
78 QBoxLayout *layout;
79
80 public slots:
81 void changeCurrencySupport ( bool );
82 void changeOneTouchViewing ( bool );
83 void setDefaultAccountPreferences ();
84};
85
86#endif
87
88
89
90
diff --git a/noncore/unsupported/qashmoney/preferences.cpp b/noncore/unsupported/qashmoney/preferences.cpp
new file mode 100755
index 0000000..880807a
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/preferences.cpp
@@ -0,0 +1,352 @@
1#include "preferences.h"
2#include <stdlib.h>
3
4Preferences::Preferences ()
5 {
6 db = sqlite_open ( "qmpreferences.db", 0, NULL );
7 }
8
9Preferences::~Preferences ()
10 {
11 sqlite_close ( db );
12 }
13
14void Preferences::addPreferences ()
15 {
16 // This function checks the preferences database for existing preferences and adds
17 // them if they are not there. First we set up variables. Preferences are always set
18 // to non-zero numbers because when we check to see if a preference has been
19 // added to the database, the result is zero if it hasn't
20 int rows = 0;
21 int columns = 0;
22 char **results;
23
24 sqlite_get_table ( db, "select count() from preferences;", &results, 0, 0, 0 );
25 if ( atoi ( results [ 1 ] ) != 7 )
26 {
27 // dateformat preference 1 = yyyymmdd 2 = yymmdd 3 = mmddyyyy 4 = mmddyy
28 // 5 = yyyyddmm 6 = yyddmm 7 = ddmmyyyy 8 = ddmmyy
29 sqlite_get_table ( db, "select preference from preferences where id = 1;", &results, &rows, &columns, 0 );
30 if ( rows == 0 )
31 sqlite_exec ( db, "insert into preferences values ( 4, 'dateformat', 0, 0, 0, NULL );", 0, 0, 0 );
32
33 // dateseparator preference 1 = / ( forward slash ) 2 = - ( dash ) 3 = . ( period )
34 rows = 0;
35 sqlite_get_table ( db, "select preference from preferences where id = 2;", &results, &rows, &columns, 0 );
36 if ( rows == 0 )
37 sqlite_exec ( db, "insert into preferences values ( 1, 'dateseparator', 0, 0, 0, NULL );", 0, 0, 0 );
38
39 // showclearedtransactions preference 0 = no 1 = yes
40 rows = 0;
41 sqlite_get_table ( db, "select preference from preferences where id = 3;", &results, &rows, &columns, 0 );
42 if ( rows == 0 )
43 sqlite_exec ( db, "insert into preferences values ( 0, 'showclearedtransactions', 0, 0, 0, NULL );", 0, 0, 0 );
44
45 // enable currency support preference 0 = no 1 = yes
46 rows = 0;
47 sqlite_get_table ( db, "select preference from preferences where id = 4;", &results, &rows, &columns, 0 );
48 if ( rows == 0 )
49 sqlite_exec ( db, "insert into preferences values ( 0, 'enablecurrencysupport', 0, 0, 0, NULL );", 0, 0, 0 );
50
51 // one touch account viewing preference 0 = no 1 = yes
52 rows = 0;
53 sqlite_get_table ( db, "select preference from preferences where id = 5;", &results, &rows, &columns, 0 );
54 if ( rows == 0 )
55 sqlite_exec ( db, "insert into preferences values ( 0, 'onetouchviewing', 0, 0, 0, NULL );", 0, 0, 0 );
56
57 // exclude transfers from limit view 0 = no 1 = yes
58 rows = 0;
59 sqlite_get_table ( db, "select preference from preferences where id = 6;", &results, &rows, &columns, 0 );
60 if ( rows == 0 )
61 sqlite_exec ( db, "insert into preferences values ( 0, 'excludetransfersfromlimit', 0, 0, 0, NULL );", 0, 0, 0 );
62
63 // limit number of transactions to 0 = 14 days 1 = 30 days, 2 = 90 days, 3 = 180 days, 4 = 365 days 5 = all
64 rows = 0;
65 sqlite_get_table ( db, "select preference from preferences where id = 7;", &results, &rows, &columns, 0 );
66 if ( rows == 0 )
67 sqlite_exec ( db, "insert into preferences values ( 0, 'limittransactions', 0, 0, 0, NULL );", 0, 0, 0 );
68 }
69 }
70
71void Preferences::initializeColumnPreferences ()
72 {
73 int rows = 0;
74 int columns = 0;
75 char **results;
76
77 // initialize accountname column width
78 sqlite_get_table ( db, "select width from columns where id = 1;", &results, &rows, &columns, 0 );
79 if ( rows == 0 )
80 sqlite_exec ( db, "insert into columns values ( 'accountname', 90, 0, 0, 0, NULL );", 0, 0, 0 );
81
82 // initialize accountbalance column width
83 sqlite_get_table ( db, "select width from columns where id = 2;", &results, &rows, &columns, 0 );
84 if ( rows == 0 )
85 sqlite_exec ( db, "insert into columns values ( 'accountbalance', 90, 0, 0, 0, NULL );", 0, 0, 0 );
86
87 // initialize transactiondate column width
88 sqlite_get_table ( db, "select width from columns where id = 3;", &results, &rows, &columns, 0 );
89 if ( rows == 0 )
90 sqlite_exec ( db, "insert into columns values ( 'normaltransactiondate', 50, 0, 0, 0, NULL );", 0, 0, 0 );
91
92 // initialize transactionname column width
93 sqlite_get_table ( db, "select width from columns where id = 4;", &results, &rows, &columns, 0 );
94 if ( rows == 0 )
95 sqlite_exec ( db, "insert into columns values ( 'normaltransactionname', 75, 0, 0, 0, NULL );", 0, 0, 0 );
96
97 // initialize transactionamount column width
98 sqlite_get_table ( db, "select width from columns where id = 5;", &results, &rows, &columns, 0 );
99 if ( rows == 0 )
100 sqlite_exec ( db, "insert into columns values ( 'normaltransactionamount', 50, 0, 0, 0, NULL );", 0, 0, 0 );
101
102 // initialize transactiondate column width
103 sqlite_get_table ( db, "select width from columns where id = 6;", &results, &rows, &columns, 0 );
104 if ( rows == 0 )
105 sqlite_exec ( db, "insert into columns values ( 'extendedtransactiondate', 50, 0, 0, 0, NULL );", 0, 0, 0 );
106
107 // initialize transactionname column width
108 sqlite_get_table ( db, "select width from columns where id = 7;", &results, &rows, &columns, 0 );
109 if ( rows == 0 )
110 sqlite_exec ( db, "insert into columns values ( 'extendedtransactionname', 75, 0, 0, 0, NULL );", 0, 0, 0 );
111
112 // initialize transactionamount column width
113 sqlite_get_table ( db, "select width from columns where id = 8;", &results, &rows, &columns, 0 );
114 if ( rows == 0 )
115 sqlite_exec ( db, "insert into columns values ( 'extendedtransactionamount', 50, 0, 0, 0, NULL );", 0, 0, 0 );
116
117 // initialize transactionaccount column width
118 sqlite_get_table ( db, "select width from columns where id = 9;", &results, &rows, &columns, 0 );
119 if ( rows == 0 )
120 sqlite_exec ( db, "insert into columns values ( 'transactionaccount', 50, 0, 0, 0, NULL );", 0, 0, 0 );
121
122 // initialize account name with currency column width
123 sqlite_get_table ( db, "select width from columns where id = 10;", &results, &rows, &columns, 0 );
124 if ( rows == 0 )
125 sqlite_exec ( db, "insert into columns values ( 'accountnamewithcurrency', 100, 0, 0, 0, NULL );", 0, 0, 0 );
126
127 // initialize account currency column width
128 sqlite_get_table ( db, "select width from columns where id = 11;", &results, &rows, &columns, 0 );
129 if ( rows == 0 )
130 sqlite_exec ( db, "insert into columns values ( 'currencycolumn', 10, 0, 0, 0, NULL );", 0, 0, 0 );
131
132 // initialize account balance with currency column width
133 sqlite_get_table ( db, "select width from columns where id = 12;", &results, &rows, &columns, 0 );
134 if ( rows == 0 )
135 sqlite_exec ( db, "insert into columns values ( 'accountbalancewithcurrency', 50, 0, 0, 0, NULL );", 0, 0, 0 );
136
137 // initialize budget line item column
138 sqlite_get_table ( db, "select width from columns where id = 13;", &results, &rows, &columns, 0 );
139 if ( rows == 0 )
140 sqlite_exec ( db, "insert into columns values ( 'budgetlineitem', 50, 0, 0, 0, NULL );", 0, 0, 0 );
141
142 // initialize budget budget column
143 sqlite_get_table ( db, "select width from columns where id = 14;", &results, &rows, &columns, 0 );
144 if ( rows == 0 )
145 sqlite_exec ( db, "insert into columns values ( 'budgetbudget', 50, 0, 0, 0, NULL );", 0, 0, 0 );
146
147 // initialize budget actual column
148 sqlite_get_table ( db, "select width from columns where id = 15;", &results, &rows, &columns, 0 );
149 if ( rows == 0 )
150 sqlite_exec ( db, "insert into columns values ( 'budgetactual', 50, 0, 0, 0, NULL );", 0, 0, 0 );
151 }
152
153void Preferences::initializeSortingPreferences ()
154 {
155 int rows = 0;
156 int columns = 0;
157 char **results;
158
159 if ( sqlite_get_table ( db, "select count() from sorting;", 0, 0, 0, 0 ) != 0 )
160 sqlite_exec ( db, "create table sorting ( listbox, column, direction, id integer primary key );", 0, 0, 0 );
161
162 // initialize account listbox sorting. Set direction = 1 here so ascending sort is default.
163 sqlite_get_table ( db, "select column, direction from sorting where id = 1;", &results, &rows, &columns, 0 );
164 if ( rows == 0 )
165 sqlite_exec ( db, "insert into sorting values ( 'accounts', 0, 1, NULL );", 0, 0, 0 );
166
167 // initialize transaction listbox sorting
168 sqlite_get_table ( db, "select column, direction from sorting where id = 2;", &results, &rows, &columns, 0);
169 if ( rows == 0 )
170 sqlite_exec ( db, "insert into sorting values ( 'transactions', 0, 1, NULL );", 0, 0, 0 );
171
172 // initialize budgets listbox sorting
173 sqlite_get_table ( db, "select column, direction from sorting where id = 3;", & results, &rows, &columns, 0 );
174 if ( rows == 0 )
175 sqlite_exec ( db, "insert into sorting values ( 'budgets', 0, 1, NULL );", 0, 0, 0 );
176 }
177
178void Preferences::changeColumnPreference ( int id, int width )
179 {
180 sqlite_exec_printf ( db, "update columns set width = %i where id = %i;", 0, 0, 0, width, id );
181 }
182
183int Preferences::getColumnPreference ( int id )
184 {
185 char **results;
186 sqlite_get_table_printf ( db, "select width from columns where id = %i;", &results, NULL, NULL, NULL, id );
187 return atoi ( results [ 1 ] );
188 }
189
190void Preferences::changeSortingPreference ( int id, int column )
191 {
192 int pColumn = 0; // column setting coming from the prefs object
193 int pDirection = 0; // direction setting coming from the prefs object
194
195 // because there appears to be no way to query the QT header object directly for it's current sort settings, we have
196 // to maintain track of them ourselves. So start by pulling the current saved setting for this view.
197 getSortingPreference ( id, &pColumn, &pDirection );
198
199 // if the current saved column == the new column, then the user wants to toggle the sort order.
200 // otherwise we behave like QT does by default, which is to select the new column and default to an ascending sort.
201 if ( column == pColumn )
202 sqlite_exec_printf ( db, "update sorting set direction = %i where id = %i;", 0, 0, 0, !pDirection, id );
203 else
204 sqlite_exec_printf ( db, "update sorting set column = %i, direction = 1 where id = %i;", 0, 0, 0, column, id );
205 }
206
207void Preferences::getSortingPreference ( int id, int *column, int *direction )
208 {
209 char **results;
210 sqlite_get_table_printf ( db, "select column, direction from sorting where id = %i;", &results, NULL, NULL, NULL, id );
211 *column = atoi ( results [ 2 ] );
212 *direction = atoi ( results [ 3 ] );
213 }
214
215int Preferences::getPreference ( int id )
216 {
217 char **results;
218 sqlite_get_table_printf ( db, "select preference from preferences where id = %i;", &results, NULL, NULL, NULL, id );
219 return atoi ( results [ 1 ] );
220 }
221
222QString Preferences::getSeparator ( )
223 {
224 int s = getPreference ( 2 );
225 if ( s == 1 )
226 return "/";
227 if ( s ==2 )
228 return "-";
229 else
230 return ".";
231 }
232
233void Preferences::changePreference ( int id, int newpreference )
234 {
235 sqlite_exec_printf ( db, "update preferences set preference = %i where id = %i;", 0, 0, 0, newpreference, id );
236 }
237
238void Preferences::setDefaultDatePreferences ()
239 {
240 sqlite_exec ( db, "update preferences set preference = 4 where id = 1;", 0, 0, 0 );
241 sqlite_exec ( db, "update preferences set preference = 1 where id = 2;", 0, 0, 0 );
242 }
243
244QString Preferences::getDate ( int y, int m, int d )
245 {
246 QString date;
247 int format = getPreference ( 1 );
248 QString separator = getSeparator();
249
250 // Convert all date integers to QStrings
251 QString year = QString::number ( y );
252 QString month = QString::number ( m );
253 if ( m < 10 )
254 month.prepend ( "0" );
255 QString day = QString::number ( d );
256 if ( d < 10 )
257 day.prepend ( "0" );
258
259 // Truncate four digit year if necessary
260 if ( format == 2 || format == 4 || format == 6 || format == 8 )
261 year.remove ( 0, 2 );
262
263 // Concatenate dates as necessary
264 if ( format == 1 || format == 2 )
265 {
266 date = year;
267 date.append ( separator );
268 date.append ( month );
269 date.append ( separator );
270 date.append ( day );
271 return date;
272 }
273 if ( format == 3 || format == 4 )
274 {
275 date = month;
276 date.append ( separator );
277 date.append ( day );
278 date.append ( separator );
279 date.append ( year );
280 return date;
281 }
282 if ( format == 5 || format == 6 )
283 {
284 date = year;
285 date.append ( separator );
286 date.append ( day );
287 date.append ( separator );
288 date.append ( month );
289 return date;
290 }
291 if ( format == 7 || format == 8 )
292 {
293 date = day;
294 date.append ( separator );
295 date.append ( month );
296 date.append ( separator );
297 date.append ( year );
298 return date;
299 }
300 }
301
302QString Preferences::getDate ( int y, int m )
303 {
304 QString date;
305 int format = getPreference ( 1 );
306 QString separator = getSeparator();
307
308 // Convert all date integers to QStrings
309 QString year = QString::number ( y );
310 QString month = QString::number ( m );
311 if ( m < 10 )
312 month.prepend ( "0" );
313
314 // Truncate four digit year if necessary
315 if ( format == 2 || format == 4 || format == 6 || format == 8 )
316 year.remove ( 0, 2 );
317
318 // Concatenate dates as necessary
319 if ( format == 1 || format == 2 )
320 {
321 date = year;
322 date.append ( separator );
323 date.append ( month );
324 return date;
325 }
326 if ( format == 3 || format == 4 )
327 {
328 date = month;
329 date.append ( separator );
330 date.append ( year );
331 return date;
332 }
333 if ( format == 5 || format == 6 )
334 {
335 date = year;
336 date.append ( separator );
337 date.append ( month );
338 return date;
339 }
340 if ( format == 7 || format == 8 )
341 {
342 date.append ( month );
343 date.append ( separator );
344 date.append ( year );
345 return date;
346 }
347 }
348
349
350
351
352
diff --git a/noncore/unsupported/qashmoney/preferences.h b/noncore/unsupported/qashmoney/preferences.h
new file mode 100755
index 0000000..38579ad
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/preferences.h
@@ -0,0 +1,53 @@
1#include <sqlite3.h>
2#include <qstring.h>
3
4#ifndef PREFERENCES_H
5#define PREFERENCES_H
6
7class Preferences
8 {
9 public:
10 Preferences ();
11 ~Preferences ();
12
13 void addPreferences ();
14 void initializeColumnPreferences ();
15 void initializeSortingPreferences ();
16
17 // Returns a preference value for the given preferences ID
18 int getPreference ( int );
19 int getColumnPreference ( int id );
20 void getSortingPreference ( int id, int *column, int *direction );
21
22 // Convenience for getting date separator with one function
23 // call. Takes the preference id as its argument
24 QString getSeparator ( );
25
26 // Changes a preference for the given ID
27 void changePreference ( int , int );
28 void changeColumnPreference ( int id, int width );
29 void changeSortingPreference ( int id, int column );
30
31 // The primary database that stores all our data
32 sqlite3 *db;
33
34 // This function returns a Qstring for the year first date formats
35 // for displaying. It takes the date numbers
36 QString getDate ( int, int, int );
37 QString getDate ( int y, int m );
38
39 void setDefaultDatePreferences ();
40 };
41
42#endif
43
44
45
46
47
48
49
50
51
52
53
diff --git a/noncore/unsupported/qashmoney/qashmoney.cpp b/noncore/unsupported/qashmoney/qashmoney.cpp
new file mode 100755
index 0000000..1455eb0
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/qashmoney.cpp
@@ -0,0 +1,402 @@
1#include "qashmoney.h"
2#include "preferencedialogs.h"
3#include "memorydialog.h"
4
5#include <qheader.h>
6
7Budget *budget = new Budget ();
8Preferences *preferences = new Preferences ();
9Account *account = new Account ();
10Transaction *transaction = new Transaction ();
11Transfer *transfer = new Transfer ();
12Memory *memory = new Memory ();
13
14QashMoney::QashMoney () : QWidget ()
15 {
16 preferences->addPreferences ();
17 preferences->initializeColumnPreferences ();
18 preferences->initializeSortingPreferences ();
19
20 // set the text in the upper part of the frame
21 setCaption ( tr ( "QashMoney" ) );
22
23 // Create new menubar for our mainwindow
24 // and add menu items
25 mainmenu = new QMenuBar ( this );
26 mainmenu->setFrameStyle ( QFrame::PopupPanel | QFrame::Raised );
27 preferencesmenu = new QPopupMenu ( this );
28 utilitiesmenu = new QPopupMenu ( this );
29 mainmenu->insertItem ( "Preferences", preferencesmenu );
30 mainmenu->insertItem ( "Utilities", utilitiesmenu );
31 preferencesmenu->insertItem ( "Date", this, SLOT ( displayDatePreferencesDialog() ) );
32 preferencesmenu->insertItem ( "Account", this, SLOT ( displayAccountPreferencesDialog() ) );
33 preferencesmenu->insertItem ( "Transaction", this, SLOT ( displayTransactionPreferencesDialog() ) );
34 utilitiesmenu->insertItem ( "Memory", this, SLOT ( displayMemoryDialog() ) );
35
36 // create the main tabwidget for displaying accounts and transactions
37 maintabs = new QTabWidget ( this );
38 tab = new QWidget ( this );
39 tab_2 = new QWidget ( this );
40 tab_3 = new QWidget ( this );
41 maintabs->addTab ( tab, "Accounts" );
42 maintabs->addTab ( tab_2, "Transactions" );
43 maintabs->addTab ( tab_3, "Budgets" );
44 tabheight = tab->height();
45 maintabs->setTabEnabled ( tab_2, FALSE );
46
47 // create a new account display object
48 accountdisplay = new AccountDisplay ( maintabs );
49 accountdisplay->setTabs ( tab_2, maintabs );
50 connect ( accountdisplay->listview, SIGNAL ( selectionChanged() ), this, SLOT ( setTransactionTab() ) );
51
52 // set the connection to disable the one touch account viewing if we are transfering money
53 connect ( accountdisplay->transferbutton, SIGNAL ( toggled(bool) ), this, SLOT ( toggleOneTouchViewing(bool) ) );
54
55 // create a new transactiondisplay object
56 transactiondisplay = new TransactionDisplay ( maintabs );
57 transactiondisplay->hide();
58
59 // create new budgetdisplay object
60 budgetdisplay = new BudgetDisplay ( maintabs );
61 budgetdisplay->hide();
62
63 tabslayout = new QVBoxLayout ( maintabs, 4, 2 );
64 tabslayout->addSpacing ( tabheight );
65 tabslayout->addWidget ( accountdisplay );
66 tabslayout->addWidget ( transactiondisplay );
67 tabslayout->addWidget ( budgetdisplay );
68
69 // connect a change in the maintabs with changing the tab display
70 connect ( maintabs, SIGNAL ( currentChanged(QWidget*) ), this, SLOT ( changeTabDisplay() ) );
71
72 // create layout that will contain the menubar and the maintabs
73 layout = new QVBoxLayout ( this, 2, 2 );
74 layout->setMenuBar ( mainmenu );
75 layout->addWidget ( maintabs );
76 }
77
78QashMoney::~QashMoney ()
79 {
80 delete budget;
81 delete preferences;
82 delete account;
83 delete transaction;
84 delete transfer;
85 delete memory;
86 }
87
88void QashMoney::changeTabDisplay ()
89 {
90 // if the user pressed the transactions tab, hide the account display
91 // object and create a new transaction display
92 if ( maintabs->currentPageIndex() == 1 )
93 {
94 // initialize variables
95 bool children = FALSE;
96
97 // hide the account display and define accountid
98 int accountid = accountdisplay->listview->selectedItem()->text ( accountdisplay->getIDColumn() ).toInt();
99
100 //remove all the columns from the transactiondisplay
101 int columns = transactiondisplay->listview->columns();
102 int counter;
103 for ( counter = 0; counter <= columns; counter++ )
104 transactiondisplay->listview->removeColumn ( 0 );
105
106 // set the account name and account balance
107 QString name = account->getAccountName ( accountid );
108 QString balance = account->getAccountBalance ( accountid );
109 transactiondisplay->name->setText ( name );
110 transactiondisplay->balance->setText ( balance );
111
112 // clear the limitbox
113 transactiondisplay->limitbox->clear();
114
115 // get parent account id
116 int parentaccountid = account->getParentAccountID ( accountid );
117
118 // add columns based on which account is selected
119 // this first if determines if we selected a parent with no children or a child
120 // in these cases, we add standard three columns for date, transaction, amount
121 transactiondisplay->listview->addColumn ( "Date", 0 );
122 transactiondisplay->listview->addColumn ( "Transaction", 0 );
123 transactiondisplay->listview->addColumn ( "Amt", 0);
124 transactiondisplay->listview->setColumnAlignment ( 2, Qt::AlignRight );
125 transactiondisplay->listview->addColumn ( "", 0 );
126
127 if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 ) // we selected a parent with children
128 {
129 // add an extra column for the account name for eac child transaction
130 transactiondisplay->listview->addColumn ( "Acct", 0 );
131 children = TRUE;
132
133 // hide the new transaction button
134 transactiondisplay->newtransaction->setEnabled ( FALSE );
135 }
136 else //we selected a parent without children or a child
137 transactiondisplay->newtransaction->setEnabled ( TRUE );
138
139 // disable the transactionid column so it can't be red
140 transactiondisplay->listview->header()->setResizeEnabled ( FALSE, 3 );
141
142 // set the accountid and children variables
143 transactiondisplay->setChildren ( children );
144 transactiondisplay->setAccountID ( accountid );
145
146 setTransactionDisplayDate ();
147
148 // display transactions
149 transactiondisplay->listview->clear();
150 QString displaytext = "%";
151 displaytext.prepend ( transactiondisplay->limitbox->text() );
152 if ( transaction->getNumberOfTransactions() > 0 )
153 transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate );
154
155 // display transfers
156 transfer->displayTransfers ( transactiondisplay->listview, accountid, children, newdate );
157
158 // open a new preferences object and resize the transaction display columns
159 // each column will have a different size based on whether we are looking at a child
160 // account or children through a parent
161 if ( parentaccountid != -1 || accountdisplay->listview->selectedItem()->childCount() == 0 ) // a parent with no children or a child - three columns
162 {
163 transactiondisplay->listview->setColumnWidth ( 0, preferences->getColumnPreference ( 3 ) ); // normal transaction date width
164 transactiondisplay->listview->setColumnWidthMode ( 0, QListView::Manual );
165 transactiondisplay->listview->setColumnWidth ( 1, preferences->getColumnPreference ( 4 ) ); // normal transaction name width
166 transactiondisplay->listview->setColumnWidthMode ( 1, QListView::Manual );
167 transactiondisplay->listview->setColumnWidth ( 2, preferences->getColumnPreference ( 5 ) ); // normal transaction amount width
168 transactiondisplay->listview->setColumnWidthMode ( 2, QListView::Manual );
169 }
170 else
171 {
172 transactiondisplay->listview->setColumnWidth ( 0, preferences->getColumnPreference ( 6 ) ); // extended transaction date width
173 transactiondisplay->listview->setColumnWidthMode ( 0, QListView::Manual );
174 transactiondisplay->listview->setColumnWidth ( 1, preferences->getColumnPreference ( 7 ) ); // extended transaction name width
175 transactiondisplay->listview->setColumnWidthMode ( 1, QListView::Manual );
176 transactiondisplay->listview->setColumnWidth ( 2, preferences->getColumnPreference ( 8 ) ); // extended transaction amount width
177 transactiondisplay->listview->setColumnWidthMode ( 2, QListView::Manual );
178 transactiondisplay->listview->setColumnWidth ( 4, preferences->getColumnPreference ( 9 ) ); // transaction account width
179 transactiondisplay->listview->setColumnWidthMode ( 4, QListView::Manual );
180 }
181
182 // pull the column sorting preference from the preferences table, and configure the listview accordingly
183 int column = 0;
184 int direction = 0;
185 preferences->getSortingPreference ( 2, &column, &direction );
186 transactiondisplay->listview->setSorting ( column, direction );
187
188 // show the window
189 transactiondisplay->show();
190 // hide the account display and define accountid
191 accountdisplay->hide();
192 // hide the budget display
193 budgetdisplay->hide();
194 }
195 else if ( maintabs->currentPageIndex() == 0 )
196 {
197 disableOneTouchViewing();
198
199 // clear the account display selection
200 accountdisplay->listview->clearSelection();
201
202 // resize the account display columns
203 accountdisplay->listview->setColumnWidth ( 0, preferences->getColumnPreference ( 1 ) );
204 accountdisplay->listview->setColumnWidth ( 1, preferences->getColumnPreference ( 2 ) );
205
206 // set sorting preference on account display columns
207 int column = 0;
208 int direction = 0;
209 preferences->getSortingPreference ( 1, &column, &direction );
210 accountdisplay->listview->setSorting ( column, direction );
211
212 // display the accounts
213 if ( account->getNumberOfAccounts() != 0 )
214 account->displayAccounts ( accountdisplay->listview );
215 maintabs->setTabEnabled ( tab_2, FALSE );
216
217 // set the toggle button
218 accountdisplay->setToggleButton ();
219
220 // show the account display
221 accountdisplay->show();
222
223 // hide the transaction display
224 transactiondisplay->hide();
225
226 // hide the budget display
227 budgetdisplay->hide();
228
229
230 enableOneTouchViewing ();
231 }
232 else
233 {
234 budgetdisplay->displayLineItems();
235 budgetdisplay->show();
236 transactiondisplay->hide();
237 accountdisplay->hide();
238 }
239 }
240
241void QashMoney::setTransactionTab ()
242 {
243 if ( accountdisplay->listview->selectedItem() == 0 )
244 maintabs->setTabEnabled ( tab_2, FALSE );
245 else
246 maintabs->setTabEnabled ( tab_2, TRUE );
247 }
248
249void QashMoney::displayDatePreferencesDialog ()
250 {
251 // this shows a dialog to set preferences for formatting the date
252 DatePreferences *pd = new DatePreferences ( this );
253 pd->exec ();
254 if ( transactiondisplay->isVisible() )
255 {
256 // set the account id
257 int accountid = accountdisplay->listview->selectedItem()->text ( accountdisplay->getIDColumn() ).toInt();
258
259 // set children so we can let displayTransfers know if there are children for the selected account
260 bool children;
261 if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 )
262 children = TRUE;
263 else
264 children = FALSE;
265
266 // redisplay transactions if they are visible incorporating
267 // any changes to the date format
268 transactiondisplay->listview->clear();
269 QString displaytext = "%";
270 displaytext.prepend ( transactiondisplay->limitbox->text() );
271
272 setTransactionDisplayDate();
273 if ( transaction->getNumberOfTransactions() > 0 )
274 transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate );
275
276 if ( transfer->getNumberOfTransfers() != 0 )
277 transfer->displayTransfers ( transactiondisplay->listview, accountid, children, newdate );
278 }
279 else if ( accountdisplay->isVisible() )
280 {
281 accountdisplay->listview->clearSelection();
282 maintabs->setTabEnabled ( tab_2, FALSE );
283 }
284 else
285 budgetdisplay->updateBudgetInformation();
286 }
287
288void QashMoney::displayTransactionPreferencesDialog ()
289 {
290 // display a dialog for setting preferences for transactions
291 TransactionPreferences *td = new TransactionPreferences ( this );
292 td->exec ();
293 if ( transactiondisplay->isVisible() )
294 {
295 // set the account id
296 int accountid = accountdisplay->listview->selectedItem()->text ( accountdisplay->getIDColumn() ).toInt();
297
298 // set children so we can let displayTransfers know if there are children for the selected account
299 bool children;
300 if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 )
301 children = TRUE;
302 else
303 children = FALSE;
304
305 // redisplay transactions incorporating any transaction preference changes
306 transactiondisplay->listview->clear();
307 QString displaytext = "%";
308 displaytext.prepend ( transactiondisplay->limitbox->text() );
309
310 setTransactionDisplayDate();
311 if ( transaction->getNumberOfTransactions() > 0 )
312 transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate );
313
314 if ( transfer->getNumberOfTransfers() != 0 )
315 transfer->displayTransfers ( transactiondisplay->listview, accountid, children, newdate );
316 }
317 else
318 {
319 accountdisplay->listview->clearSelection();
320 maintabs->setTabEnabled ( tab_2, FALSE );
321 }
322 }
323
324void QashMoney::displayAccountPreferencesDialog ()
325 {
326 // display a dialog for setting preferences for accounts
327 AccountPreferences *ap = new AccountPreferences ( this );
328 ap->exec ();
329
330 if ( accountdisplay->isVisible() && account->getNumberOfAccounts() != 0 )
331 {
332 accountdisplay->listview->clear();
333 account->displayAccounts ( accountdisplay->listview );
334 accountdisplay->listview->clearSelection();
335 maintabs->setTabEnabled ( tab_2, FALSE );
336 }
337 changeTabDisplay();
338 }
339
340void QashMoney::displayMemoryDialog ()
341 {
342 // opens a dialog to add, edit and delete memory items
343 MemoryDialog *md = new MemoryDialog ();
344 md->exec();
345 }
346
347void QashMoney::showTransactions ()
348 {
349 maintabs->setCurrentPage ( 1 );
350 }
351
352void QashMoney::enableOneTouchViewing ()
353 {
354 if ( preferences->getPreference ( 5 ) == 1 )
355 connect ( accountdisplay->listview, SIGNAL ( selectionChanged() ), this, SLOT ( showTransactions() ) );
356 else
357 disconnect ( accountdisplay->listview, SIGNAL ( selectionChanged() ), this, SLOT ( showTransactions() ) );
358 }
359
360void QashMoney::disableOneTouchViewing ()
361 {
362 disconnect ( accountdisplay->listview, SIGNAL ( selectionChanged() ), this, SLOT ( showTransactions() ) );
363 }
364
365void QashMoney::toggleOneTouchViewing ( bool state )
366 {
367 if ( state == TRUE )
368 disableOneTouchViewing();
369 else
370 enableOneTouchViewing();
371 }
372
373void QashMoney::setTransactionDisplayDate ()
374 {
375 // determine how many days of transactions to show
376 int limittype = preferences->getPreference ( 7 );
377 if ( limittype != 5 ) // set today's date if we are not showing all transactions
378 {
379 QDate today = QDate::currentDate ();
380 switch ( limittype ) // if we are not showing all transactions
381 {
382 case 0: // viewing two weeks
383 newdate = today.addDays ( -14 );
384 break;
385 case 1: // viewing one month
386 newdate = today.addDays ( -30 );
387 break;
388 case 2: // three months
389 newdate = today.addDays ( -90 );
390 break;
391 case 3: // six months
392 newdate = today.addDays ( -180 );
393 break;
394 case 4: // one year
395 newdate = today.addDays ( -365 );
396 break;
397 }
398 }
399 else
400 newdate = QDate ( 1900, 1, 1 );
401 }
402
diff --git a/noncore/unsupported/qashmoney/qashmoney.h b/noncore/unsupported/qashmoney/qashmoney.h
new file mode 100755
index 0000000..f2c456c
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/qashmoney.h
@@ -0,0 +1,64 @@
1#ifndef QASHMONEY_H
2#define QASHMONEY_H
3
4#include <qmenubar.h>
5#include <qpopupmenu.h>
6#include <qlayout.h>
7#include <qtabwidget.h>
8#include <qdatetime.h>
9
10#include "accountdisplay.h"
11#include "transactiondisplay.h"
12#include "budgetdisplay.h"
13#include "account.h"
14#include "preferences.h"
15#include "transaction.h"
16#include "transfer.h"
17#include "memory.h"
18#include "budget.h"
19
20class QashMoney : public QWidget
21 {
22 Q_OBJECT
23
24 public:
25 QashMoney ();
26 ~QashMoney();
27
28 QTabWidget* maintabs;
29 QWidget* tab;
30 QWidget* tab_2;
31 QWidget* tab_3;
32
33 QMenuBar *mainmenu;
34 QPopupMenu *preferencesmenu;
35 QPopupMenu *utilitiesmenu;
36
37 public slots:
38 void displayDatePreferencesDialog ();
39 void displayTransactionPreferencesDialog ();
40 void displayAccountPreferencesDialog ();
41 void displayMemoryDialog ();
42 void setTransactionTab ();
43
44 private slots:
45 void changeTabDisplay ();
46 void showTransactions ();
47 void enableOneTouchViewing ();
48 void disableOneTouchViewing ();
49 void toggleOneTouchViewing ( bool );
50 void setTransactionDisplayDate ();
51
52 private:
53 QVBoxLayout *layout;
54 QVBoxLayout *tabslayout;
55 AccountDisplay *accountdisplay;
56 TransactionDisplay *transactiondisplay;
57 BudgetDisplay *budgetdisplay;
58 int tabheight;
59 QDate newdate;
60
61 };
62
63#endif
64
diff --git a/noncore/unsupported/qashmoney/qashmoney.pro b/noncore/unsupported/qashmoney/qashmoney.pro
new file mode 100755
index 0000000..faa898b
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/qashmoney.pro
@@ -0,0 +1,55 @@
1TEMPLATE = app
2CONFIG = qt warn_on
3HEADERS = qashmoney.h \
4 accountdisplay.h \
5 account.h \
6 transaction.h \
7 transactiondisplay.h \
8 newtransaction.h \
9 transfer.h \
10 transferdialog.h \
11 preferences.h \
12 preferencedialogs.h \
13 memory.h \
14 memorydialog.h \
15 newaccount.h \
16 calculator.h \
17 datepicker.h \
18 budget.h \
19 budgetdisplay.h \
20 currency.h
21SOURCES = qashmoney.cpp \
22 accountdisplay.cpp \
23 account.cpp \
24 transaction.cpp \
25 transactiondisplay.cpp \
26 newtransaction.cpp \
27 transfer.cpp \
28 transferdialog.cpp \
29 preferences.cpp \
30 preferencedialogs.cpp \
31 memory.cpp \
32 memorydialog.cpp \
33 newaccount.cpp \
34 calculator.cpp \
35 datepicker.cpp \
36 main.cpp \
37 budget.cpp \
38 budgetdisplay.cpp \
39 currency.cpp
40INCLUDEPATH = $(OPIEDIR)/include
41DEPENDPATH = $(OPIEDIR)/include
42TARGET = qashmoney
43DESTDIR = $(OPIEDIR)/bin
44
45unix:LIBS += -lm
46LIBS += -lqpe -lopiecore2 -lsqlite3
47
48include ( $(OPIEDIR)/include.pro )
49
50!isEmpty( LIBSQLITE_INC_DIR ) {
51 INCLUDEPATH = $$LIBSQLITE_INC_DIR $$INCLUDEPATH
52}
53!isEmpty( LIBSQLITE_LIB_DIR ) {
54 LIBS = -L$$LIBSQLITE_LIB_DIR $$LIBS
55}
diff --git a/noncore/unsupported/qashmoney/transaction.cpp b/noncore/unsupported/qashmoney/transaction.cpp
new file mode 100755
index 0000000..d008a4f
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/transaction.cpp
@@ -0,0 +1,345 @@
1// RESERVEDONE COLUMN NAME REPRESENTS THE LINEITEMID AND SHOULD BE CHANGED IN
2// FUTURE VERSIONS OF QASHMONEY
3
4// RESERVEDTWO REPRESENTS THE TRANSACTION DESCRIPTION
5
6#include "transaction.h"
7#include "account.h"
8#include "transactiondisplay.h"
9
10#include <stdlib.h>
11
12extern Account *account;
13extern Preferences *preferences;
14
15Transaction::Transaction ()
16 {
17 tdb = sqlite_open ( "qmtransactions.db", 0, NULL );
18 }
19
20Transaction::~Transaction ()
21 {
22 sqlite_close ( tdb );
23 }
24
25void Transaction::addTransaction ( QString description, QString payee, int accountid, int parentid, int number, int day, int month, int year, float amount, int cleared, int budgetid, int lineitemid )
26 {
27 sqlite_exec_printf ( tdb, "insert into transactions values ( '%q', %i, %i, %i, %i, %i, %i, %.2f, %i, %i, 0, 0, 0, 0, 0, 0, %i, '%q', 0, "
28 "0, 0, 0, NULL );", 0, 0, 0, ( const char * ) payee, accountid, parentid, number, day, month, year, amount, cleared, budgetid, lineitemid, ( const char * ) description );
29 }
30
31void Transaction::updateTransaction ( QString description, QString payee, int number, int day, int month, int year, float amount, int cleared, int budgetid, int lineitemid, int transactionid )
32 {
33 sqlite_exec_printf ( tdb, "update transactions set reservedtwo = '%q', payee = '%q', number = %i, day = %i, month = %i, year = %i, amount = %.2f,"
34 "cleared = %i, budgetid = %i, reservedone = %i where transid = %i;", 0, 0, 0, ( const char * ) description, ( const char * ) payee, number, day, month, year,
35 amount, cleared, budgetid, lineitemid, transactionid );
36 }
37
38void Transaction::deleteTransaction ( int transid )
39 {
40 sqlite_exec_printf ( tdb, "delete from transactions where transid = %i;", 0, 0, 0, transid );
41 }
42
43void Transaction::deleteAllTransactions ( int accountid )
44 {
45 sqlite_exec_printf ( tdb, "delete from transactions where accountid = %i;", 0, 0, 0, accountid );
46 }
47
48int Transaction::getAccountID ( int id )
49 {
50 char **results;
51 sqlite_get_table_printf ( tdb, "select accountid from transactions where transid= %i;", &results, NULL, NULL, NULL, id );
52 return atol ( results [ 1 ] );
53 }
54
55int Transaction::getNumberOfTransactions ()
56 {
57 char **results;
58 sqlite_get_table ( tdb, "select count() from transactions;", &results, NULL, NULL, NULL );
59 return atoi ( results [ 1 ] );
60 }
61
62int Transaction::getNumberOfTransactions ( int accountid )
63 {
64 char **results;
65 sqlite_get_table_printf ( tdb, "select count() from transactions where accountid = %i;", &results, NULL, NULL, NULL, accountid );
66 return atol ( results [ 1 ] );
67 }
68
69QString Transaction::getPayee ( int id )
70 {
71 char **results;
72 sqlite_get_table_printf ( tdb, "select payee from transactions where transid= %i;", &results, NULL, NULL, NULL, id );
73 return results [ 1 ];
74 }
75
76QString Transaction::getTransactionDescription ( int id )
77 {
78 char **results;
79 sqlite_get_table_printf ( tdb, "select reservedtwo from transactions where transid= %i;", &results, NULL, NULL, NULL, id );
80 return results [ 1 ];
81 }
82
83QString Transaction::getNumber ( int id )
84 {
85 char **results;
86 sqlite_get_table_printf ( tdb, "select number from transactions where transid= %i;", &results, NULL, NULL, NULL, id );
87 return results [ 1 ];
88 }
89
90QString Transaction::getAmount ( int id )
91 {
92 char **results;
93 sqlite_get_table_printf ( tdb, "select amount from transactions where transid= %i;", &results, NULL, NULL, NULL, id );
94 return results [ 1 ];
95 }
96
97QString Transaction::getAbsoluteAmount ( int id )
98 {
99 char **results;
100 sqlite_get_table_printf ( tdb, "select abs ( amount ) from transactions where transid= %i;", &results, NULL, NULL, NULL, id );
101 return results [ 1 ];
102 }
103
104int Transaction::getCleared ( int id )
105 {
106 char **results;
107 sqlite_get_table_printf ( tdb, "select cleared from transactions where transid= %i;", &results, NULL, NULL, NULL, id );
108 QString cleared = results [ 1 ];
109 return cleared.toInt();
110 }
111
112void Transaction::setCleared ( int id, int cleared )
113 {
114 sqlite_exec_printf ( tdb, "update transactions set cleared = %i where transid = %i;", 0, 0, 0, cleared, id );
115 }
116
117int Transaction::getBudgetID ( int id )
118 {
119 char **results;
120 sqlite_get_table_printf ( tdb, "select budgetid from transactions where transid = %i;", &results, NULL, NULL, NULL, id );
121 QString budgetid = results [ 1 ];
122 return budgetid.toInt();
123 }
124
125int Transaction::getLineItemID ( int id )
126 {
127 char **results;
128 sqlite_get_table_printf ( tdb, "select reservedone from transactions where transid = %i;", &results, NULL, NULL, NULL, id );
129 QString lineitemid = results [ 1 ];
130 return lineitemid.toInt();
131 }
132
133int Transaction::getDay ( int id )
134 {
135 char **results;
136 sqlite_get_table_printf ( tdb, "select day from transactions where transid= %i;", &results, NULL, NULL, NULL, id );
137 QString daystring = results [ 1 ];
138 return daystring.toInt();
139 }
140
141int Transaction::getMonth ( int id )
142 {
143 char **results;
144 sqlite_get_table_printf ( tdb, "select month from transactions where transid= %i;", &results, NULL, NULL, NULL, id );
145 QString monthstring = results [ 1 ];
146 return monthstring.toInt();
147 }
148
149int Transaction::getYear ( int id )
150 {
151 char **results;
152 sqlite_get_table_printf ( tdb, "select year from transactions where transid= %i;", &results, NULL, NULL, NULL, id );
153 QString yearstring = results [ 1 ];
154 return yearstring.toInt();
155 }
156
157char ** Transaction::selectAllTransactions ( QDate fromdate, bool children, const char *limit, int id )
158 {
159 // initialize variables
160 char **results;
161 int showcleared = preferences->getPreference ( 3 );
162 QDate today = QDate::currentDate();
163 int fromyear = fromdate.year();
164 int toyear = today.year();
165 int frommonth = fromdate.month();
166 int tomonth = today.month();
167 int fromday = fromdate.day();
168
169 // construct the first part of the string
170 QString query = "select day, month, year, payee, amount, transid, accountid from transactions where";
171
172 if ( frommonth == tomonth && fromyear == toyear ) // our dates cross neither a month nor a year
173 {
174 query.append ( " year = " );
175 query.append ( QString::number ( toyear ) );
176 query.append ( " and month = " );
177 query.append ( QString::number ( tomonth ) );
178 query.append ( " and day >= " );
179 query.append ( QString::number ( fromday ) );
180 query.append ( " and" );
181 }
182 else if ( frommonth != tomonth && fromyear == toyear ) // our dates cross a month within the same year
183 {
184 query.append ( " year = " );
185 query.append ( QString::number ( toyear ) );
186 query.append ( " and ( ( month <= " );
187 query.append ( QString::number ( tomonth ) );
188 query.append ( " and month > " );
189 query.append ( QString::number ( frommonth ) );
190 query.append ( " ) or ( month = " );
191 query.append ( QString::number ( frommonth ) );
192 query.append ( " and day >= " );
193 query.append ( QString::number ( fromday ) );
194 query.append ( " ) ) and " );
195 }
196 else if ( fromyear != toyear && fromyear != 1900 ) // here we are showing transactions from an entire year
197 {
198 // divide this taks into two parts - get the transactions from the prior and then the current year
199 // current year part
200 int tmpfrommonth = 1; // set temporary from months and days to Jan. 1
201 int tmpfromday = 1;
202 query.append ( " ( year >= " );
203 query.append ( QString::number ( fromyear ) );
204 query.append ( " and ( month <= " );
205 query.append ( QString::number ( tomonth ) );
206 query.append ( " and month > " );
207 query.append ( QString::number ( tmpfrommonth ) );
208 query.append ( " ) or ( month = " );
209 query.append ( QString::number ( tmpfrommonth ) );
210 query.append ( " and day >= " );
211 query.append ( QString::number ( tmpfromday ) );
212 query.append ( " ) ) or" );
213
214 // prior year part
215 int tmptomonth = 12;
216 query.append ( " ( year = " );
217 query.append ( QString::number ( fromyear ) );
218 query.append ( " and ( ( month <= " );
219 query.append ( QString::number ( tmptomonth ) );
220 query.append ( " and month > " );
221 query.append ( QString::number ( frommonth ) );
222 query.append ( " ) or ( month = " );
223 query.append ( QString::number ( frommonth ) );
224 query.append ( " and day >= " );
225 query.append ( QString::number ( fromday ) );
226 query.append ( " ) ) ) and " );
227 }
228
229 if ( account->getParentAccountID ( id ) == -1 && children == TRUE )
230 query.append ( " parentid = %i and payee like '%q';" );
231 else
232 query.append ( " accountid = %i and payee like '%q';" );
233
234 sqlite_get_table_printf ( tdb, query, &results, &rows, &columns, NULL, id, limit );
235 return results;
236 }
237
238char ** Transaction::selectNonClearedTransactions ( QDate fromdate, bool children, const char *limit, int id )
239 {
240 char **results;
241 if ( account->getParentAccountID ( id ) == -1 && children == TRUE )
242 sqlite_get_table_printf ( tdb, "select day, month, year, payee, amount, transid, accountid from transactions where cleared = 0 and parentid = %i and payee like '%q';", &results, &rows, &columns, NULL, id, limit );
243 else
244 sqlite_get_table_printf ( tdb, "select day, month, year, payee, amount, transid, accountid from transactions where cleared = 0 and accountid = %i and payee like '%q';", &results, &rows, &columns, NULL, id, limit );
245 return results;
246 }
247
248void Transaction::displayTransactions ( QListView *listview, int id, bool children, const char *limit, QDate displaydate )
249 {
250 int showcleared = preferences->getPreference ( 3 );
251
252 char **results;
253 if ( showcleared == 0 )
254 results = selectNonClearedTransactions ( displaydate, children, limit, id );
255 else
256 results = selectAllTransactions ( displaydate, children, limit, id );
257
258 // iterate through the result list and display each item
259 int counter = 7;
260 while ( counter < ( ( rows + 1 ) * columns ) )
261 {
262 //QDate testdate ( atoi ( results [ counter + 2 ] ), atoi ( results [ counter + 1 ] ), atoi ( results [ counter ] ) );
263 QString date = preferences->getDate ( atoi ( results [ counter + 2 ] ), atoi ( results [ counter + 1 ] ), atoi ( results [ counter ] ) );
264
265 // construct transaction name, amount, id
266 QString payee = results [ counter + 3 ];
267 QString amount = results [ counter + 4 ];
268 QString transferid = results [ counter + 5 ];
269
270 //determine the account name of the child accounts that we're displaying
271 QString accountname = account->getAccountName ( atoi ( results [ counter + 6 ] ) );
272
273 // fill in values
274 if ( account->getParentAccountID ( id ) != -1 ) // use these constructors if we're showing a child account
275 {
276 if ( showcleared == 1 && getCleared ( transferid.toInt() ) == 1 )
277 ColorListItem *item = new ColorListItem ( listview, date, payee, amount, transferid );
278 else
279 QListViewItem *item = new QListViewItem ( listview, date, payee, amount, transferid );
280 }
281 else
282 {
283 if ( showcleared == 1 && getCleared ( transferid.toInt() ) == 1 )
284 ColorListItem *item = new ColorListItem ( listview, date, payee, amount, transferid, accountname );
285 else
286 QListViewItem *item = new QListViewItem ( listview, date, payee, amount, transferid, accountname );
287 }
288
289 // advance counter
290 counter = counter + 7;
291 }
292 }
293
294QString Transaction::getBudgetTotal ( int budgetid, int lineitemid, int year, int month, int viewtype )
295 {
296 // determine if we are viewing a years, months, or days budget
297 // we have to pick a different sum for each
298 char **results;
299 switch ( viewtype )
300 {
301 case 1: // we are viewing a year
302 sqlite_get_table_printf ( tdb, "select abs ( sum ( amount ) ) from transactions where year = %i and amount < 0 and budgetid = %i and reservedone = %i;", &results, NULL, NULL, NULL, year, budgetid, lineitemid );
303 break;
304
305 case 0: // we are viewing a month
306 sqlite_get_table_printf ( tdb, "select abs ( sum ( amount ) ) from transactions where year = %i and month = %i and amount < 0 and budgetid = %i and reservedone = %i;", &results, NULL, NULL, NULL, year, month, budgetid, lineitemid );
307 break;
308 }
309 QString amount = results [ 1 ];
310 float total = amount.toFloat();
311 amount.setNum ( total, 'f', 2 );
312 return amount;
313 }
314
315QString Transaction::getActualTotal ( int budgetid, int year, int month, int viewtype )
316 {
317 // determine if we are viewing a years, months, or days budget
318 // we have to pick a different sum for each
319 char **results;
320 switch ( viewtype )
321 {
322 case 1: // we are viewing a year
323 sqlite_get_table_printf ( tdb, "select abs ( sum ( amount ) ) from transactions where year = %i and amount < 0 and budgetid = %i;", &results, NULL, NULL, NULL, year, budgetid );
324 break;
325
326 case 0: // we are viewing a month
327 sqlite_get_table_printf ( tdb, "select abs ( sum ( amount ) ) from transactions where year = %i and month = %i and amount < 0 and budgetid = %i;", &results, NULL, NULL, NULL, year, month, budgetid );
328 break;
329 }
330 QString amount = results [ 1 ];
331 float total = amount.toFloat();
332 amount.setNum ( total, 'f', 2 );
333 return amount;
334 }
335
336void Transaction::clearBudgetIDs ( int budgetid, int lineitemid )
337 {
338 sqlite_exec_printf ( tdb, "update transactions set budgetid = -1 where budgetid = %i and reservedone = %i;", 0, 0, 0, budgetid, lineitemid );
339 }
340
341void Transaction::clearBudgetIDs ( int budgetid )
342 {
343 sqlite_exec_printf ( tdb, "update transactions set budgetid = -1 where budgetid = %i;", 0, 0, 0, budgetid );
344 }
345
diff --git a/noncore/unsupported/qashmoney/transaction.h b/noncore/unsupported/qashmoney/transaction.h
new file mode 100755
index 0000000..3df43a8
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/transaction.h
@@ -0,0 +1,73 @@
1#ifndef TRANSACTION_H
2#define TRANSACTION_H
3
4#include <qstring.h>
5#include <qlistview.h>
6#include <qdatetime.h>
7#include <sqlite3.h>
8
9#include "preferences.h"
10
11class Transaction
12 {
13 public:
14
15 Transaction ();
16 ~Transaction ();
17
18 // This function adds a new transaction to the database. It takes the payee, accountid,
19 // budgetid, number, day, month, year, amount, cleared
20 void addTransaction ( QString description, QString payee, int accountid, int parentid, int number, int day, int month, int year, float amount, int cleared, int budgetid, int lineitemid );
21
22 // This updates an already existing transaction
23 void updateTransaction ( QString, QString, int, int, int, int, float, int, int, int, int );
24
25 // Deletes a transaction. Takes the transid as its parameter
26 void deleteTransaction ( int );
27
28 // Returns the number of transactions
29 int getNumberOfTransactions ();
30
31 // this is an overloaded function that returns the number of
32 // transactions for an account
33 int getNumberOfTransactions ( int );
34
35 // deletes all transactions for the provided accountid
36 void deleteAllTransactions ( int accountid );
37
38 QString getBudgetTotal ( int budgetid, int lineitemid, int year, int month, int viewtype );
39 QString getActualTotal ( int budgetid, int year, int month, int viewtype );
40
41 // These two functions clear budget ids is either a line item or an entire budget is deleted
42 void clearBudgetIDs ( int, int );
43 void clearBudgetIDs ( int );
44
45 public slots:
46
47 void displayTransactions ( QListView *, int, bool, const char *, QDate );
48 char ** selectAllTransactions ( QDate fromdate, bool children, const char *limit, int id );
49 char ** selectNonClearedTransactions ( QDate fromdate, bool children, const char *limit, int id );
50 QString getPayee ( int );
51 QString getTransactionDescription ( int );
52 QString getNumber ( int );
53 QString getAmount ( int );
54 QString getAbsoluteAmount ( int );
55 int getCleared ( int );
56 void setCleared ( int id, int cleared );
57 int getBudgetID ( int id );
58 int getLineItemID ( int id );
59 int getDay ( int );
60 int getMonth ( int );
61 int getYear ( int );
62 int getAccountID ( int id );
63
64 private:
65
66 sqlite3 *tdb;
67 int rows, columns;
68 };
69
70#endif
71
72
73
diff --git a/noncore/unsupported/qashmoney/transactiondisplay.cpp b/noncore/unsupported/qashmoney/transactiondisplay.cpp
new file mode 100755
index 0000000..0b94d62
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/transactiondisplay.cpp
@@ -0,0 +1,625 @@
1#include "transactiondisplay.h"
2#include "newtransaction.h"
3#include "account.h"
4#include "budget.h"
5#include "memory.h"
6#include "transfer.h"
7#include "calculator.h"
8#include "datepicker.h"
9
10#include <qmessagebox.h>
11#include <qheader.h>
12#include <qmultilineedit.h>
13
14extern Transaction *transaction;
15extern Budget *budget;
16extern Account *account;
17extern Preferences *preferences;
18extern Memory *memory;
19extern Transfer *transfer;
20
21TransactionDisplay::TransactionDisplay ( QWidget* parent ) : QWidget ( parent )
22 {
23 // set transactiondisplay variables;
24 accountid = 0;
25 children = TRUE;
26
27 firstline = new QHBox ( this );
28 firstline->setSpacing ( 2 );
29
30 newtransaction = new QPushButton ( firstline );
31 newtransaction->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/new.png") );
32 connect ( newtransaction, SIGNAL ( released() ), this, SLOT ( addTransaction() ) );
33
34 edittransaction = new QPushButton ( firstline );
35 edittransaction->setPixmap( QPixmap ("/opt/QtPalmtop/pics/edit.png") );
36 connect ( edittransaction, SIGNAL ( released() ), this, SLOT ( checkListViewEdit() ) );
37
38 deletetransaction = new QPushButton ( firstline );
39 deletetransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/delete.png") );
40 connect ( deletetransaction, SIGNAL ( released() ), this, SLOT ( checkListViewDelete() ) );
41
42 toggletransaction = new QPushButton ( firstline );
43 toggletransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/redo.png") );
44 connect ( toggletransaction, SIGNAL ( released() ), this, SLOT ( checkListViewToggle() ) );
45
46 viewtransactionnotes = new QPushButton ( firstline );
47 viewtransactionnotes->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/info.png") );
48 connect ( viewtransactionnotes, SIGNAL ( released() ), this, SLOT ( showTransactionNotes() ) );
49
50 secondline = new QHBox ( this );
51 secondline->setSpacing ( 5 );
52
53 name = new QLabel ( secondline );
54 balance = new QLabel ( secondline );
55
56 QLabel *limit = new QLabel ( "Limit", secondline );
57 limitbox = new QLineEdit ( secondline );
58 limitbox->setMinimumWidth ( ( int ) ( this->width() / 6 ) );
59 connect ( limitbox, SIGNAL ( textChanged(const QString&) ), this, SLOT ( limitDisplay(const QString&) ) );
60
61 listview = new QListView ( this );
62 listview->setAllColumnsShowFocus ( TRUE );
63 listview->setShowSortIndicator ( TRUE );
64 listview->header()->setTracking ( FALSE );
65 connect ( listview->header(), SIGNAL ( sizeChange(int,int,int) ), this, SLOT ( saveColumnSize(int,int,int) ) );
66 connect ( listview->header(), SIGNAL ( clicked(int) ), this, SLOT ( saveSortingPreference(int) ) );
67
68 layout = new QVBoxLayout ( this, 2, 2 );
69 layout->addWidget ( firstline );
70 layout->addWidget ( secondline );
71 layout->addWidget ( listview );
72 }
73
74void TransactionDisplay::addTransaction ()
75 {
76 // create local variables
77 int cleared = -1;
78
79 // create new transaction window
80 NewTransaction *newtransaction = new NewTransaction ( this );
81 int width = this->size().width();
82 newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) );
83 newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) );
84 newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) );
85 newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
86 newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
87 newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) );
88
89 // enter today's date in the date box as defaul
90 QDate today = QDate::currentDate ();
91 int defaultday = today.day();
92 int defaultmonth = today.month();
93 int defaultyear = today.year();
94 newtransaction->transactiondate->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) );
95
96 // add memory items to the transactionname combobox
97 memory->displayMemoryItems ( newtransaction->transactionname );
98 newtransaction->transactionname->insertItem ( "", 0 );
99
100 if ( newtransaction->exec () == QDialog::Accepted )
101 {
102 if ( newtransaction->clearedcheckbox->isChecked () == TRUE ) // set a parent id and type for a child transaction
103 cleared = 1;
104 else
105 cleared = 0;
106
107 float amount = newtransaction->transactionamount->text().toFloat();
108 if ( newtransaction->depositbox->isChecked() == FALSE )
109 amount = amount * -1;
110
111 // add the transaction name to the memory items
112 memory->addMemoryItem ( newtransaction->transactionname->currentText() );
113
114 // add the transaction
115 if ( newtransaction->getDateEdited () == TRUE )
116 transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ),
117 newtransaction->transactionnumber->text().toInt(), newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(), amount, cleared, newtransaction->getCurrentBudget(),
118 newtransaction->getCurrentLineItem() );
119 else
120 transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ),
121 newtransaction->transactionnumber->text().toInt(), defaultday, defaultmonth, defaultyear, amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem() );
122
123 // redisplay transactions
124 listview->clear();
125 QString displaytext = "%";
126 displaytext.prepend ( limitbox->text() );
127 setTransactionDisplayDate ();
128 if ( transaction->getNumberOfTransactions() > 0 )
129 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
130
131 // redisplay transfers
132 if ( transfer->getNumberOfTransfers() > 0 )
133 transfer->displayTransfers ( listview, accountid, children, displaydate );
134
135 // add the transaction amount to the account it's associated with
136 // and update its parent account balance if necessary
137 account->updateAccountBalance ( accountid );
138 if ( account->getParentAccountID ( accountid ) != -1 )
139 account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) );
140
141 // format then reset the account balance
142 redisplayAccountBalance ();
143 }
144 }
145
146void TransactionDisplay::checkListViewEdit ()
147 {
148 if ( listview->selectedItem() == 0 )
149 QMessageBox::warning ( this, "QashMoney", "Please select a transaction\nto edit.");
150 else if ( listview->currentItem()->text ( getIDColumn() ).toInt() < 0 )
151 editTransfer ();
152 else
153 editTransaction();
154 }
155
156void TransactionDisplay::showCalculator ()
157 {
158 Calculator *calculator = new Calculator ( this );
159 if ( calculator->exec () == QDialog::Accepted )
160 amount->setText ( calculator->display->text() );
161 }
162
163void TransactionDisplay::showCalendar ()
164 {
165 QDate newDate = QDate::currentDate ();
166 DatePicker *dp = new DatePicker ( newDate );
167 if ( dp->exec () == QDialog::Accepted )
168 {
169 year = dp->getYear();
170 month = dp->getMonth();
171 day = dp->getDay();
172 date->setText ( preferences->getDate ( year, month, day ) );
173 }
174 }
175
176void TransactionDisplay::editTransfer ()
177 {
178 transferid = listview->currentItem()->text ( getIDColumn() ).toInt();
179 fromaccount = transfer->getFromAccountID ( transferid );
180 toaccount = transfer->getToAccountID ( transferid );
181 year = transfer->getYear ( transferid );
182 month = transfer->getMonth ( transferid );
183 day = transfer->getDay ( transferid );
184
185 QDialog *editransfer = new QDialog ( this, "edittransfer", TRUE );
186 editransfer->setCaption ( "Transfer" );
187
188 QStringList accountnames = account->getAccountNames();
189 QStringList accountids = account->getAccountIDs();
190
191 QLabel *fromaccountlabel = new QLabel ( "From Account:", editransfer );
192 QFont f = this->font();
193 f.setWeight ( QFont::Bold );
194 fromaccountlabel->setFont ( f );
195
196 QComboBox *fromaccountbox = new QComboBox ( editransfer );
197 fromaccountbox->insertStringList ( accountnames );
198 fromaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( fromaccount ) ) );
199
200 QLabel *toaccountlabel = new QLabel ( "To Account:", editransfer );
201 toaccountlabel->setFont ( f );
202
203 QComboBox *toaccountbox = new QComboBox ( editransfer );
204 toaccountbox->insertStringList ( accountnames );
205 toaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( toaccount ) ) );
206
207 QLabel *datelabel = new QLabel ( "Date", editransfer );
208 QHBox *datebox = new QHBox ( editransfer );
209 datebox->setSpacing ( 2 );
210 date = new QLineEdit ( datebox );
211 date->setAlignment ( Qt::AlignRight );
212 date->setDisabled ( TRUE );
213 date->setText ( preferences->getDate ( year, month, day ) );
214 QPushButton *datebutton = new QPushButton ( datebox );
215 datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) );
216 connect ( datebutton, SIGNAL ( released() ), this, SLOT ( showCalendar() ) );
217
218 QLabel *amounttlabel = new QLabel ( "Amount", editransfer );
219
220 QHBox *amountbox = new QHBox ( editransfer );
221 amountbox->setSpacing ( 2 );
222 amount = new QLineEdit ( amountbox );
223 amount->setAlignment ( Qt::AlignRight );
224 amount->setText ( transfer->getAmount ( transferid ) );
225 QPushButton *calculatorbutton = new QPushButton( amountbox );
226 calculatorbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) );
227 connect ( calculatorbutton, SIGNAL ( released() ), this, SLOT ( showCalculator() ) );
228
229 QCheckBox *clearedcheckbox = new QCheckBox ( "Cleared", editransfer );
230
231 QBoxLayout *layout = new QVBoxLayout ( editransfer, 4, 2 );
232 layout->addWidget ( fromaccountlabel, Qt::AlignLeft );
233 layout->addWidget ( fromaccountbox, Qt::AlignLeft );
234 layout->addWidget ( toaccountlabel, Qt::AlignLeft );
235 layout->addWidget ( toaccountbox, Qt::AlignLeft );
236 layout->addSpacing ( 5 );
237 layout->addWidget ( datelabel, Qt::AlignLeft );
238 layout->addWidget ( datebox, Qt::AlignLeft );
239 layout->addWidget ( amounttlabel, Qt::AlignLeft );
240 layout->addWidget ( amountbox, Qt::AlignLeft );
241 layout->addWidget ( clearedcheckbox, Qt::AlignLeft );
242
243 if ( editransfer->exec() == QDialog::Accepted )
244 {
245 //get fromaccount
246 fromaccount = ( accountids.operator[] ( fromaccountbox->currentItem() ) ).toInt();
247
248 //get to account
249 toaccount = ( accountids.operator[] ( toaccountbox->currentItem() ) ).toInt();
250
251 //set cleared flag
252 int cleared = 0;
253 if ( clearedcheckbox->isChecked() == TRUE )
254 cleared = 1;
255
256 //update transfer
257 transfer->updateTransfer ( fromaccount, account->getParentAccountID ( fromaccount ), toaccount, account->getParentAccountID ( toaccount ),
258 day, month, year, amount->text().toFloat(), cleared, transferid );
259
260 account->updateAccountBalance ( fromaccount );
261 if ( account->getParentAccountID ( fromaccount ) != -1 )
262 account->changeParentAccountBalance ( account->getParentAccountID ( fromaccount ) );
263
264 updateAndDisplay ( toaccount );
265 }
266 }
267
268void TransactionDisplay::editTransaction ()
269 {
270 int cleared;
271
272 // set the transaction id and budgetid
273 int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt();
274 int budgetid = transaction->getBudgetID ( transactionid );
275 int lineitemid = transaction->getLineItemID ( transactionid );
276
277 // create edit transaction window
278 NewTransaction *newtransaction = new NewTransaction ( this );
279 int width = this->width();
280 newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) );
281 newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) );
282 newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) );
283 newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
284 newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
285 newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) );
286
287 // enter the date in the date box
288 newtransaction->year = transaction->getYear ( transactionid );
289 newtransaction->month = transaction->getMonth ( transactionid );
290 newtransaction->day = transaction->getDay ( transactionid );
291 newtransaction->transactiondate->setText ( preferences->getDate ( newtransaction->year, newtransaction->month, newtransaction->day ) );
292
293 // set the description
294 newtransaction->setDescription ( transaction->getTransactionDescription ( transactionid ) );
295
296 // add memory items to the transactionname combobox
297 memory->displayMemoryItems ( newtransaction->transactionname );
298
299 // add correct transaction name
300 newtransaction->transactionname->setEditText ( transaction->getPayee ( transactionid ) );
301
302 // add transaction number
303 newtransaction->transactionnumber->setText ( transaction->getNumber ( transactionid ) );
304
305 // add transaction amount
306 newtransaction->transactionamount->setText ( transaction->getAbsoluteAmount ( transactionid ) );
307
308 // check for and set the correct budget
309 if ( budgetid >= 1 ) // only do it if this transaction has a budget and line item
310 {
311 newtransaction->budgetbox->setCurrentItem ( newtransaction->getBudgetIndex ( budgetid ) + 1 );
312 if ( lineitemid >= 1 )
313 {
314 newtransaction->setLineItems ();
315 newtransaction->lineitembox->setCurrentItem ( newtransaction->getLineItemIndex ( lineitemid ) );
316 }
317 else
318 {
319 newtransaction->lineitemlabel->setEnabled ( FALSE );
320 newtransaction->lineitembox->setEnabled ( FALSE );
321 }
322 }
323 else
324 {
325 newtransaction->lineitemlabel->setEnabled ( FALSE );
326 newtransaction->lineitembox->setEnabled ( FALSE );
327 }
328
329 // check cleared checkbox if necessary
330 if ( transaction->getCleared ( transactionid ) == 1 )
331 newtransaction->clearedcheckbox->setChecked ( TRUE );
332
333 // check deposit box if necessary
334 if ( transaction->getAmount ( transactionid ).toFloat() > 0 )
335 newtransaction->depositbox->setChecked ( TRUE );
336
337 if ( newtransaction->exec () == QDialog::Accepted )
338 {
339 if ( newtransaction->clearedcheckbox->isChecked () == TRUE )
340 cleared = 1;
341 else
342 cleared = 0;
343
344 float amount = newtransaction->transactionamount->text().toFloat();
345 if ( newtransaction->depositbox->isChecked() == FALSE )
346 amount = amount * -1;
347
348 // add the transaction name to the memory items
349 memory->addMemoryItem ( newtransaction->transactionname->currentText() );
350
351 // update the transaction
352 transaction->updateTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), newtransaction->transactionnumber->text().toInt(),
353 newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(),
354 amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem(), transactionid );
355
356 updateAndDisplay ( transaction->getAccountID ( transactionid ) );
357 }
358 }
359
360void TransactionDisplay::updateAndDisplay ( int id )
361 {
362 // redisplay transactions
363 listview->clear();
364 QString displaytext = "%";
365 displaytext.prepend ( limitbox->text() );
366 setTransactionDisplayDate ();
367 if ( transaction->getNumberOfTransactions() > 0 )
368 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
369
370 // redisplay transfers
371 if ( transfer->getNumberOfTransfers() > 0 )
372 transfer->displayTransfers ( listview, accountid, children, displaydate );
373
374 // add the transaction amount to the account it's associated with
375 // and update its parent account balance if necessary
376 account->updateAccountBalance ( id );
377 if ( account->getParentAccountID ( id ) != -1 )
378 account->changeParentAccountBalance ( account->getParentAccountID ( id ) );
379
380 // format then reset the account balance
381 redisplayAccountBalance ();
382 }
383
384void TransactionDisplay::checkListViewDelete ()
385 {
386 if ( listview->selectedItem() == 0 )
387 QMessageBox::warning ( this, "QashMoney", "Please select a transaction to\ndelete.");
388 else
389 deleteTransaction ();
390 }
391
392void TransactionDisplay::deleteTransaction ()
393 {
394 int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt();
395
396 if ( transactionid > 0 ) // takes care of deleting transactions
397 {
398 // check if we are viewing child transactions through a parent
399 // in that case we will have to update balances for the parent
400 // which is represented by accountid and the child account
401 // which will be represented by childaccountid
402 int childaccountid = -1;
403 if ( listview->columns() == 5 )
404 childaccountid = transaction->getAccountID ( transactionid );
405
406 transaction->deleteTransaction ( transactionid );
407
408 listview->clear();
409 QString displaytext = "%";
410 displaytext.prepend ( limitbox->text() );
411 setTransactionDisplayDate ();
412 if ( transaction->getNumberOfTransactions() > 0 )
413 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
414
415 if ( transfer->getNumberOfTransfers() > 0 )
416 transfer->displayTransfers ( listview, accountid, children, displaydate );
417
418 // if we are viewing different child accounts through the parent account
419 // ie if there are five columns and the parentid is -1
420 // update the accountid ( which is the parent ) and update the child account
421 // balance. Get its accountid from the transactionid
422 account->updateAccountBalance ( accountid ); // will update either a parent or child
423 if ( account->getParentAccountID ( accountid ) != -1 ) // update its parent if there is one
424 account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) );
425 if ( childaccountid != -1 ) // we've set childaccountid
426 account->updateAccountBalance ( childaccountid );
427
428 // format then reset the account balance
429 redisplayAccountBalance ();
430 }
431 else // takes care of deleting transfers
432 {
433 // get the accountids before we delete the transfer
434 int fromaccountid = transfer->getFromAccountID ( transactionid );
435 int toaccountid = transfer->getToAccountID ( transactionid );
436
437 // delete the transfer and redisplay transactions
438 transfer->deleteTransfer ( transactionid );
439
440 listview->clear();
441 QString displaytext = "%";
442 displaytext.prepend ( limitbox->text() );
443 setTransactionDisplayDate ();
444 if ( transaction->getNumberOfTransactions() > 0 )
445 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
446
447 if ( transfer->getNumberOfTransfers() > 0 )
448 transfer->displayTransfers ( listview, accountid, children, displaydate );
449
450 // for the from account
451 account->updateAccountBalance ( fromaccountid );
452 if ( account->getParentAccountID ( fromaccountid ) != -1 )
453 account->changeParentAccountBalance ( account->getParentAccountID ( fromaccountid ) );
454
455 // for the to account
456 account->updateAccountBalance ( toaccountid );
457 if ( account->getParentAccountID ( toaccountid ) != -1 )
458 account->changeParentAccountBalance ( account->getParentAccountID ( toaccountid ) );
459
460 // format then reset the account balance
461 redisplayAccountBalance ();
462 }
463 }
464
465void TransactionDisplay::checkListViewToggle ()
466 {
467 if ( listview->selectedItem() == 0 )
468 QMessageBox::warning ( this, "QashMoney", "Please select a transaction to\nclear or reset.");
469 else
470 toggleTransaction ();
471 }
472
473void TransactionDisplay::toggleTransaction ()
474 {
475 //get the transaction of the selected transaction to determine if its a transaction or transfer
476 int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt();
477
478 if ( transactionid > 0 ) // if this is a transaction
479 {
480 if ( transaction->getCleared ( transactionid ) == 0 )
481 transaction->setCleared ( transactionid, 1 );
482 else
483 transaction->setCleared ( transactionid, 0 );
484 }
485 else
486 {
487 if ( transfer->getCleared ( transactionid ) == 0 )
488 transfer->setCleared ( transactionid, 1 );
489 else
490 transfer->setCleared ( transactionid, 0 );
491 }
492
493 listview->clear();
494 QString displaytext = "%";
495 displaytext.prepend ( limitbox->text() );
496 setTransactionDisplayDate ();
497 if ( transaction->getNumberOfTransactions() > 0 )
498 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
499
500 if ( transfer->getNumberOfTransfers() != 0 )
501 transfer->displayTransfers ( listview, accountid, children, displaydate );
502 }
503
504void TransactionDisplay::redisplayAccountBalance ()
505 {
506 QString accountbalance = account->getAccountBalance ( accountid );
507 balance->setText ( accountbalance );
508 }
509
510void TransactionDisplay::setChildren ( bool c )
511 {
512 children = c;
513 }
514
515void TransactionDisplay::setAccountID ( int id )
516 {
517 accountid = id;
518 }
519
520ColorListItem::ColorListItem ( QListView *parent ) : QListViewItem ( parent )
521 {
522 }
523
524ColorListItem::ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4 )
525 : QListViewItem ( parent, label1, label2, label3, label4 )
526 {
527 }
528
529ColorListItem::ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4, QString label5 )
530 : QListViewItem ( parent, label1, label2, label3, label4, label5 )
531 {
532 }
533
534void ColorListItem::paintCell ( QPainter *p, const QColorGroup &cg, int column, int width, int alignment )
535 {
536 QColorGroup _cg ( cg );
537 _cg.setColor ( QColorGroup::Text, Qt::red );
538 QListViewItem::paintCell ( p, _cg, column, width, alignment );
539 }
540
541void TransactionDisplay::saveColumnSize ( int column, int oldsize, int newsize )
542 {
543 if ( listview->columns() == 4 )
544 preferences->changeColumnPreference ( column + 3, newsize );
545 else if ( listview->columns() == 5 && column != 4 )
546 preferences->changeColumnPreference ( column + 6, newsize );
547 else
548 preferences->changeColumnPreference ( 9, newsize );
549 }
550
551void TransactionDisplay::saveSortingPreference ( int column )
552 {
553 preferences->changeSortingPreference ( 2, column );
554 }
555
556void TransactionDisplay::limitDisplay ( const QString &text )
557 {
558 listview->clear ();
559 QString displaytext = "%";
560 displaytext.prepend ( text );
561 setTransactionDisplayDate ();
562 if ( transaction->getNumberOfTransactions() > 0 )
563 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
564
565 if ( displaytext.length() == 1 || preferences->getPreference ( 6 ) == 1 )
566 transfer->displayTransfers ( listview, accountid, children, displaydate );
567 }
568
569int TransactionDisplay::getIDColumn ()
570 {
571 int counter;
572 int columns = listview->columns();
573 for ( counter = 0; counter <= columns; counter++ )
574 if ( listview->header()->label ( counter ).length() == 0 )
575 return counter;
576 }
577
578void TransactionDisplay::showTransactionNotes ()
579 {
580 if ( listview->selectedItem() == 0 || listview->currentItem()->text ( getIDColumn() ).toInt() < 0 )
581 QMessageBox::warning ( this, "QashMoney", "Please select a valid\ntransaction to view notes.");
582 else
583 {
584 int transactionid = listview->selectedItem()->text ( getIDColumn() ).toInt ();
585 QDialog *description = new QDialog ( this, "description", TRUE );
586 description->setCaption ( "Notes" );
587 QMultiLineEdit *notes = new QMultiLineEdit ( description );
588 notes->setFixedSize ( ( int ) (this->width() * 0.75 ), ( int ) ( this->height() * 0.5 ) );
589 notes->setWrapColumnOrWidth ( ( int ) (this->width() * 0.75 ) );
590 notes->setWordWrap ( QMultiLineEdit::WidgetWidth );
591 notes->setEnabled ( FALSE );
592 notes->setText ( transaction->getTransactionDescription ( transactionid ) );
593 description->show();
594 }
595 }
596
597void TransactionDisplay::setTransactionDisplayDate ()
598 {
599 // determine how many days of transactions to show
600 int limittype = preferences->getPreference ( 7 );
601 if ( limittype != 5 ) // set today's date if we are not showing all transactions
602 {
603 QDate today = QDate::currentDate ();
604 switch ( limittype ) // if we are not showing all transactions
605 {
606 case 0: // viewing two weeks
607 displaydate = today.addDays ( -14 );
608 break;
609 case 1: // viewing one month
610 displaydate = today.addDays ( -30 );
611 break;
612 case 2: // three months
613 displaydate = today.addDays ( -90 );
614 break;
615 case 3: // six months
616 displaydate = today.addDays ( -180 );
617 break;
618 case 4: // one year
619 displaydate = today.addDays ( -365 );
620 break;
621 }
622 }
623 else
624 displaydate = QDate ( 1900, 1, 1 );
625 }
diff --git a/noncore/unsupported/qashmoney/transactiondisplay.h b/noncore/unsupported/qashmoney/transactiondisplay.h
new file mode 100755
index 0000000..594776a
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/transactiondisplay.h
@@ -0,0 +1,83 @@
1#ifndef TRANSACTIONDISPLAY_H
2#define TRANSACTIONDISPLAY_H
3
4#include <qlayout.h>
5#include <qhbox.h>
6#include <qlistview.h>
7#include <qpushbutton.h>
8#include <qlabel.h>
9#include <qlineedit.h>
10#include <qdatetime.h>
11
12class TransactionDisplay : public QWidget
13 {
14 Q_OBJECT
15
16 public:
17 TransactionDisplay ( QWidget* parent );
18
19 QListView* listview;
20 QPushButton* newtransaction;
21 QPushButton* edittransaction;
22 QPushButton* deletetransaction;
23 QPushButton* toggletransaction;
24 QPushButton* viewtransactionnotes;
25
26 QLabel *name;
27 QLabel *balance;
28 QLineEdit *limitbox;
29 QLineEdit *amount;
30 QLineEdit *date;
31
32 int getIDColumn ();
33
34 public slots:
35 void setChildren ( bool );
36 void setAccountID ( int );
37 void showTransactionNotes ();
38
39 private slots:
40 void addTransaction ();
41 void editTransaction ();
42 void editTransfer ();
43 void deleteTransaction ();
44 void toggleTransaction ();
45 void checkListViewDelete ();
46 void checkListViewEdit ();
47 void checkListViewToggle ();
48 void saveColumnSize ( int column, int oldsize, int newsize );
49 void limitDisplay ( const QString & );
50 void showCalculator ();
51 void showCalendar ();
52 void setTransactionDisplayDate ();
53 void saveSortingPreference ( int column );
54
55 private:
56 int accountid, fromaccount, fromparent, toaccount, toparent, day, month, year, transferid;
57 QDate displaydate;
58 bool children;
59 QBoxLayout *layout;
60 QHBox *firstline;
61 QHBox *secondline;
62 void redisplayAccountBalance ();
63 void updateAndDisplay ( int accountid );
64 };
65
66#endif
67
68#ifndef COLORLISTITEM_H
69#define COLORLISTITEM_H
70
71class ColorListItem : public QListViewItem
72 {
73 public:
74
75 ColorListItem ( QListView *parent );
76 ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4 );
77 ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4, QString label5 );
78
79 virtual void paintCell ( QPainter *p, const QColorGroup &cg, int column, int width, int alignment );
80 };
81
82#endif
83
diff --git a/noncore/unsupported/qashmoney/transfer.cpp b/noncore/unsupported/qashmoney/transfer.cpp
new file mode 100755
index 0000000..ae1b748
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/transfer.cpp
@@ -0,0 +1,259 @@
1#include "transfer.h"
2#include "account.h"
3#include "transactiondisplay.h"
4#include <stdlib.h>
5
6extern Account *account;
7extern Preferences *preferences;
8
9Transfer::Transfer ()
10 {
11 db = sqlite_open ( "qmtransfers.db", 0, 0 );
12 }
13
14Transfer::~Transfer ()
15 {
16 sqlite_close ( db );
17 }
18
19void Transfer::addTransfer ( int fromaccount, int fromparent, int toaccount, int toparent, int day, int month, int year, float amount, int cleared )
20 {
21 int nextrowid = -1;
22 char **results;
23 sqlite_get_table ( db, "select count() from transfers;", &results, 0, 0, 0 );
24 if ( atoi ( results [ 1 ] ) != 0 )
25 {
26 char **results;
27 sqlite_get_table ( db, "select min ( rowid ) from transfers;", &results, 0, 0, 0 );
28 nextrowid = ( atoi ( results [ 1 ] ) ) - 1;
29 }
30 sqlite_exec_printf ( db, "insert into transfers values ( %i, %i, %i, %i, %i, %i, %i, 0, 0, %.2f, %i, 0, 0, 0, 0, 0, %i );", 0, 0, 0, fromaccount, fromparent, toaccount, toparent, day, month, year, amount, cleared, nextrowid );
31 }
32
33void Transfer::updateTransfer ( int fromaccount, int fromparent, int toaccount, int toparent, int day, int month, int year, float amount, int cleared, int transferid )
34 {
35 sqlite_exec_printf ( db, "update transfers set fromaccount = %i, fromparent = %i, toaccount = %i, toparent = %i, day = %i, month = %i, year = %i,"
36 "amount = %.2f, cleared = %i where transferid = %i;", 0, 0, 0, fromaccount, fromparent, toaccount, toparent, day, month, year, amount, cleared, transferid );
37 }
38
39void Transfer::deleteTransfer ( int transferid )
40 {
41 sqlite_exec_printf ( db, "delete from transfers where transferid = %i;", 0, 0, 0, transferid );
42 }
43
44void Transfer::deleteAllTransfers ( int accountid )
45 {
46 sqlite_exec_printf ( db, "delete from transfers where fromaccount = %i;", 0, 0, 0, accountid );
47 sqlite_exec_printf ( db, "delete from transfers where toaccount = %i;", 0, 0, 0, accountid );
48 }
49
50int Transfer::getNumberOfTransfers ()
51 {
52 char **results;
53 sqlite_get_table ( db, "select count() from transfers;", &results, 0, 0, 0 );
54 return atoi ( results [ 1 ] );
55 }
56
57int Transfer::getNumberOfTransfers ( int accountid )
58 {
59 char **results;
60 sqlite_get_table_printf ( db, "select count() from transfers where fromaccount = %i;", &results, 0, 0, 0, accountid );
61 int transfers = atoi ( results [ 1 ] );
62 sqlite_get_table_printf ( db, "select count() from transfers where toaccount = %i;", &results, 0, 0, 0, accountid );
63 transfers = transfers + atoi ( results [ 1 ] );
64 return transfers;
65 }
66
67void Transfer::displayTransfers ( QListView *listview, int accountid, bool children, QDate displaydate )
68 {
69 int showcleared = preferences->getPreference ( 3 );
70
71 // select the from transfers to display
72 char **results;
73 int rows, columns;
74 if ( account->getParentAccountID ( accountid ) == -1 && children == TRUE )
75 {
76 if ( showcleared == 0 )
77 sqlite_get_table_printf ( db, "select day, month, year, amount, transferid, fromaccount, toaccount from transfers where cleared = 0 and toparent = %i;", &results, &rows, &columns, 0, accountid );
78 else
79 sqlite_get_table_printf ( db, "select day, month, year, amount, transferid, fromaccount, toaccount from transfers where toparent = %i;", &results, &rows, &columns, 0, accountid );
80 }
81 else
82 {
83 if ( showcleared == 0 )
84 sqlite_get_table_printf ( db, "select day, month, year, amount, transferid, fromaccount, toaccount from transfers where cleared = 0 and toaccount = %i;", &results, &rows, &columns, 0, accountid );
85 else
86 sqlite_get_table_printf ( db, "select day, month, year, amount, transferid, fromaccount, toaccount from transfers where toaccount = %i;", &results, &rows, &columns, 0, accountid );
87 }
88
89 // iterate through the list and display the from items
90 int counter = 7;
91 int position = 0;
92 while ( counter < ( ( rows + 1 ) * columns ) )
93 {
94 // construct the date
95 QString daystring = results [ counter ];
96 int day = daystring.toInt ();
97 QString monthstring = results [ counter + 1 ];
98 int month = monthstring.toInt ();
99 QString yearstring = results [ counter + 2 ];
100 int year = yearstring.toInt ();
101 QString date = preferences->getDate ( year, month, day );
102 QDate testdate ( year, month, day );
103
104 //construct the amount and id strings
105 QString amount = results [ counter + 3 ];
106 QString id = results [ counter + 4 ];
107
108 // construct the transaction name
109 QString transactionname = "FROM: ";
110 QString temp1 = results [ counter + 5 ];
111 transactionname.append ( account->getAccountName ( temp1.toInt() ) );
112
113 QString toaccount = account->getAccountName ( atol ( results [ counter + 6 ] ) );
114
115 if ( testdate >= displaydate || showcleared == 0 )
116 {
117 // display this transfer
118 if ( account->getParentAccountID ( accountid ) == -1 )
119 {
120 if ( showcleared == 1 && getCleared ( id.toInt() ) == 1 )
121 ColorListItem *item = new ColorListItem ( listview, date, transactionname, amount, id, toaccount );
122 else
123 QListViewItem *item = new QListViewItem ( listview, date, transactionname, amount, id, toaccount );
124 }
125 else
126 {
127 if ( showcleared == 1 && getCleared ( id.toInt() ) == 1 )
128 ColorListItem *item = new ColorListItem ( listview, date, transactionname, amount, id );
129 else
130 QListViewItem *item = new QListViewItem ( listview, date, transactionname, amount, id );
131 }
132 }
133 counter = counter + 7;
134 }
135
136 // select the to transfers to display
137 char **toresults;
138 rows = 0;
139 columns = 0;
140 if ( account->getParentAccountID ( accountid ) == -1 && children == TRUE )
141 {
142 if ( showcleared == 0 )
143 sqlite_get_table_printf ( db, "select day, month, year, amount, transferid, fromaccount, toaccount from transfers where cleared = 0 and fromparent = %i;", &toresults, &rows, &columns, 0, accountid );
144 else
145 sqlite_get_table_printf ( db, "select day, month, year, amount, transferid, fromaccount, toaccount from transfers where fromparent = %i;", &toresults, &rows, &columns, 0, accountid );
146 }
147 else
148 {
149 if ( showcleared == 0 )
150 sqlite_get_table_printf ( db, "select day, month, year, amount, transferid, fromaccount, toaccount from transfers where cleared = 0 and fromaccount = %i;", &toresults, &rows, &columns, 0, accountid );
151 else
152 sqlite_get_table_printf ( db, "select day, month, year, amount, transferid, fromaccount, toaccount from transfers where fromaccount = %i;", &toresults, &rows, &columns, 0, accountid );
153 }
154
155 // iterate through the list and display the from items
156 counter = 7;
157 position = 0;
158 while ( counter < ( ( rows + 1 ) * columns ) )
159 {
160 // construct the date
161 QString daystring = toresults [ counter ];
162 int day = daystring.toInt ();
163 QString monthstring = toresults [ counter + 1 ];
164 int month = monthstring.toInt ();
165 QString yearstring = toresults [ counter + 2 ];
166 int year = yearstring.toInt ();
167 QString date = preferences->getDate ( year, month, day );
168 QDate testdate ( year, month, day );
169
170 //construct the amount and id strings
171 QString amount = toresults [ counter + 3 ];
172 amount.prepend ( "-" );
173 QString id = toresults [ counter + 4 ];
174
175 // construct the transaction name
176 QString transactionname = "TO: ";
177 QString temp1 = toresults [ counter + 6 ];
178 transactionname.append ( account->getAccountName ( temp1.toInt() ) );
179
180 QString fromaccount = account->getAccountName ( atol ( toresults [ counter + 5 ] ) );
181
182 if ( testdate >= displaydate || showcleared == 0 )
183 {
184 // display this transfer
185 if ( account->getParentAccountID ( accountid ) == -1 )
186 {
187 if ( showcleared == 1 && getCleared ( id.toInt() ) == 1 )
188 ColorListItem *item = new ColorListItem ( listview, date, transactionname, amount, id, fromaccount );
189 else
190 QListViewItem *item = new QListViewItem ( listview, date, transactionname, amount, id, fromaccount );
191 }
192 else
193 {
194 if ( showcleared == 1 && getCleared ( id.toInt() ) == 1 )
195 ColorListItem *item = new ColorListItem ( listview, date, transactionname, amount, id );
196 else
197 QListViewItem *item = new QListViewItem ( listview, date, transactionname, amount, id );
198 }
199 }
200
201 counter = counter + 7;
202 }
203 }
204
205int Transfer::getCleared ( int id )
206 {
207 char **results;
208 sqlite_get_table_printf ( db, "select cleared from transfers where transferid= %i;", &results, 0, 0, 0, id );
209 return atoi ( results [ 1 ] );
210 }
211
212void Transfer::setCleared ( int id, int cleared )
213 {
214 sqlite_exec_printf ( db, "update transfers set cleared = %i where transferid = %i;", 0, 0, 0, cleared, id );
215 }
216
217int Transfer::getFromAccountID ( int id )
218 {
219 char **results;
220 sqlite_get_table_printf ( db, "select fromaccount from transfers where transferid= %i;", &results, 0, 0, 0, id );
221 return atoi ( results [ 1 ] );
222 }
223
224int Transfer::getToAccountID ( int id )
225 {
226 char **results;
227 sqlite_get_table_printf ( db, "select toaccount from transfers where transferid= %i;", &results, 0, 0, 0, id );
228 return atoi ( results [ 1 ] );
229 }
230
231int Transfer::getDay ( int id )
232 {
233 char **results;
234 sqlite_get_table_printf ( db, "select day from transfers where transferid= %i;", &results, 0, 0, 0, id );
235 return atoi ( results [ 1 ] );
236 }
237
238int Transfer::getMonth ( int id )
239 {
240 char **results;
241 sqlite_get_table_printf ( db, "select month from transfers where transferid= %i;", &results, 0, 0, 0, id );
242 return atoi ( results [ 1 ] );
243 }
244
245int Transfer::getYear ( int id )
246 {
247 char **results;
248 sqlite_get_table_printf ( db, "select year from transfers where transferid= %i;", &results, 0, 0, 0, id );
249 return atoi ( results [ 1 ] );
250 }
251
252QString Transfer::getAmount ( int id )
253 {
254 char **results;
255 sqlite_get_table_printf ( db, "select amount from transfers where transferid= %i;", &results, 0, 0, 0, id );
256 return results [ 1 ];
257 }
258
259
diff --git a/noncore/unsupported/qashmoney/transfer.h b/noncore/unsupported/qashmoney/transfer.h
new file mode 100755
index 0000000..cec3386
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/transfer.h
@@ -0,0 +1,52 @@
1#ifndef TRANSFER_H
2#define TRANSFER_H
3
4#include <qlistview.h>
5#include <qstring.h>
6#include <sqlite3.h>
7#include <qdatetime.h>
8
9#include "preferences.h"
10
11class Transfer
12 {
13 public:
14
15 Transfer ();
16 ~Transfer ();
17
18 // This function adds a new transfer to the database. It takes the fromaccount, toaccount,
19 // number, frombudget, tobudget, day, month, year, amount, cleared
20 void addTransfer ( int fromaccount, int fromparent, int toaccount, int toparent, int day, int month, int year, float amount, int cleared );
21 void updateTransfer ( int fromaccount, int fromparent, int toaccount, int toparent, int day, int month, int year, float amount, int cleared, int transferid );
22
23 // Deletes a transfer. Takes the transferid as its parameter
24 void deleteTransfer ( int );
25
26 // Deletes all transfers for a given accountid
27 void deleteAllTransfers ( int accountid );
28
29 // Returns the number of checking transfers
30 int getNumberOfTransfers ();
31 int getNumberOfTransfers ( int accountid );
32
33 void displayTransfers ( QListView *listview, int accountid, bool children, QDate displaydate );
34 int getCleared ( int id );
35 void setCleared ( int id, int cleared );
36 int getFromAccountID ( int id );
37 int getToAccountID ( int id );
38
39 int getDay ( int id );
40 int getMonth ( int id );
41 int getYear ( int id );
42 QString getAmount ( int id );
43
44 private:
45
46 sqlite3 *db;
47 };
48
49#endif
50
51
52
diff --git a/noncore/unsupported/qashmoney/transferdialog.cpp b/noncore/unsupported/qashmoney/transferdialog.cpp
new file mode 100755
index 0000000..7a12fbf
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/transferdialog.cpp
@@ -0,0 +1,112 @@
1#include "transferdialog.h"
2#include "datepicker.h"
3#include "calculator.h"
4
5
6extern Preferences *preferences;
7extern Account *account;
8
9TransferDialog::TransferDialog ( QWidget *parent, int fromaccountid, int toaccountid ) : QDialog ( parent, 0, TRUE )
10 {
11 dateedited = FALSE;
12 setCaption ( "Transfer" );
13
14 fromaccountlabel = new QLabel ( "From account:", this );
15 QFont f = this->font();
16 f.setWeight ( QFont::Bold );
17 fromaccountlabel->setFont ( f );
18 fromaccount = new QLabel ( account->getAccountName ( fromaccountid ), this );
19
20 toaccountlabel = new QLabel ( "To Account:", this );
21 toaccountlabel->setFont ( f );
22 toaccount = new QLabel ( account->getAccountName ( toaccountid ), this );
23
24 datelabel = new QLabel ( "Date", this );
25
26 datebox = new QHBox ( this );
27 datebox->setSpacing ( 2 );
28 date = new QLineEdit ( datebox );
29 date->setAlignment ( Qt::AlignRight );
30 date->setDisabled ( TRUE );
31 datebutton = new QPushButton ( datebox );
32 datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) );
33 connect ( datebutton, SIGNAL ( released() ), this, SLOT ( showCalendar() ) );
34
35 amounttlabel = new QLabel ( "Amount", this );
36
37 amountbox = new QHBox ( this );
38 amountbox->setSpacing ( 2 );
39 amount = new QLineEdit ( amountbox );
40 amount->setAlignment ( Qt::AlignRight );
41 calculatorbutton = new QPushButton( amountbox );
42 calculatorbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) );
43 connect ( calculatorbutton, SIGNAL ( released() ), this, SLOT ( showCalculator() ) );
44
45 clearedcheckbox = new QCheckBox ( "Cleared", this );
46
47 layout = new QVBoxLayout ( this, 4, 2 );
48 layout->addWidget ( fromaccountlabel, Qt::AlignLeft );
49 layout->addWidget ( fromaccount, Qt::AlignLeft );
50 layout->addWidget ( toaccountlabel, Qt::AlignLeft );
51 layout->addWidget ( toaccount, Qt::AlignLeft );
52 layout->addSpacing ( 5 );
53 layout->addWidget ( datelabel, Qt::AlignLeft );
54 layout->addWidget ( datebox, Qt::AlignLeft );
55 layout->addWidget ( amounttlabel, Qt::AlignLeft );
56 layout->addWidget ( amountbox, Qt::AlignLeft );
57 layout->addWidget ( clearedcheckbox, Qt::AlignLeft );
58 }
59
60bool TransferDialog::getDateEdited ()
61 {
62 return dateedited;
63 }
64
65void TransferDialog::showCalendar ()
66 {
67 QDate newDate = QDate::currentDate ();
68 DatePicker *dp = new DatePicker ( newDate );
69 if ( dp->exec () == QDialog::Accepted )
70 {
71 // Set date integers
72 year = dp->getYear();
73 month = dp->getMonth();
74 day = dp->getDay();
75
76 // Set dateedited to TRUE
77 // This tells the accountdisplay object that the user edited an account
78 // and did change the date
79 dateedited = TRUE;
80
81 // Display date with our selected format
82 date->setText ( preferences->getDate ( year, month, day ) );
83 }
84 }
85
86int TransferDialog::getDay ()
87 {
88 return day;
89 }
90
91int TransferDialog::getMonth ()
92 {
93 return month;
94 }
95
96int TransferDialog::getYear ()
97 {
98 return year;
99 }
100
101void TransferDialog::showCalculator ()
102 {
103 Calculator *calculator = new Calculator ( this );
104 if ( calculator->exec () == QDialog::Accepted )
105 amount->setText ( calculator->display->text() );
106 }
107
108
109
110
111
112
diff --git a/noncore/unsupported/qashmoney/transferdialog.h b/noncore/unsupported/qashmoney/transferdialog.h
new file mode 100755
index 0000000..dd55879
--- a/dev/null
+++ b/noncore/unsupported/qashmoney/transferdialog.h
@@ -0,0 +1,62 @@
1#ifndef TRANSFERDIALOG_H
2#define TRANSFERDIALOG_H
3
4#include <qdialog.h>
5#include <qlayout.h>
6#include <qlineedit.h>
7#include <qpushbutton.h>
8#include <qcheckbox.h>
9#include <qhbox.h>
10#include <qlabel.h>
11
12#include "preferences.h"
13#include "account.h"
14
15class TransferDialog : public QDialog
16{
17 Q_OBJECT
18
19public:
20 TransferDialog ( QWidget *parent, int fromaccountid, int toaccountid );
21
22 QLabel *fromaccountlabel;
23 QLabel *fromaccount;
24
25 QLabel *toaccountlabel;
26 QLabel *toaccount;
27
28 QLabel *datelabel;
29
30 QHBox *datebox;
31 QLineEdit *date;
32 QPushButton *datebutton;
33
34 QLabel *amounttlabel;
35
36 QHBox *amountbox;
37 QLineEdit *amount;
38 QPushButton *calculatorbutton;
39
40 QCheckBox *clearedcheckbox;
41
42 QBoxLayout *layout;
43
44 bool getDateEdited ();
45
46public slots:
47
48 void showCalendar ();
49 void showCalculator ();
50 int getDay ();
51 int getMonth ();
52 int getYear ();
53
54private:
55
56 int fromaccountid;
57 int toaccountid;
58 int year, month, day;
59 bool dateedited;
60};
61
62#endif