Diffstat (limited to 'noncore/apps/qashmoney/budget.cpp') (more/less context) (ignore whitespace changes)
-rwxr-xr-x | noncore/apps/qashmoney/budget.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
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,15 +1,16 @@ | |||
1 | #include "budget.h" | 1 | #include "budget.h" |
2 | #include "transaction.h" | 2 | #include "transaction.h" |
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #include <iostream.h> | ||
4 | 5 | ||
5 | extern Transaction *transaction; | 6 | extern Transaction *transaction; |
6 | 7 | ||
7 | Budget::Budget () | 8 | Budget::Budget () |
8 | { | 9 | { |
9 | bdb = sqlite_open ( "qmbudgets.db", 0, NULL ); | 10 | bdb = sqlite_open ( "qmbudgets.db", 0, NULL ); |
10 | } | 11 | } |
11 | 12 | ||
12 | Budget::~Budget () | 13 | Budget::~Budget () |
13 | { | 14 | { |
14 | sqlite_close ( bdb ); | 15 | sqlite_close ( bdb ); |
15 | } | 16 | } |
@@ -53,25 +54,25 @@ int Budget::getNumberOfLineItems ( int budgetid ) | |||
53 | QString tablename = "table"; | 54 | QString tablename = "table"; |
54 | tablename.append ( QString::number ( budgetid ) ); | 55 | tablename.append ( QString::number ( budgetid ) ); |
55 | char **results; | 56 | char **results; |
56 | sqlite_get_table_printf ( bdb, "select count() from '%q';", &results, NULL, NULL, NULL, ( const char * ) tablename ); | 57 | sqlite_get_table_printf ( bdb, "select count() from '%q';", &results, NULL, NULL, NULL, ( const char * ) tablename ); |
57 | return atoi ( results [ 1 ] ); | 58 | return atoi ( results [ 1 ] ); |
58 | } | 59 | } |
59 | 60 | ||
60 | QStringList* Budget::getBudgetNames () | 61 | QStringList* Budget::getBudgetNames () |
61 | { | 62 | { |
62 | QStringList *names = new QStringList (); | 63 | QStringList *names = new QStringList (); |
63 | char **results; | 64 | char **results; |
64 | int rows, counter; | 65 | int rows, counter; |
65 | sqlite_get_table ( bdb, "select name from budgets order by name asc;", &results, &rows, NULL, NULL ); | 66 | sqlite_get_table ( bdb, "select name from budgets;", &results, &rows, NULL, NULL ); |
66 | names->append ( "None" ); | 67 | names->append ( "None" ); |
67 | for ( counter = 0; counter < rows; counter++ ) | 68 | for ( counter = 0; counter < rows; counter++ ) |
68 | names->append ( results [ counter+1 ] ); | 69 | names->append ( results [ counter+1 ] ); |
69 | return names; | 70 | return names; |
70 | } | 71 | } |
71 | 72 | ||
72 | QString Budget::getBudgetName ( int budgetid ) | 73 | QString Budget::getBudgetName ( int budgetid ) |
73 | { | 74 | { |
74 | char **results; | 75 | char **results; |
75 | sqlite_get_table_printf ( bdb, "select name from budgets where budgetid= %i;", &results, NULL, NULL, NULL, budgetid ); | 76 | sqlite_get_table_printf ( bdb, "select name from budgets where budgetid= %i;", &results, NULL, NULL, NULL, budgetid ); |
76 | return ( QString ) results [ 1 ]; | 77 | return ( QString ) results [ 1 ]; |
77 | } | 78 | } |