author | mickeyl <mickeyl> | 2003-10-30 13:18:08 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-10-30 13:18:08 (UTC) |
commit | 37414f207b147af4cf6778b323a0aa23127901bd (patch) (unidiff) | |
tree | b08c10043ab689b0a40425d268cd72226799b0cf /noncore/apps/checkbook/traninfo.cpp | |
parent | d53637f46cf217fc760d7aac58b4596843a73803 (diff) | |
download | opie-37414f207b147af4cf6778b323a0aa23127901bd.zip opie-37414f207b147af4cf6778b323a0aa23127901bd.tar.gz opie-37414f207b147af4cf6778b323a0aa23127901bd.tar.bz2 |
apply patch to HEAD
Diffstat (limited to 'noncore/apps/checkbook/traninfo.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/checkbook/traninfo.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/noncore/apps/checkbook/traninfo.cpp b/noncore/apps/checkbook/traninfo.cpp index d880bb4..506f567 100644 --- a/noncore/apps/checkbook/traninfo.cpp +++ b/noncore/apps/checkbook/traninfo.cpp | |||
@@ -8,48 +8,49 @@ | |||
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "traninfo.h" | 29 | #include "traninfo.h" |
30 | 30 | ||
31 | #include <qpe/config.h> | 31 | #include <qpe/config.h> |
32 | #include <qpe/timestring.h> | ||
32 | 33 | ||
33 | QString tempstr; | 34 | QString tempstr; |
34 | 35 | ||
35 | TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal, | 36 | TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal, |
36 | const QString &type, const QString &category, float amount, | 37 | const QString &type, const QString &category, float amount, |
37 | float fee, const QString &number, const QString ¬es, int next ) | 38 | float fee, const QString &number, const QString ¬es, int next ) |
38 | { | 39 | { |
39 | i = id; | 40 | i = id; |
40 | d = desc; | 41 | d = desc; |
41 | td = date; | 42 | td = date; |
42 | w = withdrawal; | 43 | w = withdrawal; |
43 | t = type; | 44 | t = type; |
44 | c = category; | 45 | c = category; |
45 | a = amount; | 46 | a = amount; |
46 | f = fee; | 47 | f = fee; |
47 | cn = number; | 48 | cn = number; |
48 | n = notes; | 49 | n = notes; |
49 | _next=next; | 50 | _next=next; |
50 | } | 51 | } |
51 | 52 | ||
52 | TranInfo::TranInfo( Config config, int entry ) | 53 | TranInfo::TranInfo( Config config, int entry ) |
53 | { | 54 | { |
54 | config.setGroup( QString::number( entry ) ); | 55 | config.setGroup( QString::number( entry ) ); |
55 | QString desc = config.readEntry( "Description", "Not Found" ); | 56 | QString desc = config.readEntry( "Description", "Not Found" ); |
@@ -103,56 +104,59 @@ TranInfo::TranInfo( Config config, int entry ) | |||
103 | // Category | 104 | // Category |
104 | c = config.readEntry( "Category", "" ); | 105 | c = config.readEntry( "Category", "" ); |
105 | 106 | ||
106 | // Transaction amount | 107 | // Transaction amount |
107 | QString stramount = config.readEntry( "Amount", "0.00" ); | 108 | QString stramount = config.readEntry( "Amount", "0.00" ); |
108 | bool ok; | 109 | bool ok; |
109 | a = stramount.toFloat( &ok ); | 110 | a = stramount.toFloat( &ok ); |
110 | 111 | ||
111 | // Transaction fee | 112 | // Transaction fee |
112 | stramount = config.readEntry( "TransactionFee", "0.00" ); | 113 | stramount = config.readEntry( "TransactionFee", "0.00" ); |
113 | f = stramount.toFloat( &ok ); | 114 | f = stramount.toFloat( &ok ); |
114 | 115 | ||
115 | // Transaction number | 116 | // Transaction number |
116 | cn = config.readEntry( "CheckNumber", "" ); | 117 | cn = config.readEntry( "CheckNumber", "" ); |
117 | 118 | ||
118 | // Notes | 119 | // Notes |
119 | n = config.readEntry( "Comments", "" ); | 120 | n = config.readEntry( "Comments", "" ); |
120 | 121 | ||
121 | // next | 122 | // next |
122 | _next = config.readNumEntry("Next", -1); | 123 | _next = config.readNumEntry("Next", -1); |
123 | } | 124 | } |
124 | } | 125 | } |
125 | 126 | ||
126 | // --- datestr ---------------------------------------------------------------- | 127 | // --- datestr ---------------------------------------------------------------- |
127 | const QString &TranInfo::datestr() | 128 | const QString &TranInfo::datestr(bool bDisplayDate) |
128 | { | 129 | { |
129 | int y=td.year(); | 130 | if( bDisplayDate ) { |
130 | y= y>=2000 && y<=2099 ? y-2000 : y; | 131 | tempstr=TimeString::numberDateString( td ); |
131 | tempstr.sprintf( "%02d/%02d/%02d", y ,td.month(), td.day() ); | 132 | } else { |
133 | tempstr.sprintf( "%04d-%02d-%02d", td.year() ,td.month(), td.day() ); | ||
134 | } | ||
132 | return( tempstr ); | 135 | return( tempstr ); |
133 | } | 136 | } |
134 | 137 | ||
138 | |||
135 | // --- getIdStr --------------------------------------------------------------- | 139 | // --- getIdStr --------------------------------------------------------------- |
136 | const QString &TranInfo::getIdStr() | 140 | const QString &TranInfo::getIdStr() |
137 | { | 141 | { |
138 | tempstr.sprintf("%04d", i); | 142 | tempstr.sprintf("%04d", i); |
139 | return( tempstr ); | 143 | return( tempstr ); |
140 | } | 144 | } |
141 | 145 | ||
142 | // --- write ------------------------------------------------------------------ | 146 | // --- write ------------------------------------------------------------------ |
143 | void TranInfo::write( Config *config ) | 147 | void TranInfo::write( Config *config ) |
144 | { | 148 | { |
145 | config->setGroup( QString::number( id() ) ); | 149 | config->setGroup( QString::number( id() ) ); |
146 | 150 | ||
147 | config->writeEntry( "Description", d ); | 151 | config->writeEntry( "Description", d ); |
148 | 152 | ||
149 | tempstr = QString::number( td.month() ); | 153 | tempstr = QString::number( td.month() ); |
150 | tempstr.append( '/' ); | 154 | tempstr.append( '/' ); |
151 | tempstr.append( QString::number( td.day() ) ); | 155 | tempstr.append( QString::number( td.day() ) ); |
152 | tempstr.append( '/' ); | 156 | tempstr.append( '/' ); |
153 | tempstr.append( QString::number( td.year() ) ); | 157 | tempstr.append( QString::number( td.year() ) ); |
154 | config->writeEntry( "Date", tempstr ); | 158 | config->writeEntry( "Date", tempstr ); |
155 | 159 | ||
156 | w ? tempstr = "true" | 160 | w ? tempstr = "true" |
157 | : tempstr = "false"; | 161 | : tempstr = "false"; |
158 | config->writeEntry( "Payment", tempstr ); | 162 | config->writeEntry( "Payment", tempstr ); |
@@ -189,24 +193,35 @@ int TranInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 | |||
189 | 193 | ||
190 | if ( d1 < d2 ) | 194 | if ( d1 < d2 ) |
191 | r = -1; | 195 | r = -1; |
192 | else if ( d1 == d2 ) | 196 | else if ( d1 == d2 ) |
193 | r = 0; | 197 | r = 0; |
194 | else if ( d1 > d2 ) | 198 | else if ( d1 > d2 ) |
195 | r = 1; | 199 | r = 1; |
196 | return( r ); | 200 | return( r ); |
197 | } | 201 | } |
198 | 202 | ||
199 | // --- toString --------------------------------------------------------------- | 203 | // --- toString --------------------------------------------------------------- |
200 | QString TranInfo::toString() | 204 | QString TranInfo::toString() |
201 | { | 205 | { |
202 | QString ret; | 206 | QString ret; |
203 | ret.sprintf("(%4d) %10s %4s %-10s %5.2f %5.2f", | 207 | ret.sprintf("(%4d) %10s %4s %-10s %5.2f %5.2f", |
204 | id(), | 208 | id(), |
205 | (const char *)datestr(), | 209 | (const char *)datestr(), |
206 | (const char *)number(), | 210 | (const char *)number(), |
207 | (const char *)desc(), | 211 | (const char *)desc(), |
208 | (withdrawal() ? -1 : 1) * amount(), | 212 | (withdrawal() ? -1 : 1) * amount(), |
209 | fee() | 213 | fee() |
210 | ); | 214 | ); |
211 | return(ret); | 215 | return(ret); |
212 | } | 216 | } |
217 | |||
218 | |||
219 | // --- findMostRecentByDesc --------------------------------------------------- | ||
220 | TranInfo *TranInfoList::findMostRecentByDesc( const QString &desc ) | ||
221 | { | ||
222 | for(TranInfo *cur=last(); cur; cur=prev()) { | ||
223 | if( cur->desc()==desc ) | ||
224 | return( cur ); | ||
225 | } | ||
226 | return(NULL); | ||
227 | } \ No newline at end of file | ||