-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.cpp
46 lines (39 loc) · 1.01 KB
/
update.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
#include "update.h"
#include <QListWidget>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QLabel>
#include <QObject>
#include <QLineEdit>
#include <QPushButton>
#include <QMessageBox>
#include <stdio.h>
Update::Update(std::vector<Offer> offers, QWidget *parent) : QWidget(parent) {
this->offers = offers;
this->initGUI();
this->reload();
}
void Update::initGUI() {
//
//General layout of the window
//
QHBoxLayout* layout = new QHBoxLayout(this);
//
// Prepare left side components
//
QWidget* leftWidget = new QWidget();
QVBoxLayout* lLeft = new QVBoxLayout(leftWidget);
QLabel* lbl = new QLabel("Offers");
lLeft->addWidget(lbl);
offerList = new QListWidget();
lLeft->addWidget(offerList);
layout->addWidget(leftWidget);
}
void Update::reload() {
offerList->clear();
for (vector<Offer>::iterator p = this->offers.begin(); p != this->offers.end(); ++p) {
offerList->addItem(QString::fromStdString(p->getDest() + " " + p->getType() + ": " + std::to_string(p->getPrice())));
}
}
Update::~Update() {
}