-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgui.cpp
45 lines (43 loc) · 1.56 KB
/
gui.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
#include "gui.h"
GUI::GUI(Map *map, bool islist, int x, int y, QObject *parent) : QObject(parent), map(map)
{
QTableWidget *tw = new QTableWidget();
tw->setEditTriggers(QAbstractItemView::NoEditTriggers);
tw->setSelectionMode(QAbstractItemView::SingleSelection);
if(!islist)
{
QFont font;
font.setBold(true);
connect(tw, SIGNAL(cellDoubleClicked(int,int)), this, SLOT(cellDoubleClicked(int,int)));
tw->verticalHeader()->setDefaultSectionSize(50);
tw->horizontalHeader()->setDefaultSectionSize(50);
tw->setRowCount(map->network.size());
tw->setColumnCount(map->network[0].size());
for(int i = 0; i < map->network.size(); ++i)
{
for(int j = 0; j < map->network[i].size(); ++j)
{
tw->setItem(i, j, new QTableWidgetItem(QString::number(map->network[i][j]->quant_list.size())));
if(map->network[i][j]->has_map) tw->item(i, j)->setFont(font);
}
}
}
else
{
tw->setColumnCount(1);
tw->setRowCount(map->network[x][y]->quant_names.size());
for (int i = 0; i < map->network[x][y]->quant_names.size(); ++i)
{
tw->setItem(i, 0, new QTableWidgetItem(map->network[x][y]->quant_names[i]));
}
}
tw->adjustSize();
tw->show();
}
void GUI::cellDoubleClicked(int r, int c)
{
if(map->network[r][c]->has_map)
new GUI(map->network[r][c]->map, false, 0, 0, this);
else if(map->network[r][c]->quant_names.size() > 0)
new GUI(map, true, r, c, this);
}