summaryrefslogtreecommitdiff
authorallenforsythe <allenforsythe>2003-05-28 11:49:47 (UTC)
committer allenforsythe <allenforsythe>2003-05-28 11:49:47 (UTC)
commit52047fd3d3f30509d65834747c3a0c5c6760dc01 (patch) (side-by-side diff)
tree136945c2ffff2434ba1e3c8959b5335f5016e8f8
parent7c85b3e98921afa74c7c6a90da4dfd54631c89c5 (diff)
downloadopie-52047fd3d3f30509d65834747c3a0c5c6760dc01.zip
opie-52047fd3d3f30509d65834747c3a0c5c6760dc01.tar.gz
opie-52047fd3d3f30509d65834747c3a0c5c6760dc01.tar.bz2
*** empty log message ***
Diffstat (more/less context) (show whitespace changes)
-rwxr-xr-xnoncore/apps/qashmoney/CHANGES8
-rwxr-xr-xnoncore/apps/qashmoney/README35
-rwxr-xr-xnoncore/apps/qashmoney/account.cpp9
-rwxr-xr-xnoncore/apps/qashmoney/accountdisplay.cpp15
-rwxr-xr-xnoncore/apps/qashmoney/accountdisplay.h1
-rwxr-xr-xnoncore/apps/qashmoney/budget.cpp3
-rwxr-xr-xnoncore/apps/qashmoney/budgetdisplay.cpp12
-rwxr-xr-xnoncore/apps/qashmoney/budgetdisplay.h1
-rwxr-xr-xnoncore/apps/qashmoney/install/CONTROL/opie-qashmoney.control5
-rwxr-xr-xnoncore/apps/qashmoney/preferences.cpp50
-rwxr-xr-xnoncore/apps/qashmoney/preferences.h3
-rwxr-xr-xnoncore/apps/qashmoney/qashmoney.cpp21
-rwxr-xr-xnoncore/apps/qashmoney/transaction.cpp106
-rwxr-xr-xnoncore/apps/qashmoney/transaction.h3
-rwxr-xr-xnoncore/apps/qashmoney/transactiondisplay.cpp20
-rwxr-xr-xnoncore/apps/qashmoney/transactiondisplay.h1
-rwxr-xr-xnoncore/apps/qashmoney/transfer.cpp11
-rwxr-xr-xnoncore/apps/qashmoney/transfer.h3
-rwxr-xr-xnoncore/apps/qashmoney/transferdialog.cpp2
19 files changed, 240 insertions, 69 deletions
diff --git a/noncore/apps/qashmoney/CHANGES b/noncore/apps/qashmoney/CHANGES
index f17035b..a3ac224 100755
--- a/noncore/apps/qashmoney/CHANGES
+++ b/noncore/apps/qashmoney/CHANGES
@@ -1,10 +1,18 @@
QashMoney - Budget Software for the Sharp Zaurus
CHANGES
+0.76 - 5/21/03
+
+ Updated postinst file so app will install on new Sharp ROM 3.1
+ Improved algorithm for selecting cleared transaction
+ Fixed budget display bug
+
+----------------------------------------------------------------------------------
+
11/1/02 - Initial release of 0.2 version. Considered stable beta version.
11/16/02 - Release of version 0.3. This is a stable version adding function to
transfer money between accounts. Several bugs fixes and speed enhancements
have been done.
11/21/02 - 0.31 news tabs working but not yet displaying accounts
12/15/02 - QashMoney gets a complete face lift and now has a date picker.
diff --git a/noncore/apps/qashmoney/README b/noncore/apps/qashmoney/README
index 1888ce6..ef004f7 100755
--- a/noncore/apps/qashmoney/README
+++ b/noncore/apps/qashmoney/README
@@ -1,17 +1,14 @@
QashMoney - Budget Software for the Sharp Zaurus
README
-Welcome to the latest version of QashMoney! This app is designed to make your
-budgeting fast, inuitive and easy.
-
This file lists all the important files in the qashmoney CVS directory and how
to make the IPK file that goes on the Zaurus. When you checkout the
-qashmoney module from CVS, it will create a directory on your hard drive called
-qashmoney. These instructions assume you are in the directory.
+qashmoney-source module from CVS, it will create a directory on your hard drive called
+qashmoney-source. These instructions assume you are in this directory.
The first thing you need to do is have all the necessary cross-compile software
and Qtopia installed on your system. I assume you have already done this since
you are downloading CVS, but if not, go to:
http://docs.zaurus.com
@@ -20,20 +17,17 @@ and download the RPMS that you need for development.
You also must have sqlite installed on your system to successfully compile
QashMoney. Go to:
http://www.sqlite.org
-to download this progam. The SQLite library has already been compiled for the
-IPK and is in the 'install' directory. So there is no need to compile SQLite
-for ARM but you can if you want. There are instructions for that on the
-website.
+to download this progam.
After that, set the correct environment variables for the package you
-are developing.Two scripts in the qashmoney are used for that purpose: x86.sh
-andarm.shIf you are buidling for x86 type:
+are developing. Two scripts in the qashmoney-source directory are used for that purpose: x86.sh
+and arm.sh. If you are building for x86 type:
source x86.sh
and press enter. To make binaries that run on the Zaurus, type:
source arm.sh
@@ -60,30 +54,13 @@ To run QashMoney in the Qtopia Virtual Frame Buffer, type:
qvfb &
./qashmoney -qws
and QashMoney should appear in the frambuffer. You can use and test qashmoney
here as you would on the Zaurus.
-If you compile the binary file for the Zaurus, another script in this directory
-will come in handy. To automagically make the IPK file, type:
-
-su
-./make_ipk
-
-You need to be the root user to set the ownership of the binary and other
-files correctly. The IPK file will appear in the qashmoney directory. Now put
-this file onto the Zaurus and install!
-
-Two other scripts in the directory may be of use. The make_x86 script cleans
-the directory and makes the x86 qashmoney binary automatically. The make_arm
-scripts makes the ARM binary. So you should really only have to type three
-commands the make the IPK file:
-
-./make_arm
-su
-./make_ipk
+If you want to compile the app and make the IPK file, check out the qashmoney-build module and see the README file in that module.
I hope the program can be useful. If you have any questions or comments, please
contact me at qashmoneyman@attbi.com
Thanks!
diff --git a/noncore/apps/qashmoney/account.cpp b/noncore/apps/qashmoney/account.cpp
index fc2f8c1..28f9ba2 100755
--- a/noncore/apps/qashmoney/account.cpp
+++ b/noncore/apps/qashmoney/account.cpp
@@ -19,15 +19,14 @@ Account::~Account ()
sqlite_close ( adb );
}
void Account::addAccount ( QString name, int parentid, float balance, int type, QString description, float creditlimit,
int statementyear, int statementmonth, int statementday, float statementbalance, const char *currency )
{
- int r = sqlite_exec_printf ( adb, "insert into accounts2 values ( '%q', %i, %.2f, %i, '%q', %.2f, %i, %i, %i, %.2f, '%q', 0, 0, 0, 0, 0, NULL );", 0, 0, 0,
+ sqlite_exec_printf ( adb, "insert into accounts2 values ( '%q', %i, %.2f, %i, '%q', %.2f, %i, %i, %i, %.2f, '%q', 0, 0, 0, 0, 0, NULL );", 0, 0, 0,
(const char *) name, parentid, balance, type, (const char *) description, creditlimit, statementyear, statementmonth, statementday, statementbalance, currency );
- cout << "Results = " << r << endl;
}
void Account::updateAccount ( QString name, QString description, QString currencycode, int accountid )
{
sqlite_exec_printf ( adb, "update accounts2 set name = '%q', description = '%q', currency = '%q' where accountid = %i;", 0, 0, 0, ( const char * ) name, ( const char * ) description, ( const char * ) currencycode, accountid );
}
@@ -222,12 +221,18 @@ void Account::displayAccounts ( QListView *listview )
listview->setColumnWidth ( 1, preferences->getColumnPreference ( 11 ) );
listview->setColumnWidthMode ( 1, QListView::Manual );
listview->setColumnWidth ( 2, preferences->getColumnPreference ( 12 ) );
listview->setColumnWidthMode ( 2, QListView::Manual );
listview->setColumnWidthMode ( 3, QListView::Manual );
}
+
+ // Now reset the column sorting to user preference
+ int column = 0;
+ int direction = 0;
+ preferences->getSortingPreference ( 1, &column, &direction );
+ listview->setSorting ( column, direction );
}
int Account::displayParentAccountNames ( QComboBox *combobox, QString indexstring )
{
char **results;
int rows, columns, index;
diff --git a/noncore/apps/qashmoney/accountdisplay.cpp b/noncore/apps/qashmoney/accountdisplay.cpp
index b2c0838..64f4ea8 100755
--- a/noncore/apps/qashmoney/accountdisplay.cpp
+++ b/noncore/apps/qashmoney/accountdisplay.cpp
@@ -1,9 +1,10 @@
#include <qdatetime.h>
#include <qmessagebox.h>
#include <qheader.h>
+#include <iostream.h>
#include "accountdisplay.h"
#include "newaccount.h"
#include "transaction.h"
#include "transferdialog.h"
#include "preferences.h"
@@ -45,12 +46,13 @@ AccountDisplay::AccountDisplay ( QWidget *parent ) : QWidget ( parent )
listview->setMultiSelection ( FALSE );
connect ( listview, SIGNAL ( expanded ( QListViewItem * ) ), this, SLOT ( setAccountExpanded ( QListViewItem * ) ) );
connect ( listview, SIGNAL ( collapsed ( QListViewItem * ) ), this, SLOT ( setAccountCollapsed ( QListViewItem * ) ) );
listview->header()->setTracking ( FALSE );
connect ( listview->header(), SIGNAL ( sizeChange ( int, int, int ) ), this, SLOT ( saveColumnSize ( int, int, int ) ) );
+ connect ( listview->header(), SIGNAL ( clicked ( int ) ), this, SLOT ( saveSortingPreference ( int ) ) );
layout = new QVBoxLayout ( this, 2, 5 );
layout->addWidget ( firstline );
layout->addWidget ( listview );
}
@@ -265,20 +267,18 @@ void AccountDisplay::getTransferAccounts ( QListViewItem * item )
if ( td->exec() == QDialog::Accepted )
{
// set the cleared integer if the checkbox is checked
if ( td->clearedcheckbox->isChecked() == TRUE )
cleared = 1;
-
+ cout << "Year from transferdialog = " << td->getYear() << endl;
// add the transfer with a new date if its been edited or use the default date
if ( td->getDateEdited () == TRUE )
- transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid,
- account->getParentAccountID ( secondaccountid ), td->getDay(), td->getMonth(), td->getYear(), td->amount->text().toFloat(), cleared );
+ transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, account->getParentAccountID ( secondaccountid ), td->getDay(), td->getMonth(), td->getYear(), td->amount->text().toFloat(), cleared );
else
- transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid,
- account->getParentAccountID ( secondaccountid ), defaultday, defaultmonth, defaultyear, td->amount->text().toFloat(), cleared );
+ transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, account->getParentAccountID ( secondaccountid ), defaultday, defaultmonth, defaultyear, td->amount->text().toFloat(), cleared );
// update account balances of both accounts and parents if necessary
account->updateAccountBalance ( firstaccountid );
if ( account->getParentAccountID ( firstaccountid ) != -1 )
account->changeParentAccountBalance ( account->getParentAccountID ( firstaccountid ) );
account->updateAccountBalance ( secondaccountid );
@@ -344,12 +344,17 @@ void AccountDisplay::saveColumnSize ( int column, int oldsize, int newsize )
preferences->changeColumnPreference ( 12, newsize );
break;
}
}
+void AccountDisplay::saveSortingPreference ( int column )
+ {
+ preferences->changeSortingPreference ( 1, column );
+ }
+
int AccountDisplay::getIDColumn ()
{
int counter;
int columns = listview->columns();
for ( counter = 0; counter <= columns; counter++ )
if ( listview->header()->label ( counter ).length() == 0 )
diff --git a/noncore/apps/qashmoney/accountdisplay.h b/noncore/apps/qashmoney/accountdisplay.h
index 37bcb34..6d67b9b 100755
--- a/noncore/apps/qashmoney/accountdisplay.h
+++ b/noncore/apps/qashmoney/accountdisplay.h
@@ -39,12 +39,13 @@ class AccountDisplay : public QWidget
void enableAccounts ();
private slots:
void saveColumnSize ( int column, int oldsize, int newsize );
void setAccountExpanded ( QListViewItem *item );
void setAccountCollapsed ( QListViewItem *item );
+ void saveSortingPreference ( int column );
private:
int type, firstaccountid, secondaccountid, cleared;
QWidget *tab2;
QTabWidget *maintabs;
};
diff --git a/noncore/apps/qashmoney/budget.cpp b/noncore/apps/qashmoney/budget.cpp
index 42f7eca..9f74078 100755
--- a/noncore/apps/qashmoney/budget.cpp
+++ b/noncore/apps/qashmoney/budget.cpp
@@ -1,9 +1,10 @@
#include "budget.h"
#include "transaction.h"
#include <stdlib.h>
+#include <iostream.h>
extern Transaction *transaction;
Budget::Budget ()
{
bdb = sqlite_open ( "qmbudgets.db", 0, NULL );
@@ -59,13 +60,13 @@ int Budget::getNumberOfLineItems ( int budgetid )
QStringList* Budget::getBudgetNames ()
{
QStringList *names = new QStringList ();
char **results;
int rows, counter;
- sqlite_get_table ( bdb, "select name from budgets order by name asc;", &results, &rows, NULL, NULL );
+ sqlite_get_table ( bdb, "select name from budgets;", &results, &rows, NULL, NULL );
names->append ( "None" );
for ( counter = 0; counter < rows; counter++ )
names->append ( results [ counter+1 ] );
return names;
}
diff --git a/noncore/apps/qashmoney/budgetdisplay.cpp b/noncore/apps/qashmoney/budgetdisplay.cpp
index 09f62b2..afc6a2d 100755
--- a/noncore/apps/qashmoney/budgetdisplay.cpp
+++ b/noncore/apps/qashmoney/budgetdisplay.cpp
@@ -79,12 +79,19 @@ BudgetDisplay::BudgetDisplay ( QWidget *parent ) : QWidget ( parent )
listview->setColumnAlignment ( 1, Qt::AlignRight );
listview->setColumnAlignment ( 2, Qt::AlignRight );
listview->setColumnWidthMode ( 3, QListView::Manual );
listview->header()->setTracking ( FALSE );
connect ( listview->header(), SIGNAL ( sizeChange ( int, int, int ) ), this, SLOT ( saveColumnSize ( int, int, int ) ) );
+ connect ( listview->header(), SIGNAL ( clicked ( int ) ), this, SLOT ( saveSortingPreference ( int ) ) );
+
+ // pull the column sorting preference from the preferences table, and configure the listview accordingly
+ int column = 0;
+ int direction = 0;
+ preferences->getSortingPreference ( 3, &column, &direction );
+ listview->setSorting ( column, direction );
displayBudgetNames();
layout = new QVBoxLayout ( this, 2, 2 );
layout->setMenuBar ( menu );
layout->addWidget ( firstline );
@@ -115,12 +122,17 @@ void BudgetDisplay::saveColumnSize ( int column, int oldsize, int newsize )
case 2:
preferences->changeColumnPreference ( 15, newsize );
break;
}
}
+void BudgetDisplay::saveSortingPreference ( int column )
+ {
+ preferences->changeSortingPreference ( 3, column );
+ }
+
int BudgetDisplay::getIDColumn ()
{
int counter;
int columns = listview->columns();
for ( counter = 0; counter <= columns; counter++ )
if ( listview->header()->label ( counter ).length() == 0 )
diff --git a/noncore/apps/qashmoney/budgetdisplay.h b/noncore/apps/qashmoney/budgetdisplay.h
index 25e952a..3976ce1 100755
--- a/noncore/apps/qashmoney/budgetdisplay.h
+++ b/noncore/apps/qashmoney/budgetdisplay.h
@@ -66,12 +66,13 @@ class BudgetDisplay : public QWidget
void deleteLineItem ();
void checkBudgets ();
void editBudget ();
void editLineItem ();
void constructBudgetWindow ();
void constructLineItemWindow ();
+ void saveSortingPreference ( int column );
private:
QStringList *names;
QStringList *ids;
int currentbudget, year, month, day;
QDate newDate;
diff --git a/noncore/apps/qashmoney/install/CONTROL/opie-qashmoney.control b/noncore/apps/qashmoney/install/CONTROL/opie-qashmoney.control
index b00e3b1..ec65c0e 100755
--- a/noncore/apps/qashmoney/install/CONTROL/opie-qashmoney.control
+++ b/noncore/apps/qashmoney/install/CONTROL/opie-qashmoney.control
@@ -1,7 +1,8 @@
Package: qashmoney
+Files: bin/qashmoney pics/qashmony/* pics/qashmony/flags/* apps/Applications/qashmoney.desktop
Priority: optional
-Version: 0.75
+Version: 0.76
Architecture: arm
-Maintainer: Allen Forsythe qashmoneyman@attbi.com
+Maintainer: Allen Forsythe allen@qashmoney.org
Section: Applications
Description: QashMoney provides an intuitive and fast way to keep track of your accounts and budgets.
diff --git a/noncore/apps/qashmoney/preferences.cpp b/noncore/apps/qashmoney/preferences.cpp
index 9bf64dd..880807a 100755
--- a/noncore/apps/qashmoney/preferences.cpp
+++ b/noncore/apps/qashmoney/preferences.cpp
@@ -147,24 +147,74 @@ void Preferences::initializeColumnPreferences ()
// initialize budget actual column
sqlite_get_table ( db, "select width from columns where id = 15;", &results, &rows, &columns, 0 );
if ( rows == 0 )
sqlite_exec ( db, "insert into columns values ( 'budgetactual', 50, 0, 0, 0, NULL );", 0, 0, 0 );
}
+void Preferences::initializeSortingPreferences ()
+ {
+ int rows = 0;
+ int columns = 0;
+ char **results;
+
+ if ( sqlite_get_table ( db, "select count() from sorting;", 0, 0, 0, 0 ) != 0 )
+ sqlite_exec ( db, "create table sorting ( listbox, column, direction, id integer primary key );", 0, 0, 0 );
+
+ // initialize account listbox sorting. Set direction = 1 here so ascending sort is default.
+ sqlite_get_table ( db, "select column, direction from sorting where id = 1;", &results, &rows, &columns, 0 );
+ if ( rows == 0 )
+ sqlite_exec ( db, "insert into sorting values ( 'accounts', 0, 1, NULL );", 0, 0, 0 );
+
+ // initialize transaction listbox sorting
+ sqlite_get_table ( db, "select column, direction from sorting where id = 2;", &results, &rows, &columns, 0);
+ if ( rows == 0 )
+ sqlite_exec ( db, "insert into sorting values ( 'transactions', 0, 1, NULL );", 0, 0, 0 );
+
+ // initialize budgets listbox sorting
+ sqlite_get_table ( db, "select column, direction from sorting where id = 3;", & results, &rows, &columns, 0 );
+ if ( rows == 0 )
+ sqlite_exec ( db, "insert into sorting values ( 'budgets', 0, 1, NULL );", 0, 0, 0 );
+ }
+
void Preferences::changeColumnPreference ( int id, int width )
{
sqlite_exec_printf ( db, "update columns set width = %i where id = %i;", 0, 0, 0, width, id );
}
int Preferences::getColumnPreference ( int id )
{
char **results;
sqlite_get_table_printf ( db, "select width from columns where id = %i;", &results, NULL, NULL, NULL, id );
return atoi ( results [ 1 ] );
}
+void Preferences::changeSortingPreference ( int id, int column )
+ {
+ int pColumn = 0; // column setting coming from the prefs object
+ int pDirection = 0; // direction setting coming from the prefs object
+
+ // because there appears to be no way to query the QT header object directly for it's current sort settings, we have
+ // to maintain track of them ourselves. So start by pulling the current saved setting for this view.
+ getSortingPreference ( id, &pColumn, &pDirection );
+
+ // if the current saved column == the new column, then the user wants to toggle the sort order.
+ // otherwise we behave like QT does by default, which is to select the new column and default to an ascending sort.
+ if ( column == pColumn )
+ sqlite_exec_printf ( db, "update sorting set direction = %i where id = %i;", 0, 0, 0, !pDirection, id );
+ else
+ sqlite_exec_printf ( db, "update sorting set column = %i, direction = 1 where id = %i;", 0, 0, 0, column, id );
+ }
+
+void Preferences::getSortingPreference ( int id, int *column, int *direction )
+ {
+ char **results;
+ sqlite_get_table_printf ( db, "select column, direction from sorting where id = %i;", &results, NULL, NULL, NULL, id );
+ *column = atoi ( results [ 2 ] );
+ *direction = atoi ( results [ 3 ] );
+ }
+
int Preferences::getPreference ( int id )
{
char **results;
sqlite_get_table_printf ( db, "select preference from preferences where id = %i;", &results, NULL, NULL, NULL, id );
return atoi ( results [ 1 ] );
}
diff --git a/noncore/apps/qashmoney/preferences.h b/noncore/apps/qashmoney/preferences.h
index 4a3e058..10ec6e9 100755
--- a/noncore/apps/qashmoney/preferences.h
+++ b/noncore/apps/qashmoney/preferences.h
@@ -9,24 +9,27 @@ class Preferences
public:
Preferences ();
~Preferences ();
void addPreferences ();
void initializeColumnPreferences ();
+ void initializeSortingPreferences ();
// Returns a preference value for the given preferences ID
int getPreference ( int );
int getColumnPreference ( int id );
+ void getSortingPreference ( int id, int *column, int *direction );
// Convenience for getting date separator with one function
// call. Takes the preference id as its argument
QString getSeparator ( );
// Changes a preference for the given ID
void changePreference ( int , int );
void changeColumnPreference ( int id, int width );
+ void changeSortingPreference ( int id, int column );
// The primary database that stores all our data
sqlite *db;
// This function returns a Qstring for the year first date formats
// for displaying. It takes the date numbers
diff --git a/noncore/apps/qashmoney/qashmoney.cpp b/noncore/apps/qashmoney/qashmoney.cpp
index 83eea01..20e8d32 100755
--- a/noncore/apps/qashmoney/qashmoney.cpp
+++ b/noncore/apps/qashmoney/qashmoney.cpp
@@ -13,12 +13,13 @@ Transfer *transfer = new Transfer ();
Memory *memory = new Memory ();
QashMoney::QashMoney () : QWidget ()
{
preferences->addPreferences();
preferences->initializeColumnPreferences ();
+ preferences->initializeSortingPreferences ();
// set the text in the upper part of the frame
setCaption ( tr ( "QashMoney" ) );
// Create new menubar for our mainwindow
// and add menu items
@@ -150,13 +151,13 @@ void QashMoney::changeTabDisplay ()
QString displaytext = "%";
displaytext.prepend ( transactiondisplay->limitbox->text() );
if ( transaction->getNumberOfTransactions() > 0 )
transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate );
// display transfers
- transfer->displayTransfers ( transactiondisplay->listview, accountid, children );
+ transfer->displayTransfers ( transactiondisplay->listview, accountid, children, newdate );
// 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
{
@@ -176,12 +177,18 @@ void QashMoney::changeTabDisplay ()
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 );
}
+ // pull the column sorting preference from the preferences table, and configure the listview accordingly
+ int column = 0;
+ int direction = 0;
+ preferences->getSortingPreference ( 2, &column, &direction );
+ transactiondisplay->listview->setSorting ( column, direction );
+
// show the window
transactiondisplay->show();
// hide the account display and define accountid
accountdisplay->hide();
// hide the budget display
budgetdisplay->hide();
@@ -194,12 +201,18 @@ void QashMoney::changeTabDisplay ()
accountdisplay->listview->clearSelection();
// resize the account display columns
accountdisplay->listview->setColumnWidth ( 0, preferences->getColumnPreference ( 1 ) );
accountdisplay->listview->setColumnWidth ( 1, preferences->getColumnPreference ( 2 ) );
+ // set sorting preference on account display columns
+ int column = 0;
+ int direction = 0;
+ preferences->getSortingPreference ( 1, &column, &direction );
+ accountdisplay->listview->setSorting ( column, direction );
+
// display the accounts
if ( account->getNumberOfAccounts() != 0 )
account->displayAccounts ( accountdisplay->listview );
maintabs->setTabEnabled ( tab_2, FALSE );
// set the toggle button
@@ -259,13 +272,13 @@ void QashMoney::displayDatePreferencesDialog ()
setTransactionDisplayDate();
if ( transaction->getNumberOfTransactions() > 0 )
transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate );
if ( transfer->getNumberOfTransfers() != 0 )
- transfer->displayTransfers ( transactiondisplay->listview, accountid, children );
+ transfer->displayTransfers ( transactiondisplay->listview, accountid, children, newdate );
}
else if ( accountdisplay->isVisible() )
{
accountdisplay->listview->clearSelection();
maintabs->setTabEnabled ( tab_2, FALSE );
}
@@ -297,13 +310,13 @@ void QashMoney::displayTransactionPreferencesDialog ()
setTransactionDisplayDate();
if ( transaction->getNumberOfTransactions() > 0 )
transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate );
if ( transfer->getNumberOfTransfers() != 0 )
- transfer->displayTransfers ( transactiondisplay->listview, accountid, children );
+ transfer->displayTransfers ( transactiondisplay->listview, accountid, children, newdate );
}
else
{
accountdisplay->listview->clearSelection();
maintabs->setTabEnabled ( tab_2, FALSE );
}
@@ -382,9 +395,9 @@ void QashMoney::setTransactionDisplayDate ()
case 4: // one year
newdate = today.addDays ( -365 );
break;
}
}
else
- newdate = QDate ( 1, 1, 1000 );
+ newdate = QDate ( 1900, 1, 1 );
}
diff --git a/noncore/apps/qashmoney/transaction.cpp b/noncore/apps/qashmoney/transaction.cpp
index 5ecc7ed..a3bd9e7 100755
--- a/noncore/apps/qashmoney/transaction.cpp
+++ b/noncore/apps/qashmoney/transaction.cpp
@@ -152,42 +152,118 @@ 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, QDate displaydate )
+char ** Transaction::selectAllTransactions ( QDate fromdate, bool children, const char *limit, int id )
{
+ // initialize variables
+ char **results;
int showcleared = preferences->getPreference ( 3 );
- int year = ( displaydate.year() ) - 1;
+ QDate today = QDate::currentDate();
+ int fromyear = fromdate.year();
+ int toyear = today.year();
+ int frommonth = fromdate.month();
+ int tomonth = today.month();
+ int fromday = fromdate.day();
+
+ // construct the first part of the string
+ QString query = "select day, month, year, payee, amount, transid, accountid from transactions where";
+
+ if ( frommonth == tomonth && fromyear == toyear ) // our dates cross neither a month nor a year
+ {
+ query.append ( " year = " );
+ query.append ( QString::number ( toyear ) );
+ query.append ( " and month = " );
+ query.append ( QString::number ( tomonth ) );
+ query.append ( " and day >= " );
+ query.append ( QString::number ( fromday ) );
+ query.append ( " and" );
+ }
+ else if ( frommonth != tomonth && fromyear == toyear ) // our dates cross a month within the same year
+ {
+ query.append ( " year = " );
+ query.append ( QString::number ( toyear ) );
+ query.append ( " and ( ( month <= " );
+ query.append ( QString::number ( tomonth ) );
+ query.append ( " and month > " );
+ query.append ( QString::number ( frommonth ) );
+ query.append ( " ) or ( month = " );
+ query.append ( QString::number ( frommonth ) );
+ query.append ( " and day >= " );
+ query.append ( QString::number ( fromday ) );
+ query.append ( " ) ) and " );
+ }
+ else if ( fromyear != toyear && fromyear != 1900 ) // here we are showing transactions from an entire year
+ {
+ // divide this taks into two parts - get the transactions from the prior and then the current year
+ // current year part
+ int tmpfrommonth = 1; // set temporary from months and days to Jan. 1
+ int tmpfromday = 1;
+ query.append ( " ( year >= " );
+ query.append ( QString::number ( fromyear ) );
+ query.append ( " and ( month <= " );
+ query.append ( QString::number ( tomonth ) );
+ query.append ( " and month > " );
+ query.append ( QString::number ( tmpfrommonth ) );
+ query.append ( " ) or ( month = " );
+ query.append ( QString::number ( tmpfrommonth ) );
+ query.append ( " and day >= " );
+ query.append ( QString::number ( tmpfromday ) );
+ query.append ( " ) ) or" );
+
+ // prior year part
+ int tmptomonth = 12;
+ query.append ( " ( year = " );
+ query.append ( QString::number ( fromyear ) );
+ query.append ( " and ( ( month <= " );
+ query.append ( QString::number ( tmptomonth ) );
+ query.append ( " and month > " );
+ query.append ( QString::number ( frommonth ) );
+ query.append ( " ) or ( month = " );
+ query.append ( QString::number ( frommonth ) );
+ query.append ( " and day >= " );
+ query.append ( QString::number ( fromday ) );
+ query.append ( " ) ) ) and " );
+ }
- // 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 year >= %i parentid = %i and payee like '%q';", &results, &rows, &columns, NULL, year, id, limit );
+ query.append ( " parentid = %i and payee like '%q';" );
else
- 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 );
+ query.append ( " accountid = %i and payee like '%q';" );
+
+ sqlite_get_table_printf ( tdb, query, &results, &rows, &columns, NULL, id, limit );
+ return results;
}
- else
+
+char ** Transaction::selectNonClearedTransactions ( QDate fromdate, bool children, const char *limit, int id )
{
+ char **results;
if ( account->getParentAccountID ( id ) == -1 && children == TRUE )
- 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 );
+ 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 );
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 );
+ 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 );
+ return results;
}
+void Transaction::displayTransactions ( QListView *listview, int id, bool children, const char *limit, QDate displaydate )
+ {
+ int showcleared = preferences->getPreference ( 3 );
+
+ char **results;
+ if ( showcleared == 0 )
+ results = selectNonClearedTransactions ( displaydate, children, limit, id );
+ else
+ results = selectAllTransactions ( displaydate, children, limit, id );
+
// iterate through the result list and display each item
int counter = 7;
while ( counter < ( ( rows + 1 ) * columns ) )
{
- QDate displaydate ( atoi ( results [ counter + 2 ] ), atoi ( results [ counter + 1 ] ), atoi ( results [ counter ] ) );
+ //QDate testdate ( 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 ];
diff --git a/noncore/apps/qashmoney/transaction.h b/noncore/apps/qashmoney/transaction.h
index 7297bb1..5871555 100755
--- a/noncore/apps/qashmoney/transaction.h
+++ b/noncore/apps/qashmoney/transaction.h
@@ -42,12 +42,14 @@ class Transaction
void clearBudgetIDs ( int, int );
void clearBudgetIDs ( int );
public slots:
void displayTransactions ( QListView *, int, bool, const char *, QDate );
+ char ** selectAllTransactions ( QDate fromdate, bool children, const char *limit, int id );
+ char ** selectNonClearedTransactions ( QDate fromdate, bool children, const char *limit, int id );
QString getPayee ( int );
QString getTransactionDescription ( int );
QString getNumber ( int );
QString getAmount ( int );
QString getAbsoluteAmount ( int );
int getCleared ( int );
@@ -59,12 +61,13 @@ class Transaction
int getYear ( int );
int getAccountID ( int id );
private:
sqlite *tdb;
+ int rows, columns;
};
#endif
diff --git a/noncore/apps/qashmoney/transactiondisplay.cpp b/noncore/apps/qashmoney/transactiondisplay.cpp
index ae6223d..1839cd2 100755
--- a/noncore/apps/qashmoney/transactiondisplay.cpp
+++ b/noncore/apps/qashmoney/transactiondisplay.cpp
@@ -64,12 +64,13 @@ TransactionDisplay::TransactionDisplay ( QWidget* parent ) : QWidget ( parent )
listview = new QListView ( this );
listview->setAllColumnsShowFocus ( TRUE );
listview->setShowSortIndicator ( TRUE );
listview->header()->setTracking ( FALSE );
connect ( listview->header(), SIGNAL ( sizeChange ( int, int, int ) ), this, SLOT ( saveColumnSize ( int, int, int ) ) );
+ connect ( listview->header(), SIGNAL ( clicked ( int ) ), this, SLOT ( saveSortingPreference ( int ) ) );
layout = new QVBoxLayout ( this, 2, 2 );
layout->addWidget ( firstline );
layout->addWidget ( secondline );
layout->addWidget ( listview );
}
@@ -130,13 +131,13 @@ void TransactionDisplay::addTransaction ()
setTransactionDisplayDate ();
if ( transaction->getNumberOfTransactions() > 0 )
transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
// redisplay transfers
if ( transfer->getNumberOfTransfers() > 0 )
- transfer->displayTransfers ( listview, accountid, children );
+ transfer->displayTransfers ( listview, accountid, children, displaydate );
// 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 ) );
@@ -369,13 +370,13 @@ void TransactionDisplay::updateAndDisplay ( int id )
setTransactionDisplayDate ();
if ( transaction->getNumberOfTransactions() > 0 )
transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
// redisplay transfers
if ( transfer->getNumberOfTransfers() > 0 )
- transfer->displayTransfers ( listview, accountid, children );
+ transfer->displayTransfers ( listview, accountid, children, displaydate );
// 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 ) );
@@ -413,13 +414,13 @@ void TransactionDisplay::deleteTransaction ()
displaytext.prepend ( limitbox->text() );
setTransactionDisplayDate ();
if ( transaction->getNumberOfTransactions() > 0 )
transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
if ( transfer->getNumberOfTransfers() > 0 )
- transfer->displayTransfers ( listview, accountid, children );
+ transfer->displayTransfers ( listview, accountid, children, displaydate );
// 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
@@ -445,13 +446,13 @@ void TransactionDisplay::deleteTransaction ()
displaytext.prepend ( limitbox->text() );
setTransactionDisplayDate ();
if ( transaction->getNumberOfTransactions() > 0 )
transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
if ( transfer->getNumberOfTransfers() > 0 )
- transfer->displayTransfers ( listview, accountid, children );
+ transfer->displayTransfers ( listview, accountid, children, displaydate );
// for the from account
account->updateAccountBalance ( fromaccountid );
if ( account->getParentAccountID ( fromaccountid ) != -1 )
account->changeParentAccountBalance ( account->getParentAccountID ( fromaccountid ) );
@@ -498,13 +499,13 @@ void TransactionDisplay::toggleTransaction ()
displaytext.prepend ( limitbox->text() );
setTransactionDisplayDate ();
if ( transaction->getNumberOfTransactions() > 0 )
transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate );
if ( transfer->getNumberOfTransfers() != 0 )
- transfer->displayTransfers ( listview, accountid, children );
+ transfer->displayTransfers ( listview, accountid, children, displaydate );
}
void TransactionDisplay::redisplayAccountBalance ()
{
QString accountbalance = account->getAccountBalance ( accountid );
balance->setText ( accountbalance );
@@ -548,23 +549,28 @@ void TransactionDisplay::saveColumnSize ( int column, int oldsize, int newsize )
else if ( listview->columns() == 5 && column != 4 )
preferences->changeColumnPreference ( column + 6, newsize );
else
preferences->changeColumnPreference ( 9, newsize );
}
+void TransactionDisplay::saveSortingPreference ( int column )
+ {
+ preferences->changeSortingPreference ( 2, column );
+ }
+
void TransactionDisplay::limitDisplay ( const QString &text )
{
listview->clear ();
QString displaytext = "%";
displaytext.prepend ( text );
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 );
+ transfer->displayTransfers ( listview, accountid, children, displaydate );
}
int TransactionDisplay::getIDColumn ()
{
int counter;
int columns = listview->columns();
@@ -616,8 +622,8 @@ void TransactionDisplay::setTransactionDisplayDate ()
case 4: // one year
displaydate = today.addDays ( -365 );
break;
}
}
else
- displaydate = QDate ( 1, 1, 1000 );
+ displaydate = QDate ( 1900, 1, 1 );
}
diff --git a/noncore/apps/qashmoney/transactiondisplay.h b/noncore/apps/qashmoney/transactiondisplay.h
index 1746f6c..594776a 100755
--- a/noncore/apps/qashmoney/transactiondisplay.h
+++ b/noncore/apps/qashmoney/transactiondisplay.h
@@ -47,12 +47,13 @@ class TransactionDisplay : public QWidget
void checkListViewToggle ();
void saveColumnSize ( int column, int oldsize, int newsize );
void limitDisplay ( const QString & );
void showCalculator ();
void showCalendar ();
void setTransactionDisplayDate ();
+ void saveSortingPreference ( int column );
private:
int accountid, fromaccount, fromparent, toaccount, toparent, day, month, year, transferid;
QDate displaydate;
bool children;
QBoxLayout *layout;
diff --git a/noncore/apps/qashmoney/transfer.cpp b/noncore/apps/qashmoney/transfer.cpp
index 77cbb4e..568d584 100755
--- a/noncore/apps/qashmoney/transfer.cpp
+++ b/noncore/apps/qashmoney/transfer.cpp
@@ -62,13 +62,13 @@ int Transfer::getNumberOfTransfers ( int accountid )
int transfers = atoi ( results [ 1 ] );
sqlite_get_table_printf ( db, "select count() from transfers where toaccount = %i;", &results, 0, 0, 0, accountid );
transfers = transfers + atoi ( results [ 1 ] );
return transfers;
}
-void Transfer::displayTransfers ( QListView *listview, int accountid, bool children )
+void Transfer::displayTransfers ( QListView *listview, int accountid, bool children, QDate displaydate )
{
int showcleared = preferences->getPreference ( 3 );
// select the from transfers to display
char **results;
int rows, columns;
@@ -97,24 +97,27 @@ void Transfer::displayTransfers ( QListView *listview, int accountid, bool child
int day = daystring.toInt ();
QString monthstring = results [ counter + 1 ];
int month = monthstring.toInt ();
QString yearstring = results [ counter + 2 ];
int year = yearstring.toInt ();
QString date = preferences->getDate ( year, month, day );
+ QDate testdate ( year, month, day );
//construct the amount and id strings
QString amount = results [ counter + 3 ];
QString id = results [ counter + 4 ];
// construct the transaction name
QString transactionname = "FROM: ";
QString temp1 = results [ counter + 5 ];
transactionname.append ( account->getAccountName ( temp1.toInt() ) );
QString toaccount = account->getAccountName ( atol ( results [ counter + 6 ] ) );
+ if ( testdate >= displaydate || showcleared == 0 )
+ {
// display this transfer
if ( account->getParentAccountID ( accountid ) == -1 )
{
if ( showcleared == 1 && getCleared ( id.toInt() ) == 1 )
ColorListItem *item = new ColorListItem ( listview, date, transactionname, amount, id, toaccount );
else
@@ -124,13 +127,13 @@ void Transfer::displayTransfers ( QListView *listview, int accountid, bool child
{
if ( showcleared == 1 && getCleared ( id.toInt() ) == 1 )
ColorListItem *item = new ColorListItem ( listview, date, transactionname, amount, id );
else
QListViewItem *item = new QListViewItem ( listview, date, transactionname, amount, id );
}
-
+ }
counter = counter + 7;
}
// select the to transfers to display
char **toresults;
rows = 0;
@@ -160,12 +163,13 @@ void Transfer::displayTransfers ( QListView *listview, int accountid, bool child
int day = daystring.toInt ();
QString monthstring = toresults [ counter + 1 ];
int month = monthstring.toInt ();
QString yearstring = toresults [ counter + 2 ];
int year = yearstring.toInt ();
QString date = preferences->getDate ( year, month, day );
+ QDate testdate ( year, month, day );
//construct the amount and id strings
QString amount = toresults [ counter + 3 ];
amount.prepend ( "-" );
QString id = toresults [ counter + 4 ];
@@ -173,12 +177,14 @@ void Transfer::displayTransfers ( QListView *listview, int accountid, bool child
QString transactionname = "TO: ";
QString temp1 = toresults [ counter + 6 ];
transactionname.append ( account->getAccountName ( temp1.toInt() ) );
QString fromaccount = account->getAccountName ( atol ( toresults [ counter + 5 ] ) );
+ if ( testdate >= displaydate || showcleared == 0 )
+ {
// display this transfer
if ( account->getParentAccountID ( accountid ) == -1 )
{
if ( showcleared == 1 && getCleared ( id.toInt() ) == 1 )
ColorListItem *item = new ColorListItem ( listview, date, transactionname, amount, id, fromaccount );
else
@@ -188,12 +194,13 @@ void Transfer::displayTransfers ( QListView *listview, int accountid, bool child
{
if ( showcleared == 1 && getCleared ( id.toInt() ) == 1 )
ColorListItem *item = new ColorListItem ( listview, date, transactionname, amount, id );
else
QListViewItem *item = new QListViewItem ( listview, date, transactionname, amount, id );
}
+ }
counter = counter + 7;
}
}
int Transfer::getCleared ( int id )
diff --git a/noncore/apps/qashmoney/transfer.h b/noncore/apps/qashmoney/transfer.h
index 33dedf4..e910e7c 100755
--- a/noncore/apps/qashmoney/transfer.h
+++ b/noncore/apps/qashmoney/transfer.h
@@ -1,12 +1,13 @@
#ifndef TRANSFER_H
#define TRANSFER_H
#include <qlistview.h>
#include <qstring.h>
#include <sqlite.h>
+#include <qdatetime.h>
#include "preferences.h"
class Transfer
{
public:
@@ -26,13 +27,13 @@ class Transfer
void deleteAllTransfers ( int accountid );
// Returns the number of checking transfers
int getNumberOfTransfers ();
int getNumberOfTransfers ( int accountid );
- void displayTransfers ( QListView *listview, int accountid, bool children );
+ void displayTransfers ( QListView *listview, int accountid, bool children, QDate displaydate );
int getCleared ( int id );
void setCleared ( int id, int cleared );
int getFromAccountID ( int id );
int getToAccountID ( int id );
int getDay ( int id );
diff --git a/noncore/apps/qashmoney/transferdialog.cpp b/noncore/apps/qashmoney/transferdialog.cpp
index 7bc3eb0..f85c740 100755
--- a/noncore/apps/qashmoney/transferdialog.cpp
+++ b/noncore/apps/qashmoney/transferdialog.cpp
@@ -94,13 +94,13 @@ int TransferDialog::getMonth ()
{
return month;
}
int TransferDialog::getYear ()
{
- return day;
+ return year;
}
void TransferDialog::showCalculator ()
{
Calculator *calculator = new Calculator ( this );
if ( calculator->exec () == QDialog::Accepted )