summaryrefslogtreecommitdiff
path: root/noncore/unsupported/qashmoney/memory.cpp
Side-by-side diff
Diffstat (limited to 'noncore/unsupported/qashmoney/memory.cpp') (more/less context) (ignore whitespace changes)
-rwxr-xr-xnoncore/unsupported/qashmoney/memory.cpp62
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 @@
+#include "memory.h"
+
+#include <stdlib.h>
+
+Memory::Memory ()
+ {
+ db = sqlite_open ( "qmmemory.db", 0, NULL );
+ }
+
+Memory::~Memory ()
+ {
+ sqlite_close ( db );
+ }
+
+void Memory::addMemoryItem ( QString item )
+ {
+ sqlite_exec_printf ( db, "insert into memory values ( '%q', 0, 0 );", 0, 0, 0, ( const char * ) item );
+ }
+
+void Memory::deleteMemoryItem ( QString item )
+ {
+ sqlite_exec_printf ( db, "delete from memory where item = '%q';", 0, 0, 0, ( const char * ) item );
+ }
+
+int Memory::getNumberOfMemoryItems ()
+ {
+ char **results;
+ sqlite_get_table ( db, "select count() from memory;", &results, NULL, NULL, NULL );
+ return atoi ( results [ 1 ] );
+ }
+
+void Memory::changeMemoryName ( QString item )
+ {
+ sqlite_exec_printf ( db, "update memory set item = '%q' where item = '%q';", 0, 0, 0, ( const char * ) item );
+ }
+
+void Memory::displayMemoryItems ( QListBox *listbox )
+ {
+ char **results;
+ int rows;
+ sqlite_get_table ( db, "select item from memory order by item asc;", &results, &rows, NULL, NULL );
+ int counter = 1;
+ while ( counter < ( rows + 1 ) )
+ {
+ listbox->insertItem ( results [ counter ] );
+ counter ++;
+ }
+ }
+
+void Memory::displayMemoryItems ( QComboBox *box )
+ {
+ char **results;
+ int rows;
+ sqlite_get_table ( db, "select item from memory order by item asc;", &results, &rows, NULL, NULL );
+ int counter = 1;
+ while ( counter < ( rows + 1 ) )
+ {
+ box->insertItem ( results [ counter ] );
+ counter ++;
+ }
+ }
+