summaryrefslogtreecommitdiff
path: root/noncore/apps/checkbook/traninfo.cpp
authormickeyl <mickeyl>2003-10-27 19:51:32 (UTC)
committer mickeyl <mickeyl>2003-10-27 19:51:32 (UTC)
commit951d1d4125a80dc814f95d2956853bf53ca52e9a (patch) (unidiff)
tree46c7a70b80a7eebb54cd59c46204c28335f3821c /noncore/apps/checkbook/traninfo.cpp
parentf0a15a9866f9eddfe10596e63a1e6300b92b9e3f (diff)
downloadopie-951d1d4125a80dc814f95d2956853bf53ca52e9a.zip
opie-951d1d4125a80dc814f95d2956853bf53ca52e9a.tar.gz
opie-951d1d4125a80dc814f95d2956853bf53ca52e9a.tar.bz2
merge noncore/apps/* except
- advancedfm (ljp, please...) - odict (tille, please...)
Diffstat (limited to 'noncore/apps/checkbook/traninfo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/traninfo.cpp54
1 files changed, 38 insertions, 16 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
@@ -31,24 +31,25 @@
31#include <qpe/config.h> 31#include <qpe/config.h>
32 32
33QString tempstr; 33QString tempstr;
34 34
35TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal, 35TranInfo::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 &notes ) 37 float fee, const QString &number, const QString &notes, int next )
38{ 38{
39 i = id; 39 i = id;
40 d = desc; 40 d = desc;
41 td = date; 41 td = date;
42 w = withdrawal; 42 w = withdrawal;
43 t = type; 43 t = type;
44 c = category; 44 c = category;
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
51TranInfo::TranInfo( Config config, int entry ) 52TranInfo::TranInfo( Config config, int entry )
52{ 53{
53 config.setGroup( QString::number( entry ) ); 54 config.setGroup( QString::number( entry ) );
54 QString desc = config.readEntry( "Description", "Not Found" ); 55 QString desc = config.readEntry( "Description", "Not Found" );
@@ -108,38 +109,43 @@ TranInfo::TranInfo( Config config, int entry )
108 a = stramount.toFloat( &ok ); 109 a = stramount.toFloat( &ok );
109 110
110 // Transaction fee 111 // Transaction fee
111 stramount = config.readEntry( "TransactionFee", "0.00" ); 112 stramount = config.readEntry( "TransactionFee", "0.00" );
112 f = stramount.toFloat( &ok ); 113 f = stramount.toFloat( &ok );
113 114
114 // Transaction number 115 // Transaction number
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 ----------------------------------------------------------------
122const QString &TranInfo::datestr() 127const 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
134 return( tempstr ); 135// --- getIdStr ---------------------------------------------------------------
136const QString &TranInfo::getIdStr()
137{
138 tempstr.sprintf("%04d", i);
139 return( tempstr );
135} 140}
136 141
137void TranInfo::write( Config *config, int entry ) 142// --- write ------------------------------------------------------------------
143void 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() );
144 tempstr.append( '/' ); 150 tempstr.append( '/' );
145 tempstr.append( QString::number( td.day() ) ); 151 tempstr.append( QString::number( td.day() ) );
@@ -166,17 +172,18 @@ void TranInfo::write( Config *config, int entry )
166 tempstr.setNum( a, 'f', 2 ); 172 tempstr.setNum( a, 'f', 2 );
167 config->writeEntry( "Amount", tempstr ); 173 config->writeEntry( "Amount", tempstr );
168 174
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
177int TranInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 ) 184int 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();
181 int r = -1; 188 int r = -1;
182 189
@@ -185,6 +192,21 @@ int TranInfoList::compareItems( QCollection::Item item1, QCollection::Item item2
185 else if ( d1 == d2 ) 192 else if ( d1 == d2 )
186 r = 0; 193 r = 0;
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 ---------------------------------------------------------------
200QString 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}