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 @@ -34,7 +34,7 @@ QString tempstr; TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdrawal, const QString &type, const QString &category, float amount, - float fee, const QString &number, const QString ¬es ) + float fee, const QString &number, const QString ¬es, int next ) { i = id; d = desc; @@ -46,6 +46,7 @@ TranInfo::TranInfo( int id, const QString &desc, const QDate &date, bool withdra f = fee; cn = number; n = notes; + _next=next; } TranInfo::TranInfo( Config config, int entry ) @@ -116,27 +117,32 @@ TranInfo::TranInfo( Config config, int entry ) // Notes n = config.readEntry( "Comments", "" ); + + // next + _next = config.readNumEntry("Next", -1); } } +// --- datestr ---------------------------------------------------------------- const QString &TranInfo::datestr() { - tempstr = QString::number( td.year() ); - tempstr.append( '/' ); - int tempfield = td.month(); - if ( tempfield < 10 ) tempstr.append( '0' ); - tempstr.append( QString::number( tempfield ) ); - tempstr.append( '/' ); - tempfield = td.day(); - if ( tempfield < 10 ) tempstr.append( '0' ); - tempstr.append( QString::number( tempfield ) ); + int y=td.year(); + y= y>=2000 && y<=2099 ? y-2000 : y; + tempstr.sprintf( "%02d/%02d/%02d", y ,td.month(), td.day() ); + return( tempstr ); +} +// --- getIdStr --------------------------------------------------------------- +const QString &TranInfo::getIdStr() +{ + tempstr.sprintf("%04d", i); return( tempstr ); } -void TranInfo::write( Config *config, int entry ) +// --- write ------------------------------------------------------------------ +void TranInfo::write( Config *config ) { - config->setGroup( QString::number( entry ) ); + config->setGroup( QString::number( id() ) ); config->writeEntry( "Description", d ); @@ -170,10 +176,11 @@ void TranInfo::write( Config *config, int entry ) config->writeEntry( "TransactionFee", tempstr ); config->writeEntry( "CheckNumber", cn ); - config->writeEntry( "Comments", n ); + config->writeEntry( "Next", _next ); } + int TranInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 ) { QDate d1 = ((TranInfo *)item1)->date(); @@ -188,3 +195,18 @@ int TranInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 r = 1; return( r ); } + +// --- toString --------------------------------------------------------------- +QString TranInfo::toString() +{ + QString ret; + ret.sprintf("(%4d) %10s %4s %-10s %5.2f %5.2f", + id(), + (const char *)datestr(), + (const char *)number(), + (const char *)desc(), + (withdrawal() ? -1 : 1) * amount(), + fee() + ); + return(ret); +} |