summaryrefslogtreecommitdiff
path: root/noncore/apps
authorallenforsythe <allenforsythe>2003-05-14 10:55:23 (UTC)
committer allenforsythe <allenforsythe>2003-05-14 10:55:23 (UTC)
commitb92483d866f263235bc9b52aa271241e1e55112e (patch) (unidiff)
treec729906a788de935c321b0188964a0602b66036d /noncore/apps
parent79e34e9dc4870885c58f80c29a723d0227f7b788 (diff)
downloadopie-b92483d866f263235bc9b52aa271241e1e55112e.zip
opie-b92483d866f263235bc9b52aa271241e1e55112e.tar.gz
opie-b92483d866f263235bc9b52aa271241e1e55112e.tar.bz2
Initial revision
Diffstat (limited to 'noncore/apps') (more/less context) (ignore whitespace changes)
-rwxr-xr-xnoncore/apps/qashmoney/TODO15
-rwxr-xr-xnoncore/apps/qashmoney/install/CONTROL/opie-qashmoney.control7
-rwxr-xr-xnoncore/apps/qashmoney/install/opt/QtPalmtop/help/html/accountpreferenceswindow.pngbin0 -> 3522 bytes
-rwxr-xr-xnoncore/apps/qashmoney/install/opt/QtPalmtop/help/html/budgetwindow.pngbin0 -> 11896 bytes
-rwxr-xr-xnoncore/apps/qashmoney/install/opt/QtPalmtop/help/html/datepreferenceswindow.pngbin0 -> 3354 bytes
-rwxr-xr-xnoncore/apps/qashmoney/install/opt/QtPalmtop/help/html/mainwindow.pngbin0 -> 11279 bytes
-rwxr-xr-xnoncore/apps/qashmoney/install/opt/QtPalmtop/help/html/newaccountwindow.pngbin0 -> 18958 bytes
-rwxr-xr-xnoncore/apps/qashmoney/install/opt/QtPalmtop/help/html/newtransactionwindow.pngbin0 -> 16591 bytes
-rwxr-xr-xnoncore/apps/qashmoney/install/opt/QtPalmtop/help/html/qashmoney.html153
-rwxr-xr-xnoncore/apps/qashmoney/install/opt/QtPalmtop/help/html/transactionpreferenceswindow.pngbin0 -> 3669 bytes
-rwxr-xr-xnoncore/apps/qashmoney/install/opt/QtPalmtop/help/html/transactionwindow.pngbin0 -> 11827 bytes
-rwxr-xr-xnoncore/apps/qashmoney/install/opt/QtPalmtop/help/html/transferwindow.pngbin0 -> 18710 bytes
-rwxr-xr-xnoncore/apps/qashmoney/make_arm23
-rwxr-xr-xnoncore/apps/qashmoney/make_x8622
-rwxr-xr-xnoncore/apps/qashmoney/preferencedialogs.cpp195
-rwxr-xr-xnoncore/apps/qashmoney/preferencedialogs.h84
-rwxr-xr-xnoncore/apps/qashmoney/preferences.cpp296
-rwxr-xr-xnoncore/apps/qashmoney/transactiondisplay.cpp586
18 files changed, 1381 insertions, 0 deletions
diff --git a/noncore/apps/qashmoney/TODO b/noncore/apps/qashmoney/TODO
new file mode 100755
index 0000000..c85b0d2
--- a/dev/null
+++ b/noncore/apps/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/apps/qashmoney/install/CONTROL/opie-qashmoney.control b/noncore/apps/qashmoney/install/CONTROL/opie-qashmoney.control
new file mode 100755
index 0000000..ffd11db
--- a/dev/null
+++ b/noncore/apps/qashmoney/install/CONTROL/opie-qashmoney.control
@@ -0,0 +1,7 @@
1Package: qashmoney
2Priority: optional
3Version: 0.74
4Architecture: arm
5Maintainer: Allen Forsythe qashmoneyman@attbi.com
6Section: Applications
7Description: QashMoney provides an intuitive and fast way to keep track of your accounts and budgets.
diff --git a/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/accountpreferenceswindow.png b/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/accountpreferenceswindow.png
new file mode 100755
index 0000000..e37580f
--- a/dev/null
+++ b/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/accountpreferenceswindow.png
Binary files differ
diff --git a/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/budgetwindow.png b/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/budgetwindow.png
new file mode 100755
index 0000000..e42d52a
--- a/dev/null
+++ b/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/budgetwindow.png
Binary files differ
diff --git a/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/datepreferenceswindow.png b/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/datepreferenceswindow.png
new file mode 100755
index 0000000..7ae6821
--- a/dev/null
+++ b/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/datepreferenceswindow.png
Binary files differ
diff --git a/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/mainwindow.png b/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/mainwindow.png
new file mode 100755
index 0000000..c8a88c2
--- a/dev/null
+++ b/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/mainwindow.png
Binary files differ
diff --git a/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/newaccountwindow.png b/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/newaccountwindow.png
new file mode 100755
index 0000000..d0e4664
--- a/dev/null
+++ b/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/newaccountwindow.png
Binary files differ
diff --git a/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/newtransactionwindow.png b/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/newtransactionwindow.png
new file mode 100755
index 0000000..c011235
--- a/dev/null
+++ b/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/newtransactionwindow.png
Binary files differ
diff --git a/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/qashmoney.html b/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/qashmoney.html
new file mode 100755
index 0000000..40bfe27
--- a/dev/null
+++ b/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/qashmoney.html
@@ -0,0 +1,153 @@
1<html>
2
3<head>
4
5<title>QashMoney Help</title>
6<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
7
8</head>
9
10<body>
11<center><b>QashMoney</b></center>
12
13<br><center>Welcome to QashMoney help. This file should help you get started
14using QashMoney quickly! </center>
15
16<br><center><b>Main Window</b></center>
17
18<br>When you start the application, the Main Window will appear. This window
19consists of account buttons and the account display which shows you the account
20names and balances for each account. Parent accounts are to the left
21and child accounts are indented. By default, child accounts contribute
22to the balance of their respective parents. Parent accounts are used only for viewing
23transactions for the child accounts beneath them as well as deleting and clearing/reseting
24transactions in those child accounts. As such, parent accounts with child accounts will
25not accept transactions.
26
27<p><b>NOTE:</b> The columns in the account and transaction display windows default to a reasonable but
28static width. You can press in between the columns and drag to resize them to your liking and QashMoney will remember
29these widths.
30
31<center><br><img src="mainwindow.png" ></center>
32
33<br><img src="/opt/QtPalmtop/pics/new.png"> Press this button to add a new account to the list.
34
35<br><img src="/opt/QtPalmtop/pics/edit.png"> Press this button to edit the name, description,
36and currency that has been assigned to the account.&nbsp; The other parameters of the account are not editable.
37
38<br><img src="/opt/QtPalmtop/pics/delete.png"> Press this button to delete an account that you've added. When you
39delete a child account, all of its transactions will also be deleted so be careful with this. You can only delete a parent
40account if it has no child accounts.
41
42<br><img src="/opt/QtPalmtop/pics/transfer.png"> Press this button to transfer money between accounts. This is a toggle button
43and will stay down when you press it. Next, select two accounts from the account list. These will become the accounts
44between which funds are transferred. The money is transferred from the account you tap first and transferred to the account you tap second.
45A popup dialog will appear after you tap two accounts and looks like this:
46
47<center><br><img src="transferwindow.png" ></center>
48
49<br>To complete the transfer, enter the date and amount. Check the cleared check box to set this transfer cleared.
50
51<br><br><center><b>Add Account</b></center>
52
53<br><center><img src="newaccountwindow.png"></center>
54
55<br>Use the Add Account dialog to add accounts. The initial
56balance may be typed in manually or you can push the calculator to enter
57the amount with the stylus. Next, select the currency pulldown menu to choose
58the currency for this account. If currency support is disabled, this box will be disabled.
59 You'll notice that the date line is disabled. Dates may only
60be entered by pressing the calendar button and selecting the date. Today's date is put into the
61calendar entry line by default. If you select this to a child account,
62a pulldown menu will appear so you can select its parent account. Using the Type
63pulldown menu, you may select any type of equity or liability account. If you choose a
64liability account, you may also type in a credit limit for the account. Press the button next to
65the account name box to enter a description of the account. To cancel the account addition,
66click the X button. Otherwise, press OK to complete the account addition.
67
68<br><br><center><b>Transaction Window</b></center>
69
70<br><center><img src="transactionwindow.png"></center>
71
72<br>To see the transactions for each account, highlight the
73account and press the Transactions tab, this will display the transaction
74window, the account name you've selected, the account balance and several
75transaction buttons. If you've selected a child account or a parent account with no
76children, the transaction window will contain three columns for date, transaction name,
77and amount. A fourth column identifying the account for each transaction will be added
78if you choose to view a parent account with children. Entering text in the "Limit" box will
79display items that begin with the text in the box. Text in this box does not effect transfers.
80
81<br><br><img src="/opt/QtPalmtop/pics/new.png"> New Transaction
82
83<br><img src="/opt/QtPalmtop/pics/edit.png"> Edit Transaction. Use this button to edit transactions.
84Just select the transaction you want to edit and the appropriate window will appear. You cannot edit transfers
85from this window (yet). You must delete transfers and then reenter them in the account display.
86
87<br><img src="/opt/QtPalmtop/pics/delete.png"> Delete Transaction. This also deletes a transfer if one is selected.
88
89<br><img src="/opt/QtPalmtop/pics/redo.png"> Clear or Reset Transaction. Use this button to clear transactions.
90 If an uncleared transaction is selected, it will be cleared. If a cleared transaction is selected, it will be reset. This functions
91identically for transfers. If you prefer not to see cleared transactions, the transaction you clear will disappear from the
92transaction window. If however, you are showing cleared transactions, cleared transactions will appear red rather than black differentiating
93them from the non-cleared transactions.
94
95<br><img src="/opt/QtPalmtop/pics/info.png"> Transaction Information. If you've entered notes about a transaction, select the transaction and
96press this button to see the notes.
97
98<br><br><center><b>Add Transaction</b></center>
99
100<br><center><img src="newtransactionwindow.png"></center>
101
102<br>Use this dialog to enter new transactions. Enter the transaction name, transaction number, amount, and date.
103Each transaction defaults to a non-cleared debit transaction. If you want to clear the transaction right away, check
104the <b>Cleared</b> checkbox. If you want to make this a deposit (credit) to the account, check the <b>Credit</b> checkbox. Press the
105button next to Transaction Name to enter a description of this transaction. The budget and line item buttons at the bottom allow you to
106add this transaction to budgets you have set up. The budget button defaults to <b>None.</b> If you don't want the add this transaction to
107any budget, leave this as is. Otherwise, select the budget and then a line item from that budget to add the transaction. These buttons will
108be disabled unless you've set up budgets.
109
110<br><br><center><b>Budgets</b></center>
111
112<br><center><img src="budgetwindow.png"></center>
113
114<br>QashMoney's newest addition, this tab allows you to set up multiple budgets with different currencies then add any transaction from any account to any budget.
115At the top of the budget display, a menu system allows you to add, edit, and delete budgets and line items within each budget. Using the <b>Change</b> item
116under <b>Date</b> menu, you can change the date range for which you want to view budgets. Currently, you can view budgets by year and by month. The
117budgeted and actual amounts will change appropriately for the view you select. Like the column sizes in the accounts and transaction windows. Drag these to
118the size you want and QashMoney will remember them.
119
120<p><center><b>Preferences Menu</b></center>
121
122<br>The preferences menus (currently) allow you to change the date format, determine whether cleared transactions are shown in the
123transaction window, and to enable currenct support. Just tap the respective menu items to see the dialog for each preference. These dialogs are self explanatory
124and look like this:
125
126<center><br><img src="datepreferenceswindow.png" ></center>
127
128<center><br><img src="accountpreferenceswindow.png" ></center>
129
130<center><br><img src="transactionpreferenceswindow.png" ></center>
131
132<br>Defaults are provided for each preference.
133
134<br><center><b>Utilities Menu</b></center>
135
136<br>Using the utlities menu and the memory window, you can add, delete, or edit memory items. These will be presented
137in an easy to use pulldown menu when entering transactions.
138
139<br><br><center><img src="memorywindow.png"></center>
140
141<br><img src="/opt/QtPalmtop/pics/new.png"> New Memory Item. Press this button to add a new memory to the list.
142This button is also used to add an edited item ( see below ).
143
144<br><br><img src="/opt/QtPalmtop/pics/edit.png"> Edit Memory Item. Select an item in the memory
145item window then press this button to edit it. The item will be added to the line editor below the
146button and deleted from the list. You must press the new button to add it back to
147the list whether you edit it or not. Otherwise it will be lost.
148
149<br><img src="/opt/QtPalmtop/pics/delete.png"> Delete Memory Item. Press this button to delete a memory
150item after selecting it in the memory item window.
151
152</body>
153</html>
diff --git a/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/transactionpreferenceswindow.png b/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/transactionpreferenceswindow.png
new file mode 100755
index 0000000..7b183b3
--- a/dev/null
+++ b/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/transactionpreferenceswindow.png
Binary files differ
diff --git a/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/transactionwindow.png b/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/transactionwindow.png
new file mode 100755
index 0000000..3f25a0a
--- a/dev/null
+++ b/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/transactionwindow.png
Binary files differ
diff --git a/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/transferwindow.png b/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/transferwindow.png
new file mode 100755
index 0000000..13bbe0a
--- a/dev/null
+++ b/noncore/apps/qashmoney/install/opt/QtPalmtop/help/html/transferwindow.png
Binary files differ
diff --git a/noncore/apps/qashmoney/make_arm b/noncore/apps/qashmoney/make_arm
new file mode 100755
index 0000000..4d0dc1c
--- a/dev/null
+++ b/noncore/apps/qashmoney/make_arm
@@ -0,0 +1,23 @@
1# Use this script to automatically make the arm version
2# of QashMoney. The arm.sh file must be in this folder
3# for it to work
4
5# clean the directory then remove the Makefile
6echo "Cleaning the directory and removing the current Makefile..."
7if [ -e Makefile ]
8then
9 make clean
10 rm Makefile
11fi
12
13# set the environment variables for the arm environment
14echo "Setting environment variables..."
15source arm.sh
16
17# Make the new Makefile
18echo "Making the new Makefile..."
19tmake -o Makefile qashmoney.pro
20
21# Make the program
22echo "Making the program..."
23make
diff --git a/noncore/apps/qashmoney/make_x86 b/noncore/apps/qashmoney/make_x86
new file mode 100755
index 0000000..fe1874d
--- a/dev/null
+++ b/noncore/apps/qashmoney/make_x86
@@ -0,0 +1,22 @@
1# Use this script to automatically make the x86 version
2# of QashMoney. The x86.sh file must be in this folder
3# for it to work.
4
5# Clean the directory
6if [ -e Makefile ]
7then
8 make clean
9 rm Makefile
10fi
11
12# set the environment variables for the x86 environment
13echo "Setting environment variables..."
14source x86.sh
15
16# Make the new Makefile
17echo "Making the new Makefile..."
18tmake -o Makefile qashmoney.pro
19
20# Make the program
21echo "Making the program..."
22make
diff --git a/noncore/apps/qashmoney/preferencedialogs.cpp b/noncore/apps/qashmoney/preferencedialogs.cpp
new file mode 100755
index 0000000..3c2fb97
--- a/dev/null
+++ b/noncore/apps/qashmoney/preferencedialogs.cpp
@@ -0,0 +1,195 @@
1#include "preferencedialogs.h"
2#include "preferences.h"
3#include <qlabel.h>
4
5extern Preferences *preferences;
6
7DatePreferences::DatePreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE )
8 {
9 setCaption( tr( "Date" ) );
10
11 QLabel *datelabel = new QLabel ( "Format", this );
12 dateformat = new QComboBox ( this );
13 dateformat->setEditable ( FALSE );
14 dateformat->insertItem ( "yyyymmdd" );
15 dateformat->insertItem ( "yymmdd" );
16 dateformat->insertItem ( "mmddyyyy" );
17 dateformat->insertItem ( "mmddyy" );
18 dateformat->insertItem ( "yyyyddmm" );
19 dateformat->insertItem ( "yyddmm" );
20 dateformat->insertItem ( "ddmmyyyy" );
21 dateformat->insertItem ( "ddmmyy" );
22 connect ( dateformat, SIGNAL ( activated ( int ) ), this, SLOT ( changeDateFormat ( int ) ) );
23
24 QLabel *dateseparatorlabel = new QLabel ( "Separator", this );
25 dateseparator = new QComboBox ( this );
26 dateseparator->insertItem ( "/" );
27 dateseparator->insertItem ( "-" );
28 dateseparator->insertItem ( "." );
29 connect ( dateseparator, SIGNAL ( activated ( int ) ), this, SLOT ( changeDateSeparator ( int ) ) );
30
31 defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this );
32 connect ( defaults, SIGNAL ( released () ), this, SLOT ( setDefaultDatePreferences () ) );
33
34 dateformat->setCurrentItem ( ( preferences->getPreference ( 1 ) ) - 1 );
35 dateseparator->setCurrentItem ( ( preferences->getPreference ( 2 ) ) - 1 );
36
37 layout = new QVBoxLayout ( this, 2, 2 );
38 layout->addWidget ( datelabel );
39 layout->addWidget ( dateformat );
40 layout->addWidget ( dateseparatorlabel );
41 layout->addWidget ( dateseparator );
42 layout->insertSpacing ( 4, 5 );
43 layout->addWidget ( defaults );
44
45 }
46
47DatePreferences::~DatePreferences ()
48 {
49 }
50
51void DatePreferences::changeDateFormat ( int index )
52 {
53 index ++;
54 preferences->changePreference ( 1, index );
55 }
56
57void DatePreferences::changeDateSeparator ( int index )
58 {
59 index ++;
60 preferences->changePreference ( 2, index );
61 }
62
63void DatePreferences::setDefaultDatePreferences ()
64 {
65 preferences->setDefaultDatePreferences ();
66 dateformat->setCurrentItem ( ( preferences->getPreference ( 1 ) ) - 1 );
67 dateseparator->setCurrentItem ( ( preferences->getPreference ( 2 ) ) - 1 );
68 }
69
70// START TRANSACTION PREFERENCES
71
72TransactionPreferences::TransactionPreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE )
73{
74 setCaption( tr ( "Transaction" ) );
75
76 showclearedtransactions = new QCheckBox ( this );
77 showclearedtransactions->setText ( "Show Cleared Transactions" );
78
79 excludetransfers = new QCheckBox ( this );
80 excludetransfers->setText ( "Include Transfers In Limit View" );
81
82 if ( preferences->getPreference ( 3 ) == 1 )
83 showclearedtransactions->setChecked ( TRUE );
84 else
85 showclearedtransactions->setChecked ( FALSE );
86
87 if ( preferences->getPreference ( 6 ) == 1 )
88 excludetransfers->setChecked ( TRUE );
89 else
90 excludetransfers->setChecked ( FALSE );
91
92 defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this );
93 connect ( defaults, SIGNAL ( released () ), this, SLOT ( setDefaultTransactionPreferences () ) );
94
95 layout = new QVBoxLayout ( this, 2, 2 );
96 layout->addWidget ( showclearedtransactions );
97 layout->addWidget ( excludetransfers );
98 layout->insertSpacing ( 2, 5 );
99 layout->addWidget ( defaults );
100
101 connect ( showclearedtransactions, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeShowClearedPreference ( bool ) ) );
102 connect ( excludetransfers, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeExcludeTranfersPreference ( bool ) ) );
103}
104
105TransactionPreferences::~TransactionPreferences ()
106 {
107 }
108
109void TransactionPreferences::changeShowClearedPreference ( bool state )
110 {
111 if ( state == TRUE )
112 preferences->changePreference ( 3, 1 );
113 else
114 preferences->changePreference ( 3, 0 );
115 }
116
117void TransactionPreferences::changeExcludeTranfersPreference ( bool state )
118 {
119 if ( state == TRUE )
120 preferences->changePreference ( 6, 1 );
121 else
122 preferences->changePreference ( 6, 0 );
123 }
124
125void TransactionPreferences::setDefaultTransactionPreferences ()
126 {
127 preferences->changePreference ( 3, 0 );
128 preferences->changePreference ( 6, 0 );
129 showclearedtransactions->setChecked ( FALSE );
130 }
131
132// START ACCOUNT PREFERNCES
133
134AccountPreferences::AccountPreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE )
135{
136
137 setCaption( tr ( "Account" ) );
138
139 currencysupport = new QCheckBox ( this );
140 currencysupport->setText ( "Enable Currency Support" );
141
142 onetouch = new QCheckBox ( this );
143 onetouch->setText ( "One Touch Account Viewing" );
144
145 if ( preferences->getPreference ( 4 ) == 1 )
146 currencysupport->setChecked ( TRUE );
147 else
148 currencysupport->setChecked ( FALSE );
149
150 if ( preferences->getPreference ( 5 ) == 1 )
151 onetouch->setChecked ( TRUE );
152 else
153 onetouch->setChecked ( FALSE );
154
155 defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this );
156 connect ( defaults, SIGNAL ( released () ), this, SLOT ( setDefaultAccountPreferences () ) );
157
158 layout = new QVBoxLayout ( this, 2, 2 );
159 layout->addWidget ( currencysupport );
160 layout->addWidget ( onetouch );
161 layout->insertSpacing ( 2, 5 );
162 layout->addWidget ( defaults );
163
164 connect ( currencysupport, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeCurrencySupport ( bool ) ) );
165 connect ( onetouch, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeOneTouchViewing ( bool ) ) );
166}
167
168AccountPreferences::~AccountPreferences ()
169 {
170 }
171
172void AccountPreferences::changeCurrencySupport ( bool state )
173 {
174 if ( state == TRUE )
175 preferences->changePreference ( 4, 1 );
176 else
177 preferences->changePreference ( 4, 0 );
178 }
179
180void AccountPreferences::changeOneTouchViewing ( bool state )
181 {
182 if ( state == TRUE )
183 preferences->changePreference ( 5, 1 );
184 else
185 preferences->changePreference ( 5, 0 );
186 }
187
188void AccountPreferences::setDefaultAccountPreferences ()
189 {
190 preferences->changePreference ( 4, 0 );
191 preferences->changePreference ( 5, 0 );
192 currencysupport->setChecked ( FALSE );
193 onetouch->setChecked ( FALSE );
194 }
195
diff --git a/noncore/apps/qashmoney/preferencedialogs.h b/noncore/apps/qashmoney/preferencedialogs.h
new file mode 100755
index 0000000..e96c4bd
--- a/dev/null
+++ b/noncore/apps/qashmoney/preferencedialogs.h
@@ -0,0 +1,84 @@
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
10#ifndef DATEPREFERENCES_H
11#define DATEPREFERENCES_H
12
13class DatePreferences : public QDialog
14 {
15 Q_OBJECT
16
17 public:
18 DatePreferences ( QWidget * parent );
19 ~DatePreferences();
20
21 QPushButton *defaults;
22 QComboBox *dateformat;
23 QComboBox *dateseparator;
24 QBoxLayout *layout;
25
26 public slots:
27 void changeDateFormat ( int );
28 void changeDateSeparator ( int );
29 void setDefaultDatePreferences ();
30};
31
32#endif
33
34#ifndef TRANSACTIONPREFERENCES_H
35#define TRANSACTIONPREFERENCES_H
36
37class TransactionPreferences : public QDialog
38 {
39 Q_OBJECT
40
41 public:
42 TransactionPreferences ( QWidget * parent );
43 ~TransactionPreferences();
44
45 QCheckBox *showclearedtransactions;
46 QCheckBox *excludetransfers;
47 QPushButton *defaults;
48 QBoxLayout *layout;
49
50 public slots:
51 void changeShowClearedPreference ( bool );
52 void changeExcludeTranfersPreference ( bool );
53 void setDefaultTransactionPreferences ();
54};
55
56#endif
57
58#ifndef ACCOUNTPREFERENCES_H
59#define ACCOUNTPREFERENCES_H
60
61class AccountPreferences : public QDialog
62 {
63 Q_OBJECT
64
65 public:
66 AccountPreferences ( QWidget * parent );
67 ~AccountPreferences();
68
69 QCheckBox *currencysupport;
70 QCheckBox *onetouch;
71 QPushButton *defaults;
72 QBoxLayout *layout;
73
74 public slots:
75 void changeCurrencySupport ( bool );
76 void changeOneTouchViewing ( bool );
77 void setDefaultAccountPreferences ();
78};
79
80#endif
81
82
83
84
diff --git a/noncore/apps/qashmoney/preferences.cpp b/noncore/apps/qashmoney/preferences.cpp
new file mode 100755
index 0000000..8783a47
--- a/dev/null
+++ b/noncore/apps/qashmoney/preferences.cpp
@@ -0,0 +1,296 @@
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 ] ) != 6 )
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 }
64
65void Preferences::initializeColumnPreferences ()
66 {
67 int rows = 0;
68 int columns = 0;
69 char **results;
70
71 // initialize accountname column width
72 sqlite_get_table ( db, "select width from columns where id = 1;", &results, &rows, &columns, 0 );
73 if ( rows == 0 )
74 sqlite_exec ( db, "insert into columns values ( 'accountname', 90, 0, 0, 0, NULL );", 0, 0, 0 );
75
76 // initialize accountbalance column width
77 sqlite_get_table ( db, "select width from columns where id = 2;", &results, &rows, &columns, 0 );
78 if ( rows == 0 )
79 sqlite_exec ( db, "insert into columns values ( 'accountbalance', 90, 0, 0, 0, NULL );", 0, 0, 0 );
80
81 // initialize transactiondate column width
82 sqlite_get_table ( db, "select width from columns where id = 3;", &results, &rows, &columns, 0 );
83 if ( rows == 0 )
84 sqlite_exec ( db, "insert into columns values ( 'normaltransactiondate', 50, 0, 0, 0, NULL );", 0, 0, 0 );
85
86 // initialize transactionname column width
87 sqlite_get_table ( db, "select width from columns where id = 4;", &results, &rows, &columns, 0 );
88 if ( rows == 0 )
89 sqlite_exec ( db, "insert into columns values ( 'normaltransactionname', 75, 0, 0, 0, NULL );", 0, 0, 0 );
90
91 // initialize transactionamount column width
92 sqlite_get_table ( db, "select width from columns where id = 5;", &results, &rows, &columns, 0 );
93 if ( rows == 0 )
94 sqlite_exec ( db, "insert into columns values ( 'normaltransactionamount', 50, 0, 0, 0, NULL );", 0, 0, 0 );
95
96 // initialize transactiondate column width
97 sqlite_get_table ( db, "select width from columns where id = 6;", &results, &rows, &columns, 0 );
98 if ( rows == 0 )
99 sqlite_exec ( db, "insert into columns values ( 'extendedtransactiondate', 50, 0, 0, 0, NULL );", 0, 0, 0 );
100
101 // initialize transactionname column width
102 sqlite_get_table ( db, "select width from columns where id = 7;", &results, &rows, &columns, 0 );
103 if ( rows == 0 )
104 sqlite_exec ( db, "insert into columns values ( 'extendedtransactionname', 75, 0, 0, 0, NULL );", 0, 0, 0 );
105
106 // initialize transactionamount column width
107 sqlite_get_table ( db, "select width from columns where id = 8;", &results, &rows, &columns, 0 );
108 if ( rows == 0 )
109 sqlite_exec ( db, "insert into columns values ( 'extendedtransactionamount', 50, 0, 0, 0, NULL );", 0, 0, 0 );
110
111 // initialize transactionaccount column width
112 sqlite_get_table ( db, "select width from columns where id = 9;", &results, &rows, &columns, 0 );
113 if ( rows == 0 )
114 sqlite_exec ( db, "insert into columns values ( 'transactionaccount', 50, 0, 0, 0, NULL );", 0, 0, 0 );
115
116 // initialize account name with currency column width
117 sqlite_get_table ( db, "select width from columns where id = 10;", &results, &rows, &columns, 0 );
118 if ( rows == 0 )
119 sqlite_exec ( db, "insert into columns values ( 'accountnamewithcurrency', 100, 0, 0, 0, NULL );", 0, 0, 0 );
120
121 // initialize account currency column width
122 sqlite_get_table ( db, "select width from columns where id = 11;", &results, &rows, &columns, 0 );
123 if ( rows == 0 )
124 sqlite_exec ( db, "insert into columns values ( 'currencycolumn', 10, 0, 0, 0, NULL );", 0, 0, 0 );
125
126 // initialize account balance with currency column width
127 sqlite_get_table ( db, "select width from columns where id = 12;", &results, &rows, &columns, 0 );
128 if ( rows == 0 )
129 sqlite_exec ( db, "insert into columns values ( 'accountbalancewithcurrency', 50, 0, 0, 0, NULL );", 0, 0, 0 );
130
131 // initialize budget line item column
132 sqlite_get_table ( db, "select width from columns where id = 13;", &results, &rows, &columns, 0 );
133 if ( rows == 0 )
134 sqlite_exec ( db, "insert into columns values ( 'budgetlineitem', 50, 0, 0, 0, NULL );", 0, 0, 0 );
135
136 // initialize budget budget column
137 sqlite_get_table ( db, "select width from columns where id = 14;", &results, &rows, &columns, 0 );
138 if ( rows == 0 )
139 sqlite_exec ( db, "insert into columns values ( 'budgetbudget', 50, 0, 0, 0, NULL );", 0, 0, 0 );
140
141 // initialize budget actual column
142 sqlite_get_table ( db, "select width from columns where id = 15;", &results, &rows, &columns, 0 );
143 if ( rows == 0 )
144 sqlite_exec ( db, "insert into columns values ( 'budgetactual', 50, 0, 0, 0, NULL );", 0, 0, 0 );
145 }
146
147void Preferences::changeColumnPreference ( int id, int width )
148 {
149 sqlite_exec_printf ( db, "update columns set width = %i where id = %i;", 0, 0, 0, width, id );
150 }
151
152int Preferences::getColumnPreference ( int id )
153 {
154 char **results;
155 sqlite_get_table_printf ( db, "select width from columns where id = %i;", &results, NULL, NULL, NULL, id );
156 return atoi ( results [ 1 ] );
157 }
158
159int Preferences::getPreference ( int id )
160 {
161 char **results;
162 sqlite_get_table_printf ( db, "select preference from preferences where id = %i;", &results, NULL, NULL, NULL, id );
163 return atoi ( results [ 1 ] );
164 }
165
166QString Preferences::getSeparator ( )
167 {
168 int s = getPreference ( 2 );
169 if ( s == 1 )
170 return "/";
171 if ( s ==2 )
172 return "-";
173 else
174 return ".";
175 }
176
177void Preferences::changePreference ( int id, int newpreference )
178 {
179 sqlite_exec_printf ( db, "update preferences set preference = %i where id = %i;", 0, 0, 0, newpreference, id );
180 }
181
182void Preferences::setDefaultDatePreferences ()
183 {
184 sqlite_exec ( db, "update preferences set preference = 4 where id = 1;", 0, 0, 0 );
185 sqlite_exec ( db, "update preferences set preference = 1 where id = 2;", 0, 0, 0 );
186 }
187
188QString Preferences::getDate ( int y, int m, int d )
189 {
190 QString date;
191 int format = getPreference ( 1 );
192 QString separator = getSeparator();
193
194 // Convert all date integers to QStrings
195 QString year = QString::number ( y );
196 QString month = QString::number ( m );
197 if ( m < 10 )
198 month.prepend ( "0" );
199 QString day = QString::number ( d );
200 if ( d < 10 )
201 day.prepend ( "0" );
202
203 // Truncate four digit year if necessary
204 if ( format == 2 || format == 4 || format == 6 || format == 8 )
205 year.remove ( 0, 2 );
206
207 // Concatenate dates as necessary
208 if ( format == 1 || format == 2 )
209 {
210 date = year;
211 date.append ( separator );
212 date.append ( month );
213 date.append ( separator );
214 date.append ( day );
215 return date;
216 }
217 if ( format == 3 || format == 4 )
218 {
219 date = month;
220 date.append ( separator );
221 date.append ( day );
222 date.append ( separator );
223 date.append ( year );
224 return date;
225 }
226 if ( format == 5 || format == 6 )
227 {
228 date = year;
229 date.append ( separator );
230 date.append ( day );
231 date.append ( separator );
232 date.append ( month );
233 return date;
234 }
235 if ( format == 7 || format == 8 )
236 {
237 date = day;
238 date.append ( separator );
239 date.append ( month );
240 date.append ( separator );
241 date.append ( year );
242 return date;
243 }
244 }
245
246QString Preferences::getDate ( int y, int m )
247 {
248 QString date;
249 int format = getPreference ( 1 );
250 QString separator = getSeparator();
251
252 // Convert all date integers to QStrings
253 QString year = QString::number ( y );
254 QString month = QString::number ( m );
255 if ( m < 10 )
256 month.prepend ( "0" );
257
258 // Truncate four digit year if necessary
259 if ( format == 2 || format == 4 || format == 6 || format == 8 )
260 year.remove ( 0, 2 );
261
262 // Concatenate dates as necessary
263 if ( format == 1 || format == 2 )
264 {
265 date = year;
266 date.append ( separator );
267 date.append ( month );
268 return date;
269 }
270 if ( format == 3 || format == 4 )
271 {
272 date = month;
273 date.append ( separator );
274 date.append ( year );
275 return date;
276 }
277 if ( format == 5 || format == 6 )
278 {
279 date = year;
280 date.append ( separator );
281 date.append ( month );
282 return date;
283 }
284 if ( format == 7 || format == 8 )
285 {
286 date.append ( month );
287 date.append ( separator );
288 date.append ( year );
289 return date;
290 }
291 }
292
293
294
295
296
diff --git a/noncore/apps/qashmoney/transactiondisplay.cpp b/noncore/apps/qashmoney/transactiondisplay.cpp
new file mode 100755
index 0000000..6e5c4f6
--- a/dev/null
+++ b/noncore/apps/qashmoney/transactiondisplay.cpp
@@ -0,0 +1,586 @@
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 "preferences.h"
8#include "calculator.h"
9#include "datepicker.h"
10
11#include <qdatetime.h>
12#include <qmessagebox.h>
13#include <qheader.h>
14#include <qmultilineedit.h>
15#include <iostream.h>
16#include <qdatetime.h>
17
18extern Transaction *transaction;
19extern Budget *budget;
20extern Account *account;
21extern Preferences *preferences;
22extern Memory *memory;
23extern Transfer *transfer;
24
25TransactionDisplay::TransactionDisplay ( QWidget* parent ) : QWidget ( parent )
26 {
27 // set transactiondisplay variables;
28 accountid = 0;
29 children = TRUE;
30
31 firstline = new QHBox ( this );
32 firstline->setSpacing ( 2 );
33
34 newtransaction = new QPushButton ( firstline );
35 newtransaction->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/new.png") );
36 connect ( newtransaction, SIGNAL ( released () ), this, SLOT ( addTransaction () ) );
37
38 edittransaction = new QPushButton ( firstline );
39 edittransaction->setPixmap( QPixmap ("/opt/QtPalmtop/pics/edit.png") );
40 connect ( edittransaction, SIGNAL ( released () ), this, SLOT ( checkListViewEdit () ) );
41
42 deletetransaction = new QPushButton ( firstline );
43 deletetransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/delete.png") );
44 connect ( deletetransaction, SIGNAL ( released () ), this, SLOT ( checkListViewDelete () ) );
45
46 toggletransaction = new QPushButton ( firstline );
47 toggletransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/redo.png") );
48 connect ( toggletransaction, SIGNAL ( released () ), this, SLOT ( checkListViewToggle () ) );
49
50 viewtransactionnotes = new QPushButton ( firstline );
51 viewtransactionnotes->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/info.png") );
52 connect ( viewtransactionnotes, SIGNAL ( released () ), this, SLOT ( showTransactionNotes () ) );
53
54 secondline = new QHBox ( this );
55 secondline->setSpacing ( 5 );
56
57 name = new QLabel ( secondline );
58 balance = new QLabel ( secondline );
59
60 QLabel *limit = new QLabel ( "Limit", secondline );
61 limitbox = new QLineEdit ( secondline );
62 limitbox->setMinimumWidth ( ( int ) ( this->width() / 6 ) );
63 connect ( limitbox, SIGNAL ( textChanged ( const QString & ) ), this, SLOT ( limitDisplay ( const QString & ) ) );
64
65 listview = new QListView ( this );
66 listview->setAllColumnsShowFocus ( TRUE );
67 listview->setShowSortIndicator ( TRUE );
68 listview->header()->setTracking ( FALSE );
69 connect ( listview->header(), SIGNAL ( sizeChange ( int, int, int ) ), this, SLOT ( saveColumnSize ( int, int, int ) ) );
70
71 layout = new QVBoxLayout ( this, 2, 2 );
72 layout->addWidget ( firstline );
73 layout->addWidget ( secondline );
74 layout->addWidget ( listview );
75 }
76
77void TransactionDisplay::addTransaction ()
78 {
79 // create local variables
80 int cleared = -1;
81
82 // create new transaction window
83 NewTransaction *newtransaction = new NewTransaction ( this );
84 int width = this->size().width();
85 newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) );
86 newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) );
87 newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) );
88 newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
89 newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
90 newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) );
91
92 // enter today's date in the date box as defaul
93 QDate today = QDate::currentDate ();
94 int defaultday = today.day();
95 int defaultmonth = today.month();
96 int defaultyear = today.year();
97 newtransaction->transactiondate->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) );
98
99 // add memory items to the transactionname combobox
100 memory->displayMemoryItems ( newtransaction->transactionname );
101 newtransaction->transactionname->insertItem ( "", 0 );
102
103 if ( newtransaction->exec () == QDialog::Accepted )
104 {
105 if ( newtransaction->clearedcheckbox->isChecked () == TRUE ) // set a parent id and type for a child transaction
106 cleared = 1;
107 else
108 cleared = 0;
109
110 float amount = newtransaction->transactionamount->text().toFloat();
111 if ( newtransaction->depositbox->isChecked() == FALSE )
112 amount = amount * -1;
113
114 // add the transaction name to the memory items
115 memory->addMemoryItem ( newtransaction->transactionname->currentText() );
116
117 // add the transaction
118 if ( newtransaction->getDateEdited () == TRUE )
119 transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ),
120 newtransaction->transactionnumber->text().toInt(), newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(), amount, cleared, newtransaction->getCurrentBudget(),
121 newtransaction->getCurrentLineItem() );
122 else
123 transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ),
124 newtransaction->transactionnumber->text().toInt(), defaultday, defaultmonth, defaultyear, amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem() );
125
126 // redisplay transactions
127 listview->clear();
128 QString displaytext = "%";
129 displaytext.prepend ( limitbox->text() );
130 if ( transaction->getNumberOfTransactions() > 0 )
131 transaction->displayTransactions ( listview, accountid, children, displaytext );
132
133 // redisplay transfers
134 if ( transfer->getNumberOfTransfers() > 0 )
135 transfer->displayTransfers ( listview, accountid, children );
136
137 // add the transaction amount to the account it's associated with
138 // and update its parent account balance if necessary
139 account->updateAccountBalance ( accountid );
140 if ( account->getParentAccountID ( accountid ) != -1 )
141 account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) );
142
143 // format then reset the account balance
144 redisplayAccountBalance ();
145 }
146 }
147
148void TransactionDisplay::checkListViewEdit ()
149 {
150 if ( listview->selectedItem() == 0 )
151 QMessageBox::warning ( this, "QashMoney", "Please select a transaction\nto edit.");
152 else if ( listview->currentItem()->text ( getIDColumn() ).toInt() < 0 )
153 editTransfer ();
154 else
155 editTransaction();
156 }
157
158void TransactionDisplay::showCalculator ()
159 {
160 Calculator *calculator = new Calculator ( this );
161 if ( calculator->exec () == QDialog::Accepted )
162 amount->setText ( calculator->display->text() );
163 }
164
165void TransactionDisplay::showCalendar ()
166 {
167 QDate newDate = QDate::currentDate ();
168 DatePicker *dp = new DatePicker ( newDate );
169 if ( dp->exec () == QDialog::Accepted )
170 {
171 year = dp->getYear();
172 month = dp->getMonth();
173 day = dp->getDay();
174 date->setText ( preferences->getDate ( year, month, day ) );
175 }
176 }
177
178void TransactionDisplay::editTransfer ()
179 {
180 transferid = listview->currentItem()->text ( getIDColumn() ).toInt();
181 fromaccount = transfer->getFromAccountID ( transferid );
182 toaccount = transfer->getToAccountID ( transferid );
183 year = transfer->getYear ( transferid );
184 month = transfer->getMonth ( transferid );
185 day = transfer->getDay ( transferid );
186
187 QDialog *editransfer = new QDialog ( this, "edittransfer", TRUE );
188 editransfer->setCaption ( "Transfer" );
189
190 QStringList accountnames = account->getAccountNames();
191 QStringList accountids = account->getAccountIDs();
192
193 QLabel *fromaccountlabel = new QLabel ( "From Account:", editransfer );
194 QFont f = this->font();
195 f.setWeight ( QFont::Bold );
196 fromaccountlabel->setFont ( f );
197
198 QComboBox *fromaccountbox = new QComboBox ( editransfer );
199 fromaccountbox->insertStringList ( accountnames );
200 fromaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( fromaccount ) ) );
201
202 QLabel *toaccountlabel = new QLabel ( "To Account:", editransfer );
203 toaccountlabel->setFont ( f );
204
205 QComboBox *toaccountbox = new QComboBox ( editransfer );
206 toaccountbox->insertStringList ( accountnames );
207 toaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( toaccount ) ) );
208
209 QLabel *datelabel = new QLabel ( "Date", editransfer );
210 QHBox *datebox = new QHBox ( editransfer );
211 datebox->setSpacing ( 2 );
212 date = new QLineEdit ( datebox );
213 date->setAlignment ( Qt::AlignRight );
214 date->setDisabled ( TRUE );
215 date->setText ( preferences->getDate ( year, month, day ) );
216 QPushButton *datebutton = new QPushButton ( datebox );
217 datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) );
218 connect ( datebutton, SIGNAL ( released () ), this, SLOT ( showCalendar () ) );
219
220 QLabel *amounttlabel = new QLabel ( "Amount", editransfer );
221
222 QHBox *amountbox = new QHBox ( editransfer );
223 amountbox->setSpacing ( 2 );
224 amount = new QLineEdit ( amountbox );
225 amount->setAlignment ( Qt::AlignRight );
226 amount->setText ( transfer->getAmount ( transferid ) );
227 QPushButton *calculatorbutton = new QPushButton( amountbox );
228 calculatorbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) );
229 connect ( calculatorbutton, SIGNAL ( released() ), this, SLOT ( showCalculator() ) );
230
231 QCheckBox *clearedcheckbox = new QCheckBox ( "Cleared", editransfer );
232
233 QBoxLayout *layout = new QVBoxLayout ( editransfer, 4, 2 );
234 layout->addWidget ( fromaccountlabel, Qt::AlignLeft );
235 layout->addWidget ( fromaccountbox, Qt::AlignLeft );
236 layout->addWidget ( toaccountlabel, Qt::AlignLeft );
237 layout->addWidget ( toaccountbox, Qt::AlignLeft );
238 layout->addSpacing ( 5 );
239 layout->addWidget ( datelabel, Qt::AlignLeft );
240 layout->addWidget ( datebox, Qt::AlignLeft );
241 layout->addWidget ( amounttlabel, Qt::AlignLeft );
242 layout->addWidget ( amountbox, Qt::AlignLeft );
243 layout->addWidget ( clearedcheckbox, Qt::AlignLeft );
244
245 if ( editransfer->exec() == QDialog::Accepted )
246 {
247 //get fromaccount
248 fromaccount = ( accountids.operator[] ( fromaccountbox->currentItem() ) ).toInt();
249
250 //get to account
251 toaccount = ( accountids.operator[] ( toaccountbox->currentItem() ) ).toInt();
252
253 //set cleared flag
254 int cleared = 0;
255 if ( clearedcheckbox->isChecked() == TRUE )
256 cleared = 1;
257
258 //update transfer
259 transfer->updateTransfer ( fromaccount, account->getParentAccountID ( fromaccount ), toaccount, account->getParentAccountID ( toaccount ),
260 day, month, year, amount->text().toFloat(), cleared, transferid );
261
262 account->updateAccountBalance ( fromaccount );
263 if ( account->getParentAccountID ( fromaccount ) != -1 )
264 account->changeParentAccountBalance ( fromaccount );
265
266 updateAndDisplay ( toaccount );
267 }
268 }
269
270void TransactionDisplay::editTransaction ()
271 {
272 int cleared;
273
274 // set the transaction id and budgetid
275 int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt();
276 int budgetid = transaction->getBudgetID ( transactionid );
277 int lineitemid = transaction->getLineItemID ( transactionid );
278
279 // create edit transaction window
280 NewTransaction *newtransaction = new NewTransaction ( this );
281 int width = this->width();
282 newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) );
283 newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) );
284 newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) );
285 newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
286 newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
287 newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) );
288
289 // enter the date in the date box
290 newtransaction->year = transaction->getYear ( transactionid );
291 newtransaction->month = transaction->getMonth ( transactionid );
292 newtransaction->day = transaction->getDay ( transactionid );
293 newtransaction->transactiondate->setText ( preferences->getDate ( newtransaction->year, newtransaction->month, newtransaction->day ) );
294
295 // set the description
296 newtransaction->setDescription ( transaction->getTransactionDescription ( transactionid ) );
297
298 // add memory items to the transactionname combobox
299 memory->displayMemoryItems ( newtransaction->transactionname );
300
301 // add correct transaction name
302 newtransaction->transactionname->setEditText ( transaction->getPayee ( transactionid ) );
303
304 // add transaction number
305 newtransaction->transactionnumber->setText ( transaction->getNumber ( transactionid ) );
306
307 // add transaction amount
308 newtransaction->transactionamount->setText ( transaction->getAbsoluteAmount ( transactionid ) );
309
310 // check for and set the correct budget
311 if ( budgetid >= 1 ) // only do it if this transaction has a budget and line item
312 {
313 newtransaction->budgetbox->setCurrentItem ( newtransaction->getBudgetIndex ( budgetid ) + 1 );
314 if ( lineitemid >= 1 )
315 {
316 newtransaction->setLineItems ();
317 newtransaction->lineitembox->setCurrentItem ( newtransaction->getLineItemIndex ( lineitemid ) );
318 }
319 else
320 {
321 newtransaction->lineitemlabel->setEnabled ( FALSE );
322 newtransaction->lineitembox->setEnabled ( FALSE );
323 }
324 }
325 else
326 {
327 newtransaction->lineitemlabel->setEnabled ( FALSE );
328 newtransaction->lineitembox->setEnabled ( FALSE );
329 }
330
331 // check cleared checkbox if necessary
332 if ( transaction->getCleared ( transactionid ) == 1 )
333 newtransaction->clearedcheckbox->setChecked ( TRUE );
334
335 // check deposit box if necessary
336 if ( transaction->getAmount ( transactionid ).toFloat() > 0 )
337 newtransaction->depositbox->setChecked ( TRUE );
338
339 if ( newtransaction->exec () == QDialog::Accepted )
340 {
341 if ( newtransaction->clearedcheckbox->isChecked () == TRUE )
342 cleared = 1;
343 else
344 cleared = 0;
345
346 float amount = newtransaction->transactionamount->text().toFloat();
347 if ( newtransaction->depositbox->isChecked() == FALSE )
348 amount = amount * -1;
349
350 // add the transaction name to the memory items
351 memory->addMemoryItem ( newtransaction->transactionname->currentText() );
352
353 // update the transaction
354 transaction->updateTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), newtransaction->transactionnumber->text().toInt(),
355 newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(),
356 amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem(), transactionid );
357
358 updateAndDisplay ( transaction->getAccountID ( transactionid ) );
359 }
360 }
361
362void TransactionDisplay::updateAndDisplay ( int id )
363 {
364 // redisplay transactions
365 listview->clear();
366 QString displaytext = "%";
367 displaytext.prepend ( limitbox->text() );
368 if ( transaction->getNumberOfTransactions() > 0 )
369 transaction->displayTransactions ( listview, accountid, children, displaytext );
370
371 // redisplay transfers
372 if ( transfer->getNumberOfTransfers() > 0 )
373 transfer->displayTransfers ( listview, accountid, children );
374
375 // add the transaction amount to the account it's associated with
376 // and update its parent account balance if necessary
377 account->updateAccountBalance ( id );
378 if ( account->getParentAccountID ( id ) != -1 )
379 account->changeParentAccountBalance ( account->getParentAccountID ( id ) );
380
381 // format then reset the account balance
382 redisplayAccountBalance ();
383 }
384
385void TransactionDisplay::checkListViewDelete ()
386 {
387 if ( listview->selectedItem() == 0 )
388 QMessageBox::warning ( this, "QashMoney", "Please select a transaction to\ndelete.");
389 else
390 deleteTransaction ();
391 }
392
393void TransactionDisplay::deleteTransaction ()
394 {
395 int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt();
396
397 if ( transactionid > 0 ) // takes care of deleting transactions
398 {
399 // check if we are viewing child transactions through a parent
400 // in that case we will have to update balances for the parent
401 // which is represented by accountid and the child account
402 // which will be represented by childaccountid
403 int childaccountid = -1;
404 if ( listview->columns() == 5 )
405 childaccountid = transaction->getAccountID ( transactionid );
406
407 transaction->deleteTransaction ( transactionid );
408
409 listview->clear();
410 QString displaytext = "%";
411 displaytext.prepend ( limitbox->text() );
412 if ( transaction->getNumberOfTransactions() > 0 )
413 transaction->displayTransactions ( listview, accountid, children, displaytext );
414
415 if ( transfer->getNumberOfTransfers() > 0 )
416 transfer->displayTransfers ( listview, accountid, children );
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 if ( transaction->getNumberOfTransactions() > 0 )
444 transaction->displayTransactions ( listview, accountid, children, displaytext );
445
446 if ( transfer->getNumberOfTransfers() > 0 )
447 transfer->displayTransfers ( listview, accountid, children );
448
449 // for the from account
450 account->updateAccountBalance ( fromaccountid );
451 if ( account->getParentAccountID ( fromaccountid ) != -1 )
452 account->changeParentAccountBalance ( account->getParentAccountID ( fromaccountid ) );
453
454 // for the to account
455 account->updateAccountBalance ( toaccountid );
456 if ( account->getParentAccountID ( toaccountid ) != -1 )
457 account->changeParentAccountBalance ( account->getParentAccountID ( toaccountid ) );
458
459 // format then reset the account balance
460 redisplayAccountBalance ();
461 }
462 }
463
464void TransactionDisplay::checkListViewToggle ()
465 {
466 if ( listview->selectedItem() == 0 )
467 QMessageBox::warning ( this, "QashMoney", "Please select a transaction to\nclear or reset.");
468 else
469 toggleTransaction ();
470 }
471
472void TransactionDisplay::toggleTransaction ()
473 {
474 //get the transaction of the selected transaction to determine if its a transaction or transfer
475 int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt();
476
477 if ( transactionid > 0 ) // if this is a transaction
478 {
479 if ( transaction->getCleared ( transactionid ) == 0 )
480 transaction->setCleared ( transactionid, 1 );
481 else
482 transaction->setCleared ( transactionid, 0 );
483 }
484 else
485 {
486 if ( transfer->getCleared ( transactionid ) == 0 )
487 transfer->setCleared ( transactionid, 1 );
488 else
489 transfer->setCleared ( transactionid, 0 );
490 }
491
492 listview->clear();
493 QString displaytext = "%";
494 displaytext.prepend ( limitbox->text() );
495 if ( transaction->getNumberOfTransactions() > 0 )
496 transaction->displayTransactions ( listview, accountid, children, displaytext );
497
498 if ( transfer->getNumberOfTransfers() != 0 )
499 transfer->displayTransfers ( listview, accountid, children );
500 }
501
502void TransactionDisplay::redisplayAccountBalance ()
503 {
504 QString accountbalance = account->getAccountBalance ( accountid );
505 balance->setText ( accountbalance );
506 }
507
508void TransactionDisplay::setChildren ( bool c )
509 {
510 children = c;
511 }
512
513void TransactionDisplay::setAccountID ( int id )
514 {
515 accountid = id;
516 }
517
518ColorListItem::ColorListItem ( QListView *parent ) : QListViewItem ( parent )
519 {
520 }
521
522ColorListItem::ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4 )
523 : QListViewItem ( parent, label1, label2, label3, label4 )
524 {
525 }
526
527ColorListItem::ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4, QString label5 )
528 : QListViewItem ( parent, label1, label2, label3, label4, label5 )
529 {
530 }
531
532void ColorListItem::paintCell ( QPainter *p, const QColorGroup &cg, int column, int width, int alignment )
533 {
534 QColorGroup _cg ( cg );
535 _cg.setColor ( QColorGroup::Text, Qt::red );
536 QListViewItem::paintCell ( p, _cg, column, width, alignment );
537 }
538
539void TransactionDisplay::saveColumnSize ( int column, int oldsize, int newsize )
540 {
541 if ( listview->columns() == 4 )
542 preferences->changeColumnPreference ( column + 3, newsize );
543 else if ( listview->columns() == 5 && column != 4 )
544 preferences->changeColumnPreference ( column + 6, newsize );
545 else
546 preferences->changeColumnPreference ( 9, newsize );
547 }
548
549void TransactionDisplay::limitDisplay ( const QString &text )
550 {
551 listview->clear ();
552 QString displaytext = "%";
553 displaytext.prepend ( text );
554 transaction->displayTransactions ( listview, accountid, children, displaytext );
555 if ( displaytext.length() == 1 || preferences->getPreference ( 6 ) == 1 )
556 transfer->displayTransfers ( listview, accountid, children );
557 }
558
559int TransactionDisplay::getIDColumn ()
560 {
561 int counter;
562 int columns = listview->columns();
563 for ( counter = 0; counter <= columns; counter++ )
564 if ( listview->header()->label ( counter ).length() == 0 )
565 return counter;
566 }
567
568void TransactionDisplay::showTransactionNotes ()
569 {
570 if ( listview->selectedItem() == 0 || listview->currentItem()->text ( getIDColumn() ).toInt() < 0 )
571 QMessageBox::warning ( this, "QashMoney", "Please select a valid\ntransaction to view notes.");
572 else
573 {
574 int transactionid = listview->selectedItem()->text ( getIDColumn() ).toInt ();
575 QDialog *description = new QDialog ( this, "description", TRUE );
576 description->setCaption ( "Notes" );
577 QMultiLineEdit *notes = new QMultiLineEdit ( description );
578 notes->setFixedSize ( ( int ) (this->width() * 0.75 ), ( int ) ( this->height() * 0.5 ) );
579 notes->setWrapColumnOrWidth ( ( int ) (this->width() * 0.75 ) );
580 notes->setWordWrap ( QMultiLineEdit::WidgetWidth );
581 notes->setEnabled ( FALSE );
582 notes->setText ( transaction->getTransactionDescription ( transactionid ) );
583 description->show();
584 }
585 }
586