-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
74 lines (60 loc) · 2.2 KB
/
mainwindow.cpp
File metadata and controls
74 lines (60 loc) · 2.2 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "mainwindow.h"
#include "./ui_mainwindow.h"
#include <QMessageBox>
#include <QFileDialog>
#include <quickfix/SessionSettings.h>
#include <quickfix/FileStore.h>
#include <quickfix/SessionID.h>
#include "ClientApplication.h"
#include "fixwidget.h"
#include "FixClientLogFactory.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow), running(false) {
ui->setupUi(this);
connect(ui->LoadFile, SIGNAL(clicked()), this, SLOT(print()));
connect(ui->actionLoadFile, SIGNAL(triggered()), this, SLOT(print()));
}
MainWindow::~MainWindow() {
delete ui;
}
void MainWindow::print() {
if (this->running) {
QMessageBox::warning(this, "ERROR", "文件已加载!");
return;
}
QFileDialog dialog;
dialog.setWindowTitle("加载文件");
dialog.setFileMode(QFileDialog::ExistingFile);
auto result = dialog.exec();
if (result == QDialog::Accepted) {
QString file = dialog.selectedFiles().at(0);
auto name = file.toStdString();
try {
this->running = true;
auto settings = std::make_unique<FIX::SessionSettings>(name);
std::set<FIX::SessionID> session_ids = settings->getSessions();
if (session_ids.empty()) {
throw FIX::ConfigError("没有session配置");
}
auto fileStoreFactory = std::make_unique<FIX::FileStoreFactory>(*settings);
auto fixClientLogFactory = std::make_unique<FixClientLogFactory>(*settings);
auto client = std::make_unique<ClientApplication>(*settings);
auto fix = new FixWidget(
std::move(settings),
std::move(fileStoreFactory),
std::move(fixClientLogFactory),
std::move(client)
);
this->hide();
fix->showFullScreen();
} catch (FIX::ConfigError &e) {
QMessageBox::warning(this, "ERROR", QString::fromStdString(e.detail));
this->running = false;
} catch (...) {
QMessageBox::warning(this, "ERROR", "文件错误");
this->running = false;
}
}
}
void MainWindow::on_LoadFile_clicked() {
}