Diffstat (limited to 'noncore/apps/qashmoney/account.cpp') (more/less context) (ignore 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 | |||
@@ -13,27 +13,26 @@ Account::Account () | |||
13 | { | 13 | { |
14 | adb = sqlite_open ( "qmaccounts.db", 0, NULL ); | 14 | adb = sqlite_open ( "qmaccounts.db", 0, NULL ); |
15 | } | 15 | } |
16 | 16 | ||
17 | Account::~Account () | 17 | Account::~Account () |
18 | { | 18 | { |
19 | sqlite_close ( adb ); | 19 | sqlite_close ( adb ); |
20 | } | 20 | } |
21 | 21 | ||
22 | void Account::addAccount ( QString name, int parentid, float balance, int type, QString description, float creditlimit, | 22 | void Account::addAccount ( QString name, int parentid, float balance, int type, QString description, float creditlimit, |
23 | int statementyear, int statementmonth, int statementday, float statementbalance, const char *currency ) | 23 | int statementyear, int statementmonth, int statementday, float statementbalance, const char *currency ) |
24 | { | 24 | { |
25 | 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, | 25 | 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, |
26 | (const char *) name, parentid, balance, type, (const char *) description, creditlimit, statementyear, statementmonth, statementday, statementbalance, currency ); | 26 | (const char *) name, parentid, balance, type, (const char *) description, creditlimit, statementyear, statementmonth, statementday, statementbalance, currency ); |
27 | cout << "Results = " << r << endl; | ||
28 | } | 27 | } |
29 | 28 | ||
30 | void Account::updateAccount ( QString name, QString description, QString currencycode, int accountid ) | 29 | void Account::updateAccount ( QString name, QString description, QString currencycode, int accountid ) |
31 | { | 30 | { |
32 | 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 ); | 31 | 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 ); |
33 | } | 32 | } |
34 | 33 | ||
35 | void Account::deleteAccount ( int accountid ) | 34 | void Account::deleteAccount ( int accountid ) |
36 | { | 35 | { |
37 | sqlite_exec_printf ( adb, "delete from accounts2 where accountid = %i;", 0, 0, 0, accountid ); | 36 | sqlite_exec_printf ( adb, "delete from accounts2 where accountid = %i;", 0, 0, 0, accountid ); |
38 | } | 37 | } |
39 | 38 | ||
@@ -216,24 +215,30 @@ void Account::displayAccounts ( QListView *listview ) | |||
216 | listview->setColumnWidthMode ( 2, QListView::Manual ); | 215 | listview->setColumnWidthMode ( 2, QListView::Manual ); |
217 | } | 216 | } |
218 | else | 217 | else |
219 | { | 218 | { |
220 | listview->setColumnWidth ( 0, preferences->getColumnPreference ( 10 ) ); | 219 | listview->setColumnWidth ( 0, preferences->getColumnPreference ( 10 ) ); |
221 | listview->setColumnWidthMode ( 0, QListView::Manual ); | 220 | listview->setColumnWidthMode ( 0, QListView::Manual ); |
222 | listview->setColumnWidth ( 1, preferences->getColumnPreference ( 11 ) ); | 221 | listview->setColumnWidth ( 1, preferences->getColumnPreference ( 11 ) ); |
223 | listview->setColumnWidthMode ( 1, QListView::Manual ); | 222 | listview->setColumnWidthMode ( 1, QListView::Manual ); |
224 | listview->setColumnWidth ( 2, preferences->getColumnPreference ( 12 ) ); | 223 | listview->setColumnWidth ( 2, preferences->getColumnPreference ( 12 ) ); |
225 | listview->setColumnWidthMode ( 2, QListView::Manual ); | 224 | listview->setColumnWidthMode ( 2, QListView::Manual ); |
226 | listview->setColumnWidthMode ( 3, QListView::Manual ); | 225 | listview->setColumnWidthMode ( 3, QListView::Manual ); |
227 | } | 226 | } |
227 | |||
228 | // Now reset the column sorting to user preference | ||
229 | int column = 0; | ||
230 | int direction = 0; | ||
231 | preferences->getSortingPreference ( 1, &column, &direction ); | ||
232 | listview->setSorting ( column, direction ); | ||
228 | } | 233 | } |
229 | 234 | ||
230 | int Account::displayParentAccountNames ( QComboBox *combobox, QString indexstring ) | 235 | int Account::displayParentAccountNames ( QComboBox *combobox, QString indexstring ) |
231 | { | 236 | { |
232 | char **results; | 237 | char **results; |
233 | int rows, columns, index; | 238 | int rows, columns, index; |
234 | index = 0; | 239 | index = 0; |
235 | sqlite_get_table ( adb, "select name from accounts2 order by name asc;", &results, &rows, &columns, NULL ); | 240 | sqlite_get_table ( adb, "select name from accounts2 order by name asc;", &results, &rows, &columns, NULL ); |
236 | int counter = 1; | 241 | int counter = 1; |
237 | int indexcounter = 1; | 242 | int indexcounter = 1; |
238 | int total = ( rows + 1 ) * columns; | 243 | int total = ( rows + 1 ) * columns; |
239 | while ( counter < total ) | 244 | while ( counter < total ) |