summaryrefslogtreecommitdiff
authorallenforsythe <allenforsythe>2003-05-16 20:08:38 (UTC)
committer allenforsythe <allenforsythe>2003-05-16 20:08:38 (UTC)
commite6ff2dbd2d128c3cf873e23f4df8006759b47079 (patch) (unidiff)
treebb3c996b76c8937d871f642f0e32032848d32396
parent87051a7ba4834aed152bc09aad7f4935c9729ccb (diff)
downloadopie-e6ff2dbd2d128c3cf873e23f4df8006759b47079.zip
opie-e6ff2dbd2d128c3cf873e23f4df8006759b47079.tar.gz
opie-e6ff2dbd2d128c3cf873e23f4df8006759b47079.tar.bz2
Working on time frame for displaying cleared transactions. Not yet working.
Diffstat (more/less context) (ignore whitespace changes)
-rwxr-xr-xnoncore/apps/qashmoney/install/CONTROL/opie-qashmoney.control2
-rwxr-xr-xnoncore/apps/qashmoney/preferencedialogs.cpp13
-rwxr-xr-xnoncore/apps/qashmoney/preferences.cpp2
-rwxr-xr-xnoncore/apps/qashmoney/qashmoney.cpp42
-rwxr-xr-xnoncore/apps/qashmoney/qashmoney.h3
-rwxr-xr-xnoncore/apps/qashmoney/qmaccounts.dbbin4096 -> 6144 bytes
-rwxr-xr-xnoncore/apps/qashmoney/qmbudgets.dbbin3072 -> 4096 bytes
-rwxr-xr-xnoncore/apps/qashmoney/qmmemory.dbbin4096 -> 10240 bytes
-rwxr-xr-xnoncore/apps/qashmoney/qmpreferences.dbbin4096 -> 4096 bytes
-rwxr-xr-xnoncore/apps/qashmoney/qmtransactions.dbbin4096 -> 24576 bytes
-rwxr-xr-xnoncore/apps/qashmoney/qmtransfers.dbbin3072 -> 3072 bytes
-rwxr-xr-xnoncore/apps/qashmoney/transaction.cpp20
-rwxr-xr-xnoncore/apps/qashmoney/transaction.h3
-rwxr-xr-xnoncore/apps/qashmoney/transactiondisplay.cpp49
-rwxr-xr-xnoncore/apps/qashmoney/transactiondisplay.h3
15 files changed, 106 insertions, 31 deletions
diff --git a/noncore/apps/qashmoney/install/CONTROL/opie-qashmoney.control b/noncore/apps/qashmoney/install/CONTROL/opie-qashmoney.control
index ffd11db..b00e3b1 100755
--- a/noncore/apps/qashmoney/install/CONTROL/opie-qashmoney.control
+++ b/noncore/apps/qashmoney/install/CONTROL/opie-qashmoney.control
@@ -1,7 +1,7 @@
1Package: qashmoney 1Package: qashmoney
2Priority: optional 2Priority: optional
3Version: 0.74 3Version: 0.75
4Architecture: arm 4Architecture: arm
5Maintainer: Allen Forsythe qashmoneyman@attbi.com 5Maintainer: Allen Forsythe qashmoneyman@attbi.com
6Section: Applications 6Section: Applications
7Description: QashMoney provides an intuitive and fast way to keep track of your accounts and budgets. 7Description: QashMoney provides an intuitive and fast way to keep track of your accounts and budgets.
diff --git a/noncore/apps/qashmoney/preferencedialogs.cpp b/noncore/apps/qashmoney/preferencedialogs.cpp
index 00d52c6..d7c66d3 100755
--- a/noncore/apps/qashmoney/preferencedialogs.cpp
+++ b/noncore/apps/qashmoney/preferencedialogs.cpp
@@ -1,216 +1,217 @@
1#include "preferencedialogs.h" 1#include "preferencedialogs.h"
2#include "preferences.h" 2#include "preferences.h"
3#include <qlabel.h> 3#include <qlabel.h>
4 4
5extern Preferences *preferences; 5extern Preferences *preferences;
6 6
7DatePreferences::DatePreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE ) 7DatePreferences::DatePreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE )
8 { 8 {
9 setCaption( tr( "Date" ) ); 9 setCaption( tr( "Date" ) );
10 10
11 QLabel *datelabel = new QLabel ( "Format", this ); 11 QLabel *datelabel = new QLabel ( "Format", this );
12 dateformat = new QComboBox ( this ); 12 dateformat = new QComboBox ( this );
13 dateformat->setEditable ( FALSE ); 13 dateformat->setEditable ( FALSE );
14 dateformat->insertItem ( "yyyymmdd" ); 14 dateformat->insertItem ( "yyyymmdd" );
15 dateformat->insertItem ( "yymmdd" ); 15 dateformat->insertItem ( "yymmdd" );
16 dateformat->insertItem ( "mmddyyyy" ); 16 dateformat->insertItem ( "mmddyyyy" );
17 dateformat->insertItem ( "mmddyy" ); 17 dateformat->insertItem ( "mmddyy" );
18 dateformat->insertItem ( "yyyyddmm" ); 18 dateformat->insertItem ( "yyyyddmm" );
19 dateformat->insertItem ( "yyddmm" ); 19 dateformat->insertItem ( "yyddmm" );
20 dateformat->insertItem ( "ddmmyyyy" ); 20 dateformat->insertItem ( "ddmmyyyy" );
21 dateformat->insertItem ( "ddmmyy" ); 21 dateformat->insertItem ( "ddmmyy" );
22 connect ( dateformat, SIGNAL ( activated ( int ) ), this, SLOT ( changeDateFormat ( int ) ) ); 22 connect ( dateformat, SIGNAL ( activated ( int ) ), this, SLOT ( changeDateFormat ( int ) ) );
23 23
24 QLabel *dateseparatorlabel = new QLabel ( "Separator", this ); 24 QLabel *dateseparatorlabel = new QLabel ( "Separator", this );
25 dateseparator = new QComboBox ( this ); 25 dateseparator = new QComboBox ( this );
26 dateseparator->insertItem ( "/" ); 26 dateseparator->insertItem ( "/" );
27 dateseparator->insertItem ( "-" ); 27 dateseparator->insertItem ( "-" );
28 dateseparator->insertItem ( "." ); 28 dateseparator->insertItem ( "." );
29 connect ( dateseparator, SIGNAL ( activated ( int ) ), this, SLOT ( changeDateSeparator ( int ) ) ); 29 connect ( dateseparator, SIGNAL ( activated ( int ) ), this, SLOT ( changeDateSeparator ( int ) ) );
30 30
31 defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this ); 31 defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this );
32 connect ( defaults, SIGNAL ( released () ), this, SLOT ( setDefaultDatePreferences () ) ); 32 connect ( defaults, SIGNAL ( released () ), this, SLOT ( setDefaultDatePreferences () ) );
33 33
34 dateformat->setCurrentItem ( ( preferences->getPreference ( 1 ) ) - 1 ); 34 dateformat->setCurrentItem ( ( preferences->getPreference ( 1 ) ) - 1 );
35 dateseparator->setCurrentItem ( ( preferences->getPreference ( 2 ) ) - 1 ); 35 dateseparator->setCurrentItem ( ( preferences->getPreference ( 2 ) ) - 1 );
36 36
37 layout = new QVBoxLayout ( this, 2, 2 ); 37 layout = new QVBoxLayout ( this, 2, 2 );
38 layout->addWidget ( datelabel ); 38 layout->addWidget ( datelabel );
39 layout->addWidget ( dateformat ); 39 layout->addWidget ( dateformat );
40 layout->addWidget ( dateseparatorlabel ); 40 layout->addWidget ( dateseparatorlabel );
41 layout->addWidget ( dateseparator ); 41 layout->addWidget ( dateseparator );
42 layout->insertSpacing ( 4, 5 ); 42 layout->insertSpacing ( 4, 5 );
43 layout->addWidget ( defaults ); 43 layout->addWidget ( defaults );
44 44
45 } 45 }
46 46
47DatePreferences::~DatePreferences () 47DatePreferences::~DatePreferences ()
48 { 48 {
49 } 49 }
50 50
51void DatePreferences::changeDateFormat ( int index ) 51void DatePreferences::changeDateFormat ( int index )
52 { 52 {
53 index ++; 53 index ++;
54 preferences->changePreference ( 1, index ); 54 preferences->changePreference ( 1, index );
55 } 55 }
56 56
57void DatePreferences::changeDateSeparator ( int index ) 57void DatePreferences::changeDateSeparator ( int index )
58 { 58 {
59 index ++; 59 index ++;
60 preferences->changePreference ( 2, index ); 60 preferences->changePreference ( 2, index );
61 } 61 }
62 62
63void DatePreferences::setDefaultDatePreferences () 63void DatePreferences::setDefaultDatePreferences ()
64 { 64 {
65 preferences->setDefaultDatePreferences (); 65 preferences->setDefaultDatePreferences ();
66 dateformat->setCurrentItem ( ( preferences->getPreference ( 1 ) ) - 1 ); 66 dateformat->setCurrentItem ( ( preferences->getPreference ( 1 ) ) - 1 );
67 dateseparator->setCurrentItem ( ( preferences->getPreference ( 2 ) ) - 1 ); 67 dateseparator->setCurrentItem ( ( preferences->getPreference ( 2 ) ) - 1 );
68 } 68 }
69 69
70// START TRANSACTION PREFERENCES 70// START TRANSACTION PREFERENCES
71 71
72TransactionPreferences::TransactionPreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE ) 72TransactionPreferences::TransactionPreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE )
73{ 73{
74 setCaption( tr ( "Transaction" ) ); 74 setCaption( tr ( "Transaction" ) );
75 75
76 showclearedtransactions = new QCheckBox ( this ); 76 showclearedtransactions = new QCheckBox ( this );
77 showclearedtransactions->setText ( "Show Cleared Transactions" ); 77 showclearedtransactions->setText ( "Show Cleared Transactions" );
78 78
79 excludetransfers = new QCheckBox ( this );
80 excludetransfers->setText ( "Include Transfers In Limit View" );
81
82 limittransactionsbox = new QHBox ( this ); 79 limittransactionsbox = new QHBox ( this );
83 limittransactionsbox->setSpacing ( 2 ); 80 limittransactionsbox->setSpacing ( 2 );
84 limittransactionslabel = new QLabel ( "Limit All Transactions To", limittransactionsbox ); 81 limittransactionslabel = new QLabel ( "Show ", limittransactionsbox );
85 limittransactions = new QComboBox ( limittransactionsbox ); 82 limittransactions = new QComboBox ( limittransactionsbox );
83 QLabel *limittransactionslabel2 = new QLabel ( "of cleared transactions. ", limittransactionsbox );
86 limittransactions->insertItem ( "14 days" ); 84 limittransactions->insertItem ( "14 days" );
87 limittransactions->insertItem ( "30 days" ); 85 limittransactions->insertItem ( "30 days" );
88 limittransactions->insertItem ( "60 days" );
89 limittransactions->insertItem ( "90 days" ); 86 limittransactions->insertItem ( "90 days" );
90 limittransactions->insertItem ( "180 days" ); 87 limittransactions->insertItem ( "180 days" );
91 limittransactions->insertItem ( "365 days" ); 88 limittransactions->insertItem ( "365 days" );
92 limittransactions->insertItem ( "All" ); 89 limittransactions->insertItem ( "All" );
90 limittransactions->setCurrentItem ( preferences->getPreference ( 7 ) );
91
92 excludetransfers = new QCheckBox ( this );
93 excludetransfers->setText ( "Include Transfers In Limit View" );
93 94
94 if ( preferences->getPreference ( 3 ) == 1 ) 95 if ( preferences->getPreference ( 3 ) == 1 )
95 showclearedtransactions->setChecked ( TRUE ); 96 showclearedtransactions->setChecked ( TRUE );
96 else 97 else
97 showclearedtransactions->setChecked ( FALSE ); 98 showclearedtransactions->setChecked ( FALSE );
98 99
99 if ( preferences->getPreference ( 6 ) == 1 ) 100 if ( preferences->getPreference ( 6 ) == 1 )
100 excludetransfers->setChecked ( TRUE ); 101 excludetransfers->setChecked ( TRUE );
101 else 102 else
102 excludetransfers->setChecked ( FALSE ); 103 excludetransfers->setChecked ( FALSE );
103 104
104 defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this ); 105 defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this );
105 connect ( defaults, SIGNAL ( released () ), this, SLOT ( setDefaultTransactionPreferences () ) ); 106 connect ( defaults, SIGNAL ( released () ), this, SLOT ( setDefaultTransactionPreferences () ) );
106 107
107 layout = new QVBoxLayout ( this, 2, 2 ); 108 layout = new QVBoxLayout ( this, 2, 2 );
108 layout->addWidget ( showclearedtransactions ); 109 layout->addWidget ( showclearedtransactions );
109 layout->addWidget ( excludetransfers );
110 layout->addWidget ( limittransactionsbox ); 110 layout->addWidget ( limittransactionsbox );
111 layout->addWidget ( excludetransfers );
111 layout->insertSpacing ( 3, 5 ); 112 layout->insertSpacing ( 3, 5 );
112 layout->addWidget ( defaults ); 113 layout->addWidget ( defaults );
113 114
114 connect ( showclearedtransactions, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeShowClearedPreference ( bool ) ) ); 115 connect ( showclearedtransactions, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeShowClearedPreference ( bool ) ) );
115 connect ( excludetransfers, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeExcludeTranfersPreference ( bool ) ) ); 116 connect ( excludetransfers, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeExcludeTranfersPreference ( bool ) ) );
116 connect ( limittransactions, SIGNAL ( activated ( int ) ), this, SLOT ( changeLimitTransactionsPreference ( int ) ) ); 117 connect ( limittransactions, SIGNAL ( activated ( int ) ), this, SLOT ( changeLimitTransactionsPreference ( int ) ) );
117} 118}
118 119
119TransactionPreferences::~TransactionPreferences () 120TransactionPreferences::~TransactionPreferences ()
120 { 121 {
121 } 122 }
122 123
123void TransactionPreferences::changeLimitTransactionsPreference ( int pref ) 124void TransactionPreferences::changeLimitTransactionsPreference ( int pref )
124 { 125 {
125 preferences->changePreference ( 7, pref ); 126 preferences->changePreference ( 7, pref );
126 } 127 }
127 128
128void TransactionPreferences::changeShowClearedPreference ( bool state ) 129void TransactionPreferences::changeShowClearedPreference ( bool state )
129 { 130 {
130 if ( state == TRUE ) 131 if ( state == TRUE )
131 preferences->changePreference ( 3, 1 ); 132 preferences->changePreference ( 3, 1 );
132 else 133 else
133 preferences->changePreference ( 3, 0 ); 134 preferences->changePreference ( 3, 0 );
134 } 135 }
135 136
136void TransactionPreferences::changeExcludeTranfersPreference ( bool state ) 137void TransactionPreferences::changeExcludeTranfersPreference ( bool state )
137 { 138 {
138 if ( state == TRUE ) 139 if ( state == TRUE )
139 preferences->changePreference ( 6, 1 ); 140 preferences->changePreference ( 6, 1 );
140 else 141 else
141 preferences->changePreference ( 6, 0 ); 142 preferences->changePreference ( 6, 0 );
142 } 143 }
143 144
144void TransactionPreferences::setDefaultTransactionPreferences () 145void TransactionPreferences::setDefaultTransactionPreferences ()
145 { 146 {
146 preferences->changePreference ( 3, 0 ); 147 preferences->changePreference ( 3, 0 );
147 preferences->changePreference ( 6, 0 ); 148 preferences->changePreference ( 6, 0 );
148 preferences->changePreference ( 7, 0 ); 149 preferences->changePreference ( 7, 0 );
149 showclearedtransactions->setChecked ( FALSE ); 150 showclearedtransactions->setChecked ( FALSE );
150 limittransactions->setCurrentItem ( 0 ); 151 limittransactions->setCurrentItem ( 0 );
151 } 152 }
152 153
153// START ACCOUNT PREFERNCES 154// START ACCOUNT PREFERNCES
154 155
155AccountPreferences::AccountPreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE ) 156AccountPreferences::AccountPreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE )
156{ 157{
157 158
158 setCaption( tr ( "Account" ) ); 159 setCaption( tr ( "Account" ) );
159 160
160 currencysupport = new QCheckBox ( this ); 161 currencysupport = new QCheckBox ( this );
161 currencysupport->setText ( "Enable Currency Support" ); 162 currencysupport->setText ( "Enable Currency Support" );
162 163
163 onetouch = new QCheckBox ( this ); 164 onetouch = new QCheckBox ( this );
164 onetouch->setText ( "One Touch Account Viewing" ); 165 onetouch->setText ( "One Touch Account Viewing" );
165 166
166 if ( preferences->getPreference ( 4 ) == 1 ) 167 if ( preferences->getPreference ( 4 ) == 1 )
167 currencysupport->setChecked ( TRUE ); 168 currencysupport->setChecked ( TRUE );
168 else 169 else
169 currencysupport->setChecked ( FALSE ); 170 currencysupport->setChecked ( FALSE );
170 171
171 if ( preferences->getPreference ( 5 ) == 1 ) 172 if ( preferences->getPreference ( 5 ) == 1 )
172 onetouch->setChecked ( TRUE ); 173 onetouch->setChecked ( TRUE );
173 else 174 else
174 onetouch->setChecked ( FALSE ); 175 onetouch->setChecked ( FALSE );
175 176
176 defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this ); 177 defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this );
177 connect ( defaults, SIGNAL ( released () ), this, SLOT ( setDefaultAccountPreferences () ) ); 178 connect ( defaults, SIGNAL ( released () ), this, SLOT ( setDefaultAccountPreferences () ) );
178 179
179 layout = new QVBoxLayout ( this, 2, 2 ); 180 layout = new QVBoxLayout ( this, 2, 2 );
180 layout->addWidget ( currencysupport ); 181 layout->addWidget ( currencysupport );
181 layout->addWidget ( onetouch ); 182 layout->addWidget ( onetouch );
182 layout->insertSpacing ( 2, 5 ); 183 layout->insertSpacing ( 2, 5 );
183 layout->addWidget ( defaults ); 184 layout->addWidget ( defaults );
184 185
185 connect ( currencysupport, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeCurrencySupport ( bool ) ) ); 186 connect ( currencysupport, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeCurrencySupport ( bool ) ) );
186 connect ( onetouch, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeOneTouchViewing ( bool ) ) ); 187 connect ( onetouch, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeOneTouchViewing ( bool ) ) );
187} 188}
188 189
189AccountPreferences::~AccountPreferences () 190AccountPreferences::~AccountPreferences ()
190 { 191 {
191 } 192 }
192 193
193void AccountPreferences::changeCurrencySupport ( bool state ) 194void AccountPreferences::changeCurrencySupport ( bool state )
194 { 195 {
195 if ( state == TRUE ) 196 if ( state == TRUE )
196 preferences->changePreference ( 4, 1 ); 197 preferences->changePreference ( 4, 1 );
197 else 198 else
198 preferences->changePreference ( 4, 0 ); 199 preferences->changePreference ( 4, 0 );
199 } 200 }
200 201
201void AccountPreferences::changeOneTouchViewing ( bool state ) 202void AccountPreferences::changeOneTouchViewing ( bool state )
202 { 203 {
203 if ( state == TRUE ) 204 if ( state == TRUE )
204 preferences->changePreference ( 5, 1 ); 205 preferences->changePreference ( 5, 1 );
205 else 206 else
206 preferences->changePreference ( 5, 0 ); 207 preferences->changePreference ( 5, 0 );
207 } 208 }
208 209
209void AccountPreferences::setDefaultAccountPreferences () 210void AccountPreferences::setDefaultAccountPreferences ()
210 { 211 {
211 preferences->changePreference ( 4, 0 ); 212 preferences->changePreference ( 4, 0 );
212 preferences->changePreference ( 5, 0 ); 213 preferences->changePreference ( 5, 0 );
213 currencysupport->setChecked ( FALSE ); 214 currencysupport->setChecked ( FALSE );
214 onetouch->setChecked ( FALSE ); 215 onetouch->setChecked ( FALSE );
215 } 216 }
216 217
diff --git a/noncore/apps/qashmoney/preferences.cpp b/noncore/apps/qashmoney/preferences.cpp
index 819d5cf..9bf64dd 100755
--- a/noncore/apps/qashmoney/preferences.cpp
+++ b/noncore/apps/qashmoney/preferences.cpp
@@ -1,255 +1,255 @@
1#include "preferences.h" 1#include "preferences.h"
2#include <stdlib.h> 2#include <stdlib.h>
3 3
4Preferences::Preferences () 4Preferences::Preferences ()
5 { 5 {
6 db = sqlite_open ( "qmpreferences.db", 0, NULL ); 6 db = sqlite_open ( "qmpreferences.db", 0, NULL );
7 } 7 }
8 8
9Preferences::~Preferences () 9Preferences::~Preferences ()
10 { 10 {
11 sqlite_close ( db ); 11 sqlite_close ( db );
12 } 12 }
13 13
14void Preferences::addPreferences () 14void Preferences::addPreferences ()
15 { 15 {
16 // This function checks the preferences database for existing preferences and adds 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 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 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 19 // added to the database, the result is zero if it hasn't
20 int rows = 0; 20 int rows = 0;
21 int columns = 0; 21 int columns = 0;
22 char **results; 22 char **results;
23 23
24 sqlite_get_table ( db, "select count() from preferences;", &results, 0, 0, 0 ); 24 sqlite_get_table ( db, "select count() from preferences;", &results, 0, 0, 0 );
25 if ( atoi ( results [ 1 ] ) != 7 ) 25 if ( atoi ( results [ 1 ] ) != 7 )
26 { 26 {
27 // dateformat preference 1 = yyyymmdd 2 = yymmdd 3 = mmddyyyy 4 = mmddyy 27 // dateformat preference 1 = yyyymmdd 2 = yymmdd 3 = mmddyyyy 4 = mmddyy
28 // 5 = yyyyddmm 6 = yyddmm 7 = ddmmyyyy 8 = ddmmyy 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 ); 29 sqlite_get_table ( db, "select preference from preferences where id = 1;", &results, &rows, &columns, 0 );
30 if ( rows == 0 ) 30 if ( rows == 0 )
31 sqlite_exec ( db, "insert into preferences values ( 4, 'dateformat', 0, 0, 0, NULL );", 0, 0, 0 ); 31 sqlite_exec ( db, "insert into preferences values ( 4, 'dateformat', 0, 0, 0, NULL );", 0, 0, 0 );
32 32
33 // dateseparator preference 1 = / ( forward slash ) 2 = - ( dash ) 3 = . ( period ) 33 // dateseparator preference 1 = / ( forward slash ) 2 = - ( dash ) 3 = . ( period )
34 rows = 0; 34 rows = 0;
35 sqlite_get_table ( db, "select preference from preferences where id = 2;", &results, &rows, &columns, 0 ); 35 sqlite_get_table ( db, "select preference from preferences where id = 2;", &results, &rows, &columns, 0 );
36 if ( rows == 0 ) 36 if ( rows == 0 )
37 sqlite_exec ( db, "insert into preferences values ( 1, 'dateseparator', 0, 0, 0, NULL );", 0, 0, 0 ); 37 sqlite_exec ( db, "insert into preferences values ( 1, 'dateseparator', 0, 0, 0, NULL );", 0, 0, 0 );
38 38
39 // showclearedtransactions preference 0 = no 1 = yes 39 // showclearedtransactions preference 0 = no 1 = yes
40 rows = 0; 40 rows = 0;
41 sqlite_get_table ( db, "select preference from preferences where id = 3;", &results, &rows, &columns, 0 ); 41 sqlite_get_table ( db, "select preference from preferences where id = 3;", &results, &rows, &columns, 0 );
42 if ( rows == 0 ) 42 if ( rows == 0 )
43 sqlite_exec ( db, "insert into preferences values ( 0, 'showclearedtransactions', 0, 0, 0, NULL );", 0, 0, 0 ); 43 sqlite_exec ( db, "insert into preferences values ( 0, 'showclearedtransactions', 0, 0, 0, NULL );", 0, 0, 0 );
44 44
45 // enable currency support preference 0 = no 1 = yes 45 // enable currency support preference 0 = no 1 = yes
46 rows = 0; 46 rows = 0;
47 sqlite_get_table ( db, "select preference from preferences where id = 4;", &results, &rows, &columns, 0 ); 47 sqlite_get_table ( db, "select preference from preferences where id = 4;", &results, &rows, &columns, 0 );
48 if ( rows == 0 ) 48 if ( rows == 0 )
49 sqlite_exec ( db, "insert into preferences values ( 0, 'enablecurrencysupport', 0, 0, 0, NULL );", 0, 0, 0 ); 49 sqlite_exec ( db, "insert into preferences values ( 0, 'enablecurrencysupport', 0, 0, 0, NULL );", 0, 0, 0 );
50 50
51 // one touch account viewing preference 0 = no 1 = yes 51 // one touch account viewing preference 0 = no 1 = yes
52 rows = 0; 52 rows = 0;
53 sqlite_get_table ( db, "select preference from preferences where id = 5;", &results, &rows, &columns, 0 ); 53 sqlite_get_table ( db, "select preference from preferences where id = 5;", &results, &rows, &columns, 0 );
54 if ( rows == 0 ) 54 if ( rows == 0 )
55 sqlite_exec ( db, "insert into preferences values ( 0, 'onetouchviewing', 0, 0, 0, NULL );", 0, 0, 0 ); 55 sqlite_exec ( db, "insert into preferences values ( 0, 'onetouchviewing', 0, 0, 0, NULL );", 0, 0, 0 );
56 56
57 // exclude transfers from limit view 0 = no 1 = yes 57 // exclude transfers from limit view 0 = no 1 = yes
58 rows = 0; 58 rows = 0;
59 sqlite_get_table ( db, "select preference from preferences where id = 6;", &results, &rows, &columns, 0 ); 59 sqlite_get_table ( db, "select preference from preferences where id = 6;", &results, &rows, &columns, 0 );
60 if ( rows == 0 ) 60 if ( rows == 0 )
61 sqlite_exec ( db, "insert into preferences values ( 0, 'excludetransfersfromlimit', 0, 0, 0, NULL );", 0, 0, 0 ); 61 sqlite_exec ( db, "insert into preferences values ( 0, 'excludetransfersfromlimit', 0, 0, 0, NULL );", 0, 0, 0 );
62 62
63 // limit number of transactions to 0 = 14 days 1 = 30 days, 2 = 60 days, 3 = 90 days, 4 = 180 days, 5 = 365 days, 6 = all 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; 64 rows = 0;
65 sqlite_get_table ( db, "select preference from preferences where id = 7;", &results, &rows, &columns, 0 ); 65 sqlite_get_table ( db, "select preference from preferences where id = 7;", &results, &rows, &columns, 0 );
66 if ( rows == 0 ) 66 if ( rows == 0 )
67 sqlite_exec ( db, "insert into preferences values ( 0, 'limittransactions', 0, 0, 0, NULL );", 0, 0, 0 ); 67 sqlite_exec ( db, "insert into preferences values ( 0, 'limittransactions', 0, 0, 0, NULL );", 0, 0, 0 );
68 } 68 }
69 } 69 }
70 70
71void Preferences::initializeColumnPreferences () 71void Preferences::initializeColumnPreferences ()
72 { 72 {
73 int rows = 0; 73 int rows = 0;
74 int columns = 0; 74 int columns = 0;
75 char **results; 75 char **results;
76 76
77 // initialize accountname column width 77 // initialize accountname column width
78 sqlite_get_table ( db, "select width from columns where id = 1;", &results, &rows, &columns, 0 ); 78 sqlite_get_table ( db, "select width from columns where id = 1;", &results, &rows, &columns, 0 );
79 if ( rows == 0 ) 79 if ( rows == 0 )
80 sqlite_exec ( db, "insert into columns values ( 'accountname', 90, 0, 0, 0, NULL );", 0, 0, 0 ); 80 sqlite_exec ( db, "insert into columns values ( 'accountname', 90, 0, 0, 0, NULL );", 0, 0, 0 );
81 81
82 // initialize accountbalance column width 82 // initialize accountbalance column width
83 sqlite_get_table ( db, "select width from columns where id = 2;", &results, &rows, &columns, 0 ); 83 sqlite_get_table ( db, "select width from columns where id = 2;", &results, &rows, &columns, 0 );
84 if ( rows == 0 ) 84 if ( rows == 0 )
85 sqlite_exec ( db, "insert into columns values ( 'accountbalance', 90, 0, 0, 0, NULL );", 0, 0, 0 ); 85 sqlite_exec ( db, "insert into columns values ( 'accountbalance', 90, 0, 0, 0, NULL );", 0, 0, 0 );
86 86
87 // initialize transactiondate column width 87 // initialize transactiondate column width
88 sqlite_get_table ( db, "select width from columns where id = 3;", &results, &rows, &columns, 0 ); 88 sqlite_get_table ( db, "select width from columns where id = 3;", &results, &rows, &columns, 0 );
89 if ( rows == 0 ) 89 if ( rows == 0 )
90 sqlite_exec ( db, "insert into columns values ( 'normaltransactiondate', 50, 0, 0, 0, NULL );", 0, 0, 0 ); 90 sqlite_exec ( db, "insert into columns values ( 'normaltransactiondate', 50, 0, 0, 0, NULL );", 0, 0, 0 );
91 91
92 // initialize transactionname column width 92 // initialize transactionname column width
93 sqlite_get_table ( db, "select width from columns where id = 4;", &results, &rows, &columns, 0 ); 93 sqlite_get_table ( db, "select width from columns where id = 4;", &results, &rows, &columns, 0 );
94 if ( rows == 0 ) 94 if ( rows == 0 )
95 sqlite_exec ( db, "insert into columns values ( 'normaltransactionname', 75, 0, 0, 0, NULL );", 0, 0, 0 ); 95 sqlite_exec ( db, "insert into columns values ( 'normaltransactionname', 75, 0, 0, 0, NULL );", 0, 0, 0 );
96 96
97 // initialize transactionamount column width 97 // initialize transactionamount column width
98 sqlite_get_table ( db, "select width from columns where id = 5;", &results, &rows, &columns, 0 ); 98 sqlite_get_table ( db, "select width from columns where id = 5;", &results, &rows, &columns, 0 );
99 if ( rows == 0 ) 99 if ( rows == 0 )
100 sqlite_exec ( db, "insert into columns values ( 'normaltransactionamount', 50, 0, 0, 0, NULL );", 0, 0, 0 ); 100 sqlite_exec ( db, "insert into columns values ( 'normaltransactionamount', 50, 0, 0, 0, NULL );", 0, 0, 0 );
101 101
102 // initialize transactiondate column width 102 // initialize transactiondate column width
103 sqlite_get_table ( db, "select width from columns where id = 6;", &results, &rows, &columns, 0 ); 103 sqlite_get_table ( db, "select width from columns where id = 6;", &results, &rows, &columns, 0 );
104 if ( rows == 0 ) 104 if ( rows == 0 )
105 sqlite_exec ( db, "insert into columns values ( 'extendedtransactiondate', 50, 0, 0, 0, NULL );", 0, 0, 0 ); 105 sqlite_exec ( db, "insert into columns values ( 'extendedtransactiondate', 50, 0, 0, 0, NULL );", 0, 0, 0 );
106 106
107 // initialize transactionname column width 107 // initialize transactionname column width
108 sqlite_get_table ( db, "select width from columns where id = 7;", &results, &rows, &columns, 0 ); 108 sqlite_get_table ( db, "select width from columns where id = 7;", &results, &rows, &columns, 0 );
109 if ( rows == 0 ) 109 if ( rows == 0 )
110 sqlite_exec ( db, "insert into columns values ( 'extendedtransactionname', 75, 0, 0, 0, NULL );", 0, 0, 0 ); 110 sqlite_exec ( db, "insert into columns values ( 'extendedtransactionname', 75, 0, 0, 0, NULL );", 0, 0, 0 );
111 111
112 // initialize transactionamount column width 112 // initialize transactionamount column width
113 sqlite_get_table ( db, "select width from columns where id = 8;", &results, &rows, &columns, 0 ); 113 sqlite_get_table ( db, "select width from columns where id = 8;", &results, &rows, &columns, 0 );
114 if ( rows == 0 ) 114 if ( rows == 0 )
115 sqlite_exec ( db, "insert into columns values ( 'extendedtransactionamount', 50, 0, 0, 0, NULL );", 0, 0, 0 ); 115 sqlite_exec ( db, "insert into columns values ( 'extendedtransactionamount', 50, 0, 0, 0, NULL );", 0, 0, 0 );
116 116
117 // initialize transactionaccount column width 117 // initialize transactionaccount column width
118 sqlite_get_table ( db, "select width from columns where id = 9;", &results, &rows, &columns, 0 ); 118 sqlite_get_table ( db, "select width from columns where id = 9;", &results, &rows, &columns, 0 );
119 if ( rows == 0 ) 119 if ( rows == 0 )
120 sqlite_exec ( db, "insert into columns values ( 'transactionaccount', 50, 0, 0, 0, NULL );", 0, 0, 0 ); 120 sqlite_exec ( db, "insert into columns values ( 'transactionaccount', 50, 0, 0, 0, NULL );", 0, 0, 0 );
121 121
122 // initialize account name with currency column width 122 // initialize account name with currency column width
123 sqlite_get_table ( db, "select width from columns where id = 10;", &results, &rows, &columns, 0 ); 123 sqlite_get_table ( db, "select width from columns where id = 10;", &results, &rows, &columns, 0 );
124 if ( rows == 0 ) 124 if ( rows == 0 )
125 sqlite_exec ( db, "insert into columns values ( 'accountnamewithcurrency', 100, 0, 0, 0, NULL );", 0, 0, 0 ); 125 sqlite_exec ( db, "insert into columns values ( 'accountnamewithcurrency', 100, 0, 0, 0, NULL );", 0, 0, 0 );
126 126
127 // initialize account currency column width 127 // initialize account currency column width
128 sqlite_get_table ( db, "select width from columns where id = 11;", &results, &rows, &columns, 0 ); 128 sqlite_get_table ( db, "select width from columns where id = 11;", &results, &rows, &columns, 0 );
129 if ( rows == 0 ) 129 if ( rows == 0 )
130 sqlite_exec ( db, "insert into columns values ( 'currencycolumn', 10, 0, 0, 0, NULL );", 0, 0, 0 ); 130 sqlite_exec ( db, "insert into columns values ( 'currencycolumn', 10, 0, 0, 0, NULL );", 0, 0, 0 );
131 131
132 // initialize account balance with currency column width 132 // initialize account balance with currency column width
133 sqlite_get_table ( db, "select width from columns where id = 12;", &results, &rows, &columns, 0 ); 133 sqlite_get_table ( db, "select width from columns where id = 12;", &results, &rows, &columns, 0 );
134 if ( rows == 0 ) 134 if ( rows == 0 )
135 sqlite_exec ( db, "insert into columns values ( 'accountbalancewithcurrency', 50, 0, 0, 0, NULL );", 0, 0, 0 ); 135 sqlite_exec ( db, "insert into columns values ( 'accountbalancewithcurrency', 50, 0, 0, 0, NULL );", 0, 0, 0 );
136 136
137 // initialize budget line item column 137 // initialize budget line item column
138 sqlite_get_table ( db, "select width from columns where id = 13;", &results, &rows, &columns, 0 ); 138 sqlite_get_table ( db, "select width from columns where id = 13;", &results, &rows, &columns, 0 );
139 if ( rows == 0 ) 139 if ( rows == 0 )
140 sqlite_exec ( db, "insert into columns values ( 'budgetlineitem', 50, 0, 0, 0, NULL );", 0, 0, 0 ); 140 sqlite_exec ( db, "insert into columns values ( 'budgetlineitem', 50, 0, 0, 0, NULL );", 0, 0, 0 );
141 141
142 // initialize budget budget column 142 // initialize budget budget column
143 sqlite_get_table ( db, "select width from columns where id = 14;", &results, &rows, &columns, 0 ); 143 sqlite_get_table ( db, "select width from columns where id = 14;", &results, &rows, &columns, 0 );
144 if ( rows == 0 ) 144 if ( rows == 0 )
145 sqlite_exec ( db, "insert into columns values ( 'budgetbudget', 50, 0, 0, 0, NULL );", 0, 0, 0 ); 145 sqlite_exec ( db, "insert into columns values ( 'budgetbudget', 50, 0, 0, 0, NULL );", 0, 0, 0 );
146 146
147 // initialize budget actual column 147 // initialize budget actual column
148 sqlite_get_table ( db, "select width from columns where id = 15;", &results, &rows, &columns, 0 ); 148 sqlite_get_table ( db, "select width from columns where id = 15;", &results, &rows, &columns, 0 );
149 if ( rows == 0 ) 149 if ( rows == 0 )
150 sqlite_exec ( db, "insert into columns values ( 'budgetactual', 50, 0, 0, 0, NULL );", 0, 0, 0 ); 150 sqlite_exec ( db, "insert into columns values ( 'budgetactual', 50, 0, 0, 0, NULL );", 0, 0, 0 );
151 } 151 }
152 152
153void Preferences::changeColumnPreference ( int id, int width ) 153void Preferences::changeColumnPreference ( int id, int width )
154 { 154 {
155 sqlite_exec_printf ( db, "update columns set width = %i where id = %i;", 0, 0, 0, width, id ); 155 sqlite_exec_printf ( db, "update columns set width = %i where id = %i;", 0, 0, 0, width, id );
156 } 156 }
157 157
158int Preferences::getColumnPreference ( int id ) 158int Preferences::getColumnPreference ( int id )
159 { 159 {
160 char **results; 160 char **results;
161 sqlite_get_table_printf ( db, "select width from columns where id = %i;", &results, NULL, NULL, NULL, id ); 161 sqlite_get_table_printf ( db, "select width from columns where id = %i;", &results, NULL, NULL, NULL, id );
162 return atoi ( results [ 1 ] ); 162 return atoi ( results [ 1 ] );
163 } 163 }
164 164
165int Preferences::getPreference ( int id ) 165int Preferences::getPreference ( int id )
166 { 166 {
167 char **results; 167 char **results;
168 sqlite_get_table_printf ( db, "select preference from preferences where id = %i;", &results, NULL, NULL, NULL, id ); 168 sqlite_get_table_printf ( db, "select preference from preferences where id = %i;", &results, NULL, NULL, NULL, id );
169 return atoi ( results [ 1 ] ); 169 return atoi ( results [ 1 ] );
170 } 170 }
171 171
172QString Preferences::getSeparator ( ) 172QString Preferences::getSeparator ( )
173 { 173 {
174 int s = getPreference ( 2 ); 174 int s = getPreference ( 2 );
175 if ( s == 1 ) 175 if ( s == 1 )
176 return "/"; 176 return "/";
177 if ( s ==2 ) 177 if ( s ==2 )
178 return "-"; 178 return "-";
179 else 179 else
180 return "."; 180 return ".";
181 } 181 }
182 182
183void Preferences::changePreference ( int id, int newpreference ) 183void Preferences::changePreference ( int id, int newpreference )
184 { 184 {
185 sqlite_exec_printf ( db, "update preferences set preference = %i where id = %i;", 0, 0, 0, newpreference, id ); 185 sqlite_exec_printf ( db, "update preferences set preference = %i where id = %i;", 0, 0, 0, newpreference, id );
186 } 186 }
187 187
188void Preferences::setDefaultDatePreferences () 188void Preferences::setDefaultDatePreferences ()
189 { 189 {
190 sqlite_exec ( db, "update preferences set preference = 4 where id = 1;", 0, 0, 0 ); 190 sqlite_exec ( db, "update preferences set preference = 4 where id = 1;", 0, 0, 0 );
191 sqlite_exec ( db, "update preferences set preference = 1 where id = 2;", 0, 0, 0 ); 191 sqlite_exec ( db, "update preferences set preference = 1 where id = 2;", 0, 0, 0 );
192 } 192 }
193 193
194QString Preferences::getDate ( int y, int m, int d ) 194QString Preferences::getDate ( int y, int m, int d )
195 { 195 {
196 QString date; 196 QString date;
197 int format = getPreference ( 1 ); 197 int format = getPreference ( 1 );
198 QString separator = getSeparator(); 198 QString separator = getSeparator();
199 199
200 // Convert all date integers to QStrings 200 // Convert all date integers to QStrings
201 QString year = QString::number ( y ); 201 QString year = QString::number ( y );
202 QString month = QString::number ( m ); 202 QString month = QString::number ( m );
203 if ( m < 10 ) 203 if ( m < 10 )
204 month.prepend ( "0" ); 204 month.prepend ( "0" );
205 QString day = QString::number ( d ); 205 QString day = QString::number ( d );
206 if ( d < 10 ) 206 if ( d < 10 )
207 day.prepend ( "0" ); 207 day.prepend ( "0" );
208 208
209 // Truncate four digit year if necessary 209 // Truncate four digit year if necessary
210 if ( format == 2 || format == 4 || format == 6 || format == 8 ) 210 if ( format == 2 || format == 4 || format == 6 || format == 8 )
211 year.remove ( 0, 2 ); 211 year.remove ( 0, 2 );
212 212
213 // Concatenate dates as necessary 213 // Concatenate dates as necessary
214 if ( format == 1 || format == 2 ) 214 if ( format == 1 || format == 2 )
215 { 215 {
216 date = year; 216 date = year;
217 date.append ( separator ); 217 date.append ( separator );
218 date.append ( month ); 218 date.append ( month );
219 date.append ( separator ); 219 date.append ( separator );
220 date.append ( day ); 220 date.append ( day );
221 return date; 221 return date;
222 } 222 }
223 if ( format == 3 || format == 4 ) 223 if ( format == 3 || format == 4 )
224 { 224 {
225 date = month; 225 date = month;
226 date.append ( separator ); 226 date.append ( separator );
227 date.append ( day ); 227 date.append ( day );
228 date.append ( separator ); 228 date.append ( separator );
229 date.append ( year ); 229 date.append ( year );
230 return date; 230 return date;
231 } 231 }
232 if ( format == 5 || format == 6 ) 232 if ( format == 5 || format == 6 )
233 { 233 {
234 date = year; 234 date = year;
235 date.append ( separator ); 235 date.append ( separator );
236 date.append ( day ); 236 date.append ( day );
237 date.append ( separator ); 237 date.append ( separator );
238 date.append ( month ); 238 date.append ( month );
239 return date; 239 return date;
240 } 240 }
241 if ( format == 7 || format == 8 ) 241 if ( format == 7 || format == 8 )
242 { 242 {
243 date = day; 243 date = day;
244 date.append ( separator ); 244 date.append ( separator );
245 date.append ( month ); 245 date.append ( month );
246 date.append ( separator ); 246 date.append ( separator );
247 date.append ( year ); 247 date.append ( year );
248 return date; 248 return date;
249 } 249 }
250 } 250 }
251 251
252QString Preferences::getDate ( int y, int m ) 252QString Preferences::getDate ( int y, int m )
253 { 253 {
254 QString date; 254 QString date;
255 int format = getPreference ( 1 ); 255 int format = getPreference ( 1 );
diff --git a/noncore/apps/qashmoney/qashmoney.cpp b/noncore/apps/qashmoney/qashmoney.cpp
index 1ea358c..83eea01 100755
--- a/noncore/apps/qashmoney/qashmoney.cpp
+++ b/noncore/apps/qashmoney/qashmoney.cpp
@@ -1,356 +1,390 @@
1#include "qashmoney.h" 1#include "qashmoney.h"
2#include "preferencedialogs.h" 2#include "preferencedialogs.h"
3#include "memorydialog.h" 3#include "memorydialog.h"
4 4
5#include <qheader.h> 5#include <qheader.h>
6#include <iostream.h> 6#include <iostream.h>
7 7
8Budget *budget = new Budget (); 8Budget *budget = new Budget ();
9Preferences *preferences = new Preferences (); 9Preferences *preferences = new Preferences ();
10Account *account = new Account (); 10Account *account = new Account ();
11Transaction *transaction = new Transaction (); 11Transaction *transaction = new Transaction ();
12Transfer *transfer = new Transfer (); 12Transfer *transfer = new Transfer ();
13Memory *memory = new Memory (); 13Memory *memory = new Memory ();
14 14
15QashMoney::QashMoney () : QWidget () 15QashMoney::QashMoney () : QWidget ()
16 { 16 {
17 preferences->addPreferences(); 17 preferences->addPreferences();
18 preferences->initializeColumnPreferences (); 18 preferences->initializeColumnPreferences ();
19 19
20 // set the text in the upper part of the frame 20 // set the text in the upper part of the frame
21 setCaption ( tr ( "QashMoney" ) ); 21 setCaption ( tr ( "QashMoney" ) );
22 22
23 // Create new menubar for our mainwindow 23 // Create new menubar for our mainwindow
24 // and add menu items 24 // and add menu items
25 mainmenu = new QPEMenuBar ( this ); 25 mainmenu = new QPEMenuBar ( this );
26 mainmenu->setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); 26 mainmenu->setFrameStyle ( QFrame::PopupPanel | QFrame::Raised );
27 preferencesmenu = new QPopupMenu ( this ); 27 preferencesmenu = new QPopupMenu ( this );
28 utilitiesmenu = new QPopupMenu ( this ); 28 utilitiesmenu = new QPopupMenu ( this );
29 mainmenu->insertItem ( "Preferences", preferencesmenu ); 29 mainmenu->insertItem ( "Preferences", preferencesmenu );
30 mainmenu->insertItem ( "Utilities", utilitiesmenu ); 30 mainmenu->insertItem ( "Utilities", utilitiesmenu );
31 preferencesmenu->insertItem ( "Date", this, SLOT ( displayDatePreferencesDialog () ) ); 31 preferencesmenu->insertItem ( "Date", this, SLOT ( displayDatePreferencesDialog () ) );
32 preferencesmenu->insertItem ( "Account", this, SLOT ( displayAccountPreferencesDialog () ) ); 32 preferencesmenu->insertItem ( "Account", this, SLOT ( displayAccountPreferencesDialog () ) );
33 preferencesmenu->insertItem ( "Transaction", this, SLOT ( displayTransactionPreferencesDialog () ) ); 33 preferencesmenu->insertItem ( "Transaction", this, SLOT ( displayTransactionPreferencesDialog () ) );
34 utilitiesmenu->insertItem ( "Memory", this, SLOT ( displayMemoryDialog () ) ); 34 utilitiesmenu->insertItem ( "Memory", this, SLOT ( displayMemoryDialog () ) );
35 35
36 // create the main tabwidget for displaying accounts and transactions 36 // create the main tabwidget for displaying accounts and transactions
37 maintabs = new QTabWidget ( this ); 37 maintabs = new QTabWidget ( this );
38 tab = new QWidget ( this ); 38 tab = new QWidget ( this );
39 tab_2 = new QWidget ( this ); 39 tab_2 = new QWidget ( this );
40 tab_3 = new QWidget ( this ); 40 tab_3 = new QWidget ( this );
41 maintabs->addTab ( tab, "Accounts" ); 41 maintabs->addTab ( tab, "Accounts" );
42 maintabs->addTab ( tab_2, "Transactions" ); 42 maintabs->addTab ( tab_2, "Transactions" );
43 maintabs->addTab ( tab_3, "Budgets" ); 43 maintabs->addTab ( tab_3, "Budgets" );
44 tabheight = tab->height(); 44 tabheight = tab->height();
45 maintabs->setTabEnabled ( tab_2, FALSE ); 45 maintabs->setTabEnabled ( tab_2, FALSE );
46 46
47 // create a new account display object 47 // create a new account display object
48 accountdisplay = new AccountDisplay ( maintabs ); 48 accountdisplay = new AccountDisplay ( maintabs );
49 accountdisplay->setTabs ( tab_2, maintabs ); 49 accountdisplay->setTabs ( tab_2, maintabs );
50 connect ( accountdisplay->listview, SIGNAL ( selectionChanged () ), this, SLOT ( setTransactionTab () ) ); 50 connect ( accountdisplay->listview, SIGNAL ( selectionChanged () ), this, SLOT ( setTransactionTab () ) );
51 51
52 // set the connection to disable the one touch account viewing if we are transfering money 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 ) ) ); 53 connect ( accountdisplay->transferbutton, SIGNAL ( toggled ( bool ) ), this, SLOT ( toggleOneTouchViewing ( bool ) ) );
54 54
55 // create a new transactiondisplay object 55 // create a new transactiondisplay object
56 transactiondisplay = new TransactionDisplay ( maintabs ); 56 transactiondisplay = new TransactionDisplay ( maintabs );
57 transactiondisplay->hide(); 57 transactiondisplay->hide();
58 58
59 // create new budgetdisplay object 59 // create new budgetdisplay object
60 budgetdisplay = new BudgetDisplay ( maintabs ); 60 budgetdisplay = new BudgetDisplay ( maintabs );
61 budgetdisplay->hide(); 61 budgetdisplay->hide();
62 62
63 tabslayout = new QVBoxLayout ( maintabs, 4, 2 ); 63 tabslayout = new QVBoxLayout ( maintabs, 4, 2 );
64 tabslayout->addSpacing ( tabheight ); 64 tabslayout->addSpacing ( tabheight );
65 tabslayout->addWidget ( accountdisplay ); 65 tabslayout->addWidget ( accountdisplay );
66 tabslayout->addWidget ( transactiondisplay ); 66 tabslayout->addWidget ( transactiondisplay );
67 tabslayout->addWidget ( budgetdisplay ); 67 tabslayout->addWidget ( budgetdisplay );
68 68
69 // connect a change in the maintabs with changing the tab display 69 // connect a change in the maintabs with changing the tab display
70 connect ( maintabs, SIGNAL ( currentChanged ( QWidget * ) ), this, SLOT ( changeTabDisplay () ) ); 70 connect ( maintabs, SIGNAL ( currentChanged ( QWidget * ) ), this, SLOT ( changeTabDisplay () ) );
71 71
72 // create layout that will contain the menubar and the maintabs 72 // create layout that will contain the menubar and the maintabs
73 layout = new QVBoxLayout ( this, 2, 2 ); 73 layout = new QVBoxLayout ( this, 2, 2 );
74 layout->setMenuBar ( mainmenu ); 74 layout->setMenuBar ( mainmenu );
75 layout->addWidget ( maintabs ); 75 layout->addWidget ( maintabs );
76 } 76 }
77 77
78QashMoney::~QashMoney () 78QashMoney::~QashMoney ()
79 { 79 {
80 delete budget; 80 delete budget;
81 delete preferences; 81 delete preferences;
82 delete account; 82 delete account;
83 delete transaction; 83 delete transaction;
84 delete transfer; 84 delete transfer;
85 delete memory; 85 delete memory;
86 } 86 }
87 87
88void QashMoney::changeTabDisplay () 88void QashMoney::changeTabDisplay ()
89 { 89 {
90 // if the user pressed the transactions tab, hide the account display 90 // if the user pressed the transactions tab, hide the account display
91 // object and create a new transaction display 91 // object and create a new transaction display
92 if ( maintabs->currentPageIndex() == 1 ) 92 if ( maintabs->currentPageIndex() == 1 )
93 { 93 {
94 // initialize variables 94 // initialize variables
95 bool children = FALSE; 95 bool children = FALSE;
96 96
97 // hide the account display and define accountid 97 // hide the account display and define accountid
98 int accountid = accountdisplay->listview->selectedItem()->text ( accountdisplay->getIDColumn() ).toInt(); 98 int accountid = accountdisplay->listview->selectedItem()->text ( accountdisplay->getIDColumn() ).toInt();
99 99
100 //remove all the columns from the transactiondisplay 100 //remove all the columns from the transactiondisplay
101 int columns = transactiondisplay->listview->columns(); 101 int columns = transactiondisplay->listview->columns();
102 int counter; 102 int counter;
103 for ( counter = 0; counter <= columns; counter++ ) 103 for ( counter = 0; counter <= columns; counter++ )
104 transactiondisplay->listview->removeColumn ( 0 ); 104 transactiondisplay->listview->removeColumn ( 0 );
105 105
106 // set the account name and account balance 106 // set the account name and account balance
107 QString name = account->getAccountName ( accountid ); 107 QString name = account->getAccountName ( accountid );
108 QString balance = account->getAccountBalance ( accountid ); 108 QString balance = account->getAccountBalance ( accountid );
109 transactiondisplay->name->setText ( name ); 109 transactiondisplay->name->setText ( name );
110 transactiondisplay->balance->setText ( balance ); 110 transactiondisplay->balance->setText ( balance );
111 111
112 // clear the limitbox 112 // clear the limitbox
113 transactiondisplay->limitbox->clear(); 113 transactiondisplay->limitbox->clear();
114 114
115 // get parent account id 115 // get parent account id
116 int parentaccountid = account->getParentAccountID ( accountid ); 116 int parentaccountid = account->getParentAccountID ( accountid );
117 117
118 // add columns based on which account is selected 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 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 120 // in these cases, we add standard three columns for date, transaction, amount
121 transactiondisplay->listview->addColumn ( "Date", 0 ); 121 transactiondisplay->listview->addColumn ( "Date", 0 );
122 transactiondisplay->listview->addColumn ( "Transaction", 0 ); 122 transactiondisplay->listview->addColumn ( "Transaction", 0 );
123 transactiondisplay->listview->addColumn ( "Amt", 0); 123 transactiondisplay->listview->addColumn ( "Amt", 0);
124 transactiondisplay->listview->setColumnAlignment ( 2, Qt::AlignRight ); 124 transactiondisplay->listview->setColumnAlignment ( 2, Qt::AlignRight );
125 transactiondisplay->listview->addColumn ( "", 0 ); 125 transactiondisplay->listview->addColumn ( "", 0 );
126 126
127 if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 ) // we selected a parent with children 127 if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 ) // we selected a parent with children
128 { 128 {
129 // add an extra column for the account name for eac child transaction 129 // add an extra column for the account name for eac child transaction
130 transactiondisplay->listview->addColumn ( "Acct", 0 ); 130 transactiondisplay->listview->addColumn ( "Acct", 0 );
131 children = TRUE; 131 children = TRUE;
132 132
133 // hide the new transaction button 133 // hide the new transaction button
134 transactiondisplay->newtransaction->setEnabled ( FALSE ); 134 transactiondisplay->newtransaction->setEnabled ( FALSE );
135 } 135 }
136 else //we selected a parent without children or a child 136 else //we selected a parent without children or a child
137 transactiondisplay->newtransaction->setEnabled ( TRUE ); 137 transactiondisplay->newtransaction->setEnabled ( TRUE );
138 138
139 // disable the transactionid column so it can't be red 139 // disable the transactionid column so it can't be red
140 transactiondisplay->listview->header()->setResizeEnabled ( FALSE, 3 ); 140 transactiondisplay->listview->header()->setResizeEnabled ( FALSE, 3 );
141 141
142 // set the accountid and children variables 142 // set the accountid and children variables
143 transactiondisplay->setChildren ( children ); 143 transactiondisplay->setChildren ( children );
144 transactiondisplay->setAccountID ( accountid ); 144 transactiondisplay->setAccountID ( accountid );
145 145
146 setTransactionDisplayDate ();
147
146 // display transactions 148 // display transactions
147 transactiondisplay->listview->clear(); 149 transactiondisplay->listview->clear();
148 QString displaytext = "%"; 150 QString displaytext = "%";
149 displaytext.prepend ( transactiondisplay->limitbox->text() ); 151 displaytext.prepend ( transactiondisplay->limitbox->text() );
150 if ( transaction->getNumberOfTransactions() > 0 ) 152 if ( transaction->getNumberOfTransactions() > 0 )
151 transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext ); 153 transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate );
152 154
153 // display transfers 155 // display transfers
154 transfer->displayTransfers ( transactiondisplay->listview, accountid, children ); 156 transfer->displayTransfers ( transactiondisplay->listview, accountid, children );
155 157
156 // open a new preferences object and resize the transaction display columns 158 // open a new preferences object and resize the transaction display columns
157 // each column will have a different size based on whether we are looking at a child 159 // each column will have a different size based on whether we are looking at a child
158 // account or children through a parent 160 // account or children through a parent
159 if ( parentaccountid != -1 || accountdisplay->listview->selectedItem()->childCount() == 0 ) // a parent with no children or a child - three columns 161 if ( parentaccountid != -1 || accountdisplay->listview->selectedItem()->childCount() == 0 ) // a parent with no children or a child - three columns
160 { 162 {
161 transactiondisplay->listview->setColumnWidth ( 0, preferences->getColumnPreference ( 3 ) ); // normal transaction date width 163 transactiondisplay->listview->setColumnWidth ( 0, preferences->getColumnPreference ( 3 ) ); // normal transaction date width
162 transactiondisplay->listview->setColumnWidthMode ( 0, QListView::Manual ); 164 transactiondisplay->listview->setColumnWidthMode ( 0, QListView::Manual );
163 transactiondisplay->listview->setColumnWidth ( 1, preferences->getColumnPreference ( 4 ) ); // normal transaction name width 165 transactiondisplay->listview->setColumnWidth ( 1, preferences->getColumnPreference ( 4 ) ); // normal transaction name width
164 transactiondisplay->listview->setColumnWidthMode ( 1, QListView::Manual ); 166 transactiondisplay->listview->setColumnWidthMode ( 1, QListView::Manual );
165 transactiondisplay->listview->setColumnWidth ( 2, preferences->getColumnPreference ( 5 ) ); // normal transaction amount width 167 transactiondisplay->listview->setColumnWidth ( 2, preferences->getColumnPreference ( 5 ) ); // normal transaction amount width
166 transactiondisplay->listview->setColumnWidthMode ( 2, QListView::Manual ); 168 transactiondisplay->listview->setColumnWidthMode ( 2, QListView::Manual );
167 } 169 }
168 else 170 else
169 { 171 {
170 transactiondisplay->listview->setColumnWidth ( 0, preferences->getColumnPreference ( 6 ) ); // extended transaction date width 172 transactiondisplay->listview->setColumnWidth ( 0, preferences->getColumnPreference ( 6 ) ); // extended transaction date width
171 transactiondisplay->listview->setColumnWidthMode ( 0, QListView::Manual ); 173 transactiondisplay->listview->setColumnWidthMode ( 0, QListView::Manual );
172 transactiondisplay->listview->setColumnWidth ( 1, preferences->getColumnPreference ( 7 ) ); // extended transaction name width 174 transactiondisplay->listview->setColumnWidth ( 1, preferences->getColumnPreference ( 7 ) ); // extended transaction name width
173 transactiondisplay->listview->setColumnWidthMode ( 1, QListView::Manual ); 175 transactiondisplay->listview->setColumnWidthMode ( 1, QListView::Manual );
174 transactiondisplay->listview->setColumnWidth ( 2, preferences->getColumnPreference ( 8 ) ); // extended transaction amount width 176 transactiondisplay->listview->setColumnWidth ( 2, preferences->getColumnPreference ( 8 ) ); // extended transaction amount width
175 transactiondisplay->listview->setColumnWidthMode ( 2, QListView::Manual ); 177 transactiondisplay->listview->setColumnWidthMode ( 2, QListView::Manual );
176 transactiondisplay->listview->setColumnWidth ( 4, preferences->getColumnPreference ( 9 ) ); // transaction account width 178 transactiondisplay->listview->setColumnWidth ( 4, preferences->getColumnPreference ( 9 ) ); // transaction account width
177 transactiondisplay->listview->setColumnWidthMode ( 4, QListView::Manual ); 179 transactiondisplay->listview->setColumnWidthMode ( 4, QListView::Manual );
178 } 180 }
179 181
180 // show the window 182 // show the window
181 transactiondisplay->show(); 183 transactiondisplay->show();
182 // hide the account display and define accountid 184 // hide the account display and define accountid
183 accountdisplay->hide(); 185 accountdisplay->hide();
184 // hide the budget display 186 // hide the budget display
185 budgetdisplay->hide(); 187 budgetdisplay->hide();
186 } 188 }
187 else if ( maintabs->currentPageIndex() == 0 ) 189 else if ( maintabs->currentPageIndex() == 0 )
188 { 190 {
189 disableOneTouchViewing(); 191 disableOneTouchViewing();
190 192
191 // clear the account display selection 193 // clear the account display selection
192 accountdisplay->listview->clearSelection(); 194 accountdisplay->listview->clearSelection();
193 195
194 // resize the account display columns 196 // resize the account display columns
195 accountdisplay->listview->setColumnWidth ( 0, preferences->getColumnPreference ( 1 ) ); 197 accountdisplay->listview->setColumnWidth ( 0, preferences->getColumnPreference ( 1 ) );
196 accountdisplay->listview->setColumnWidth ( 1, preferences->getColumnPreference ( 2 ) ); 198 accountdisplay->listview->setColumnWidth ( 1, preferences->getColumnPreference ( 2 ) );
197 199
198 // display the accounts 200 // display the accounts
199 if ( account->getNumberOfAccounts() != 0 ) 201 if ( account->getNumberOfAccounts() != 0 )
200 account->displayAccounts ( accountdisplay->listview ); 202 account->displayAccounts ( accountdisplay->listview );
201 maintabs->setTabEnabled ( tab_2, FALSE ); 203 maintabs->setTabEnabled ( tab_2, FALSE );
202 204
203 // set the toggle button 205 // set the toggle button
204 accountdisplay->setToggleButton (); 206 accountdisplay->setToggleButton ();
205 207
206 // show the account display 208 // show the account display
207 accountdisplay->show(); 209 accountdisplay->show();
208 210
209 // hide the transaction display 211 // hide the transaction display
210 transactiondisplay->hide(); 212 transactiondisplay->hide();
211 213
212 // hide the budget display 214 // hide the budget display
213 budgetdisplay->hide(); 215 budgetdisplay->hide();
214 216
215 217
216 enableOneTouchViewing (); 218 enableOneTouchViewing ();
217 } 219 }
218 else 220 else
219 { 221 {
220 budgetdisplay->displayLineItems(); 222 budgetdisplay->displayLineItems();
221 budgetdisplay->show(); 223 budgetdisplay->show();
222 transactiondisplay->hide(); 224 transactiondisplay->hide();
223 accountdisplay->hide(); 225 accountdisplay->hide();
224 } 226 }
225 } 227 }
226 228
227void QashMoney::setTransactionTab () 229void QashMoney::setTransactionTab ()
228 { 230 {
229 if ( accountdisplay->listview->selectedItem() == 0 ) 231 if ( accountdisplay->listview->selectedItem() == 0 )
230 maintabs->setTabEnabled ( tab_2, FALSE ); 232 maintabs->setTabEnabled ( tab_2, FALSE );
231 else 233 else
232 maintabs->setTabEnabled ( tab_2, TRUE ); 234 maintabs->setTabEnabled ( tab_2, TRUE );
233 } 235 }
234 236
235void QashMoney::displayDatePreferencesDialog () 237void QashMoney::displayDatePreferencesDialog ()
236 { 238 {
237 // this shows a dialog to set preferences for formatting the date 239 // this shows a dialog to set preferences for formatting the date
238 DatePreferences *pd = new DatePreferences ( this ); 240 DatePreferences *pd = new DatePreferences ( this );
239 pd->exec (); 241 pd->exec ();
240 if ( transactiondisplay->isVisible() ) 242 if ( transactiondisplay->isVisible() )
241 { 243 {
242 // set the account id 244 // set the account id
243 int accountid = accountdisplay->listview->selectedItem()->text ( accountdisplay->getIDColumn() ).toInt(); 245 int accountid = accountdisplay->listview->selectedItem()->text ( accountdisplay->getIDColumn() ).toInt();
244 246
245 // set children so we can let displayTransfers know if there are children for the selected account 247 // set children so we can let displayTransfers know if there are children for the selected account
246 bool children; 248 bool children;
247 if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 ) 249 if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 )
248 children = TRUE; 250 children = TRUE;
249 else 251 else
250 children = FALSE; 252 children = FALSE;
251 253
252 // redisplay transactions if they are visible incorporating 254 // redisplay transactions if they are visible incorporating
253 // any changes to the date format 255 // any changes to the date format
254 transactiondisplay->listview->clear(); 256 transactiondisplay->listview->clear();
255 QString displaytext = "%"; 257 QString displaytext = "%";
256 displaytext.prepend ( transactiondisplay->limitbox->text() ); 258 displaytext.prepend ( transactiondisplay->limitbox->text() );
259
260 setTransactionDisplayDate();
257 if ( transaction->getNumberOfTransactions() > 0 ) 261 if ( transaction->getNumberOfTransactions() > 0 )
258 transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext ); 262 transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate );
259 263
260 if ( transfer->getNumberOfTransfers() != 0 ) 264 if ( transfer->getNumberOfTransfers() != 0 )
261 transfer->displayTransfers ( transactiondisplay->listview, accountid, children ); 265 transfer->displayTransfers ( transactiondisplay->listview, accountid, children );
262 } 266 }
263 else if ( accountdisplay->isVisible() ) 267 else if ( accountdisplay->isVisible() )
264 { 268 {
265 accountdisplay->listview->clearSelection(); 269 accountdisplay->listview->clearSelection();
266 maintabs->setTabEnabled ( tab_2, FALSE ); 270 maintabs->setTabEnabled ( tab_2, FALSE );
267 } 271 }
268 else 272 else
269 budgetdisplay->updateBudgetInformation(); 273 budgetdisplay->updateBudgetInformation();
270 } 274 }
271 275
272void QashMoney::displayTransactionPreferencesDialog () 276void QashMoney::displayTransactionPreferencesDialog ()
273 { 277 {
274 // display a dialog for setting preferences for transactions 278 // display a dialog for setting preferences for transactions
275 TransactionPreferences *td = new TransactionPreferences ( this ); 279 TransactionPreferences *td = new TransactionPreferences ( this );
276 td->exec (); 280 td->exec ();
277 if ( transactiondisplay->isVisible() ) 281 if ( transactiondisplay->isVisible() )
278 { 282 {
279 // set the account id 283 // set the account id
280 int accountid = accountdisplay->listview->selectedItem()->text ( accountdisplay->getIDColumn() ).toInt(); 284 int accountid = accountdisplay->listview->selectedItem()->text ( accountdisplay->getIDColumn() ).toInt();
281 285
282 // set children so we can let displayTransfers know if there are children for the selected account 286 // set children so we can let displayTransfers know if there are children for the selected account
283 bool children; 287 bool children;
284 if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 ) 288 if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 )
285 children = TRUE; 289 children = TRUE;
286 else 290 else
287 children = FALSE; 291 children = FALSE;
288 292
289 // redisplay transactions incorporating any transaction preference changes 293 // redisplay transactions incorporating any transaction preference changes
290 transactiondisplay->listview->clear(); 294 transactiondisplay->listview->clear();
291 QString displaytext = "%"; 295 QString displaytext = "%";
292 displaytext.prepend ( transactiondisplay->limitbox->text() ); 296 displaytext.prepend ( transactiondisplay->limitbox->text() );
297
298 setTransactionDisplayDate();
293 if ( transaction->getNumberOfTransactions() > 0 ) 299 if ( transaction->getNumberOfTransactions() > 0 )
294 transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext ); 300 transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate );
295 301
296 if ( transfer->getNumberOfTransfers() != 0 ) 302 if ( transfer->getNumberOfTransfers() != 0 )
297 transfer->displayTransfers ( transactiondisplay->listview, accountid, children ); 303 transfer->displayTransfers ( transactiondisplay->listview, accountid, children );
298 } 304 }
299 else 305 else
300 { 306 {
301 accountdisplay->listview->clearSelection(); 307 accountdisplay->listview->clearSelection();
302 maintabs->setTabEnabled ( tab_2, FALSE ); 308 maintabs->setTabEnabled ( tab_2, FALSE );
303 } 309 }
304 } 310 }
305 311
306void QashMoney::displayAccountPreferencesDialog () 312void QashMoney::displayAccountPreferencesDialog ()
307 { 313 {
308 // display a dialog for setting preferences for accounts 314 // display a dialog for setting preferences for accounts
309 AccountPreferences *ap = new AccountPreferences ( this ); 315 AccountPreferences *ap = new AccountPreferences ( this );
310 ap->exec (); 316 ap->exec ();
311 317
312 if ( accountdisplay->isVisible() && account->getNumberOfAccounts() != 0 ) 318 if ( accountdisplay->isVisible() && account->getNumberOfAccounts() != 0 )
313 { 319 {
314 accountdisplay->listview->clear(); 320 accountdisplay->listview->clear();
315 account->displayAccounts ( accountdisplay->listview ); 321 account->displayAccounts ( accountdisplay->listview );
316 accountdisplay->listview->clearSelection(); 322 accountdisplay->listview->clearSelection();
317 maintabs->setTabEnabled ( tab_2, FALSE ); 323 maintabs->setTabEnabled ( tab_2, FALSE );
318 } 324 }
319 changeTabDisplay(); 325 changeTabDisplay();
320 } 326 }
321 327
322void QashMoney::displayMemoryDialog () 328void QashMoney::displayMemoryDialog ()
323 { 329 {
324 // opens a dialog to add, edit and delete memory items 330 // opens a dialog to add, edit and delete memory items
325 MemoryDialog *md = new MemoryDialog (); 331 MemoryDialog *md = new MemoryDialog ();
326 md->exec(); 332 md->exec();
327 } 333 }
328 334
329void QashMoney::showTransactions () 335void QashMoney::showTransactions ()
330 { 336 {
331 maintabs->setCurrentPage ( 1 ); 337 maintabs->setCurrentPage ( 1 );
332 } 338 }
333 339
334void QashMoney::enableOneTouchViewing () 340void QashMoney::enableOneTouchViewing ()
335 { 341 {
336 if ( preferences->getPreference ( 5 ) == 1 ) 342 if ( preferences->getPreference ( 5 ) == 1 )
337 connect ( accountdisplay->listview, SIGNAL ( selectionChanged () ), this, SLOT ( showTransactions () ) ); 343 connect ( accountdisplay->listview, SIGNAL ( selectionChanged () ), this, SLOT ( showTransactions () ) );
338 else 344 else
339 disconnect ( accountdisplay->listview, SIGNAL ( selectionChanged () ), this, SLOT ( showTransactions () ) ); 345 disconnect ( accountdisplay->listview, SIGNAL ( selectionChanged () ), this, SLOT ( showTransactions () ) );
340 } 346 }
341 347
342void QashMoney::disableOneTouchViewing () 348void QashMoney::disableOneTouchViewing ()
343 { 349 {
344 disconnect ( accountdisplay->listview, SIGNAL ( selectionChanged () ), this, SLOT ( showTransactions () ) ); 350 disconnect ( accountdisplay->listview, SIGNAL ( selectionChanged () ), this, SLOT ( showTransactions () ) );
345 } 351 }
346 352
347void QashMoney::toggleOneTouchViewing ( bool state ) 353void QashMoney::toggleOneTouchViewing ( bool state )
348 { 354 {
349 if ( state == TRUE ) 355 if ( state == TRUE )
350 disableOneTouchViewing(); 356 disableOneTouchViewing();
351 else 357 else
352 enableOneTouchViewing(); 358 enableOneTouchViewing();
353 } 359 }
354 360
355 361void QashMoney::setTransactionDisplayDate ()
362 {
363 // determine how many days of transactions to show
364 int limittype = preferences->getPreference ( 7 );
365 if ( limittype != 5 ) // set today's date if we are not showing all transactions
366 {
367 QDate today = QDate::currentDate ();
368 switch ( limittype ) // if we are not showing all transactions
369 {
370 case 0: // viewing two weeks
371 newdate = today.addDays ( -14 );
372 break;
373 case 1: // viewing one month
374 newdate = today.addDays ( -30 );
375 break;
376 case 2: // three months
377 newdate = today.addDays ( -90 );
378 break;
379 case 3: // six months
380 newdate = today.addDays ( -180 );
381 break;
382 case 4: // one year
383 newdate = today.addDays ( -365 );
384 break;
385 }
386 }
387 else
388 newdate = QDate ( 1, 1, 1000 );
389 }
356 390
diff --git a/noncore/apps/qashmoney/qashmoney.h b/noncore/apps/qashmoney/qashmoney.h
index cf0bd42..ec2c7ec 100755
--- a/noncore/apps/qashmoney/qashmoney.h
+++ b/noncore/apps/qashmoney/qashmoney.h
@@ -1,61 +1,64 @@
1#ifndef QASHMONEY_H 1#ifndef QASHMONEY_H
2#define QASHMONEY_H 2#define QASHMONEY_H
3 3
4#include <qpe/qpemenubar.h> 4#include <qpe/qpemenubar.h>
5#include <qpopupmenu.h> 5#include <qpopupmenu.h>
6#include <qlayout.h> 6#include <qlayout.h>
7#include <qtabwidget.h> 7#include <qtabwidget.h>
8#include <qdatetime.h>
8 9
9#include "accountdisplay.h" 10#include "accountdisplay.h"
10#include "transactiondisplay.h" 11#include "transactiondisplay.h"
11#include "budgetdisplay.h" 12#include "budgetdisplay.h"
12#include "account.h" 13#include "account.h"
13#include "preferences.h" 14#include "preferences.h"
14#include "transaction.h" 15#include "transaction.h"
15#include "transfer.h" 16#include "transfer.h"
16#include "memory.h" 17#include "memory.h"
17#include "budget.h" 18#include "budget.h"
18 19
19class QashMoney : public QWidget 20class QashMoney : public QWidget
20 { 21 {
21 Q_OBJECT 22 Q_OBJECT
22 23
23 public: 24 public:
24 QashMoney (); 25 QashMoney ();
25 ~QashMoney(); 26 ~QashMoney();
26 27
27 QTabWidget* maintabs; 28 QTabWidget* maintabs;
28 QWidget* tab; 29 QWidget* tab;
29 QWidget* tab_2; 30 QWidget* tab_2;
30 QWidget* tab_3; 31 QWidget* tab_3;
31 32
32 QPEMenuBar *mainmenu; 33 QPEMenuBar *mainmenu;
33 QPopupMenu *preferencesmenu; 34 QPopupMenu *preferencesmenu;
34 QPopupMenu *utilitiesmenu; 35 QPopupMenu *utilitiesmenu;
35 36
36 public slots: 37 public slots:
37 void displayDatePreferencesDialog (); 38 void displayDatePreferencesDialog ();
38 void displayTransactionPreferencesDialog (); 39 void displayTransactionPreferencesDialog ();
39 void displayAccountPreferencesDialog (); 40 void displayAccountPreferencesDialog ();
40 void displayMemoryDialog (); 41 void displayMemoryDialog ();
41 void setTransactionTab (); 42 void setTransactionTab ();
42 43
43 private slots: 44 private slots:
44 void changeTabDisplay (); 45 void changeTabDisplay ();
45 void showTransactions (); 46 void showTransactions ();
46 void enableOneTouchViewing (); 47 void enableOneTouchViewing ();
47 void disableOneTouchViewing (); 48 void disableOneTouchViewing ();
48 void toggleOneTouchViewing ( bool ); 49 void toggleOneTouchViewing ( bool );
50 void setTransactionDisplayDate ();
49 51
50 private: 52 private:
51 QVBoxLayout *layout; 53 QVBoxLayout *layout;
52 QVBoxLayout *tabslayout; 54 QVBoxLayout *tabslayout;
53 AccountDisplay *accountdisplay; 55 AccountDisplay *accountdisplay;
54 TransactionDisplay *transactiondisplay; 56 TransactionDisplay *transactiondisplay;
55 BudgetDisplay *budgetdisplay; 57 BudgetDisplay *budgetdisplay;
56 int tabheight; 58 int tabheight;
59 QDate newdate;
57 60
58 }; 61 };
59 62
60#endif 63#endif
61 64
diff --git a/noncore/apps/qashmoney/qmaccounts.db b/noncore/apps/qashmoney/qmaccounts.db
index 449bcab..76db78b 100755
--- a/noncore/apps/qashmoney/qmaccounts.db
+++ b/noncore/apps/qashmoney/qmaccounts.db
Binary files differ
diff --git a/noncore/apps/qashmoney/qmbudgets.db b/noncore/apps/qashmoney/qmbudgets.db
index d798f0c..ef75719 100755
--- a/noncore/apps/qashmoney/qmbudgets.db
+++ b/noncore/apps/qashmoney/qmbudgets.db
Binary files differ
diff --git a/noncore/apps/qashmoney/qmmemory.db b/noncore/apps/qashmoney/qmmemory.db
index 5c23122..c6b7920 100755
--- a/noncore/apps/qashmoney/qmmemory.db
+++ b/noncore/apps/qashmoney/qmmemory.db
Binary files differ
diff --git a/noncore/apps/qashmoney/qmpreferences.db b/noncore/apps/qashmoney/qmpreferences.db
index a4e96f5..91596cb 100755
--- a/noncore/apps/qashmoney/qmpreferences.db
+++ b/noncore/apps/qashmoney/qmpreferences.db
Binary files differ
diff --git a/noncore/apps/qashmoney/qmtransactions.db b/noncore/apps/qashmoney/qmtransactions.db
index 9e4acc9..a5eb4f3 100755
--- a/noncore/apps/qashmoney/qmtransactions.db
+++ b/noncore/apps/qashmoney/qmtransactions.db
Binary files differ
diff --git a/noncore/apps/qashmoney/qmtransfers.db b/noncore/apps/qashmoney/qmtransfers.db
index c31df1a..3ca9f78 100755
--- a/noncore/apps/qashmoney/qmtransfers.db
+++ b/noncore/apps/qashmoney/qmtransfers.db
Binary files differ
diff --git a/noncore/apps/qashmoney/transaction.cpp b/noncore/apps/qashmoney/transaction.cpp
index af7d18f..5ecc7ed 100755
--- a/noncore/apps/qashmoney/transaction.cpp
+++ b/noncore/apps/qashmoney/transaction.cpp
@@ -1,274 +1,270 @@
1// RESERVEDONE COLUMN NAME REPRESENTS THE LINEITEMID AND SHOULD BE CHANGED IN 1// RESERVEDONE COLUMN NAME REPRESENTS THE LINEITEMID AND SHOULD BE CHANGED IN
2// FUTURE VERSIONS OF QASHMONEY 2// FUTURE VERSIONS OF QASHMONEY
3 3
4// RESERVEDTWO REPRESENTS THE TRANSACTION DESCRIPTION 4// RESERVEDTWO REPRESENTS THE TRANSACTION DESCRIPTION
5 5
6#include "transaction.h" 6#include "transaction.h"
7#include "account.h" 7#include "account.h"
8#include "transactiondisplay.h" 8#include "transactiondisplay.h"
9 9
10#include <stdlib.h> 10#include <stdlib.h>
11#include <iostream.h>
11 12
12extern Account *account; 13extern Account *account;
13extern Preferences *preferences; 14extern Preferences *preferences;
14 15
15Transaction::Transaction () 16Transaction::Transaction ()
16 { 17 {
17 tdb = sqlite_open ( "qmtransactions.db", 0, NULL ); 18 tdb = sqlite_open ( "qmtransactions.db", 0, NULL );
18 } 19 }
19 20
20Transaction::~Transaction () 21Transaction::~Transaction ()
21 { 22 {
22 sqlite_close ( tdb ); 23 sqlite_close ( tdb );
23 } 24 }
24 25
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 ) 26void 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 {
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 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 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 }
30 31
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 ) 32void 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 {
33 sqlite_exec_printf ( tdb, "update transactions set reservedtwo = '%q', payee = '%q', number = %i, day = %i, month = %i, year = %i, amount = %.2f, 34 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 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 amount, cleared, budgetid, lineitemid, transactionid );
36 } 37 }
37 38
38void Transaction::deleteTransaction ( int transid ) 39void Transaction::deleteTransaction ( int transid )
39 { 40 {
40 sqlite_exec_printf ( tdb, "delete from transactions where transid = %i;", 0, 0, 0, transid ); 41 sqlite_exec_printf ( tdb, "delete from transactions where transid = %i;", 0, 0, 0, transid );
41 } 42 }
42 43
43void Transaction::deleteAllTransactions ( int accountid ) 44void Transaction::deleteAllTransactions ( int accountid )
44 { 45 {
45 sqlite_exec_printf ( tdb, "delete from transactions where accountid = %i;", 0, 0, 0, accountid ); 46 sqlite_exec_printf ( tdb, "delete from transactions where accountid = %i;", 0, 0, 0, accountid );
46 } 47 }
47 48
48int Transaction::getAccountID ( int id ) 49int Transaction::getAccountID ( int id )
49 { 50 {
50 char **results; 51 char **results;
51 sqlite_get_table_printf ( tdb, "select accountid from transactions where transid= %i;", &results, NULL, NULL, NULL, id ); 52 sqlite_get_table_printf ( tdb, "select accountid from transactions where transid= %i;", &results, NULL, NULL, NULL, id );
52 return atol ( results [ 1 ] ); 53 return atol ( results [ 1 ] );
53 } 54 }
54 55
55int Transaction::getNumberOfTransactions () 56int Transaction::getNumberOfTransactions ()
56 { 57 {
57 char **results; 58 char **results;
58 sqlite_get_table ( tdb, "select count() from transactions;", &results, NULL, NULL, NULL ); 59 sqlite_get_table ( tdb, "select count() from transactions;", &results, NULL, NULL, NULL );
59 return atoi ( results [ 1 ] ); 60 return atoi ( results [ 1 ] );
60 } 61 }
61 62
62int Transaction::getNumberOfTransactions ( int accountid ) 63int Transaction::getNumberOfTransactions ( int accountid )
63 { 64 {
64 char **results; 65 char **results;
65 sqlite_get_table_printf ( tdb, "select count() from transactions where accountid = %i;", &results, NULL, NULL, NULL, accountid ); 66 sqlite_get_table_printf ( tdb, "select count() from transactions where accountid = %i;", &results, NULL, NULL, NULL, accountid );
66 return atol ( results [ 1 ] ); 67 return atol ( results [ 1 ] );
67 } 68 }
68 69
69QString Transaction::getPayee ( int id ) 70QString Transaction::getPayee ( int id )
70 { 71 {
71 char **results; 72 char **results;
72 sqlite_get_table_printf ( tdb, "select payee from transactions where transid= %i;", &results, NULL, NULL, NULL, id ); 73 sqlite_get_table_printf ( tdb, "select payee from transactions where transid= %i;", &results, NULL, NULL, NULL, id );
73 return results [ 1 ]; 74 return results [ 1 ];
74 } 75 }
75 76
76QString Transaction::getTransactionDescription ( int id ) 77QString Transaction::getTransactionDescription ( int id )
77 { 78 {
78 char **results; 79 char **results;
79 sqlite_get_table_printf ( tdb, "select reservedtwo from transactions where transid= %i;", &results, NULL, NULL, NULL, id ); 80 sqlite_get_table_printf ( tdb, "select reservedtwo from transactions where transid= %i;", &results, NULL, NULL, NULL, id );
80 return results [ 1 ]; 81 return results [ 1 ];
81 } 82 }
82 83
83QString Transaction::getNumber ( int id ) 84QString Transaction::getNumber ( int id )
84 { 85 {
85 char **results; 86 char **results;
86 sqlite_get_table_printf ( tdb, "select number from transactions where transid= %i;", &results, NULL, NULL, NULL, id ); 87 sqlite_get_table_printf ( tdb, "select number from transactions where transid= %i;", &results, NULL, NULL, NULL, id );
87 return results [ 1 ]; 88 return results [ 1 ];
88 } 89 }
89 90
90QString Transaction::getAmount ( int id ) 91QString Transaction::getAmount ( int id )
91 { 92 {
92 char **results; 93 char **results;
93 sqlite_get_table_printf ( tdb, "select amount from transactions where transid= %i;", &results, NULL, NULL, NULL, id ); 94 sqlite_get_table_printf ( tdb, "select amount from transactions where transid= %i;", &results, NULL, NULL, NULL, id );
94 return results [ 1 ]; 95 return results [ 1 ];
95 } 96 }
96 97
97QString Transaction::getAbsoluteAmount ( int id ) 98QString Transaction::getAbsoluteAmount ( int id )
98 { 99 {
99 char **results; 100 char **results;
100 sqlite_get_table_printf ( tdb, "select abs ( amount ) from transactions where transid= %i;", &results, NULL, NULL, NULL, id ); 101 sqlite_get_table_printf ( tdb, "select abs ( amount ) from transactions where transid= %i;", &results, NULL, NULL, NULL, id );
101 return results [ 1 ]; 102 return results [ 1 ];
102 } 103 }
103 104
104int Transaction::getCleared ( int id ) 105int Transaction::getCleared ( int id )
105 { 106 {
106 char **results; 107 char **results;
107 sqlite_get_table_printf ( tdb, "select cleared from transactions where transid= %i;", &results, NULL, NULL, NULL, id ); 108 sqlite_get_table_printf ( tdb, "select cleared from transactions where transid= %i;", &results, NULL, NULL, NULL, id );
108 QString cleared = results [ 1 ]; 109 QString cleared = results [ 1 ];
109 return cleared.toInt(); 110 return cleared.toInt();
110 } 111 }
111 112
112void Transaction::setCleared ( int id, int cleared ) 113void Transaction::setCleared ( int id, int cleared )
113 { 114 {
114 sqlite_exec_printf ( tdb, "update transactions set cleared = %i where transid = %i;", 0, 0, 0, cleared, id ); 115 sqlite_exec_printf ( tdb, "update transactions set cleared = %i where transid = %i;", 0, 0, 0, cleared, id );
115 } 116 }
116 117
117int Transaction::getBudgetID ( int id ) 118int Transaction::getBudgetID ( int id )
118 { 119 {
119 char **results; 120 char **results;
120 sqlite_get_table_printf ( tdb, "select budgetid from transactions where transid = %i;", &results, NULL, NULL, NULL, id ); 121 sqlite_get_table_printf ( tdb, "select budgetid from transactions where transid = %i;", &results, NULL, NULL, NULL, id );
121 QString budgetid = results [ 1 ]; 122 QString budgetid = results [ 1 ];
122 return budgetid.toInt(); 123 return budgetid.toInt();
123 } 124 }
124 125
125int Transaction::getLineItemID ( int id ) 126int Transaction::getLineItemID ( int id )
126 { 127 {
127 char **results; 128 char **results;
128 sqlite_get_table_printf ( tdb, "select reservedone from transactions where transid = %i;", &results, NULL, NULL, NULL, id ); 129 sqlite_get_table_printf ( tdb, "select reservedone from transactions where transid = %i;", &results, NULL, NULL, NULL, id );
129 QString lineitemid = results [ 1 ]; 130 QString lineitemid = results [ 1 ];
130 return lineitemid.toInt(); 131 return lineitemid.toInt();
131 } 132 }
132 133
133int Transaction::getDay ( int id ) 134int Transaction::getDay ( int id )
134 { 135 {
135 char **results; 136 char **results;
136 sqlite_get_table_printf ( tdb, "select day from transactions where transid= %i;", &results, NULL, NULL, NULL, id ); 137 sqlite_get_table_printf ( tdb, "select day from transactions where transid= %i;", &results, NULL, NULL, NULL, id );
137 QString daystring = results [ 1 ]; 138 QString daystring = results [ 1 ];
138 return daystring.toInt(); 139 return daystring.toInt();
139 } 140 }
140 141
141int Transaction::getMonth ( int id ) 142int Transaction::getMonth ( int id )
142 { 143 {
143 char **results; 144 char **results;
144 sqlite_get_table_printf ( tdb, "select month from transactions where transid= %i;", &results, NULL, NULL, NULL, id ); 145 sqlite_get_table_printf ( tdb, "select month from transactions where transid= %i;", &results, NULL, NULL, NULL, id );
145 QString monthstring = results [ 1 ]; 146 QString monthstring = results [ 1 ];
146 return monthstring.toInt(); 147 return monthstring.toInt();
147 } 148 }
148 149
149int Transaction::getYear ( int id ) 150int Transaction::getYear ( int id )
150 { 151 {
151 char **results; 152 char **results;
152 sqlite_get_table_printf ( tdb, "select year from transactions where transid= %i;", &results, NULL, NULL, NULL, id ); 153 sqlite_get_table_printf ( tdb, "select year from transactions where transid= %i;", &results, NULL, NULL, NULL, id );
153 QString yearstring = results [ 1 ]; 154 QString yearstring = results [ 1 ];
154 return yearstring.toInt(); 155 return yearstring.toInt();
155 } 156 }
156 157
157void Transaction::displayTransactions ( QListView *listview, int id, bool children, const char *limit ) 158void Transaction::displayTransactions ( QListView *listview, int id, bool children, const char *limit, QDate displaydate )
158 { 159 {
159 int showcleared = preferences->getPreference ( 3 ); 160 int showcleared = preferences->getPreference ( 3 );
161 int year = ( displaydate.year() ) - 1;
160 162
161 // select the transactions to display 163 // select the transactions to display
162 // two different statements are used based on 164 // two different statements are used based on
163 // whether we are showing cleared transactions 165 // whether we are showing cleared transactions
164 char **results; 166 char **results;
165 int rows, columns; 167 int rows, columns;
166 if ( showcleared == 0 ) 168 if ( showcleared == 0 )
167 { 169 {
168 if ( account->getParentAccountID ( id ) == -1 && children == TRUE ) 170 if ( account->getParentAccountID ( id ) == -1 && children == TRUE )
169 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 ); 171 sqlite_get_table_printf ( tdb, "select day, month, year, payee, amount, transid, accountid from transactions where cleared = 0 and year >= %i parentid = %i and payee like '%q';", &results, &rows, &columns, NULL, year, id, limit );
170 else 172 else
171 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 ); 173 sqlite_get_table_printf ( tdb, "select day, month, year, payee, amount, transid, accountid from transactions where cleared = 0 year >= %i accountid = %i and payee like '%q';", &results, &rows, &columns, NULL, year, id, limit );
172 } 174 }
173 else 175 else
174 { 176 {
175 if ( account->getParentAccountID ( id ) == -1 && children == TRUE ) 177 if ( account->getParentAccountID ( id ) == -1 && children == TRUE )
176 sqlite_get_table_printf ( tdb, "select day, month, year, payee, amount, transid, accountid from transactions where parentid = %i and payee like '%q';", &results, &rows, &columns, NULL, id, limit ); 178 sqlite_get_table_printf ( tdb, "select day, month, year, payee, amount, transid, accountid from transactions where year >= %i and parentid = %i and payee like '%q';", &results, &rows, &columns, NULL, year, id, limit );
177 else 179 else
178 sqlite_get_table_printf ( tdb, "select day, month, year, payee, amount, transid, accountid from transactions where accountid = %i and payee like '%q';", &results, &rows, &columns, NULL, id, limit ); 180 sqlite_get_table_printf ( tdb, "select day, month, year, payee, amount, transid, accountid from transactions where accountid = %i and payee like '%q';", &results, &rows, &columns, NULL, id, limit );
179 } 181 }
180 182
181 // iterate through the result list and display each item 183 // iterate through the result list and display each item
182 int counter = 7; 184 int counter = 7;
183 while ( counter < ( ( rows + 1 ) * columns ) ) 185 while ( counter < ( ( rows + 1 ) * columns ) )
184 { 186 {
185 // construct the date 187 QDate displaydate ( atoi ( results [ counter + 2 ] ), atoi ( results [ counter + 1 ] ), atoi ( results [ counter ] ) );
186 //QString daystring = results [ counter ]; 188 QString date = preferences->getDate ( atoi ( results [ counter + 2 ] ), atoi ( results [ counter + 1 ] ), atoi ( results [ counter ] ) );
187 //int day = results [ counter ].toInt ();
188 //QString monthstring = results [ counter + 1 ];
189 //int month = results [ counter + 1 ].toInt ();
190 //QString yearstring = results [ counter + 2 ];
191 //int year = results [ counter + 2 ].toInt ();
192 QString date = preferences->getDate ( atoi ( results [ counter + 2 ] ), atoi ( results [ counter + 1 ] ), atoi ( results [ counter ] ) );
193 189
194 // construct transaction name, amount, id 190 // construct transaction name, amount, id
195 QString payee = results [ counter + 3 ]; 191 QString payee = results [ counter + 3 ];
196 QString amount = results [ counter + 4 ]; 192 QString amount = results [ counter + 4 ];
197 QString transferid = results [ counter + 5 ]; 193 QString transferid = results [ counter + 5 ];
198 194
199 //determine the account name of the child accounts that we're displaying 195 //determine the account name of the child accounts that we're displaying
200 QString accountname = account->getAccountName ( atoi ( results [ counter + 6 ] ) ); 196 QString accountname = account->getAccountName ( atoi ( results [ counter + 6 ] ) );
201 197
202 // fill in values 198 // fill in values
203 if ( account->getParentAccountID ( id ) != -1 ) // use these constructors if we're showing a child account 199 if ( account->getParentAccountID ( id ) != -1 ) // use these constructors if we're showing a child account
204 { 200 {
205 if ( showcleared == 1 && getCleared ( transferid.toInt() ) == 1 ) 201 if ( showcleared == 1 && getCleared ( transferid.toInt() ) == 1 )
206 ColorListItem *item = new ColorListItem ( listview, date, payee, amount, transferid); 202 ColorListItem *item = new ColorListItem ( listview, date, payee, amount, transferid);
207 else 203 else
208 QListViewItem *item = new QListViewItem ( listview, date, payee, amount, transferid ); 204 QListViewItem *item = new QListViewItem ( listview, date, payee, amount, transferid );
209 } 205 }
210 else 206 else
211 { 207 {
212 if ( showcleared == 1 && getCleared ( transferid.toInt() ) == 1 ) 208 if ( showcleared == 1 && getCleared ( transferid.toInt() ) == 1 )
213 ColorListItem *item = new ColorListItem ( listview, date, payee, amount, transferid, accountname ); 209 ColorListItem *item = new ColorListItem ( listview, date, payee, amount, transferid, accountname );
214 else 210 else
215 QListViewItem *item = new QListViewItem ( listview, date, payee, amount, transferid, accountname ); 211 QListViewItem *item = new QListViewItem ( listview, date, payee, amount, transferid, accountname );
216 } 212 }
217 213
218 // advance counter 214 // advance counter
219 counter = counter + 7; 215 counter = counter + 7;
220 } 216 }
221 } 217 }
222 218
223QString Transaction::getBudgetTotal ( int budgetid, int lineitemid, int year, int month, int viewtype ) 219QString Transaction::getBudgetTotal ( int budgetid, int lineitemid, int year, int month, int viewtype )
224 { 220 {
225 // determine if we are viewing a years, months, or days budget 221 // determine if we are viewing a years, months, or days budget
226 // we have to pick a different sum for each 222 // we have to pick a different sum for each
227 char **results; 223 char **results;
228 switch ( viewtype ) 224 switch ( viewtype )
229 { 225 {
230 case 1: // we are viewing a year 226 case 1: // we are viewing a year
231 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 ); 227 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 );
232 break; 228 break;
233 229
234 case 0: // we are viewing a month 230 case 0: // we are viewing a month
235 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 ); 231 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 );
236 break; 232 break;
237 } 233 }
238 QString amount = results [ 1 ]; 234 QString amount = results [ 1 ];
239 float total = amount.toFloat(); 235 float total = amount.toFloat();
240 amount.setNum ( total, 'f', 2 ); 236 amount.setNum ( total, 'f', 2 );
241 return amount; 237 return amount;
242 } 238 }
243 239
244QString Transaction::getActualTotal ( int budgetid, int year, int month, int viewtype ) 240QString Transaction::getActualTotal ( int budgetid, int year, int month, int viewtype )
245 { 241 {
246 // determine if we are viewing a years, months, or days budget 242 // determine if we are viewing a years, months, or days budget
247 // we have to pick a different sum for each 243 // we have to pick a different sum for each
248 char **results; 244 char **results;
249 switch ( viewtype ) 245 switch ( viewtype )
250 { 246 {
251 case 1: // we are viewing a year 247 case 1: // we are viewing a year
252 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 ); 248 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 );
253 break; 249 break;
254 250
255 case 0: // we are viewing a month 251 case 0: // we are viewing a month
256 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 ); 252 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 );
257 break; 253 break;
258 } 254 }
259 QString amount = results [ 1 ]; 255 QString amount = results [ 1 ];
260 float total = amount.toFloat(); 256 float total = amount.toFloat();
261 amount.setNum ( total, 'f', 2 ); 257 amount.setNum ( total, 'f', 2 );
262 return amount; 258 return amount;
263 } 259 }
264 260
265void Transaction::clearBudgetIDs ( int budgetid, int lineitemid ) 261void Transaction::clearBudgetIDs ( int budgetid, int lineitemid )
266 { 262 {
267 sqlite_exec_printf ( tdb, "update transactions set budgetid = -1 where budgetid = %i and reservedone = %i;", 0, 0, 0, budgetid, lineitemid ); 263 sqlite_exec_printf ( tdb, "update transactions set budgetid = -1 where budgetid = %i and reservedone = %i;", 0, 0, 0, budgetid, lineitemid );
268 } 264 }
269 265
270void Transaction::clearBudgetIDs ( int budgetid ) 266void Transaction::clearBudgetIDs ( int budgetid )
271 { 267 {
272 sqlite_exec_printf ( tdb, "update transactions set budgetid = -1 where budgetid = %i;", 0, 0, 0, budgetid ); 268 sqlite_exec_printf ( tdb, "update transactions set budgetid = -1 where budgetid = %i;", 0, 0, 0, budgetid );
273 } 269 }
274 270
diff --git a/noncore/apps/qashmoney/transaction.h b/noncore/apps/qashmoney/transaction.h
index 5db011c..7297bb1 100755
--- a/noncore/apps/qashmoney/transaction.h
+++ b/noncore/apps/qashmoney/transaction.h
@@ -1,69 +1,70 @@
1#ifndef TRANSACTION_H 1#ifndef TRANSACTION_H
2#define TRANSACTION_H 2#define TRANSACTION_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qlistview.h> 5#include <qlistview.h>
6#include <qdatetime.h>
6#include <sqlite.h> 7#include <sqlite.h>
7 8
8#include "preferences.h" 9#include "preferences.h"
9 10
10class Transaction 11class Transaction
11 { 12 {
12 public: 13 public:
13 14
14 Transaction (); 15 Transaction ();
15 ~Transaction (); 16 ~Transaction ();
16 17
17 // This function adds a new transaction to the database. It takes the payee, accountid, 18 // This function adds a new transaction to the database. It takes the payee, accountid,
18 // budgetid, number, day, month, year, amount, cleared 19 // budgetid, number, day, month, year, amount, cleared
19 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 ); 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 );
20 21
21 // This updates an already existing transaction 22 // This updates an already existing transaction
22 void updateTransaction ( QString, QString, int, int, int, int, float, int, int, int, int ); 23 void updateTransaction ( QString, QString, int, int, int, int, float, int, int, int, int );
23 24
24 // Deletes a transaction. Takes the transid as its parameter 25 // Deletes a transaction. Takes the transid as its parameter
25 void deleteTransaction ( int ); 26 void deleteTransaction ( int );
26 27
27 // Returns the number of transactions 28 // Returns the number of transactions
28 int getNumberOfTransactions (); 29 int getNumberOfTransactions ();
29 30
30 // this is an overloaded function that returns the number of 31 // this is an overloaded function that returns the number of
31 // transactions for an account 32 // transactions for an account
32 int getNumberOfTransactions ( int ); 33 int getNumberOfTransactions ( int );
33 34
34 // deletes all transactions for the provided accountid 35 // deletes all transactions for the provided accountid
35 void deleteAllTransactions ( int accountid ); 36 void deleteAllTransactions ( int accountid );
36 37
37 QString getBudgetTotal ( int budgetid, int lineitemid, int year, int month, int viewtype ); 38 QString getBudgetTotal ( int budgetid, int lineitemid, int year, int month, int viewtype );
38 QString getActualTotal ( int budgetid, int year, int month, int viewtype ); 39 QString getActualTotal ( int budgetid, int year, int month, int viewtype );
39 40
40 // These two functions clear budget ids is either a line item or an entire budget is deleted 41 // These two functions clear budget ids is either a line item or an entire budget is deleted
41 void clearBudgetIDs ( int, int ); 42 void clearBudgetIDs ( int, int );
42 void clearBudgetIDs ( int ); 43 void clearBudgetIDs ( int );
43 44
44 public slots: 45 public slots:
45 46
46 void displayTransactions ( QListView *, int, bool, const char * ); 47 void displayTransactions ( QListView *, int, bool, const char *, QDate );
47 QString getPayee ( int ); 48 QString getPayee ( int );
48 QString getTransactionDescription ( int ); 49 QString getTransactionDescription ( int );
49 QString getNumber ( int ); 50 QString getNumber ( int );
50 QString getAmount ( int ); 51 QString getAmount ( int );
51 QString getAbsoluteAmount ( int ); 52 QString getAbsoluteAmount ( int );
52 int getCleared ( int ); 53 int getCleared ( int );
53 void setCleared ( int id, int cleared ); 54 void setCleared ( int id, int cleared );
54 int getBudgetID ( int id ); 55 int getBudgetID ( int id );
55 int getLineItemID ( int id ); 56 int getLineItemID ( int id );
56 int getDay ( int ); 57 int getDay ( int );
57 int getMonth ( int ); 58 int getMonth ( int );
58 int getYear ( int ); 59 int getYear ( int );
59 int getAccountID ( int id ); 60 int getAccountID ( int id );
60 61
61 private: 62 private:
62 63
63 sqlite *tdb; 64 sqlite *tdb;
64 }; 65 };
65 66
66#endif 67#endif
67 68
68 69
69 70
diff --git a/noncore/apps/qashmoney/transactiondisplay.cpp b/noncore/apps/qashmoney/transactiondisplay.cpp
index 14f5641..ae6223d 100755
--- a/noncore/apps/qashmoney/transactiondisplay.cpp
+++ b/noncore/apps/qashmoney/transactiondisplay.cpp
@@ -1,586 +1,623 @@
1#include "transactiondisplay.h" 1#include "transactiondisplay.h"
2#include "newtransaction.h" 2#include "newtransaction.h"
3#include "account.h" 3#include "account.h"
4#include "budget.h" 4#include "budget.h"
5#include "memory.h" 5#include "memory.h"
6#include "transfer.h" 6#include "transfer.h"
7#include "preferences.h" 7#include "preferences.h"
8#include "calculator.h" 8#include "calculator.h"
9#include "datepicker.h" 9#include "datepicker.h"
10 10
11#include <qdatetime.h> 11#include <qdatetime.h>
12#include <qmessagebox.h> 12#include <qmessagebox.h>
13#include <qheader.h> 13#include <qheader.h>
14#include <qmultilineedit.h> 14#include <qmultilineedit.h>
15#include <iostream.h> 15#include <iostream.h>
16#include <qdatetime.h> 16#include <qdatetime.h>
17 17
18extern Transaction *transaction; 18extern Transaction *transaction;
19extern Budget *budget; 19extern Budget *budget;
20extern Account *account; 20extern Account *account;
21extern Preferences *preferences; 21extern Preferences *preferences;
22extern Memory *memory; 22extern Memory *memory;
23extern Transfer *transfer; 23extern Transfer *transfer;
24 24
25TransactionDisplay::TransactionDisplay ( QWidget* parent ) : QWidget ( parent ) 25TransactionDisplay::TransactionDisplay ( QWidget* parent ) : QWidget ( parent )
26 { 26 {
27 // set transactiondisplay variables; 27 // set transactiondisplay variables;
28 accountid = 0; 28 accountid = 0;
29 children = TRUE; 29 children = TRUE;
30 30
31 firstline = new QHBox ( this ); 31 firstline = new QHBox ( this );
32 firstline->setSpacing ( 2 ); 32 firstline->setSpacing ( 2 );
33 33
34 newtransaction = new QPushButton ( firstline ); 34 newtransaction = new QPushButton ( firstline );
35 newtransaction->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/new.png") ); 35 newtransaction->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/new.png") );
36 connect ( newtransaction, SIGNAL ( released () ), this, SLOT ( addTransaction () ) ); 36 connect ( newtransaction, SIGNAL ( released () ), this, SLOT ( addTransaction () ) );
37 37
38 edittransaction = new QPushButton ( firstline ); 38 edittransaction = new QPushButton ( firstline );
39 edittransaction->setPixmap( QPixmap ("/opt/QtPalmtop/pics/edit.png") ); 39 edittransaction->setPixmap( QPixmap ("/opt/QtPalmtop/pics/edit.png") );
40 connect ( edittransaction, SIGNAL ( released () ), this, SLOT ( checkListViewEdit () ) ); 40 connect ( edittransaction, SIGNAL ( released () ), this, SLOT ( checkListViewEdit () ) );
41 41
42 deletetransaction = new QPushButton ( firstline ); 42 deletetransaction = new QPushButton ( firstline );
43 deletetransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/delete.png") ); 43 deletetransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/delete.png") );
44 connect ( deletetransaction, SIGNAL ( released () ), this, SLOT ( checkListViewDelete () ) ); 44 connect ( deletetransaction, SIGNAL ( released () ), this, SLOT ( checkListViewDelete () ) );
45 45
46 toggletransaction = new QPushButton ( firstline ); 46 toggletransaction = new QPushButton ( firstline );
47 toggletransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/redo.png") ); 47 toggletransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/redo.png") );
48 connect ( toggletransaction, SIGNAL ( released () ), this, SLOT ( checkListViewToggle () ) ); 48 connect ( toggletransaction, SIGNAL ( released () ), this, SLOT ( checkListViewToggle () ) );
49 49
50 viewtransactionnotes = new QPushButton ( firstline ); 50 viewtransactionnotes = new QPushButton ( firstline );
51 viewtransactionnotes->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/info.png") ); 51 viewtransactionnotes->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/info.png") );
52 connect ( viewtransactionnotes, SIGNAL ( released () ), this, SLOT ( showTransactionNotes () ) ); 52 connect ( viewtransactionnotes, SIGNAL ( released () ), this, SLOT ( showTransactionNotes () ) );
53 53
54 secondline = new QHBox ( this ); 54 secondline = new QHBox ( this );
55 secondline->setSpacing ( 5 ); 55 secondline->setSpacing ( 5 );
56 56
57 name = new QLabel ( secondline ); 57 name = new QLabel ( secondline );
58 balance = new QLabel ( secondline ); 58 balance = new QLabel ( secondline );
59 59
60 QLabel *limit = new QLabel ( "Limit", secondline ); 60 QLabel *limit = new QLabel ( "Limit", secondline );
61 limitbox = new QLineEdit ( secondline ); 61 limitbox = new QLineEdit ( secondline );
62 limitbox->setMinimumWidth ( ( int ) ( this->width() / 6 ) ); 62 limitbox->setMinimumWidth ( ( int ) ( this->width() / 6 ) );
63 connect ( limitbox, SIGNAL ( textChanged ( const QString & ) ), this, SLOT ( limitDisplay ( const QString & ) ) ); 63 connect ( limitbox, SIGNAL ( textChanged ( const QString & ) ), this, SLOT ( limitDisplay ( const QString & ) ) );
64 64
65 listview = new QListView ( this ); 65 listview = new QListView ( this );
66 listview->setAllColumnsShowFocus ( TRUE ); 66 listview->setAllColumnsShowFocus ( TRUE );
67 listview->setShowSortIndicator ( TRUE ); 67 listview->setShowSortIndicator ( TRUE );
68 listview->header()->setTracking ( FALSE ); 68 listview->header()->setTracking ( FALSE );
69 connect ( listview->header(), SIGNAL ( sizeChange ( int, int, int ) ), this, SLOT ( saveColumnSize ( int, int, int ) ) ); 69 connect ( listview->header(), SIGNAL ( sizeChange ( int, int, int ) ), this, SLOT ( saveColumnSize ( int, int, int ) ) );
70 70
71 layout = new QVBoxLayout ( this, 2, 2 ); 71 layout = new QVBoxLayout ( this, 2, 2 );
72 layout->addWidget ( firstline ); 72 layout->addWidget ( firstline );
73 layout->addWidget ( secondline ); 73 layout->addWidget ( secondline );
74 layout->addWidget ( listview ); 74 layout->addWidget ( listview );
75 } 75 }
76 76
77void TransactionDisplay::addTransaction () 77void TransactionDisplay::addTransaction ()
78 { 78 {
79 // create local variables 79 // create local variables
80 int cleared = -1; 80 int cleared = -1;
81 81
82 // create new transaction window 82 // create new transaction window
83 NewTransaction *newtransaction = new NewTransaction ( this ); 83 NewTransaction *newtransaction = new NewTransaction ( this );
84 int width = this->size().width(); 84 int width = this->size().width();
85 newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) ); 85 newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) );
86 newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) ); 86 newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) );
87 newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) ); 87 newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) );
88 newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); 88 newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
89 newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); 89 newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
90 newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) ); 90 newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) );
91 91
92 // enter today's date in the date box as defaul 92 // enter today's date in the date box as defaul
93 QDate today = QDate::currentDate (); 93 QDate today = QDate::currentDate ();
94 int defaultday = today.day(); 94 int defaultday = today.day();
95 int defaultmonth = today.month(); 95 int defaultmonth = today.month();
96 int defaultyear = today.year(); 96 int defaultyear = today.year();
97 newtransaction->transactiondate->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) ); 97 newtransaction->transactiondate->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) );
98 98
99 // add memory items to the transactionname combobox 99 // add memory items to the transactionname combobox
100 memory->displayMemoryItems ( newtransaction->transactionname ); 100 memory->displayMemoryItems ( newtransaction->transactionname );
101 newtransaction->transactionname->insertItem ( "", 0 ); 101 newtransaction->transactionname->insertItem ( "", 0 );
102 102
103 if ( newtransaction->exec () == QDialog::Accepted ) 103 if ( newtransaction->exec () == QDialog::Accepted )
104 { 104 {
105 if ( newtransaction->clearedcheckbox->isChecked () == TRUE ) // set a parent id and type for a child transaction 105 if ( newtransaction->clearedcheckbox->isChecked () == TRUE ) // set a parent id and type for a child transaction
106 cleared = 1; 106 cleared = 1;
107 else 107 else
108 cleared = 0; 108 cleared = 0;
109 109
110 float amount = newtransaction->transactionamount->text().toFloat(); 110 float amount = newtransaction->transactionamount->text().toFloat();
111 if ( newtransaction->depositbox->isChecked() == FALSE ) 111 if ( newtransaction->depositbox->isChecked() == FALSE )
112 amount = amount * -1; 112 amount = amount * -1;
113 113
114 // add the transaction name to the memory items 114 // add the transaction name to the memory items
115 memory->addMemoryItem ( newtransaction->transactionname->currentText() ); 115 memory->addMemoryItem ( newtransaction->transactionname->currentText() );
116 116
117 // add the transaction 117 // add the transaction
118 if ( newtransaction->getDateEdited () == TRUE ) 118 if ( newtransaction->getDateEdited () == TRUE )
119 transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ), 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(), 120 newtransaction->transactionnumber->text().toInt(), newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(), amount, cleared, newtransaction->getCurrentBudget(),
121 newtransaction->getCurrentLineItem() ); 121 newtransaction->getCurrentLineItem() );
122 else 122 else
123 transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ), 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() ); 124 newtransaction->transactionnumber->text().toInt(), defaultday, defaultmonth, defaultyear, amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem() );
125 125
126 // redisplay transactions 126 // redisplay transactions
127 listview->clear(); 127 listview->clear();
128 QString displaytext = "%"; 128 QString displaytext = "%";
129 displaytext.prepend ( limitbox->text() ); 129 displaytext.prepend ( limitbox->text() );
130 setTransactionDisplayDate ();
130 if ( transaction->getNumberOfTransactions() > 0 ) 131 if ( transaction->getNumberOfTransactions() > 0 )
131 transaction->displayTransactions ( listview, accountid, children, displaytext ); 132 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
132 133
133 // redisplay transfers 134 // redisplay transfers
134 if ( transfer->getNumberOfTransfers() > 0 ) 135 if ( transfer->getNumberOfTransfers() > 0 )
135 transfer->displayTransfers ( listview, accountid, children ); 136 transfer->displayTransfers ( listview, accountid, children );
136 137
137 // add the transaction amount to the account it's associated with 138 // add the transaction amount to the account it's associated with
138 // and update its parent account balance if necessary 139 // and update its parent account balance if necessary
139 account->updateAccountBalance ( accountid ); 140 account->updateAccountBalance ( accountid );
140 if ( account->getParentAccountID ( accountid ) != -1 ) 141 if ( account->getParentAccountID ( accountid ) != -1 )
141 account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) ); 142 account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) );
142 143
143 // format then reset the account balance 144 // format then reset the account balance
144 redisplayAccountBalance (); 145 redisplayAccountBalance ();
145 } 146 }
146 } 147 }
147 148
148void TransactionDisplay::checkListViewEdit () 149void TransactionDisplay::checkListViewEdit ()
149 { 150 {
150 if ( listview->selectedItem() == 0 ) 151 if ( listview->selectedItem() == 0 )
151 QMessageBox::warning ( this, "QashMoney", "Please select a transaction\nto edit."); 152 QMessageBox::warning ( this, "QashMoney", "Please select a transaction\nto edit.");
152 else if ( listview->currentItem()->text ( getIDColumn() ).toInt() < 0 ) 153 else if ( listview->currentItem()->text ( getIDColumn() ).toInt() < 0 )
153 editTransfer (); 154 editTransfer ();
154 else 155 else
155 editTransaction(); 156 editTransaction();
156 } 157 }
157 158
158void TransactionDisplay::showCalculator () 159void TransactionDisplay::showCalculator ()
159 { 160 {
160 Calculator *calculator = new Calculator ( this ); 161 Calculator *calculator = new Calculator ( this );
161 if ( calculator->exec () == QDialog::Accepted ) 162 if ( calculator->exec () == QDialog::Accepted )
162 amount->setText ( calculator->display->text() ); 163 amount->setText ( calculator->display->text() );
163 } 164 }
164 165
165void TransactionDisplay::showCalendar () 166void TransactionDisplay::showCalendar ()
166 { 167 {
167 QDate newDate = QDate::currentDate (); 168 QDate newDate = QDate::currentDate ();
168 DatePicker *dp = new DatePicker ( newDate ); 169 DatePicker *dp = new DatePicker ( newDate );
169 if ( dp->exec () == QDialog::Accepted ) 170 if ( dp->exec () == QDialog::Accepted )
170 { 171 {
171 year = dp->getYear(); 172 year = dp->getYear();
172 month = dp->getMonth(); 173 month = dp->getMonth();
173 day = dp->getDay(); 174 day = dp->getDay();
174 date->setText ( preferences->getDate ( year, month, day ) ); 175 date->setText ( preferences->getDate ( year, month, day ) );
175 } 176 }
176 } 177 }
177 178
178void TransactionDisplay::editTransfer () 179void TransactionDisplay::editTransfer ()
179 { 180 {
180 transferid = listview->currentItem()->text ( getIDColumn() ).toInt(); 181 transferid = listview->currentItem()->text ( getIDColumn() ).toInt();
181 fromaccount = transfer->getFromAccountID ( transferid ); 182 fromaccount = transfer->getFromAccountID ( transferid );
182 toaccount = transfer->getToAccountID ( transferid ); 183 toaccount = transfer->getToAccountID ( transferid );
183 year = transfer->getYear ( transferid ); 184 year = transfer->getYear ( transferid );
184 month = transfer->getMonth ( transferid ); 185 month = transfer->getMonth ( transferid );
185 day = transfer->getDay ( transferid ); 186 day = transfer->getDay ( transferid );
186 187
187 QDialog *editransfer = new QDialog ( this, "edittransfer", TRUE ); 188 QDialog *editransfer = new QDialog ( this, "edittransfer", TRUE );
188 editransfer->setCaption ( "Transfer" ); 189 editransfer->setCaption ( "Transfer" );
189 190
190 QStringList accountnames = account->getAccountNames(); 191 QStringList accountnames = account->getAccountNames();
191 QStringList accountids = account->getAccountIDs(); 192 QStringList accountids = account->getAccountIDs();
192 193
193 QLabel *fromaccountlabel = new QLabel ( "From Account:", editransfer ); 194 QLabel *fromaccountlabel = new QLabel ( "From Account:", editransfer );
194 QFont f = this->font(); 195 QFont f = this->font();
195 f.setWeight ( QFont::Bold ); 196 f.setWeight ( QFont::Bold );
196 fromaccountlabel->setFont ( f ); 197 fromaccountlabel->setFont ( f );
197 198
198 QComboBox *fromaccountbox = new QComboBox ( editransfer ); 199 QComboBox *fromaccountbox = new QComboBox ( editransfer );
199 fromaccountbox->insertStringList ( accountnames ); 200 fromaccountbox->insertStringList ( accountnames );
200 fromaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( fromaccount ) ) ); 201 fromaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( fromaccount ) ) );
201 202
202 QLabel *toaccountlabel = new QLabel ( "To Account:", editransfer ); 203 QLabel *toaccountlabel = new QLabel ( "To Account:", editransfer );
203 toaccountlabel->setFont ( f ); 204 toaccountlabel->setFont ( f );
204 205
205 QComboBox *toaccountbox = new QComboBox ( editransfer ); 206 QComboBox *toaccountbox = new QComboBox ( editransfer );
206 toaccountbox->insertStringList ( accountnames ); 207 toaccountbox->insertStringList ( accountnames );
207 toaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( toaccount ) ) ); 208 toaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( toaccount ) ) );
208 209
209 QLabel *datelabel = new QLabel ( "Date", editransfer ); 210 QLabel *datelabel = new QLabel ( "Date", editransfer );
210 QHBox *datebox = new QHBox ( editransfer ); 211 QHBox *datebox = new QHBox ( editransfer );
211 datebox->setSpacing ( 2 ); 212 datebox->setSpacing ( 2 );
212 date = new QLineEdit ( datebox ); 213 date = new QLineEdit ( datebox );
213 date->setAlignment ( Qt::AlignRight ); 214 date->setAlignment ( Qt::AlignRight );
214 date->setDisabled ( TRUE ); 215 date->setDisabled ( TRUE );
215 date->setText ( preferences->getDate ( year, month, day ) ); 216 date->setText ( preferences->getDate ( year, month, day ) );
216 QPushButton *datebutton = new QPushButton ( datebox ); 217 QPushButton *datebutton = new QPushButton ( datebox );
217 datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) ); 218 datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) );
218 connect ( datebutton, SIGNAL ( released () ), this, SLOT ( showCalendar () ) ); 219 connect ( datebutton, SIGNAL ( released () ), this, SLOT ( showCalendar () ) );
219 220
220 QLabel *amounttlabel = new QLabel ( "Amount", editransfer ); 221 QLabel *amounttlabel = new QLabel ( "Amount", editransfer );
221 222
222 QHBox *amountbox = new QHBox ( editransfer ); 223 QHBox *amountbox = new QHBox ( editransfer );
223 amountbox->setSpacing ( 2 ); 224 amountbox->setSpacing ( 2 );
224 amount = new QLineEdit ( amountbox ); 225 amount = new QLineEdit ( amountbox );
225 amount->setAlignment ( Qt::AlignRight ); 226 amount->setAlignment ( Qt::AlignRight );
226 amount->setText ( transfer->getAmount ( transferid ) ); 227 amount->setText ( transfer->getAmount ( transferid ) );
227 QPushButton *calculatorbutton = new QPushButton( amountbox ); 228 QPushButton *calculatorbutton = new QPushButton( amountbox );
228 calculatorbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) ); 229 calculatorbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) );
229 connect ( calculatorbutton, SIGNAL ( released() ), this, SLOT ( showCalculator() ) ); 230 connect ( calculatorbutton, SIGNAL ( released() ), this, SLOT ( showCalculator() ) );
230 231
231 QCheckBox *clearedcheckbox = new QCheckBox ( "Cleared", editransfer ); 232 QCheckBox *clearedcheckbox = new QCheckBox ( "Cleared", editransfer );
232 233
233 QBoxLayout *layout = new QVBoxLayout ( editransfer, 4, 2 ); 234 QBoxLayout *layout = new QVBoxLayout ( editransfer, 4, 2 );
234 layout->addWidget ( fromaccountlabel, Qt::AlignLeft ); 235 layout->addWidget ( fromaccountlabel, Qt::AlignLeft );
235 layout->addWidget ( fromaccountbox, Qt::AlignLeft ); 236 layout->addWidget ( fromaccountbox, Qt::AlignLeft );
236 layout->addWidget ( toaccountlabel, Qt::AlignLeft ); 237 layout->addWidget ( toaccountlabel, Qt::AlignLeft );
237 layout->addWidget ( toaccountbox, Qt::AlignLeft ); 238 layout->addWidget ( toaccountbox, Qt::AlignLeft );
238 layout->addSpacing ( 5 ); 239 layout->addSpacing ( 5 );
239 layout->addWidget ( datelabel, Qt::AlignLeft ); 240 layout->addWidget ( datelabel, Qt::AlignLeft );
240 layout->addWidget ( datebox, Qt::AlignLeft ); 241 layout->addWidget ( datebox, Qt::AlignLeft );
241 layout->addWidget ( amounttlabel, Qt::AlignLeft ); 242 layout->addWidget ( amounttlabel, Qt::AlignLeft );
242 layout->addWidget ( amountbox, Qt::AlignLeft ); 243 layout->addWidget ( amountbox, Qt::AlignLeft );
243 layout->addWidget ( clearedcheckbox, Qt::AlignLeft ); 244 layout->addWidget ( clearedcheckbox, Qt::AlignLeft );
244 245
245 if ( editransfer->exec() == QDialog::Accepted ) 246 if ( editransfer->exec() == QDialog::Accepted )
246 { 247 {
247 //get fromaccount 248 //get fromaccount
248 fromaccount = ( accountids.operator[] ( fromaccountbox->currentItem() ) ).toInt(); 249 fromaccount = ( accountids.operator[] ( fromaccountbox->currentItem() ) ).toInt();
249 250
250 //get to account 251 //get to account
251 toaccount = ( accountids.operator[] ( toaccountbox->currentItem() ) ).toInt(); 252 toaccount = ( accountids.operator[] ( toaccountbox->currentItem() ) ).toInt();
252 253
253 //set cleared flag 254 //set cleared flag
254 int cleared = 0; 255 int cleared = 0;
255 if ( clearedcheckbox->isChecked() == TRUE ) 256 if ( clearedcheckbox->isChecked() == TRUE )
256 cleared = 1; 257 cleared = 1;
257 258
258 //update transfer 259 //update transfer
259 transfer->updateTransfer ( fromaccount, account->getParentAccountID ( fromaccount ), toaccount, account->getParentAccountID ( toaccount ), 260 transfer->updateTransfer ( fromaccount, account->getParentAccountID ( fromaccount ), toaccount, account->getParentAccountID ( toaccount ),
260 day, month, year, amount->text().toFloat(), cleared, transferid ); 261 day, month, year, amount->text().toFloat(), cleared, transferid );
261 262
262 account->updateAccountBalance ( fromaccount ); 263 account->updateAccountBalance ( fromaccount );
263 if ( account->getParentAccountID ( fromaccount ) != -1 ) 264 if ( account->getParentAccountID ( fromaccount ) != -1 )
264 account->changeParentAccountBalance ( account->getParentAccountID ( fromaccount ) ); 265 account->changeParentAccountBalance ( account->getParentAccountID ( fromaccount ) );
265 266
266 updateAndDisplay ( toaccount ); 267 updateAndDisplay ( toaccount );
267 } 268 }
268 } 269 }
269 270
270void TransactionDisplay::editTransaction () 271void TransactionDisplay::editTransaction ()
271 { 272 {
272 int cleared; 273 int cleared;
273 274
274 // set the transaction id and budgetid 275 // set the transaction id and budgetid
275 int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt(); 276 int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt();
276 int budgetid = transaction->getBudgetID ( transactionid ); 277 int budgetid = transaction->getBudgetID ( transactionid );
277 int lineitemid = transaction->getLineItemID ( transactionid ); 278 int lineitemid = transaction->getLineItemID ( transactionid );
278 279
279 // create edit transaction window 280 // create edit transaction window
280 NewTransaction *newtransaction = new NewTransaction ( this ); 281 NewTransaction *newtransaction = new NewTransaction ( this );
281 int width = this->width(); 282 int width = this->width();
282 newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) ); 283 newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) );
283 newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) ); 284 newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) );
284 newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) ); 285 newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) );
285 newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); 286 newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
286 newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); 287 newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) );
287 newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) ); 288 newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) );
288 289
289 // enter the date in the date box 290 // enter the date in the date box
290 newtransaction->year = transaction->getYear ( transactionid ); 291 newtransaction->year = transaction->getYear ( transactionid );
291 newtransaction->month = transaction->getMonth ( transactionid ); 292 newtransaction->month = transaction->getMonth ( transactionid );
292 newtransaction->day = transaction->getDay ( transactionid ); 293 newtransaction->day = transaction->getDay ( transactionid );
293 newtransaction->transactiondate->setText ( preferences->getDate ( newtransaction->year, newtransaction->month, newtransaction->day ) ); 294 newtransaction->transactiondate->setText ( preferences->getDate ( newtransaction->year, newtransaction->month, newtransaction->day ) );
294 295
295 // set the description 296 // set the description
296 newtransaction->setDescription ( transaction->getTransactionDescription ( transactionid ) ); 297 newtransaction->setDescription ( transaction->getTransactionDescription ( transactionid ) );
297 298
298 // add memory items to the transactionname combobox 299 // add memory items to the transactionname combobox
299 memory->displayMemoryItems ( newtransaction->transactionname ); 300 memory->displayMemoryItems ( newtransaction->transactionname );
300 301
301 // add correct transaction name 302 // add correct transaction name
302 newtransaction->transactionname->setEditText ( transaction->getPayee ( transactionid ) ); 303 newtransaction->transactionname->setEditText ( transaction->getPayee ( transactionid ) );
303 304
304 // add transaction number 305 // add transaction number
305 newtransaction->transactionnumber->setText ( transaction->getNumber ( transactionid ) ); 306 newtransaction->transactionnumber->setText ( transaction->getNumber ( transactionid ) );
306 307
307 // add transaction amount 308 // add transaction amount
308 newtransaction->transactionamount->setText ( transaction->getAbsoluteAmount ( transactionid ) ); 309 newtransaction->transactionamount->setText ( transaction->getAbsoluteAmount ( transactionid ) );
309 310
310 // check for and set the correct budget 311 // check for and set the correct budget
311 if ( budgetid >= 1 ) // only do it if this transaction has a budget and line item 312 if ( budgetid >= 1 ) // only do it if this transaction has a budget and line item
312 { 313 {
313 newtransaction->budgetbox->setCurrentItem ( newtransaction->getBudgetIndex ( budgetid ) + 1 ); 314 newtransaction->budgetbox->setCurrentItem ( newtransaction->getBudgetIndex ( budgetid ) + 1 );
314 if ( lineitemid >= 1 ) 315 if ( lineitemid >= 1 )
315 { 316 {
316 newtransaction->setLineItems (); 317 newtransaction->setLineItems ();
317 newtransaction->lineitembox->setCurrentItem ( newtransaction->getLineItemIndex ( lineitemid ) ); 318 newtransaction->lineitembox->setCurrentItem ( newtransaction->getLineItemIndex ( lineitemid ) );
318 } 319 }
319 else 320 else
320 { 321 {
321 newtransaction->lineitemlabel->setEnabled ( FALSE ); 322 newtransaction->lineitemlabel->setEnabled ( FALSE );
322 newtransaction->lineitembox->setEnabled ( FALSE ); 323 newtransaction->lineitembox->setEnabled ( FALSE );
323 } 324 }
324 } 325 }
325 else 326 else
326 { 327 {
327 newtransaction->lineitemlabel->setEnabled ( FALSE ); 328 newtransaction->lineitemlabel->setEnabled ( FALSE );
328 newtransaction->lineitembox->setEnabled ( FALSE ); 329 newtransaction->lineitembox->setEnabled ( FALSE );
329 } 330 }
330 331
331 // check cleared checkbox if necessary 332 // check cleared checkbox if necessary
332 if ( transaction->getCleared ( transactionid ) == 1 ) 333 if ( transaction->getCleared ( transactionid ) == 1 )
333 newtransaction->clearedcheckbox->setChecked ( TRUE ); 334 newtransaction->clearedcheckbox->setChecked ( TRUE );
334 335
335 // check deposit box if necessary 336 // check deposit box if necessary
336 if ( transaction->getAmount ( transactionid ).toFloat() > 0 ) 337 if ( transaction->getAmount ( transactionid ).toFloat() > 0 )
337 newtransaction->depositbox->setChecked ( TRUE ); 338 newtransaction->depositbox->setChecked ( TRUE );
338 339
339 if ( newtransaction->exec () == QDialog::Accepted ) 340 if ( newtransaction->exec () == QDialog::Accepted )
340 { 341 {
341 if ( newtransaction->clearedcheckbox->isChecked () == TRUE ) 342 if ( newtransaction->clearedcheckbox->isChecked () == TRUE )
342 cleared = 1; 343 cleared = 1;
343 else 344 else
344 cleared = 0; 345 cleared = 0;
345 346
346 float amount = newtransaction->transactionamount->text().toFloat(); 347 float amount = newtransaction->transactionamount->text().toFloat();
347 if ( newtransaction->depositbox->isChecked() == FALSE ) 348 if ( newtransaction->depositbox->isChecked() == FALSE )
348 amount = amount * -1; 349 amount = amount * -1;
349 350
350 // add the transaction name to the memory items 351 // add the transaction name to the memory items
351 memory->addMemoryItem ( newtransaction->transactionname->currentText() ); 352 memory->addMemoryItem ( newtransaction->transactionname->currentText() );
352 353
353 // update the transaction 354 // update the transaction
354 transaction->updateTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), newtransaction->transactionnumber->text().toInt(), 355 transaction->updateTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), newtransaction->transactionnumber->text().toInt(),
355 newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(), 356 newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(),
356 amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem(), transactionid ); 357 amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem(), transactionid );
357 358
358 updateAndDisplay ( transaction->getAccountID ( transactionid ) ); 359 updateAndDisplay ( transaction->getAccountID ( transactionid ) );
359 } 360 }
360 } 361 }
361 362
362void TransactionDisplay::updateAndDisplay ( int id ) 363void TransactionDisplay::updateAndDisplay ( int id )
363 { 364 {
364 // redisplay transactions 365 // redisplay transactions
365 listview->clear(); 366 listview->clear();
366 QString displaytext = "%"; 367 QString displaytext = "%";
367 displaytext.prepend ( limitbox->text() ); 368 displaytext.prepend ( limitbox->text() );
369 setTransactionDisplayDate ();
368 if ( transaction->getNumberOfTransactions() > 0 ) 370 if ( transaction->getNumberOfTransactions() > 0 )
369 transaction->displayTransactions ( listview, accountid, children, displaytext ); 371 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
370 372
371 // redisplay transfers 373 // redisplay transfers
372 if ( transfer->getNumberOfTransfers() > 0 ) 374 if ( transfer->getNumberOfTransfers() > 0 )
373 transfer->displayTransfers ( listview, accountid, children ); 375 transfer->displayTransfers ( listview, accountid, children );
374 376
375 // add the transaction amount to the account it's associated with 377 // add the transaction amount to the account it's associated with
376 // and update its parent account balance if necessary 378 // and update its parent account balance if necessary
377 account->updateAccountBalance ( id ); 379 account->updateAccountBalance ( id );
378 if ( account->getParentAccountID ( id ) != -1 ) 380 if ( account->getParentAccountID ( id ) != -1 )
379 account->changeParentAccountBalance ( account->getParentAccountID ( id ) ); 381 account->changeParentAccountBalance ( account->getParentAccountID ( id ) );
380 382
381 // format then reset the account balance 383 // format then reset the account balance
382 redisplayAccountBalance (); 384 redisplayAccountBalance ();
383 } 385 }
384 386
385void TransactionDisplay::checkListViewDelete () 387void TransactionDisplay::checkListViewDelete ()
386 { 388 {
387 if ( listview->selectedItem() == 0 ) 389 if ( listview->selectedItem() == 0 )
388 QMessageBox::warning ( this, "QashMoney", "Please select a transaction to\ndelete."); 390 QMessageBox::warning ( this, "QashMoney", "Please select a transaction to\ndelete.");
389 else 391 else
390 deleteTransaction (); 392 deleteTransaction ();
391 } 393 }
392 394
393void TransactionDisplay::deleteTransaction () 395void TransactionDisplay::deleteTransaction ()
394 { 396 {
395 int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt(); 397 int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt();
396 398
397 if ( transactionid > 0 ) // takes care of deleting transactions 399 if ( transactionid > 0 ) // takes care of deleting transactions
398 { 400 {
399 // check if we are viewing child transactions through a parent 401 // check if we are viewing child transactions through a parent
400 // in that case we will have to update balances for the parent 402 // in that case we will have to update balances for the parent
401 // which is represented by accountid and the child account 403 // which is represented by accountid and the child account
402 // which will be represented by childaccountid 404 // which will be represented by childaccountid
403 int childaccountid = -1; 405 int childaccountid = -1;
404 if ( listview->columns() == 5 ) 406 if ( listview->columns() == 5 )
405 childaccountid = transaction->getAccountID ( transactionid ); 407 childaccountid = transaction->getAccountID ( transactionid );
406 408
407 transaction->deleteTransaction ( transactionid ); 409 transaction->deleteTransaction ( transactionid );
408 410
409 listview->clear(); 411 listview->clear();
410 QString displaytext = "%"; 412 QString displaytext = "%";
411 displaytext.prepend ( limitbox->text() ); 413 displaytext.prepend ( limitbox->text() );
414 setTransactionDisplayDate ();
412 if ( transaction->getNumberOfTransactions() > 0 ) 415 if ( transaction->getNumberOfTransactions() > 0 )
413 transaction->displayTransactions ( listview, accountid, children, displaytext ); 416 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
414 417
415 if ( transfer->getNumberOfTransfers() > 0 ) 418 if ( transfer->getNumberOfTransfers() > 0 )
416 transfer->displayTransfers ( listview, accountid, children ); 419 transfer->displayTransfers ( listview, accountid, children );
417 420
418 // if we are viewing different child accounts through the parent account 421 // if we are viewing different child accounts through the parent account
419 // ie if there are five columns and the parentid is -1 422 // ie if there are five columns and the parentid is -1
420 // update the accountid ( which is the parent ) and update the child account 423 // update the accountid ( which is the parent ) and update the child account
421 // balance. Get its accountid from the transactionid 424 // balance. Get its accountid from the transactionid
422 account->updateAccountBalance ( accountid ); // will update either a parent or child 425 account->updateAccountBalance ( accountid ); // will update either a parent or child
423 if ( account->getParentAccountID ( accountid ) != -1 ) // update its parent if there is one 426 if ( account->getParentAccountID ( accountid ) != -1 ) // update its parent if there is one
424 account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) ); 427 account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) );
425 if ( childaccountid != -1 ) // we've set childaccountid 428 if ( childaccountid != -1 ) // we've set childaccountid
426 account->updateAccountBalance ( childaccountid ); 429 account->updateAccountBalance ( childaccountid );
427 430
428 // format then reset the account balance 431 // format then reset the account balance
429 redisplayAccountBalance (); 432 redisplayAccountBalance ();
430 } 433 }
431 else // takes care of deleting transfers 434 else // takes care of deleting transfers
432 { 435 {
433 // get the accountids before we delete the transfer 436 // get the accountids before we delete the transfer
434 int fromaccountid = transfer->getFromAccountID ( transactionid ); 437 int fromaccountid = transfer->getFromAccountID ( transactionid );
435 int toaccountid = transfer->getToAccountID ( transactionid ); 438 int toaccountid = transfer->getToAccountID ( transactionid );
436 439
437 // delete the transfer and redisplay transactions 440 // delete the transfer and redisplay transactions
438 transfer->deleteTransfer ( transactionid ); 441 transfer->deleteTransfer ( transactionid );
439 442
440 listview->clear(); 443 listview->clear();
441 QString displaytext = "%"; 444 QString displaytext = "%";
442 displaytext.prepend ( limitbox->text() ); 445 displaytext.prepend ( limitbox->text() );
446 setTransactionDisplayDate ();
443 if ( transaction->getNumberOfTransactions() > 0 ) 447 if ( transaction->getNumberOfTransactions() > 0 )
444 transaction->displayTransactions ( listview, accountid, children, displaytext ); 448 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
445 449
446 if ( transfer->getNumberOfTransfers() > 0 ) 450 if ( transfer->getNumberOfTransfers() > 0 )
447 transfer->displayTransfers ( listview, accountid, children ); 451 transfer->displayTransfers ( listview, accountid, children );
448 452
449 // for the from account 453 // for the from account
450 account->updateAccountBalance ( fromaccountid ); 454 account->updateAccountBalance ( fromaccountid );
451 if ( account->getParentAccountID ( fromaccountid ) != -1 ) 455 if ( account->getParentAccountID ( fromaccountid ) != -1 )
452 account->changeParentAccountBalance ( account->getParentAccountID ( fromaccountid ) ); 456 account->changeParentAccountBalance ( account->getParentAccountID ( fromaccountid ) );
453 457
454 // for the to account 458 // for the to account
455 account->updateAccountBalance ( toaccountid ); 459 account->updateAccountBalance ( toaccountid );
456 if ( account->getParentAccountID ( toaccountid ) != -1 ) 460 if ( account->getParentAccountID ( toaccountid ) != -1 )
457 account->changeParentAccountBalance ( account->getParentAccountID ( toaccountid ) ); 461 account->changeParentAccountBalance ( account->getParentAccountID ( toaccountid ) );
458 462
459 // format then reset the account balance 463 // format then reset the account balance
460 redisplayAccountBalance (); 464 redisplayAccountBalance ();
461 } 465 }
462 } 466 }
463 467
464void TransactionDisplay::checkListViewToggle () 468void TransactionDisplay::checkListViewToggle ()
465 { 469 {
466 if ( listview->selectedItem() == 0 ) 470 if ( listview->selectedItem() == 0 )
467 QMessageBox::warning ( this, "QashMoney", "Please select a transaction to\nclear or reset."); 471 QMessageBox::warning ( this, "QashMoney", "Please select a transaction to\nclear or reset.");
468 else 472 else
469 toggleTransaction (); 473 toggleTransaction ();
470 } 474 }
471 475
472void TransactionDisplay::toggleTransaction () 476void TransactionDisplay::toggleTransaction ()
473 { 477 {
474 //get the transaction of the selected transaction to determine if its a transaction or transfer 478 //get the transaction of the selected transaction to determine if its a transaction or transfer
475 int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt(); 479 int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt();
476 480
477 if ( transactionid > 0 ) // if this is a transaction 481 if ( transactionid > 0 ) // if this is a transaction
478 { 482 {
479 if ( transaction->getCleared ( transactionid ) == 0 ) 483 if ( transaction->getCleared ( transactionid ) == 0 )
480 transaction->setCleared ( transactionid, 1 ); 484 transaction->setCleared ( transactionid, 1 );
481 else 485 else
482 transaction->setCleared ( transactionid, 0 ); 486 transaction->setCleared ( transactionid, 0 );
483 } 487 }
484 else 488 else
485 { 489 {
486 if ( transfer->getCleared ( transactionid ) == 0 ) 490 if ( transfer->getCleared ( transactionid ) == 0 )
487 transfer->setCleared ( transactionid, 1 ); 491 transfer->setCleared ( transactionid, 1 );
488 else 492 else
489 transfer->setCleared ( transactionid, 0 ); 493 transfer->setCleared ( transactionid, 0 );
490 } 494 }
491 495
492 listview->clear(); 496 listview->clear();
493 QString displaytext = "%"; 497 QString displaytext = "%";
494 displaytext.prepend ( limitbox->text() ); 498 displaytext.prepend ( limitbox->text() );
499 setTransactionDisplayDate ();
495 if ( transaction->getNumberOfTransactions() > 0 ) 500 if ( transaction->getNumberOfTransactions() > 0 )
496 transaction->displayTransactions ( listview, accountid, children, displaytext ); 501 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
497 502
498 if ( transfer->getNumberOfTransfers() != 0 ) 503 if ( transfer->getNumberOfTransfers() != 0 )
499 transfer->displayTransfers ( listview, accountid, children ); 504 transfer->displayTransfers ( listview, accountid, children );
500 } 505 }
501 506
502void TransactionDisplay::redisplayAccountBalance () 507void TransactionDisplay::redisplayAccountBalance ()
503 { 508 {
504 QString accountbalance = account->getAccountBalance ( accountid ); 509 QString accountbalance = account->getAccountBalance ( accountid );
505 balance->setText ( accountbalance ); 510 balance->setText ( accountbalance );
506 } 511 }
507 512
508void TransactionDisplay::setChildren ( bool c ) 513void TransactionDisplay::setChildren ( bool c )
509 { 514 {
510 children = c; 515 children = c;
511 } 516 }
512 517
513void TransactionDisplay::setAccountID ( int id ) 518void TransactionDisplay::setAccountID ( int id )
514 { 519 {
515 accountid = id; 520 accountid = id;
516 } 521 }
517 522
518ColorListItem::ColorListItem ( QListView *parent ) : QListViewItem ( parent ) 523ColorListItem::ColorListItem ( QListView *parent ) : QListViewItem ( parent )
519 { 524 {
520 } 525 }
521 526
522ColorListItem::ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4 ) 527ColorListItem::ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4 )
523 : QListViewItem ( parent, label1, label2, label3, label4 ) 528 : QListViewItem ( parent, label1, label2, label3, label4 )
524 { 529 {
525 } 530 }
526 531
527ColorListItem::ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4, QString label5 ) 532ColorListItem::ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4, QString label5 )
528 : QListViewItem ( parent, label1, label2, label3, label4, label5 ) 533 : QListViewItem ( parent, label1, label2, label3, label4, label5 )
529 { 534 {
530 } 535 }
531 536
532void ColorListItem::paintCell ( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ) 537void ColorListItem::paintCell ( QPainter *p, const QColorGroup &cg, int column, int width, int alignment )
533 { 538 {
534 QColorGroup _cg ( cg ); 539 QColorGroup _cg ( cg );
535 _cg.setColor ( QColorGroup::Text, Qt::red ); 540 _cg.setColor ( QColorGroup::Text, Qt::red );
536 QListViewItem::paintCell ( p, _cg, column, width, alignment ); 541 QListViewItem::paintCell ( p, _cg, column, width, alignment );
537 } 542 }
538 543
539void TransactionDisplay::saveColumnSize ( int column, int oldsize, int newsize ) 544void TransactionDisplay::saveColumnSize ( int column, int oldsize, int newsize )
540 { 545 {
541 if ( listview->columns() == 4 ) 546 if ( listview->columns() == 4 )
542 preferences->changeColumnPreference ( column + 3, newsize ); 547 preferences->changeColumnPreference ( column + 3, newsize );
543 else if ( listview->columns() == 5 && column != 4 ) 548 else if ( listview->columns() == 5 && column != 4 )
544 preferences->changeColumnPreference ( column + 6, newsize ); 549 preferences->changeColumnPreference ( column + 6, newsize );
545 else 550 else
546 preferences->changeColumnPreference ( 9, newsize ); 551 preferences->changeColumnPreference ( 9, newsize );
547 } 552 }
548 553
549void TransactionDisplay::limitDisplay ( const QString &text ) 554void TransactionDisplay::limitDisplay ( const QString &text )
550 { 555 {
551 listview->clear (); 556 listview->clear ();
552 QString displaytext = "%"; 557 QString displaytext = "%";
553 displaytext.prepend ( text ); 558 displaytext.prepend ( text );
554 transaction->displayTransactions ( listview, accountid, children, displaytext ); 559 setTransactionDisplayDate ();
560 if ( transaction->getNumberOfTransactions() > 0 )
561 transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
562
555 if ( displaytext.length() == 1 || preferences->getPreference ( 6 ) == 1 ) 563 if ( displaytext.length() == 1 || preferences->getPreference ( 6 ) == 1 )
556 transfer->displayTransfers ( listview, accountid, children ); 564 transfer->displayTransfers ( listview, accountid, children );
557 } 565 }
558 566
559int TransactionDisplay::getIDColumn () 567int TransactionDisplay::getIDColumn ()
560 { 568 {
561 int counter; 569 int counter;
562 int columns = listview->columns(); 570 int columns = listview->columns();
563 for ( counter = 0; counter <= columns; counter++ ) 571 for ( counter = 0; counter <= columns; counter++ )
564 if ( listview->header()->label ( counter ).length() == 0 ) 572 if ( listview->header()->label ( counter ).length() == 0 )
565 return counter; 573 return counter;
566 } 574 }
567 575
568void TransactionDisplay::showTransactionNotes () 576void TransactionDisplay::showTransactionNotes ()
569 { 577 {
570 if ( listview->selectedItem() == 0 || listview->currentItem()->text ( getIDColumn() ).toInt() < 0 ) 578 if ( listview->selectedItem() == 0 || listview->currentItem()->text ( getIDColumn() ).toInt() < 0 )
571 QMessageBox::warning ( this, "QashMoney", "Please select a valid\ntransaction to view notes."); 579 QMessageBox::warning ( this, "QashMoney", "Please select a valid\ntransaction to view notes.");
572 else 580 else
573 { 581 {
574 int transactionid = listview->selectedItem()->text ( getIDColumn() ).toInt (); 582 int transactionid = listview->selectedItem()->text ( getIDColumn() ).toInt ();
575 QDialog *description = new QDialog ( this, "description", TRUE ); 583 QDialog *description = new QDialog ( this, "description", TRUE );
576 description->setCaption ( "Notes" ); 584 description->setCaption ( "Notes" );
577 QMultiLineEdit *notes = new QMultiLineEdit ( description ); 585 QMultiLineEdit *notes = new QMultiLineEdit ( description );
578 notes->setFixedSize ( ( int ) (this->width() * 0.75 ), ( int ) ( this->height() * 0.5 ) ); 586 notes->setFixedSize ( ( int ) (this->width() * 0.75 ), ( int ) ( this->height() * 0.5 ) );
579 notes->setWrapColumnOrWidth ( ( int ) (this->width() * 0.75 ) ); 587 notes->setWrapColumnOrWidth ( ( int ) (this->width() * 0.75 ) );
580 notes->setWordWrap ( QMultiLineEdit::WidgetWidth ); 588 notes->setWordWrap ( QMultiLineEdit::WidgetWidth );
581 notes->setEnabled ( FALSE ); 589 notes->setEnabled ( FALSE );
582 notes->setText ( transaction->getTransactionDescription ( transactionid ) ); 590 notes->setText ( transaction->getTransactionDescription ( transactionid ) );
583 description->show(); 591 description->show();
584 } 592 }
585 } 593 }
586 594
595void TransactionDisplay::setTransactionDisplayDate ()
596 {
597 // determine how many days of transactions to show
598 int limittype = preferences->getPreference ( 7 );
599 if ( limittype != 5 ) // set today's date if we are not showing all transactions
600 {
601 QDate today = QDate::currentDate ();
602 switch ( limittype ) // if we are not showing all transactions
603 {
604 case 0: // viewing two weeks
605 displaydate = today.addDays ( -14 );
606 break;
607 case 1: // viewing one month
608 displaydate = today.addDays ( -30 );
609 break;
610 case 2: // three months
611 displaydate = today.addDays ( -90 );
612 break;
613 case 3: // six months
614 displaydate = today.addDays ( -180 );
615 break;
616 case 4: // one year
617 displaydate = today.addDays ( -365 );
618 break;
619 }
620 }
621 else
622 displaydate = QDate ( 1, 1, 1000 );
623 }
diff --git a/noncore/apps/qashmoney/transactiondisplay.h b/noncore/apps/qashmoney/transactiondisplay.h
index 79f20ba..1746f6c 100755
--- a/noncore/apps/qashmoney/transactiondisplay.h
+++ b/noncore/apps/qashmoney/transactiondisplay.h
@@ -1,79 +1,82 @@
1#ifndef TRANSACTIONDISPLAY_H 1#ifndef TRANSACTIONDISPLAY_H
2#define TRANSACTIONDISPLAY_H 2#define TRANSACTIONDISPLAY_H
3 3
4#include <qlayout.h> 4#include <qlayout.h>
5#include <qhbox.h> 5#include <qhbox.h>
6#include <qlistview.h> 6#include <qlistview.h>
7#include <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qlabel.h> 8#include <qlabel.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qdatetime.h>
10 11
11class TransactionDisplay : public QWidget 12class TransactionDisplay : public QWidget
12 { 13 {
13 Q_OBJECT 14 Q_OBJECT
14 15
15 public: 16 public:
16 TransactionDisplay ( QWidget* parent ); 17 TransactionDisplay ( QWidget* parent );
17 18
18 QListView* listview; 19 QListView* listview;
19 QPushButton* newtransaction; 20 QPushButton* newtransaction;
20 QPushButton* edittransaction; 21 QPushButton* edittransaction;
21 QPushButton* deletetransaction; 22 QPushButton* deletetransaction;
22 QPushButton* toggletransaction; 23 QPushButton* toggletransaction;
23 QPushButton* viewtransactionnotes; 24 QPushButton* viewtransactionnotes;
24 25
25 QLabel *name; 26 QLabel *name;
26 QLabel *balance; 27 QLabel *balance;
27 QLineEdit *limitbox; 28 QLineEdit *limitbox;
28 QLineEdit *amount; 29 QLineEdit *amount;
29 QLineEdit *date; 30 QLineEdit *date;
30 31
31 int getIDColumn (); 32 int getIDColumn ();
32 33
33 public slots: 34 public slots:
34 void setChildren ( bool ); 35 void setChildren ( bool );
35 void setAccountID ( int ); 36 void setAccountID ( int );
36 void showTransactionNotes (); 37 void showTransactionNotes ();
37 38
38 private slots: 39 private slots:
39 void addTransaction (); 40 void addTransaction ();
40 void editTransaction (); 41 void editTransaction ();
41 void editTransfer (); 42 void editTransfer ();
42 void deleteTransaction (); 43 void deleteTransaction ();
43 void toggleTransaction (); 44 void toggleTransaction ();
44 void checkListViewDelete (); 45 void checkListViewDelete ();
45 void checkListViewEdit (); 46 void checkListViewEdit ();
46 void checkListViewToggle (); 47 void checkListViewToggle ();
47 void saveColumnSize ( int column, int oldsize, int newsize ); 48 void saveColumnSize ( int column, int oldsize, int newsize );
48 void limitDisplay ( const QString & ); 49 void limitDisplay ( const QString & );
49 void showCalculator (); 50 void showCalculator ();
50 void showCalendar (); 51 void showCalendar ();
52 void setTransactionDisplayDate ();
51 53
52 private: 54 private:
53 int accountid, fromaccount, fromparent, toaccount, toparent, day, month, year, transferid; 55 int accountid, fromaccount, fromparent, toaccount, toparent, day, month, year, transferid;
56 QDate displaydate;
54 bool children; 57 bool children;
55 QBoxLayout *layout; 58 QBoxLayout *layout;
56 QHBox *firstline; 59 QHBox *firstline;
57 QHBox *secondline; 60 QHBox *secondline;
58 void redisplayAccountBalance (); 61 void redisplayAccountBalance ();
59 void updateAndDisplay ( int accountid ); 62 void updateAndDisplay ( int accountid );
60 }; 63 };
61 64
62#endif 65#endif
63 66
64#ifndef COLORLISTITEM_H 67#ifndef COLORLISTITEM_H
65#define COLORLISTITEM_H 68#define COLORLISTITEM_H
66 69
67class ColorListItem : public QListViewItem 70class ColorListItem : public QListViewItem
68 { 71 {
69 public: 72 public:
70 73
71 ColorListItem ( QListView *parent ); 74 ColorListItem ( QListView *parent );
72 ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4 ); 75 ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4 );
73 ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4, QString label5 ); 76 ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4, QString label5 );
74 77
75 virtual void paintCell ( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); 78 virtual void paintCell ( QPainter *p, const QColorGroup &cg, int column, int width, int alignment );
76 }; 79 };
77 80
78#endif 81#endif
79 82