From e224e28dfa730ce315caa7ae570496c9cd3ffbe2 Mon Sep 17 00:00:00 2001 From: drw Date: Sat, 02 Nov 2002 23:13:41 +0000 Subject: Fixes --- (limited to 'noncore') diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp index 77c1f57..ab25516 100644 --- a/noncore/apps/checkbook/checkbook.cpp +++ b/noncore/apps/checkbook/checkbook.cpp @@ -311,7 +311,7 @@ void Checkbook::loadCheckbook() stramount.sprintf( "%c%.2f", currencySymbol, amount ); // Add to transaction list - transactions.append( tran ); + transactions.inSort( tran ); // Add to transaction table ( void ) new QListViewItem( tranTable, QString::number( i ), tran->datestr(), @@ -415,7 +415,7 @@ void Checkbook::slotNewTran() stramount.sprintf( "%c%.2f", currencySymbol, amount ); // Add to transaction list - transactions.append( traninfo ); + transactions.inSort( traninfo ); // Add to transaction table ( void ) new QListViewItem( tranTable, QString::number( highTranNum ), @@ -562,7 +562,7 @@ void Checkbook::drawCategoryChart( bool withdrawals ) DataPointList *list = new DataPointList(); TranInfo *tran = transactions.first(); - if ( tran->withdrawal() == withdrawals ) + if ( tran && tran->withdrawal() == withdrawals ) { list->append( new DataPointInfo( tran->category(), tran->amount() ) ); } diff --git a/noncore/apps/checkbook/traninfo.cpp b/noncore/apps/checkbook/traninfo.cpp index 460466c..dcba869 100644 --- a/noncore/apps/checkbook/traninfo.cpp +++ b/noncore/apps/checkbook/traninfo.cpp @@ -173,3 +173,18 @@ void TranInfo::write( Config *config, int entry ) config->writeEntry( "Comments", n ); } + +int TranInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 ) +{ + QDate d1 = ((TranInfo *)item1)->date(); + QDate d2 = ((TranInfo *)item2)->date(); + int r = -1; + + if ( d1 < d2 ) + r = -1; + else if ( d1 == d2 ) + r = 0; + else if ( d1 > d2 ) + r = 1; + return( r ); +} \ No newline at end of file diff --git a/noncore/apps/checkbook/traninfo.h b/noncore/apps/checkbook/traninfo.h index e944c29..e488816 100644 --- a/noncore/apps/checkbook/traninfo.h +++ b/noncore/apps/checkbook/traninfo.h @@ -81,6 +81,12 @@ class TranInfo QString n; }; -typedef QList TranInfoList; +class TranInfoList : public QList +{ + protected: + int compareItems( QCollection::Item, QCollection::Item ); +}; + +//typedef TranList TranInfoList; #endif -- cgit v0.9.0.2