forked from mrkite/TerraFirma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkilldialog.cpp
40 lines (32 loc) · 960 Bytes
/
killdialog.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
/**
* @Copyright 2015 seancode
*
* Handles the list of kills
*/
#include "./killdialog.h"
#include "./ui_killdialog.h"
KillDialog::KillDialog(const WorldHeader &header, const WorldInfo &info,
QWidget *parent)
: QDialog(parent), ui(new Ui::KillDialog) {
ui->setupUi(this);
model = new QStandardItemModel(0, 2, this);
ui->tableView->setModel(model);
QStringList labels;
labels << "NPC";
labels << "Kills";
model->setHorizontalHeaderLabels(labels);
auto list = header["killCount"];
for (int i = 0; i < list->length(); i++) {
if (info.npcsByBanner.contains(i))
add(info.npcsByBanner[i]->title, list->at(i)->toInt());
}
}
KillDialog::~KillDialog() {
delete ui;
}
void KillDialog::add(QString npc, int kills) {
auto first = new QStandardItem(npc);
auto second = new QStandardItem();
second->setData(kills, Qt::DisplayRole);
model->appendRow(QList<QStandardItem *>() << first << second);
}