-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
72 lines (61 loc) · 2.42 KB
/
mainwindow.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// File: mainwindow.cpp
// Author: Daniele Picciaia
// Project: CrossMonitor
// url: https://github.com/picciaia/crossmonitor
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(ui->spUpdate, SIGNAL(valueChanged(int)), this, SLOT(spUpdate_changed(int)));
AddLog("Application started");
}
MainWindow::~MainWindow()
{
delete ui;
}
//Add log information with timestamp
void MainWindow::AddLog(const QString& string)
{
QDateTime current = QDateTime::currentDateTime();
QString timestamp = current.toString("[dd.MM.yyyy]" );
ui->txtLog->appendPlainText(timestamp + " " + string);
}
void MainWindow::spUpdate_changed(int v)
{
QString s = "Refresh changed to " + QString::number(v) + " seconds";
AddLog(s);
UpdatePeriod(v);
}
//Display the cross values. This slot is signaled by the model
void MainWindow::OnCrossChanged(const Cross& cross)
{
ui->lcdAsk->display( cross.Ask );
ui->lcdBid->display(cross.Bid);
ui->lblHigh->setText( QString::number(cross.High) );
ui->lblLast->setText( QString::number(cross.Last) );
ui->lblLow->setText( QString::number(cross.Low) );
ui->lblOpen->setText( QString::number(cross.Open) );
ui->lblTime->setText( QString::number(cross.Timestamp) );
ui->lblVol->setText( QString::number(cross.Volume) );
ui->lblVwap->setText( QString::number(cross.Vwap) );
}
void MainWindow::closeEvent(QCloseEvent *event)
{
emit CloseWindowEvent();
event->accept();
}