Diffstat (limited to 'noncore/unsupported/qashmoney/memory.cpp') (more/less context) (ignore whitespace changes)
-rwxr-xr-x | noncore/unsupported/qashmoney/memory.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/noncore/unsupported/qashmoney/memory.cpp b/noncore/unsupported/qashmoney/memory.cpp new file mode 100755 index 0000000..b5155b3 --- a/dev/null +++ b/noncore/unsupported/qashmoney/memory.cpp | |||
@@ -0,0 +1,62 @@ | |||
1 | #include "memory.h" | ||
2 | |||
3 | #include <stdlib.h> | ||
4 | |||
5 | Memory::Memory () | ||
6 | { | ||
7 | db = sqlite_open ( "qmmemory.db", 0, NULL ); | ||
8 | } | ||
9 | |||
10 | Memory::~Memory () | ||
11 | { | ||
12 | sqlite_close ( db ); | ||
13 | } | ||
14 | |||
15 | void Memory::addMemoryItem ( QString item ) | ||
16 | { | ||
17 | sqlite_exec_printf ( db, "insert into memory values ( '%q', 0, 0 );", 0, 0, 0, ( const char * ) item ); | ||
18 | } | ||
19 | |||
20 | void Memory::deleteMemoryItem ( QString item ) | ||
21 | { | ||
22 | sqlite_exec_printf ( db, "delete from memory where item = '%q';", 0, 0, 0, ( const char * ) item ); | ||
23 | } | ||
24 | |||
25 | int Memory::getNumberOfMemoryItems () | ||
26 | { | ||
27 | char **results; | ||
28 | sqlite_get_table ( db, "select count() from memory;", &results, NULL, NULL, NULL ); | ||
29 | return atoi ( results [ 1 ] ); | ||
30 | } | ||
31 | |||
32 | void Memory::changeMemoryName ( QString item ) | ||
33 | { | ||
34 | sqlite_exec_printf ( db, "update memory set item = '%q' where item = '%q';", 0, 0, 0, ( const char * ) item ); | ||
35 | } | ||
36 | |||
37 | void Memory::displayMemoryItems ( QListBox *listbox ) | ||
38 | { | ||
39 | char **results; | ||
40 | int rows; | ||
41 | sqlite_get_table ( db, "select item from memory order by item asc;", &results, &rows, NULL, NULL ); | ||
42 | int counter = 1; | ||
43 | while ( counter < ( rows + 1 ) ) | ||
44 | { | ||
45 | listbox->insertItem ( results [ counter ] ); | ||
46 | counter ++; | ||
47 | } | ||
48 | } | ||
49 | |||
50 | void Memory::displayMemoryItems ( QComboBox *box ) | ||
51 | { | ||
52 | char **results; | ||
53 | int rows; | ||
54 | sqlite_get_table ( db, "select item from memory order by item asc;", &results, &rows, NULL, NULL ); | ||
55 | int counter = 1; | ||
56 | while ( counter < ( rows + 1 ) ) | ||
57 | { | ||
58 | box->insertItem ( results [ counter ] ); | ||
59 | counter ++; | ||
60 | } | ||
61 | } | ||
62 | |||