-
Notifications
You must be signed in to change notification settings - Fork 0
/
DialogVictimView.cpp
56 lines (46 loc) · 2.01 KB
/
DialogVictimView.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
#include "DialogVictimView.h"
#include "VictimsTableModel.h"
#include "Service.h"
#include <QSortFilterProxyModel>
#include <qheaderview.h>
#include "PictureDelegate.h"
DialogVictimView::DialogVictimView(TransferInterface& t, Service& service, QWidget* parent)
: QWidget(parent), service{ service }, transList{ t }
{
ui.setupUi(this);
this->setWindowIcon(QIcon("Resources/coroner.png"));
this->transList.addObserver(this);
// create and set a QSortFilterProxyModel and enable sorting
this->tableModel = new VictimsTableModel{ this->service.getAllSaved() };
QSortFilterProxyModel* proxyModel =
new QSortFilterProxyModel{};
proxyModel->setSourceModel(this->tableModel);
ui.tableView->setSortingEnabled(true);
ui.tableView->setModel(proxyModel);
this->ui.tableView->setItemDelegate(new PictureDelegate{});
ui.tableView->resizeColumnsToContents();
ui.tableView->resizeRowsToContents();
this->ui.tableView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
this->ui.tableView->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
this->ui.tableView->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch);
//this->ui.tableView->horizontalHeader()->setSectionResizeMode(3, QHeaderView::Stretch);
}
DialogVictimView::~DialogVictimView()
{
this->transList.removeObserver(this);
}
void DialogVictimView::update()
{
this->tableModel = new VictimsTableModel{ this->service.getAllSaved() };
QSortFilterProxyModel* proxyModel =
new QSortFilterProxyModel{};
proxyModel->setSourceModel(this->tableModel);
ui.tableView->setSortingEnabled(true);
ui.tableView->setModel(proxyModel);
this->ui.tableView->setItemDelegate(new PictureDelegate{});
ui.tableView->resizeColumnsToContents();
ui.tableView->resizeRowsToContents();
this->ui.tableView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
this->ui.tableView->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
this->ui.tableView->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch);
}