-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddstockwindow.cpp.autosave
51 lines (43 loc) · 1.32 KB
/
addstockwindow.cpp.autosave
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
#include "addstockwindow.h"
#include "ui_addstockwindow.h"
/* QT libraires */
#include <QMessageBox>
AddStockWindow::AddStockWindow(QWidget *parent, QTableWidget *stockListTableWidget) :
QWidget(parent),
ui(new Ui::AddStockWindow),
stockListTableWidget(stockListTableWidget)
{
ui->setupUi(this);
// Connect
connect(&yahooFinance, &YahooFinance::transmitResult, this, &AddStockWindow::receiveResult);
}
AddStockWindow::~AddStockWindow()
{
delete ui;
}
void AddStockWindow::on_addToStockListPushButton_clicked()
{
// Check if this exist
stockName = ui->stockNameLineEdit->text();
stockIndexName = ui->selectedIndexComboBox->currentText();
yahooFinance.stockNameExist(stockName);
}
void AddStockWindow::receiveResult(int result){
// If status error is above 0, then we got an error
if(result > 0){
QMessageBox::warning(this, "Stock name", "No connection to that stock");
}else{
// Check if the stock name exist
int stockAdded = stockListTableWidget->rowCount();
bool exist = false;
for(int i = 0; i < stockAdded; i++){
if(stockName == stockListTableWidget->item(i, 0)->text()){
exist = true;
break;
}
}
if(!exist){
stockListTableWidget.setc
}
}
}