summaryrefslogtreecommitdiff
path: root/noncore/apps/checkbook/traninfo.cpp
Unidiff
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
@@ -36,3 +36,3 @@ TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdra
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{
@@ -48,2 +48,3 @@ TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdra
48 n = notes; 48 n = notes;
49 _next=next;
49} 50}
@@ -113,3 +114,3 @@ TranInfo::TranInfo( Config config, int entry )
113 114
114 // Transaction number 115 // Transaction number
115 cn = config.readEntry( "CheckNumber", "" ); 116 cn = config.readEntry( "CheckNumber", "" );
@@ -118,2 +119,5 @@ TranInfo::TranInfo( Config config, int entry )
118 n = config.readEntry( "Comments", "" ); 119 n = config.readEntry( "Comments", "" );
120
121 // next
122 _next = config.readNumEntry("Next", -1);
119 } 123 }
@@ -121,20 +125,22 @@ TranInfo::TranInfo( Config config, int entry )
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
@@ -171,7 +177,8 @@ void TranInfo::write( Config *config, int entry )
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 )
@@ -190 +197,16 @@ int TranInfoList::compareItems( QCollection::Item item1, QCollection::Item item2
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}