-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.h
110 lines (87 loc) · 2.79 KB
/
mainwindow.h
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QSpinBox>
#include <QGridLayout>
#include <QButtonGroup>
#include <QPushButton>
#include <QLineEdit>
#include <QLabel>
#include <QVector>
#include "testswriter.h"
#include "deletebutton.h"
#define _GNU_SOURCE
#define MIN_QUESTIONS_COUNT 1
#define MAX_QUESTIONS_COUNT 10000
#define START_QUESTIONS_COUNT 10
#define MAX_FILENAME_LENGTH 65
#define TESTS_FOLDER "Tests"
#define TEST_FILENAME "test"
#define FILE_EXTENSION ".json"
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class DeleteButton;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
void showDialog();
QString truncateFilename(const QString &filename);
void addFileWidget(const QString &filename);
void addAnswerWidget(const QString &answer);
void saveCurQuestion();
void restoreCurQuestion(const TestsWriter::Question &question);
void showCurQuestion();
void clearQuestionFields();
std::string getVacantFilename();
signals:
void removeLineSignal(DeleteButton *const btn);
public slots:
void removeLine(DeleteButton *const btn);
private slots:
void initQuestionsCount();
void on_qCreateBtn_clicked();
void switchQuestion();
void addAnswer();
void addAnswerField();
void on_singleChoiceRB_clicked();
void on_multipleChoiceRB_clicked();
void on_addFileBtn_clicked();
void on_textAnswerRB_clicked();
void on_goPrevBtn_clicked();
void on_goNextBtn_clicked();
void on_resetTestBtn_clicked();
void on_saveTestBtn_clicked();
private:
Ui::MainWindow *ui;
TestsWriter writer;
QString filepath = "C:\\";
QDialog *dialog;
QSpinBox *qInitCountSB;
QButtonGroup *answerTypeButtons;
QButtonGroup *answerButtons;
size_t questionsCount, curQuestionIndex;
TestsWriter::Question::AnswerType curAnswerType;
QWidget *questionSwitchersWidget;
QGridLayout *questionSwitchersLayout;
QVector<QPushButton *> questionSwitchers;
// QSpacerItem *questionSwitchersHSpacer;
QWidget *answersWidget;
QGridLayout *answersLayout;
QPushButton *addAnswerBtn;
QLineEdit *answerField;
QVector<QPair<QWidget *, DeleteButton *>> answers; // заменить все * на умные указатели
QVector<QSpacerItem *> answersHSpacers;
QSpacerItem *answersVSpacer, *answersHSpacer;
size_t answersCountOfAllTime;
QWidget *filesWidget;
QGridLayout *filesLayout;
QVector<QPair<QLabel *, DeleteButton *>> files;
QVector<QSpacerItem *> filesHSpacers;
QSpacerItem *filesVSpacer;
size_t filesCountOfAllTime;
};
#endif // MAINWINDOW_H