summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/checkbook.cpp6
-rw-r--r--noncore/apps/checkbook/traninfo.cpp15
-rw-r--r--noncore/apps/checkbook/traninfo.h8
3 files changed, 25 insertions, 4 deletions
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
@@ -312,5 +312,5 @@ void Checkbook::loadCheckbook()
// Add to transaction list
- transactions.append( tran );
+ transactions.inSort( tran );
// Add to transaction table
@@ -416,5 +416,5 @@ void Checkbook::slotNewTran()
// Add to transaction list
- transactions.append( traninfo );
+ transactions.inSort( traninfo );
// Add to transaction table
@@ -563,5 +563,5 @@ void Checkbook::drawCategoryChart( bool withdrawals )
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
@@ -174,2 +174,17 @@ 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
@@ -82,5 +82,11 @@ class TranInfo
};
-typedef QList<TranInfo> TranInfoList;
+class TranInfoList : public QList<TranInfo>
+{
+ protected:
+ int compareItems( QCollection::Item, QCollection::Item );
+};
+
+//typedef TranList<TranInfo> TranInfoList;
#endif