-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTDBAdminList.cpp
64 lines (54 loc) · 1.39 KB
/
TDBAdminList.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
#include "TDBAdminList.h"
TDBAdminList::TDBAdminList (QWidget* parent) : QTreeWidget(parent)
{
setColumnCount(3);
QStringList header_strings;
header_strings << "Trigramme" << "Nom" << "Niveau";
setHeaderLabels(header_strings);
setSelectionMode(QAbstractItemView::SingleSelection);
}
TDBAdminList::~TDBAdminList ()
{
;
}
void TDBAdminList::fill ()
{
TDBDatabase::open();
QSqlQuery query;
query.prepare("SELECT accounts.trigramme as tri, accounts.nickname as nick, admins.permissions as perm FROM accounts JOIN admins ON accounts.id = admins.id ORDER BY perm DESC, tri DESC");
query.exec();
if(query.first())
{
insert_item(query);
}
while(query.next())
{
insert_item(query);
}
TDBDatabase::close();
}
void TDBAdminList::insert_item(QSqlQuery& query)
{
QStringList item;
QSqlRecord record;
record = query.record();
item.clear();
item<<record.value("tri").toString()
<<record.value("nick").toString();
switch(record.value("perm").toInt())
{
case pekin:
item<<"pékin";
break;
case ami_du_bob:
item<<"Ami du BôB";
break;
case bobarman:
item<<"Ancien BôBarman";
break;
case root:
item<<"BôBarman";
break;
}
insertTopLevelItem(0,new QTreeWidgetItem(this, item));
}