Diffstat (limited to 'noncore/apps/qashmoney/account.cpp') (more/less context) (show whitespace changes)
-rwxr-xr-x | noncore/apps/qashmoney/account.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
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 @@ -1,51 +1,50 @@ #include "account.h" #include "transaction.h" #include "transfer.h" #include "preferences.h" #include <qpixmap.h> #include <stdlib.h> #include <iostream.h> extern Preferences *preferences; Account::Account () { adb = sqlite_open ( "qmaccounts.db", 0, NULL ); } 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 ); } void Account::deleteAccount ( int accountid ) { sqlite_exec_printf ( adb, "delete from accounts2 where accountid = %i;", 0, 0, 0, accountid ); } void Account::setAccountExpanded ( int expanded, int accountid ) { sqlite_exec_printf ( adb, "update accounts2 set r1 = %i where accountid = %i;", 0, 0, 0, expanded, accountid ); } int Account::getAccountExpanded ( int id ) { char **results; sqlite_get_table_printf ( adb, "select r1 from accounts2 where accountid = %i;", &results, 0, 0, 0, id ); if ( strlen ( results [1] ) == 0 ) return 0; else @@ -204,48 +203,54 @@ void Account::displayAccounts ( QListView *listview ) //End display child accounts } counter = counter + 5; } // resize all columns appropriately if ( preferences->getPreference ( 4 ) == 0 ) { listview->setColumnWidth ( 0, preferences->getColumnPreference ( 1 ) ); listview->setColumnWidthMode ( 0, QListView::Manual ); listview->setColumnWidth ( 1, preferences->getColumnPreference ( 2 ) ); listview->setColumnWidthMode ( 1, QListView::Manual ); listview->setColumnWidthMode ( 2, QListView::Manual ); } else { listview->setColumnWidth ( 0, preferences->getColumnPreference ( 10 ) ); listview->setColumnWidthMode ( 0, QListView::Manual ); 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; index = 0; sqlite_get_table ( adb, "select name from accounts2 order by name asc;", &results, &rows, &columns, NULL ); int counter = 1; int indexcounter = 1; int total = ( rows + 1 ) * columns; while ( counter < total ) { if ( getParentAccountID ( results [ counter ] ) == -1 ) { combobox->insertItem ( results [ counter ], -1 ); if ( strcmp ( results [ counter ], indexstring ) == 0 ) index = indexcounter; indexcounter++; } counter ++; } return index; } |