-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathshoppingcart.cpp
More file actions
59 lines (46 loc) · 1.51 KB
/
shoppingcart.cpp
File metadata and controls
59 lines (46 loc) · 1.51 KB
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
57
#include "shoppingcart.h"
#include "ui_shoppingcart.h"
#include <QKeyEvent>
#include "deletebutton.h"
#include <iostream>
//#include "checkoutbutton.h"
#include <QPalette>
#include <QColorDialog>
ShoppingCart::ShoppingCart(QWidget *parent) :
QDialog(parent),
ui(new Ui::ShoppingCart)
{
ui->setupUi(this);
ui->shoppingTable->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->deleteRowButton->setMainWindow(this);
ui->outputLabel->setStyleSheet("font-weight: bold; color: red;");
ui->outputLabel->setVisible(false); // makes label invisible
ui->shoppingTable->setColumnCount(2);
ui->shoppingTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
//distributed collaboration
connect(ui->deleteRowButton,SIGNAL(clicked()),ui->deleteRowButton,SLOT(deleteRow())); // deletes selection
connect(ui->checkoutPriceButton,SIGNAL(clicked()),ui->shoppingTable,SLOT(checkout())); // checkout
connect(ui->shoppingTable,SIGNAL(changeLabel(QString)),ui->outputLabel,SLOT(changeText(QString))); // checkout
}
ShoppingCart::~ShoppingCart()
{
delete ui;
}
void ShoppingCart::showOrHide(){
if (isVisible() == false){
show();
emit isShown(true);
}
else{
hide();
emit isShown(false);
}
}
// workaround to emit a signal whenever window is closed
void ShoppingCart::closeEvent(QCloseEvent *event){
emit dialogClosed();
event->accept(); // accepts the closure
}
cartTable* ShoppingCart::returnTable(){
return this->ui->shoppingTable;
}