Diffstat (limited to 'noncore/apps/checkbook/traninfo.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/checkbook/traninfo.cpp | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/noncore/apps/checkbook/traninfo.cpp b/noncore/apps/checkbook/traninfo.cpp index 65c190c..d880bb4 100644 --- a/noncore/apps/checkbook/traninfo.cpp +++ b/noncore/apps/checkbook/traninfo.cpp | |||
@@ -33,9 +33,9 @@ | |||
33 | QString tempstr; | 33 | QString tempstr; |
34 | 34 | ||
35 | TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal, | 35 | TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal, |
36 | const QString &type, const QString &category, float amount, | 36 | const QString &type, const QString &category, float amount, |
37 | float fee, const QString &number, const QString ¬es ) | 37 | float fee, const QString &number, const QString ¬es, int next ) |
38 | { | 38 | { |
39 | i = id; | 39 | i = id; |
40 | d = desc; | 40 | d = desc; |
41 | td = date; | 41 | td = date; |
@@ -45,8 +45,9 @@ TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdra | |||
45 | a = amount; | 45 | a = amount; |
46 | f = fee; | 46 | f = fee; |
47 | cn = number; | 47 | cn = number; |
48 | n = notes; | 48 | n = notes; |
49 | _next=next; | ||
49 | } | 50 | } |
50 | 51 | ||
51 | TranInfo::TranInfo( Config config, int entry ) | 52 | TranInfo::TranInfo( Config config, int entry ) |
52 | { | 53 | { |
@@ -115,29 +116,34 @@ TranInfo::TranInfo( Config config, int entry ) | |||
115 | cn = config.readEntry( "CheckNumber", "" ); | 116 | cn = config.readEntry( "CheckNumber", "" ); |
116 | 117 | ||
117 | // Notes | 118 | // Notes |
118 | n = config.readEntry( "Comments", "" ); | 119 | n = config.readEntry( "Comments", "" ); |
120 | |||
121 | // next | ||
122 | _next = config.readNumEntry("Next", -1); | ||
119 | } | 123 | } |
120 | } | 124 | } |
121 | 125 | ||
126 | // --- datestr ---------------------------------------------------------------- | ||
122 | const QString &TranInfo::datestr() | 127 | const QString &TranInfo::datestr() |
123 | { | 128 | { |
124 | tempstr = QString::number( td.year() ); | 129 | int y=td.year(); |
125 | tempstr.append( '/' ); | 130 | y= y>=2000 && y<=2099 ? y-2000 : y; |
126 | int tempfield = td.month(); | 131 | tempstr.sprintf( "%02d/%02d/%02d", y ,td.month(), td.day() ); |
127 | if ( tempfield < 10 ) tempstr.append( '0' ); | 132 | return( tempstr ); |
128 | tempstr.append( QString::number( tempfield ) ); | 133 | } |
129 | tempstr.append( '/' ); | ||
130 | tempfield = td.day(); | ||
131 | if ( tempfield < 10 ) tempstr.append( '0' ); | ||
132 | tempstr.append( QString::number( tempfield ) ); | ||
133 | 134 | ||
135 | // --- getIdStr --------------------------------------------------------------- | ||
136 | const QString &TranInfo::getIdStr() | ||
137 | { | ||
138 | tempstr.sprintf("%04d", i); | ||
134 | return( tempstr ); | 139 | return( tempstr ); |
135 | } | 140 | } |
136 | 141 | ||
137 | void TranInfo::write( Config *config, int entry ) | 142 | // --- write ------------------------------------------------------------------ |
143 | void TranInfo::write( Config *config ) | ||
138 | { | 144 | { |
139 | config->setGroup( QString::number( entry ) ); | 145 | config->setGroup( QString::number( id() ) ); |
140 | 146 | ||
141 | config->writeEntry( "Description", d ); | 147 | config->writeEntry( "Description", d ); |
142 | 148 | ||
143 | tempstr = QString::number( td.month() ); | 149 | tempstr = QString::number( td.month() ); |
@@ -169,12 +175,13 @@ void TranInfo::write( Config *config, int entry ) | |||
169 | tempstr.setNum( f, 'f', 2 ); | 175 | tempstr.setNum( f, 'f', 2 ); |
170 | config->writeEntry( "TransactionFee", tempstr ); | 176 | config->writeEntry( "TransactionFee", tempstr ); |
171 | 177 | ||
172 | config->writeEntry( "CheckNumber", cn ); | 178 | config->writeEntry( "CheckNumber", cn ); |
173 | |||
174 | config->writeEntry( "Comments", n ); | 179 | config->writeEntry( "Comments", n ); |
180 | config->writeEntry( "Next", _next ); | ||
175 | } | 181 | } |
176 | 182 | ||
183 | |||
177 | int TranInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 ) | 184 | int TranInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 ) |
178 | { | 185 | { |
179 | QDate d1 = ((TranInfo *)item1)->date(); | 186 | QDate d1 = ((TranInfo *)item1)->date(); |
180 | QDate d2 = ((TranInfo *)item2)->date(); | 187 | QDate d2 = ((TranInfo *)item2)->date(); |
@@ -187,4 +194,19 @@ int TranInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 | |||
187 | else if ( d1 > d2 ) | 194 | else if ( d1 > d2 ) |
188 | r = 1; | 195 | r = 1; |
189 | return( r ); | 196 | return( r ); |
190 | } | 197 | } |
198 | |||
199 | // --- toString --------------------------------------------------------------- | ||
200 | QString TranInfo::toString() | ||
201 | { | ||
202 | QString ret; | ||
203 | ret.sprintf("(%4d) %10s %4s %-10s %5.2f %5.2f", | ||
204 | id(), | ||
205 | (const char *)datestr(), | ||
206 | (const char *)number(), | ||
207 | (const char *)desc(), | ||
208 | (withdrawal() ? -1 : 1) * amount(), | ||
209 | fee() | ||
210 | ); | ||
211 | return(ret); | ||
212 | } | ||