author | allenforsythe <allenforsythe> | 2003-05-16 20:08:38 (UTC) |
---|---|---|
committer | allenforsythe <allenforsythe> | 2003-05-16 20:08:38 (UTC) |
commit | e6ff2dbd2d128c3cf873e23f4df8006759b47079 (patch) (side-by-side diff) | |
tree | bb3c996b76c8937d871f642f0e32032848d32396 | |
parent | 87051a7ba4834aed152bc09aad7f4935c9729ccb (diff) | |
download | opie-e6ff2dbd2d128c3cf873e23f4df8006759b47079.zip opie-e6ff2dbd2d128c3cf873e23f4df8006759b47079.tar.gz opie-e6ff2dbd2d128c3cf873e23f4df8006759b47079.tar.bz2 |
Working on time frame for displaying cleared transactions. Not yet working.
-rwxr-xr-x | noncore/apps/qashmoney/install/CONTROL/opie-qashmoney.control | 2 | ||||
-rwxr-xr-x | noncore/apps/qashmoney/preferencedialogs.cpp | 13 | ||||
-rwxr-xr-x | noncore/apps/qashmoney/preferences.cpp | 2 | ||||
-rwxr-xr-x | noncore/apps/qashmoney/qashmoney.cpp | 42 | ||||
-rwxr-xr-x | noncore/apps/qashmoney/qashmoney.h | 3 | ||||
-rwxr-xr-x | noncore/apps/qashmoney/qmaccounts.db | bin | 4096 -> 6144 bytes | |||
-rwxr-xr-x | noncore/apps/qashmoney/qmbudgets.db | bin | 3072 -> 4096 bytes | |||
-rwxr-xr-x | noncore/apps/qashmoney/qmmemory.db | bin | 4096 -> 10240 bytes | |||
-rwxr-xr-x | noncore/apps/qashmoney/qmpreferences.db | bin | 4096 -> 4096 bytes | |||
-rwxr-xr-x | noncore/apps/qashmoney/qmtransactions.db | bin | 4096 -> 24576 bytes | |||
-rwxr-xr-x | noncore/apps/qashmoney/qmtransfers.db | bin | 3072 -> 3072 bytes | |||
-rwxr-xr-x | noncore/apps/qashmoney/transaction.cpp | 20 | ||||
-rwxr-xr-x | noncore/apps/qashmoney/transaction.h | 3 | ||||
-rwxr-xr-x | noncore/apps/qashmoney/transactiondisplay.cpp | 49 | ||||
-rwxr-xr-x | noncore/apps/qashmoney/transactiondisplay.h | 3 |
15 files changed, 106 insertions, 31 deletions
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,7 +1,7 @@ Package: qashmoney Priority: optional -Version: 0.74 +Version: 0.75 Architecture: arm Maintainer: Allen Forsythe qashmoneyman@attbi.com Section: Applications Description: QashMoney provides an intuitive and fast way to keep track of your accounts and budgets. 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 @@ -31,128 +31,129 @@ DatePreferences::DatePreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this ); connect ( defaults, SIGNAL ( released () ), this, SLOT ( setDefaultDatePreferences () ) ); dateformat->setCurrentItem ( ( preferences->getPreference ( 1 ) ) - 1 ); dateseparator->setCurrentItem ( ( preferences->getPreference ( 2 ) ) - 1 ); layout = new QVBoxLayout ( this, 2, 2 ); layout->addWidget ( datelabel ); layout->addWidget ( dateformat ); layout->addWidget ( dateseparatorlabel ); layout->addWidget ( dateseparator ); layout->insertSpacing ( 4, 5 ); layout->addWidget ( defaults ); } DatePreferences::~DatePreferences () { } void DatePreferences::changeDateFormat ( int index ) { index ++; preferences->changePreference ( 1, index ); } void DatePreferences::changeDateSeparator ( int index ) { index ++; preferences->changePreference ( 2, index ); } void DatePreferences::setDefaultDatePreferences () { preferences->setDefaultDatePreferences (); dateformat->setCurrentItem ( ( preferences->getPreference ( 1 ) ) - 1 ); dateseparator->setCurrentItem ( ( preferences->getPreference ( 2 ) ) - 1 ); } // START TRANSACTION PREFERENCES TransactionPreferences::TransactionPreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE ) { setCaption( tr ( "Transaction" ) ); 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 ); else showclearedtransactions->setChecked ( FALSE ); if ( preferences->getPreference ( 6 ) == 1 ) excludetransfers->setChecked ( TRUE ); else excludetransfers->setChecked ( FALSE ); defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this ); connect ( defaults, SIGNAL ( released () ), this, SLOT ( setDefaultTransactionPreferences () ) ); 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 ); connect ( showclearedtransactions, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeShowClearedPreference ( bool ) ) ); connect ( excludetransfers, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeExcludeTranfersPreference ( bool ) ) ); connect ( limittransactions, SIGNAL ( activated ( int ) ), this, SLOT ( changeLimitTransactionsPreference ( int ) ) ); } TransactionPreferences::~TransactionPreferences () { } void TransactionPreferences::changeLimitTransactionsPreference ( int pref ) { preferences->changePreference ( 7, pref ); } void TransactionPreferences::changeShowClearedPreference ( bool state ) { if ( state == TRUE ) preferences->changePreference ( 3, 1 ); else preferences->changePreference ( 3, 0 ); } void TransactionPreferences::changeExcludeTranfersPreference ( bool state ) { if ( state == TRUE ) preferences->changePreference ( 6, 1 ); else preferences->changePreference ( 6, 0 ); } void TransactionPreferences::setDefaultTransactionPreferences () { preferences->changePreference ( 3, 0 ); preferences->changePreference ( 6, 0 ); preferences->changePreference ( 7, 0 ); showclearedtransactions->setChecked ( FALSE ); limittransactions->setCurrentItem ( 0 ); } // START ACCOUNT PREFERNCES AccountPreferences::AccountPreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE ) { setCaption( tr ( "Account" ) ); 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 @@ -15,97 +15,97 @@ void Preferences::addPreferences () { // This function checks the preferences database for existing preferences and adds // them if they are not there. First we set up variables. Preferences are always set // to non-zero numbers because when we check to see if a preference has been // added to the database, the result is zero if it hasn't int rows = 0; int columns = 0; char **results; sqlite_get_table ( db, "select count() from preferences;", &results, 0, 0, 0 ); if ( atoi ( results [ 1 ] ) != 7 ) { // dateformat preference 1 = yyyymmdd 2 = yymmdd 3 = mmddyyyy 4 = mmddyy // 5 = yyyyddmm 6 = yyddmm 7 = ddmmyyyy 8 = ddmmyy sqlite_get_table ( db, "select preference from preferences where id = 1;", &results, &rows, &columns, 0 ); if ( rows == 0 ) sqlite_exec ( db, "insert into preferences values ( 4, 'dateformat', 0, 0, 0, NULL );", 0, 0, 0 ); // dateseparator preference 1 = / ( forward slash ) 2 = - ( dash ) 3 = . ( period ) rows = 0; sqlite_get_table ( db, "select preference from preferences where id = 2;", &results, &rows, &columns, 0 ); if ( rows == 0 ) sqlite_exec ( db, "insert into preferences values ( 1, 'dateseparator', 0, 0, 0, NULL );", 0, 0, 0 ); // showclearedtransactions preference 0 = no 1 = yes rows = 0; sqlite_get_table ( db, "select preference from preferences where id = 3;", &results, &rows, &columns, 0 ); if ( rows == 0 ) sqlite_exec ( db, "insert into preferences values ( 0, 'showclearedtransactions', 0, 0, 0, NULL );", 0, 0, 0 ); // enable currency support preference 0 = no 1 = yes rows = 0; sqlite_get_table ( db, "select preference from preferences where id = 4;", &results, &rows, &columns, 0 ); if ( rows == 0 ) sqlite_exec ( db, "insert into preferences values ( 0, 'enablecurrencysupport', 0, 0, 0, NULL );", 0, 0, 0 ); // one touch account viewing preference 0 = no 1 = yes rows = 0; sqlite_get_table ( db, "select preference from preferences where id = 5;", &results, &rows, &columns, 0 ); if ( rows == 0 ) sqlite_exec ( db, "insert into preferences values ( 0, 'onetouchviewing', 0, 0, 0, NULL );", 0, 0, 0 ); // exclude transfers from limit view 0 = no 1 = yes rows = 0; sqlite_get_table ( db, "select preference from preferences where id = 6;", &results, &rows, &columns, 0 ); 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 ) sqlite_exec ( db, "insert into preferences values ( 0, 'limittransactions', 0, 0, 0, NULL );", 0, 0, 0 ); } } void Preferences::initializeColumnPreferences () { int rows = 0; int columns = 0; char **results; // initialize accountname column width sqlite_get_table ( db, "select width from columns where id = 1;", &results, &rows, &columns, 0 ); if ( rows == 0 ) sqlite_exec ( db, "insert into columns values ( 'accountname', 90, 0, 0, 0, NULL );", 0, 0, 0 ); // initialize accountbalance column width sqlite_get_table ( db, "select width from columns where id = 2;", &results, &rows, &columns, 0 ); if ( rows == 0 ) sqlite_exec ( db, "insert into columns values ( 'accountbalance', 90, 0, 0, 0, NULL );", 0, 0, 0 ); // initialize transactiondate column width sqlite_get_table ( db, "select width from columns where id = 3;", &results, &rows, &columns, 0 ); if ( rows == 0 ) sqlite_exec ( db, "insert into columns values ( 'normaltransactiondate', 50, 0, 0, 0, NULL );", 0, 0, 0 ); // initialize transactionname column width sqlite_get_table ( db, "select width from columns where id = 4;", &results, &rows, &columns, 0 ); if ( rows == 0 ) sqlite_exec ( db, "insert into columns values ( 'normaltransactionname', 75, 0, 0, 0, NULL );", 0, 0, 0 ); // initialize transactionamount column width sqlite_get_table ( db, "select width from columns where id = 5;", &results, &rows, &columns, 0 ); if ( rows == 0 ) sqlite_exec ( db, "insert into columns values ( 'normaltransactionamount', 50, 0, 0, 0, NULL );", 0, 0, 0 ); // initialize transactiondate column width sqlite_get_table ( db, "select width from columns where id = 6;", &results, &rows, &columns, 0 ); if ( rows == 0 ) sqlite_exec ( db, "insert into columns values ( 'extendedtransactiondate', 50, 0, 0, 0, NULL );", 0, 0, 0 ); // initialize transactionname column width sqlite_get_table ( db, "select width from columns where id = 7;", &results, &rows, &columns, 0 ); if ( rows == 0 ) sqlite_exec ( db, "insert into columns values ( 'extendedtransactionname', 75, 0, 0, 0, NULL );", 0, 0, 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 @@ -98,102 +98,104 @@ void QashMoney::changeTabDisplay () int accountid = accountdisplay->listview->selectedItem()->text ( accountdisplay->getIDColumn() ).toInt(); //remove all the columns from the transactiondisplay int columns = transactiondisplay->listview->columns(); int counter; for ( counter = 0; counter <= columns; counter++ ) transactiondisplay->listview->removeColumn ( 0 ); // set the account name and account balance QString name = account->getAccountName ( accountid ); QString balance = account->getAccountBalance ( accountid ); transactiondisplay->name->setText ( name ); transactiondisplay->balance->setText ( balance ); // clear the limitbox transactiondisplay->limitbox->clear(); // get parent account id int parentaccountid = account->getParentAccountID ( accountid ); // add columns based on which account is selected // this first if determines if we selected a parent with no children or a child // in these cases, we add standard three columns for date, transaction, amount transactiondisplay->listview->addColumn ( "Date", 0 ); transactiondisplay->listview->addColumn ( "Transaction", 0 ); transactiondisplay->listview->addColumn ( "Amt", 0); transactiondisplay->listview->setColumnAlignment ( 2, Qt::AlignRight ); transactiondisplay->listview->addColumn ( "", 0 ); if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 ) // we selected a parent with children { // add an extra column for the account name for eac child transaction transactiondisplay->listview->addColumn ( "Acct", 0 ); children = TRUE; // hide the new transaction button transactiondisplay->newtransaction->setEnabled ( FALSE ); } else //we selected a parent without children or a child transactiondisplay->newtransaction->setEnabled ( TRUE ); // disable the transactionid column so it can't be red transactiondisplay->listview->header()->setResizeEnabled ( FALSE, 3 ); // set the accountid and children variables 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 ); // open a new preferences object and resize the transaction display columns // each column will have a different size based on whether we are looking at a child // account or children through a parent if ( parentaccountid != -1 || accountdisplay->listview->selectedItem()->childCount() == 0 ) // a parent with no children or a child - three columns { transactiondisplay->listview->setColumnWidth ( 0, preferences->getColumnPreference ( 3 ) ); // normal transaction date width transactiondisplay->listview->setColumnWidthMode ( 0, QListView::Manual ); transactiondisplay->listview->setColumnWidth ( 1, preferences->getColumnPreference ( 4 ) ); // normal transaction name width transactiondisplay->listview->setColumnWidthMode ( 1, QListView::Manual ); transactiondisplay->listview->setColumnWidth ( 2, preferences->getColumnPreference ( 5 ) ); // normal transaction amount width transactiondisplay->listview->setColumnWidthMode ( 2, QListView::Manual ); } else { transactiondisplay->listview->setColumnWidth ( 0, preferences->getColumnPreference ( 6 ) ); // extended transaction date width transactiondisplay->listview->setColumnWidthMode ( 0, QListView::Manual ); transactiondisplay->listview->setColumnWidth ( 1, preferences->getColumnPreference ( 7 ) ); // extended transaction name width transactiondisplay->listview->setColumnWidthMode ( 1, QListView::Manual ); transactiondisplay->listview->setColumnWidth ( 2, preferences->getColumnPreference ( 8 ) ); // extended transaction amount width transactiondisplay->listview->setColumnWidthMode ( 2, QListView::Manual ); transactiondisplay->listview->setColumnWidth ( 4, preferences->getColumnPreference ( 9 ) ); // transaction account width transactiondisplay->listview->setColumnWidthMode ( 4, QListView::Manual ); } // show the window transactiondisplay->show(); // hide the account display and define accountid accountdisplay->hide(); // hide the budget display budgetdisplay->hide(); } else if ( maintabs->currentPageIndex() == 0 ) { disableOneTouchViewing(); // clear the account display selection accountdisplay->listview->clearSelection(); // resize the account display columns accountdisplay->listview->setColumnWidth ( 0, preferences->getColumnPreference ( 1 ) ); accountdisplay->listview->setColumnWidth ( 1, preferences->getColumnPreference ( 2 ) ); // display the accounts if ( account->getNumberOfAccounts() != 0 ) @@ -209,148 +211,180 @@ void QashMoney::changeTabDisplay () // hide the transaction display transactiondisplay->hide(); // hide the budget display budgetdisplay->hide(); enableOneTouchViewing (); } else { budgetdisplay->displayLineItems(); budgetdisplay->show(); transactiondisplay->hide(); accountdisplay->hide(); } } void QashMoney::setTransactionTab () { if ( accountdisplay->listview->selectedItem() == 0 ) maintabs->setTabEnabled ( tab_2, FALSE ); else maintabs->setTabEnabled ( tab_2, TRUE ); } void QashMoney::displayDatePreferencesDialog () { // this shows a dialog to set preferences for formatting the date DatePreferences *pd = new DatePreferences ( this ); pd->exec (); if ( transactiondisplay->isVisible() ) { // set the account id int accountid = accountdisplay->listview->selectedItem()->text ( accountdisplay->getIDColumn() ).toInt(); // set children so we can let displayTransfers know if there are children for the selected account bool children; if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 ) children = TRUE; else children = FALSE; // redisplay transactions if they are visible incorporating // any changes to the date format 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 ); } else if ( accountdisplay->isVisible() ) { accountdisplay->listview->clearSelection(); maintabs->setTabEnabled ( tab_2, FALSE ); } else budgetdisplay->updateBudgetInformation(); } void QashMoney::displayTransactionPreferencesDialog () { // display a dialog for setting preferences for transactions TransactionPreferences *td = new TransactionPreferences ( this ); td->exec (); if ( transactiondisplay->isVisible() ) { // set the account id int accountid = accountdisplay->listview->selectedItem()->text ( accountdisplay->getIDColumn() ).toInt(); // set children so we can let displayTransfers know if there are children for the selected account bool children; if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 ) children = TRUE; else children = FALSE; // redisplay transactions incorporating any transaction preference changes 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 ); } else { accountdisplay->listview->clearSelection(); maintabs->setTabEnabled ( tab_2, FALSE ); } } void QashMoney::displayAccountPreferencesDialog () { // display a dialog for setting preferences for accounts AccountPreferences *ap = new AccountPreferences ( this ); ap->exec (); if ( accountdisplay->isVisible() && account->getNumberOfAccounts() != 0 ) { accountdisplay->listview->clear(); account->displayAccounts ( accountdisplay->listview ); accountdisplay->listview->clearSelection(); maintabs->setTabEnabled ( tab_2, FALSE ); } changeTabDisplay(); } void QashMoney::displayMemoryDialog () { // opens a dialog to add, edit and delete memory items MemoryDialog *md = new MemoryDialog (); md->exec(); } void QashMoney::showTransactions () { maintabs->setCurrentPage ( 1 ); } void QashMoney::enableOneTouchViewing () { if ( preferences->getPreference ( 5 ) == 1 ) connect ( accountdisplay->listview, SIGNAL ( selectionChanged () ), this, SLOT ( showTransactions () ) ); else disconnect ( accountdisplay->listview, SIGNAL ( selectionChanged () ), this, SLOT ( showTransactions () ) ); } void QashMoney::disableOneTouchViewing () { disconnect ( accountdisplay->listview, SIGNAL ( selectionChanged () ), this, SLOT ( showTransactions () ) ); } void QashMoney::toggleOneTouchViewing ( bool state ) { if ( state == TRUE ) disableOneTouchViewing(); else 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 @@ -1,61 +1,64 @@ #ifndef QASHMONEY_H #define QASHMONEY_H #include <qpe/qpemenubar.h> #include <qpopupmenu.h> #include <qlayout.h> #include <qtabwidget.h> +#include <qdatetime.h> #include "accountdisplay.h" #include "transactiondisplay.h" #include "budgetdisplay.h" #include "account.h" #include "preferences.h" #include "transaction.h" #include "transfer.h" #include "memory.h" #include "budget.h" class QashMoney : public QWidget { Q_OBJECT public: QashMoney (); ~QashMoney(); QTabWidget* maintabs; QWidget* tab; QWidget* tab_2; QWidget* tab_3; QPEMenuBar *mainmenu; QPopupMenu *preferencesmenu; QPopupMenu *utilitiesmenu; public slots: void displayDatePreferencesDialog (); void displayTransactionPreferencesDialog (); void displayAccountPreferencesDialog (); void displayMemoryDialog (); void setTransactionTab (); private slots: void changeTabDisplay (); void showTransactions (); void enableOneTouchViewing (); void disableOneTouchViewing (); void toggleOneTouchViewing ( bool ); + void setTransactionDisplayDate (); private: QVBoxLayout *layout; QVBoxLayout *tabslayout; AccountDisplay *accountdisplay; TransactionDisplay *transactiondisplay; BudgetDisplay *budgetdisplay; int tabheight; + QDate newdate; }; #endif diff --git a/noncore/apps/qashmoney/qmaccounts.db b/noncore/apps/qashmoney/qmaccounts.db Binary files differindex 449bcab..76db78b 100755 --- a/noncore/apps/qashmoney/qmaccounts.db +++ b/noncore/apps/qashmoney/qmaccounts.db diff --git a/noncore/apps/qashmoney/qmbudgets.db b/noncore/apps/qashmoney/qmbudgets.db Binary files differindex d798f0c..ef75719 100755 --- a/noncore/apps/qashmoney/qmbudgets.db +++ b/noncore/apps/qashmoney/qmbudgets.db diff --git a/noncore/apps/qashmoney/qmmemory.db b/noncore/apps/qashmoney/qmmemory.db Binary files differindex 5c23122..c6b7920 100755 --- a/noncore/apps/qashmoney/qmmemory.db +++ b/noncore/apps/qashmoney/qmmemory.db diff --git a/noncore/apps/qashmoney/qmpreferences.db b/noncore/apps/qashmoney/qmpreferences.db Binary files differindex a4e96f5..91596cb 100755 --- a/noncore/apps/qashmoney/qmpreferences.db +++ b/noncore/apps/qashmoney/qmpreferences.db diff --git a/noncore/apps/qashmoney/qmtransactions.db b/noncore/apps/qashmoney/qmtransactions.db Binary files differindex 9e4acc9..a5eb4f3 100755 --- a/noncore/apps/qashmoney/qmtransactions.db +++ b/noncore/apps/qashmoney/qmtransactions.db diff --git a/noncore/apps/qashmoney/qmtransfers.db b/noncore/apps/qashmoney/qmtransfers.db Binary files differindex c31df1a..3ca9f78 100755 --- a/noncore/apps/qashmoney/qmtransfers.db +++ b/noncore/apps/qashmoney/qmtransfers.db 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 @@ -1,58 +1,59 @@ // RESERVEDONE COLUMN NAME REPRESENTS THE LINEITEMID AND SHOULD BE CHANGED IN // FUTURE VERSIONS OF QASHMONEY // RESERVEDTWO REPRESENTS THE TRANSACTION DESCRIPTION #include "transaction.h" #include "account.h" #include "transactiondisplay.h" #include <stdlib.h> +#include <iostream.h> extern Account *account; extern Preferences *preferences; Transaction::Transaction () { tdb = sqlite_open ( "qmtransactions.db", 0, NULL ); } Transaction::~Transaction () { sqlite_close ( tdb ); } void Transaction::addTransaction ( QString description, QString payee, int accountid, int parentid, int number, int day, int month, int year, float amount, int cleared, int budgetid, int lineitemid ) { sqlite_exec_printf ( tdb, "insert into transactions values ( '%q', %i, %i, %i, %i, %i, %i, %.2f, %i, %i, 0, 0, 0, 0, 0, 0, %i, '%q', 0, 0, 0, 0, NULL );", 0, 0, 0, ( const char * ) payee, accountid, parentid, number, day, month, year, amount, cleared, budgetid, lineitemid, ( const char * ) description ); } void Transaction::updateTransaction ( QString description, QString payee, int number, int day, int month, int year, float amount, int cleared, int budgetid, int lineitemid, int transactionid ) { sqlite_exec_printf ( tdb, "update transactions set reservedtwo = '%q', payee = '%q', number = %i, day = %i, month = %i, year = %i, amount = %.2f, cleared = %i, budgetid = %i, reservedone = %i where transid = %i;", 0, 0, 0, ( const char * ) description, ( const char * ) payee, number, day, month, year, amount, cleared, budgetid, lineitemid, transactionid ); } void Transaction::deleteTransaction ( int transid ) { sqlite_exec_printf ( tdb, "delete from transactions where transid = %i;", 0, 0, 0, transid ); } void Transaction::deleteAllTransactions ( int accountid ) { sqlite_exec_printf ( tdb, "delete from transactions where accountid = %i;", 0, 0, 0, accountid ); } int Transaction::getAccountID ( int id ) { char **results; sqlite_get_table_printf ( tdb, "select accountid from transactions where transid= %i;", &results, NULL, NULL, NULL, id ); return atol ( results [ 1 ] ); } int Transaction::getNumberOfTransactions () { char **results; sqlite_get_table ( tdb, "select count() from transactions;", &results, NULL, NULL, NULL ); @@ -109,132 +110,127 @@ int Transaction::getCleared ( int id ) return cleared.toInt(); } void Transaction::setCleared ( int id, int cleared ) { sqlite_exec_printf ( tdb, "update transactions set cleared = %i where transid = %i;", 0, 0, 0, cleared, id ); } int Transaction::getBudgetID ( int id ) { char **results; sqlite_get_table_printf ( tdb, "select budgetid from transactions where transid = %i;", &results, NULL, NULL, NULL, id ); QString budgetid = results [ 1 ]; return budgetid.toInt(); } int Transaction::getLineItemID ( int id ) { char **results; sqlite_get_table_printf ( tdb, "select reservedone from transactions where transid = %i;", &results, NULL, NULL, NULL, id ); QString lineitemid = results [ 1 ]; return lineitemid.toInt(); } int Transaction::getDay ( int id ) { char **results; sqlite_get_table_printf ( tdb, "select day from transactions where transid= %i;", &results, NULL, NULL, NULL, id ); QString daystring = results [ 1 ]; return daystring.toInt(); } int Transaction::getMonth ( int id ) { char **results; sqlite_get_table_printf ( tdb, "select month from transactions where transid= %i;", &results, NULL, NULL, NULL, id ); QString monthstring = results [ 1 ]; return monthstring.toInt(); } int Transaction::getYear ( int id ) { char **results; sqlite_get_table_printf ( tdb, "select year from transactions where transid= %i;", &results, NULL, NULL, NULL, id ); QString yearstring = results [ 1 ]; 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 // whether we are showing cleared transactions char **results; int rows, columns; 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 ); } // iterate through the result list and display each item 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 ]; QString amount = results [ counter + 4 ]; QString transferid = results [ counter + 5 ]; //determine the account name of the child accounts that we're displaying QString accountname = account->getAccountName ( atoi ( results [ counter + 6 ] ) ); // fill in values if ( account->getParentAccountID ( id ) != -1 ) // use these constructors if we're showing a child account { if ( showcleared == 1 && getCleared ( transferid.toInt() ) == 1 ) ColorListItem *item = new ColorListItem ( listview, date, payee, amount, transferid); else QListViewItem *item = new QListViewItem ( listview, date, payee, amount, transferid ); } else { if ( showcleared == 1 && getCleared ( transferid.toInt() ) == 1 ) ColorListItem *item = new ColorListItem ( listview, date, payee, amount, transferid, accountname ); else QListViewItem *item = new QListViewItem ( listview, date, payee, amount, transferid, accountname ); } // advance counter counter = counter + 7; } } QString Transaction::getBudgetTotal ( int budgetid, int lineitemid, int year, int month, int viewtype ) { // determine if we are viewing a years, months, or days budget // we have to pick a different sum for each char **results; switch ( viewtype ) { case 1: // we are viewing a year sqlite_get_table_printf ( tdb, "select abs ( sum ( amount ) ) from transactions where year = %i and amount < 0 and budgetid = %i and reservedone = %i;", &results, NULL, NULL, NULL, year, budgetid, lineitemid ); break; case 0: // we are viewing a month sqlite_get_table_printf ( tdb, "select abs ( sum ( amount ) ) from transactions where year = %i and month = %i and amount < 0 and budgetid = %i and reservedone = %i;", &results, NULL, NULL, NULL, year, month, budgetid, lineitemid ); break; } QString amount = results [ 1 ]; float total = amount.toFloat(); amount.setNum ( total, 'f', 2 ); 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 @@ -1,69 +1,70 @@ #ifndef TRANSACTION_H #define TRANSACTION_H #include <qstring.h> #include <qlistview.h> +#include <qdatetime.h> #include <sqlite.h> #include "preferences.h" class Transaction { public: Transaction (); ~Transaction (); // This function adds a new transaction to the database. It takes the payee, accountid, // budgetid, number, day, month, year, amount, cleared void addTransaction ( QString description, QString payee, int accountid, int parentid, int number, int day, int month, int year, float amount, int cleared, int budgetid, int lineitemid ); // This updates an already existing transaction void updateTransaction ( QString, QString, int, int, int, int, float, int, int, int, int ); // Deletes a transaction. Takes the transid as its parameter void deleteTransaction ( int ); // Returns the number of transactions int getNumberOfTransactions (); // this is an overloaded function that returns the number of // transactions for an account int getNumberOfTransactions ( int ); // deletes all transactions for the provided accountid void deleteAllTransactions ( int accountid ); QString getBudgetTotal ( int budgetid, int lineitemid, int year, int month, int viewtype ); QString getActualTotal ( int budgetid, int year, int month, int viewtype ); // These two functions clear budget ids is either a line item or an entire budget is deleted void clearBudgetIDs ( int, int ); void clearBudgetIDs ( int ); 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 ); QString getAmount ( int ); QString getAbsoluteAmount ( int ); int getCleared ( int ); void setCleared ( int id, int cleared ); int getBudgetID ( int id ); int getLineItemID ( int id ); int getDay ( int ); int getMonth ( int ); int getYear ( int ); int getAccountID ( int id ); private: sqlite *tdb; }; #endif 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 @@ -82,98 +82,99 @@ void TransactionDisplay::addTransaction () // create new transaction window NewTransaction *newtransaction = new NewTransaction ( this ); int width = this->size().width(); newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) ); newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) ); newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) ); newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) ); // enter today's date in the date box as defaul QDate today = QDate::currentDate (); int defaultday = today.day(); int defaultmonth = today.month(); int defaultyear = today.year(); newtransaction->transactiondate->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) ); // add memory items to the transactionname combobox memory->displayMemoryItems ( newtransaction->transactionname ); newtransaction->transactionname->insertItem ( "", 0 ); if ( newtransaction->exec () == QDialog::Accepted ) { if ( newtransaction->clearedcheckbox->isChecked () == TRUE ) // set a parent id and type for a child transaction cleared = 1; else cleared = 0; float amount = newtransaction->transactionamount->text().toFloat(); if ( newtransaction->depositbox->isChecked() == FALSE ) amount = amount * -1; // add the transaction name to the memory items memory->addMemoryItem ( newtransaction->transactionname->currentText() ); // add the transaction if ( newtransaction->getDateEdited () == TRUE ) transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ), newtransaction->transactionnumber->text().toInt(), newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(), amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem() ); else transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ), newtransaction->transactionnumber->text().toInt(), defaultday, defaultmonth, defaultyear, amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem() ); // redisplay transactions 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 ) transfer->displayTransfers ( listview, accountid, children ); // add the transaction amount to the account it's associated with // and update its parent account balance if necessary account->updateAccountBalance ( accountid ); if ( account->getParentAccountID ( accountid ) != -1 ) account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) ); // format then reset the account balance redisplayAccountBalance (); } } void TransactionDisplay::checkListViewEdit () { if ( listview->selectedItem() == 0 ) QMessageBox::warning ( this, "QashMoney", "Please select a transaction\nto edit."); else if ( listview->currentItem()->text ( getIDColumn() ).toInt() < 0 ) editTransfer (); else editTransaction(); } void TransactionDisplay::showCalculator () { Calculator *calculator = new Calculator ( this ); if ( calculator->exec () == QDialog::Accepted ) amount->setText ( calculator->display->text() ); } void TransactionDisplay::showCalendar () { QDate newDate = QDate::currentDate (); DatePicker *dp = new DatePicker ( newDate ); if ( dp->exec () == QDialog::Accepted ) { year = dp->getYear(); month = dp->getMonth(); day = dp->getDay(); date->setText ( preferences->getDate ( year, month, day ) ); } } void TransactionDisplay::editTransfer () { @@ -320,267 +321,303 @@ void TransactionDisplay::editTransaction () { newtransaction->lineitemlabel->setEnabled ( FALSE ); newtransaction->lineitembox->setEnabled ( FALSE ); } } else { newtransaction->lineitemlabel->setEnabled ( FALSE ); newtransaction->lineitembox->setEnabled ( FALSE ); } // check cleared checkbox if necessary if ( transaction->getCleared ( transactionid ) == 1 ) newtransaction->clearedcheckbox->setChecked ( TRUE ); // check deposit box if necessary if ( transaction->getAmount ( transactionid ).toFloat() > 0 ) newtransaction->depositbox->setChecked ( TRUE ); if ( newtransaction->exec () == QDialog::Accepted ) { if ( newtransaction->clearedcheckbox->isChecked () == TRUE ) cleared = 1; else cleared = 0; float amount = newtransaction->transactionamount->text().toFloat(); if ( newtransaction->depositbox->isChecked() == FALSE ) amount = amount * -1; // add the transaction name to the memory items memory->addMemoryItem ( newtransaction->transactionname->currentText() ); // update the transaction transaction->updateTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), newtransaction->transactionnumber->text().toInt(), newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(), amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem(), transactionid ); updateAndDisplay ( transaction->getAccountID ( transactionid ) ); } } void TransactionDisplay::updateAndDisplay ( int id ) { // redisplay transactions 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 ) transfer->displayTransfers ( listview, accountid, children ); // add the transaction amount to the account it's associated with // and update its parent account balance if necessary account->updateAccountBalance ( id ); if ( account->getParentAccountID ( id ) != -1 ) account->changeParentAccountBalance ( account->getParentAccountID ( id ) ); // format then reset the account balance redisplayAccountBalance (); } void TransactionDisplay::checkListViewDelete () { if ( listview->selectedItem() == 0 ) QMessageBox::warning ( this, "QashMoney", "Please select a transaction to\ndelete."); else deleteTransaction (); } void TransactionDisplay::deleteTransaction () { int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt(); if ( transactionid > 0 ) // takes care of deleting transactions { // check if we are viewing child transactions through a parent // in that case we will have to update balances for the parent // which is represented by accountid and the child account // which will be represented by childaccountid int childaccountid = -1; if ( listview->columns() == 5 ) childaccountid = transaction->getAccountID ( transactionid ); transaction->deleteTransaction ( transactionid ); 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 ); // if we are viewing different child accounts through the parent account // ie if there are five columns and the parentid is -1 // update the accountid ( which is the parent ) and update the child account // balance. Get its accountid from the transactionid account->updateAccountBalance ( accountid ); // will update either a parent or child if ( account->getParentAccountID ( accountid ) != -1 ) // update its parent if there is one account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) ); if ( childaccountid != -1 ) // we've set childaccountid account->updateAccountBalance ( childaccountid ); // format then reset the account balance redisplayAccountBalance (); } else // takes care of deleting transfers { // get the accountids before we delete the transfer int fromaccountid = transfer->getFromAccountID ( transactionid ); int toaccountid = transfer->getToAccountID ( transactionid ); // delete the transfer and redisplay transactions transfer->deleteTransfer ( transactionid ); 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 ); // for the from account account->updateAccountBalance ( fromaccountid ); if ( account->getParentAccountID ( fromaccountid ) != -1 ) account->changeParentAccountBalance ( account->getParentAccountID ( fromaccountid ) ); // for the to account account->updateAccountBalance ( toaccountid ); if ( account->getParentAccountID ( toaccountid ) != -1 ) account->changeParentAccountBalance ( account->getParentAccountID ( toaccountid ) ); // format then reset the account balance redisplayAccountBalance (); } } void TransactionDisplay::checkListViewToggle () { if ( listview->selectedItem() == 0 ) QMessageBox::warning ( this, "QashMoney", "Please select a transaction to\nclear or reset."); else toggleTransaction (); } void TransactionDisplay::toggleTransaction () { //get the transaction of the selected transaction to determine if its a transaction or transfer int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt(); if ( transactionid > 0 ) // if this is a transaction { if ( transaction->getCleared ( transactionid ) == 0 ) transaction->setCleared ( transactionid, 1 ); else transaction->setCleared ( transactionid, 0 ); } else { if ( transfer->getCleared ( transactionid ) == 0 ) transfer->setCleared ( transactionid, 1 ); else transfer->setCleared ( transactionid, 0 ); } 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 ); } void TransactionDisplay::redisplayAccountBalance () { QString accountbalance = account->getAccountBalance ( accountid ); balance->setText ( accountbalance ); } void TransactionDisplay::setChildren ( bool c ) { children = c; } void TransactionDisplay::setAccountID ( int id ) { accountid = id; } ColorListItem::ColorListItem ( QListView *parent ) : QListViewItem ( parent ) { } ColorListItem::ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4 ) : QListViewItem ( parent, label1, label2, label3, label4 ) { } ColorListItem::ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4, QString label5 ) : QListViewItem ( parent, label1, label2, label3, label4, label5 ) { } void ColorListItem::paintCell ( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ) { QColorGroup _cg ( cg ); _cg.setColor ( QColorGroup::Text, Qt::red ); QListViewItem::paintCell ( p, _cg, column, width, alignment ); } void TransactionDisplay::saveColumnSize ( int column, int oldsize, int newsize ) { if ( listview->columns() == 4 ) preferences->changeColumnPreference ( column + 3, newsize ); else if ( listview->columns() == 5 && column != 4 ) preferences->changeColumnPreference ( column + 6, newsize ); else preferences->changeColumnPreference ( 9, newsize ); } 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 ); } int TransactionDisplay::getIDColumn () { int counter; int columns = listview->columns(); for ( counter = 0; counter <= columns; counter++ ) if ( listview->header()->label ( counter ).length() == 0 ) return counter; } void TransactionDisplay::showTransactionNotes () { if ( listview->selectedItem() == 0 || listview->currentItem()->text ( getIDColumn() ).toInt() < 0 ) QMessageBox::warning ( this, "QashMoney", "Please select a valid\ntransaction to view notes."); else { int transactionid = listview->selectedItem()->text ( getIDColumn() ).toInt (); QDialog *description = new QDialog ( this, "description", TRUE ); description->setCaption ( "Notes" ); QMultiLineEdit *notes = new QMultiLineEdit ( description ); notes->setFixedSize ( ( int ) (this->width() * 0.75 ), ( int ) ( this->height() * 0.5 ) ); notes->setWrapColumnOrWidth ( ( int ) (this->width() * 0.75 ) ); notes->setWordWrap ( QMultiLineEdit::WidgetWidth ); notes->setEnabled ( FALSE ); notes->setText ( transaction->getTransactionDescription ( transactionid ) ); description->show(); } } +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 @@ -1,79 +1,82 @@ #ifndef TRANSACTIONDISPLAY_H #define TRANSACTIONDISPLAY_H #include <qlayout.h> #include <qhbox.h> #include <qlistview.h> #include <qpushbutton.h> #include <qlabel.h> #include <qlineedit.h> +#include <qdatetime.h> class TransactionDisplay : public QWidget { Q_OBJECT public: TransactionDisplay ( QWidget* parent ); QListView* listview; QPushButton* newtransaction; QPushButton* edittransaction; QPushButton* deletetransaction; QPushButton* toggletransaction; QPushButton* viewtransactionnotes; QLabel *name; QLabel *balance; QLineEdit *limitbox; QLineEdit *amount; QLineEdit *date; int getIDColumn (); public slots: void setChildren ( bool ); void setAccountID ( int ); void showTransactionNotes (); private slots: void addTransaction (); void editTransaction (); void editTransfer (); void deleteTransaction (); void toggleTransaction (); void checkListViewDelete (); void checkListViewEdit (); void checkListViewToggle (); void saveColumnSize ( int column, int oldsize, int newsize ); 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; QHBox *secondline; void redisplayAccountBalance (); void updateAndDisplay ( int accountid ); }; #endif #ifndef COLORLISTITEM_H #define COLORLISTITEM_H class ColorListItem : public QListViewItem { public: ColorListItem ( QListView *parent ); ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4 ); ColorListItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4, QString label5 ); virtual void paintCell ( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); }; #endif |