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 | |||
@@ -20,24 +20,25 @@ | |||
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; |
@@ -115,32 +116,35 @@ TranInfo::TranInfo( Config config, int entry ) | |||
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 | ||
@@ -201,12 +205,23 @@ 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 | ||