-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
81 lines (76 loc) · 2.28 KB
/
mainwindow.cpp
File metadata and controls
81 lines (76 loc) · 2.28 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
74
75
76
77
78
79
80
81
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QFile>
#include <QTextStream>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
setFixedSize(272, 276);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::saveVarToFile(QString varName, QString filename = "") {
QString filePath;
if(filename == "") {
filePath = ui->mainFolder->text() + varName + ".txt";
} else {
filePath = ui->mainFolder->text() + filename + ".txt";
}
QLineEdit * lineedit = ui->tabWidget-> findChild < QLineEdit *>(varName);
if (lineedit == NULL) {
qDebug() << "Widget not found: " << varName << filename;
return;
}
QString text = lineedit->text();
QFile file(filePath);
file.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream out(&file);
out << text;
file.close();
}
void MainWindow::saveIntToFile(QString varName, QString filename = "") {
QString filePath;
if(filename == "") {
filePath = ui->mainFolder->text() + varName + ".txt";
} else {
filePath = ui->mainFolder->text() + filename + ".txt";
}
QSpinBox * lineedit = ui->tabWidget-> findChild < QSpinBox *>(varName);
if (lineedit == NULL) {
qDebug() << "Widget not found";
return;
}
QString text = lineedit->text();
QFile file(filePath);
file.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream out(&file);
out << text;
file.close();
}
void MainWindow::on_pushButton_clicked()
{
saveVarToFile("varTourName");
if( ui->varSwapTeams->isChecked() ) {
// swap teams
saveVarToFile("varTeam1", "varTeam2");
saveVarToFile("varTeam1Rate", "varTeam2Rate");
saveIntToFile("varTeam1Score", "varTeam2Score");
saveVarToFile("varTeam2", "varTeam1");
saveVarToFile("varTeam2Rate", "varTeam1Rate");
saveIntToFile("varTeam2Score", "varTeam1Score");
} else {
saveVarToFile("varTeam1");
saveVarToFile("varTeam1Rate");
saveIntToFile("varTeam1Score");
saveVarToFile("varTeam2");
saveVarToFile("varTeam2Rate");
saveIntToFile("varTeam2Score");
}
saveVarToFile("varCaster");
saveVarToFile("varTourDescript");
}