#include "ui_main_window.h"
#include <QFile>
#include <QFileDialog>
#include <QCloseEvent>
#include <QMessageBox>
#include <QButtonGroup>
#include <QTcpSocket>
#include <QProgressDialog>
#include <QTextStream>
#include <QHeaderView>
#include <QTimer>
#include <QTime>
#include <QSettings>
#include <QTranslator>
#include "question_item.h"
class QuestionAnswer
{
public:
QuestionAnswer();
QuestionAnswer(QuestionItem::Answer, QuestionItem::Answer);
void setAnswered(QuestionItem::Answer); QuestionItem::Answer answered();
void setCorrectAnswer(QuestionItem::Answer); QuestionItem::Answer correctAnswer();
bool isAnsweredCorrectly();
private:
QuestionItem::Answer qa_answered;
QuestionItem::Answer qa_correct_answer;
};
class MainWindow : public QMainWindow, private Ui::MainWindow
{
Q_OBJECT
public:
MainWindow();
private slots:
void varinit();
void about();
void updateGeometry();
void errorInvalidData();
void getReady();
void start();
void browse_i(); void browse_o();
void enableConnectButton();
void enableLoadButton();
void toggleInputType(QAbstractButton *);
void enableInputTypeSelection();
void disableInputTypeSelection();
void connect();
void readIncomingData();
void displayError(QAbstractSocket::SocketError);
void loadTest(QString); void loadFile(); void loadFile(QString);
void randomlySelectQuestions();
void updateTime();
void finish(); void sendResults(); void saveResults();
void loadResults(QMap<QString, QuestionAnswer> *, QTableWidget *);
void readResults(QString);
void setCurrentQuestion();
void nextQuestion(); void lastQuestion();
void setQuestionAnswered(QAbstractButton *);
private:
QString current_db_name;
QString current_db_date;
QString current_db_comments;
QList<QuestionItem *> current_db_questions;
int current_test_qnum;
QMap<QListWidgetItem *, QuestionItem *> current_test_questions;
QMap<QString, QuestionAnswer> * current_test_results;
int current_test_time_remaining;
int current_test_score;
bool current_test_results_sent;
QString current_test_date;
QString current_test_time_finished;
bool current_db_fe[20]; QString current_db_f[20];
void closeEvent(QCloseEvent*);
QButtonGroup * rbtngrpInputType;
QProgressDialog * progress_dialog;
QButtonGroup * rbtngrpAnswer;
QTcpSocket * tcpSocket;
quint64 blocksize;
quint32 client_number;
bool test_loaded;
quint64 num_entries;
quint64 current_entry;
QString received_data;
QTableWidgetItem * ITW_test_name;
QTableWidgetItem * ITW_test_date;
QTableWidgetItem * ITW_test_timestamp;
QTableWidgetItem * ITW_test_time;
QTableWidgetItem * ITW_test_qnum;
QTableWidgetItem * ITW_test_fnum;
QTableWidgetItem * ITW_test_flags;
QTextBrowser * ITW_test_comments;
QString ver; float f_ver; QString db_ver; float f_db_ver;
};