summaryrefslogtreecommitdiff
authordrw <drw>2002-11-02 23:13:41 (UTC)
committer drw <drw>2002-11-02 23:13:41 (UTC)
commite224e28dfa730ce315caa7ae570496c9cd3ffbe2 (patch) (side-by-side diff)
treeed97aca731ee3f92dfb6c7c47a4394da87061b66
parentefb3cb40de57d53de1eb22662261e58333a3a39d (diff)
downloadopie-e224e28dfa730ce315caa7ae570496c9cd3ffbe2.zip
opie-e224e28dfa730ce315caa7ae570496c9cd3ffbe2.tar.gz
opie-e224e28dfa730ce315caa7ae570496c9cd3ffbe2.tar.bz2
Fixes
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
@@ -306,17 +306,17 @@ void Checkbook::loadCheckbook()
if ( tran->withdrawal() )
{
amount *= -1;
}
currBalance += amount;
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(),
trandesc, stramount );
}
else
{
delete tran;
@@ -410,17 +410,17 @@ void Checkbook::slotNewTran()
if ( traninfo->withdrawal() )
{
amount *= -1;
}
QString stramount;
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 ),
traninfo->datestr(), traninfo->desc(), stramount );
adjustBalance( amount );
}
else
@@ -557,17 +557,17 @@ void Checkbook::drawBalanceChart()
graphInfo = new GraphInfo( GraphInfo::BarChart, list );
}
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() ) );
}
tran = transactions.next();
DataPointInfo *cat;
for ( ; tran; tran = transactions.next() )
{
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
@@ -168,8 +168,23 @@ void TranInfo::write( Config *config, int entry )
tempstr.setNum( f, 'f', 2 );
config->writeEntry( "TransactionFee", tempstr );
config->writeEntry( "CheckNumber", cn );
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
@@ -76,11 +76,17 @@ class TranInfo
QString t;
QString c;
float a;
float f;
QString cn;
QString n;
};
-typedef QList<TranInfo> TranInfoList;
+class TranInfoList : public QList<TranInfo>
+{
+ protected:
+ int compareItems( QCollection::Item, QCollection::Item );
+};
+
+//typedef TranList<TranInfo> TranInfoList;
#endif