From e6ff2dbd2d128c3cf873e23f4df8006759b47079 Mon Sep 17 00:00:00 2001 From: allenforsythe Date: Fri, 16 May 2003 20:08:38 +0000 Subject: Working on time frame for displaying cleared transactions. Not yet working. --- (limited to 'noncore/apps/qashmoney') diff --git a/noncore/apps/qashmoney/install/CONTROL/opie-qashmoney.control b/noncore/apps/qashmoney/install/CONTROL/opie-qashmoney.control index ffd11db..b00e3b1 100755 --- a/noncore/apps/qashmoney/install/CONTROL/opie-qashmoney.control +++ b/noncore/apps/qashmoney/install/CONTROL/opie-qashmoney.control @@ -1,6 +1,6 @@ Package: qashmoney Priority: optional -Version: 0.74 +Version: 0.75 Architecture: arm Maintainer: Allen Forsythe qashmoneyman@attbi.com Section: Applications diff --git a/noncore/apps/qashmoney/preferencedialogs.cpp b/noncore/apps/qashmoney/preferencedialogs.cpp index 00d52c6..d7c66d3 100755 --- a/noncore/apps/qashmoney/preferencedialogs.cpp +++ b/noncore/apps/qashmoney/preferencedialogs.cpp @@ -76,20 +76,21 @@ TransactionPreferences::TransactionPreferences ( QWidget* parent ) : QDialog ( p showclearedtransactions = new QCheckBox ( this ); showclearedtransactions->setText ( "Show Cleared Transactions" ); - excludetransfers = new QCheckBox ( this ); - excludetransfers->setText ( "Include Transfers In Limit View" ); - limittransactionsbox = new QHBox ( this ); limittransactionsbox->setSpacing ( 2 ); - limittransactionslabel = new QLabel ( "Limit All Transactions To", limittransactionsbox ); + limittransactionslabel = new QLabel ( "Show ", limittransactionsbox ); limittransactions = new QComboBox ( limittransactionsbox ); + QLabel *limittransactionslabel2 = new QLabel ( "of cleared transactions. ", limittransactionsbox ); limittransactions->insertItem ( "14 days" ); limittransactions->insertItem ( "30 days" ); - limittransactions->insertItem ( "60 days" ); limittransactions->insertItem ( "90 days" ); limittransactions->insertItem ( "180 days" ); limittransactions->insertItem ( "365 days" ); limittransactions->insertItem ( "All" ); + limittransactions->setCurrentItem ( preferences->getPreference ( 7 ) ); + + excludetransfers = new QCheckBox ( this ); + excludetransfers->setText ( "Include Transfers In Limit View" ); if ( preferences->getPreference ( 3 ) == 1 ) showclearedtransactions->setChecked ( TRUE ); @@ -106,8 +107,8 @@ TransactionPreferences::TransactionPreferences ( QWidget* parent ) : QDialog ( p layout = new QVBoxLayout ( this, 2, 2 ); layout->addWidget ( showclearedtransactions ); - layout->addWidget ( excludetransfers ); layout->addWidget ( limittransactionsbox ); + layout->addWidget ( excludetransfers ); layout->insertSpacing ( 3, 5 ); layout->addWidget ( defaults ); diff --git a/noncore/apps/qashmoney/preferences.cpp b/noncore/apps/qashmoney/preferences.cpp index 819d5cf..9bf64dd 100755 --- a/noncore/apps/qashmoney/preferences.cpp +++ b/noncore/apps/qashmoney/preferences.cpp @@ -60,7 +60,7 @@ void Preferences::addPreferences () if ( rows == 0 ) sqlite_exec ( db, "insert into preferences values ( 0, 'excludetransfersfromlimit', 0, 0, 0, NULL );", 0, 0, 0 ); - // limit number of transactions to 0 = 14 days 1 = 30 days, 2 = 60 days, 3 = 90 days, 4 = 180 days, 5 = 365 days, 6 = all + // limit number of transactions to 0 = 14 days 1 = 30 days, 2 = 90 days, 3 = 180 days, 4 = 365 days 5 = all rows = 0; sqlite_get_table ( db, "select preference from preferences where id = 7;", &results, &rows, &columns, 0 ); if ( rows == 0 ) diff --git a/noncore/apps/qashmoney/qashmoney.cpp b/noncore/apps/qashmoney/qashmoney.cpp index 1ea358c..83eea01 100755 --- a/noncore/apps/qashmoney/qashmoney.cpp +++ b/noncore/apps/qashmoney/qashmoney.cpp @@ -143,12 +143,14 @@ void QashMoney::changeTabDisplay () transactiondisplay->setChildren ( children ); transactiondisplay->setAccountID ( accountid ); + setTransactionDisplayDate (); + // display transactions transactiondisplay->listview->clear(); QString displaytext = "%"; displaytext.prepend ( transactiondisplay->limitbox->text() ); if ( transaction->getNumberOfTransactions() > 0 ) - transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext ); + transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate ); // display transfers transfer->displayTransfers ( transactiondisplay->listview, accountid, children ); @@ -254,8 +256,10 @@ void QashMoney::displayDatePreferencesDialog () transactiondisplay->listview->clear(); QString displaytext = "%"; displaytext.prepend ( transactiondisplay->limitbox->text() ); + + setTransactionDisplayDate(); if ( transaction->getNumberOfTransactions() > 0 ) - transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext ); + transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate ); if ( transfer->getNumberOfTransfers() != 0 ) transfer->displayTransfers ( transactiondisplay->listview, accountid, children ); @@ -290,8 +294,10 @@ void QashMoney::displayTransactionPreferencesDialog () transactiondisplay->listview->clear(); QString displaytext = "%"; displaytext.prepend ( transactiondisplay->limitbox->text() ); + + setTransactionDisplayDate(); if ( transaction->getNumberOfTransactions() > 0 ) - transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext ); + transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate ); if ( transfer->getNumberOfTransfers() != 0 ) transfer->displayTransfers ( transactiondisplay->listview, accountid, children ); @@ -352,5 +358,33 @@ void QashMoney::toggleOneTouchViewing ( bool state ) enableOneTouchViewing(); } - +void QashMoney::setTransactionDisplayDate () + { + // determine how many days of transactions to show + int limittype = preferences->getPreference ( 7 ); + if ( limittype != 5 ) // set today's date if we are not showing all transactions + { + QDate today = QDate::currentDate (); + switch ( limittype ) // if we are not showing all transactions + { + case 0: // viewing two weeks + newdate = today.addDays ( -14 ); + break; + case 1: // viewing one month + newdate = today.addDays ( -30 ); + break; + case 2: // three months + newdate = today.addDays ( -90 ); + break; + case 3: // six months + newdate = today.addDays ( -180 ); + break; + case 4: // one year + newdate = today.addDays ( -365 ); + break; + } + } + else + newdate = QDate ( 1, 1, 1000 ); + } diff --git a/noncore/apps/qashmoney/qashmoney.h b/noncore/apps/qashmoney/qashmoney.h index cf0bd42..ec2c7ec 100755 --- a/noncore/apps/qashmoney/qashmoney.h +++ b/noncore/apps/qashmoney/qashmoney.h @@ -5,6 +5,7 @@ #include #include #include +#include #include "accountdisplay.h" #include "transactiondisplay.h" @@ -46,6 +47,7 @@ class QashMoney : public QWidget void enableOneTouchViewing (); void disableOneTouchViewing (); void toggleOneTouchViewing ( bool ); + void setTransactionDisplayDate (); private: QVBoxLayout *layout; @@ -54,6 +56,7 @@ class QashMoney : public QWidget TransactionDisplay *transactiondisplay; BudgetDisplay *budgetdisplay; int tabheight; + QDate newdate; }; diff --git a/noncore/apps/qashmoney/qmaccounts.db b/noncore/apps/qashmoney/qmaccounts.db index 449bcab..76db78b 100755 --- a/noncore/apps/qashmoney/qmaccounts.db +++ b/noncore/apps/qashmoney/qmaccounts.db Binary files differ diff --git a/noncore/apps/qashmoney/qmbudgets.db b/noncore/apps/qashmoney/qmbudgets.db index d798f0c..ef75719 100755 --- a/noncore/apps/qashmoney/qmbudgets.db +++ b/noncore/apps/qashmoney/qmbudgets.db Binary files differ diff --git a/noncore/apps/qashmoney/qmmemory.db b/noncore/apps/qashmoney/qmmemory.db index 5c23122..c6b7920 100755 --- a/noncore/apps/qashmoney/qmmemory.db +++ b/noncore/apps/qashmoney/qmmemory.db Binary files differ diff --git a/noncore/apps/qashmoney/qmpreferences.db b/noncore/apps/qashmoney/qmpreferences.db index a4e96f5..91596cb 100755 --- a/noncore/apps/qashmoney/qmpreferences.db +++ b/noncore/apps/qashmoney/qmpreferences.db Binary files differ diff --git a/noncore/apps/qashmoney/qmtransactions.db b/noncore/apps/qashmoney/qmtransactions.db index 9e4acc9..a5eb4f3 100755 --- a/noncore/apps/qashmoney/qmtransactions.db +++ b/noncore/apps/qashmoney/qmtransactions.db Binary files differ diff --git a/noncore/apps/qashmoney/qmtransfers.db b/noncore/apps/qashmoney/qmtransfers.db index c31df1a..3ca9f78 100755 --- a/noncore/apps/qashmoney/qmtransfers.db +++ b/noncore/apps/qashmoney/qmtransfers.db Binary files differ diff --git a/noncore/apps/qashmoney/transaction.cpp b/noncore/apps/qashmoney/transaction.cpp index af7d18f..5ecc7ed 100755 --- a/noncore/apps/qashmoney/transaction.cpp +++ b/noncore/apps/qashmoney/transaction.cpp @@ -8,6 +8,7 @@ #include "transactiondisplay.h" #include +#include extern Account *account; extern Preferences *preferences; @@ -154,9 +155,10 @@ int Transaction::getYear ( int id ) return yearstring.toInt(); } -void Transaction::displayTransactions ( QListView *listview, int id, bool children, const char *limit ) +void Transaction::displayTransactions ( QListView *listview, int id, bool children, const char *limit, QDate displaydate ) { int showcleared = preferences->getPreference ( 3 ); + int year = ( displaydate.year() ) - 1; // select the transactions to display // two different statements are used based on @@ -166,14 +168,14 @@ void Transaction::displayTransactions ( QListView *listview, int id, bool childr if ( showcleared == 0 ) { if ( account->getParentAccountID ( id ) == -1 && children == TRUE ) - sqlite_get_table_printf ( tdb, "select day, month, year, payee, amount, transid, accountid from transactions where cleared = 0 and parentid = %i and payee like '%q';", &results, &rows, &columns, NULL, id, limit ); + sqlite_get_table_printf ( tdb, "select day, month, year, payee, amount, transid, accountid from transactions where cleared = 0 and year >= %i parentid = %i and payee like '%q';", &results, &rows, &columns, NULL, year, id, limit ); else - sqlite_get_table_printf ( tdb, "select day, month, year, payee, amount, transid, accountid from transactions where cleared = 0 and accountid = %i and payee like '%q';", &results, &rows, &columns, NULL, id, limit ); + sqlite_get_table_printf ( tdb, "select day, month, year, payee, amount, transid, accountid from transactions where cleared = 0 year >= %i accountid = %i and payee like '%q';", &results, &rows, &columns, NULL, year, id, limit ); } else { if ( account->getParentAccountID ( id ) == -1 && children == TRUE ) - sqlite_get_table_printf ( tdb, "select day, month, year, payee, amount, transid, accountid from transactions where parentid = %i and payee like '%q';", &results, &rows, &columns, NULL, id, limit ); + sqlite_get_table_printf ( tdb, "select day, month, year, payee, amount, transid, accountid from transactions where year >= %i and parentid = %i and payee like '%q';", &results, &rows, &columns, NULL, year, id, limit ); else sqlite_get_table_printf ( tdb, "select day, month, year, payee, amount, transid, accountid from transactions where accountid = %i and payee like '%q';", &results, &rows, &columns, NULL, id, limit ); } @@ -182,14 +184,8 @@ void Transaction::displayTransactions ( QListView *listview, int id, bool childr int counter = 7; while ( counter < ( ( rows + 1 ) * columns ) ) { - // construct the date - //QString daystring = results [ counter ]; - //int day = results [ counter ].toInt (); - //QString monthstring = results [ counter + 1 ]; - //int month = results [ counter + 1 ].toInt (); - //QString yearstring = results [ counter + 2 ]; - //int year = results [ counter + 2 ].toInt (); - QString date = preferences->getDate ( atoi ( results [ counter + 2 ] ), atoi ( results [ counter + 1 ] ), atoi ( results [ counter ] ) ); + QDate displaydate ( atoi ( results [ counter + 2 ] ), atoi ( results [ counter + 1 ] ), atoi ( results [ counter ] ) ); + QString date = preferences->getDate ( atoi ( results [ counter + 2 ] ), atoi ( results [ counter + 1 ] ), atoi ( results [ counter ] ) ); // construct transaction name, amount, id QString payee = results [ counter + 3 ]; diff --git a/noncore/apps/qashmoney/transaction.h b/noncore/apps/qashmoney/transaction.h index 5db011c..7297bb1 100755 --- a/noncore/apps/qashmoney/transaction.h +++ b/noncore/apps/qashmoney/transaction.h @@ -3,6 +3,7 @@ #include #include +#include #include #include "preferences.h" @@ -43,7 +44,7 @@ class Transaction public slots: - void displayTransactions ( QListView *, int, bool, const char * ); + void displayTransactions ( QListView *, int, bool, const char *, QDate ); QString getPayee ( int ); QString getTransactionDescription ( int ); QString getNumber ( int ); diff --git a/noncore/apps/qashmoney/transactiondisplay.cpp b/noncore/apps/qashmoney/transactiondisplay.cpp index 14f5641..ae6223d 100755 --- a/noncore/apps/qashmoney/transactiondisplay.cpp +++ b/noncore/apps/qashmoney/transactiondisplay.cpp @@ -127,8 +127,9 @@ void TransactionDisplay::addTransaction () listview->clear(); QString displaytext = "%"; displaytext.prepend ( limitbox->text() ); + setTransactionDisplayDate (); if ( transaction->getNumberOfTransactions() > 0 ) - transaction->displayTransactions ( listview, accountid, children, displaytext ); + transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate ); // redisplay transfers if ( transfer->getNumberOfTransfers() > 0 ) @@ -365,8 +366,9 @@ void TransactionDisplay::updateAndDisplay ( int id ) listview->clear(); QString displaytext = "%"; displaytext.prepend ( limitbox->text() ); + setTransactionDisplayDate (); if ( transaction->getNumberOfTransactions() > 0 ) - transaction->displayTransactions ( listview, accountid, children, displaytext ); + transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate ); // redisplay transfers if ( transfer->getNumberOfTransfers() > 0 ) @@ -409,8 +411,9 @@ void TransactionDisplay::deleteTransaction () listview->clear(); QString displaytext = "%"; displaytext.prepend ( limitbox->text() ); + setTransactionDisplayDate (); if ( transaction->getNumberOfTransactions() > 0 ) - transaction->displayTransactions ( listview, accountid, children, displaytext ); + transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate ); if ( transfer->getNumberOfTransfers() > 0 ) transfer->displayTransfers ( listview, accountid, children ); @@ -440,8 +443,9 @@ void TransactionDisplay::deleteTransaction () listview->clear(); QString displaytext = "%"; displaytext.prepend ( limitbox->text() ); + setTransactionDisplayDate (); if ( transaction->getNumberOfTransactions() > 0 ) - transaction->displayTransactions ( listview, accountid, children, displaytext ); + transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate ); if ( transfer->getNumberOfTransfers() > 0 ) transfer->displayTransfers ( listview, accountid, children ); @@ -492,8 +496,9 @@ void TransactionDisplay::toggleTransaction () listview->clear(); QString displaytext = "%"; displaytext.prepend ( limitbox->text() ); + setTransactionDisplayDate (); if ( transaction->getNumberOfTransactions() > 0 ) - transaction->displayTransactions ( listview, accountid, children, displaytext ); + transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate ); if ( transfer->getNumberOfTransfers() != 0 ) transfer->displayTransfers ( listview, accountid, children ); @@ -551,7 +556,10 @@ void TransactionDisplay::limitDisplay ( const QString &text ) listview->clear (); QString displaytext = "%"; displaytext.prepend ( text ); - transaction->displayTransactions ( listview, accountid, children, displaytext ); + setTransactionDisplayDate (); + if ( transaction->getNumberOfTransactions() > 0 ) + transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate ); + if ( displaytext.length() == 1 || preferences->getPreference ( 6 ) == 1 ) transfer->displayTransfers ( listview, accountid, children ); } @@ -584,3 +592,32 @@ void TransactionDisplay::showTransactionNotes () } } +void TransactionDisplay::setTransactionDisplayDate () + { + // determine how many days of transactions to show + int limittype = preferences->getPreference ( 7 ); + if ( limittype != 5 ) // set today's date if we are not showing all transactions + { + QDate today = QDate::currentDate (); + switch ( limittype ) // if we are not showing all transactions + { + case 0: // viewing two weeks + displaydate = today.addDays ( -14 ); + break; + case 1: // viewing one month + displaydate = today.addDays ( -30 ); + break; + case 2: // three months + displaydate = today.addDays ( -90 ); + break; + case 3: // six months + displaydate = today.addDays ( -180 ); + break; + case 4: // one year + displaydate = today.addDays ( -365 ); + break; + } + } + else + displaydate = QDate ( 1, 1, 1000 ); + } diff --git a/noncore/apps/qashmoney/transactiondisplay.h b/noncore/apps/qashmoney/transactiondisplay.h index 79f20ba..1746f6c 100755 --- a/noncore/apps/qashmoney/transactiondisplay.h +++ b/noncore/apps/qashmoney/transactiondisplay.h @@ -7,6 +7,7 @@ #include #include #include +#include class TransactionDisplay : public QWidget { @@ -48,9 +49,11 @@ class TransactionDisplay : public QWidget void limitDisplay ( const QString & ); void showCalculator (); void showCalendar (); + void setTransactionDisplayDate (); private: int accountid, fromaccount, fromparent, toaccount, toparent, day, month, year, transferid; + QDate displaydate; bool children; QBoxLayout *layout; QHBox *firstline; -- cgit v0.9.0.2