-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhouserepresenter.cpp
More file actions
42 lines (32 loc) · 854 Bytes
/
houserepresenter.cpp
File metadata and controls
42 lines (32 loc) · 854 Bytes
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
#include "houserepresenter.h"
#include "ui_houserepresenter.h"
#include <iostream>
#include <QGridLayout>
#include <QLabel>
#include "appliancewidget.h"
HouseRepresenter::HouseRepresenter(QWidget *parent, House* h) :
QWidget(parent),
ui(new Ui::HouseRepresenter)
{
ui->setupUi(this);
house = h;
for(int i = 0; i < h->appliances.size(); i++)
{
ApplianceWidget* wid = new ApplianceWidget(this, h->appliances[i]);
AWs.push_back(wid);
ui->gridLayout_2->addWidget(wid, i / 3, i % 3);
}
}
HouseRepresenter::~HouseRepresenter()
{
delete ui;
}
void HouseRepresenter::tick(int t)
{
for(int i = 0; i < AWs.size(); i++)
{
AWs[i]->tick(t);
}
ui->power->setText(QString::number(house->getPower()) + " W");
ui->forced->setText(QString::number(house->getForced()) + " W");
}