-
Notifications
You must be signed in to change notification settings - Fork 1
/
dbtables.cpp
70 lines (59 loc) · 1.86 KB
/
dbtables.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <QtSql/QSqlDatabase>
#include "dbtables.hpp"
#include "db.hpp"
#include "rt.hpp"
using namespace std;
using namespace SMSDB;
void DBTables::InitTables()
{
RT::DB()->CreateTable(RT::DBTables()->Table(TableName::Categories),
RT::DBTables()->Fields(TableName::Categories));
RT::DB()->CreateTable(RT::DBTables()->Table(TableName::SubCategories),
RT::DBTables()->Fields(TableName::SubCategories));
RT::DB()->CreateTable(RT::DBTables()->Table(TableName::Messages),
RT::DBTables()->Fields(TableName::Messages));
}
DBTables::DBTables()
{
InitHashes();
}
string DBTables::Table(TableName id)
{
if (m_tablesHash.find(id) != m_tablesHash.end()) {
return m_tablesHash[id];
} else {
return "{?}";
}
}
string DBTables::Fields(TableName id)
{
if (m_fieldsHash.find(id) != m_fieldsHash.end()) {
return m_fieldsHash[id];
} else {
return "{?}";
}
}
void DBTables::InitHashes()
{
m_tablesHash[TableName::Categories] = "categories";
m_tablesHash[TableName::SubCategories] = "subcategories";
m_tablesHash[TableName::Messages] = "messages";
m_fieldsHash[TableName::Categories] =
" id TEXT NOT NULL, "
" name TEXT NOT NULL, "
" icon TEXT NOT NULL, "
" PRIMARY KEY ( id, name ASC ) ";
m_fieldsHash[TableName::SubCategories] =
" id TEXT NOT NULL, "
" name TEXT NOT NULL, "
" catid TEXT NOT NULL, "
" icon TEXT NOT NULL, "
" lastpage TEXT, "
" PRIMARY KEY ( id, name, catid ASC ) ";
m_fieldsHash[TableName::Messages] =
" id TEXT NOT NULL, "
" subcatid TEXT NOT NULL, "
" text TEXT NOT NULL, "
" fav INTEGER NOT NULL, "
" PRIMARY KEY ( id, subcatid ASC ) ";
}