/**
  * modeselectiondialog.cpp
  * Dialog pro vyber mezi testovacim a vyukovym modem ruznych druhu objektu v mape (kraje, krajska mesta, obycejna mesta).
  *
  * @author Michala Capkova
  */

#include "modeselctiondialog.h"
#include <QLabel>
#include <QGridLayout>
#include <QLineEdit>
#include <QRadioButton>
#include <QGroupBox>
#include <QVBoxLayout>
#include <QPushButton>
#include <QHBoxLayout>

/**
  * konstruktor
  */
ModeSelectionDialog::ModeSelectionDialog()
{
    this->setWindowTitle(trUtf8("Nastavení"));
    QVBoxLayout *main_layout = new QVBoxLayout();

    QGroupBox *selectMapGroupBox = new QGroupBox(trUtf8("Výběr mapy"),this);
    QVBoxLayout *selectMapLayout = new QVBoxLayout();
    this->regions_button = new QRadioButton(trUtf8("Kraje"));
    regions_button->setChecked(true);
    selectMapLayout->addWidget(regions_button);
    this->region_capitals_button = new QRadioButton(trUtf8("Krajská města"));
    selectMapLayout->addWidget(region_capitals_button);
    this->towns_button = new QRadioButton(trUtf8("Města"));
    selectMapLayout->addWidget(towns_button);
    selectMapGroupBox->setLayout(selectMapLayout);
    main_layout->addWidget(selectMapGroupBox);

    QGroupBox *selectModeGroupBox = new QGroupBox(trUtf8("Výběr módu"),this);
    QVBoxLayout *selectModeLayout = new QVBoxLayout();
    this->teaching_mode_button = new QRadioButton(trUtf8("Výuka"));
    teaching_mode_button->setChecked(true);
    selectModeLayout->addWidget(teaching_mode_button);
    this->testing_mode_button = new QRadioButton(trUtf8("Testování"));
    selectModeLayout->addWidget(testing_mode_button);
    selectModeGroupBox->setLayout(selectModeLayout);
    main_layout->addWidget(selectModeGroupBox);

    QHBoxLayout *buttonLayout = new QHBoxLayout();
    QPushButton *cancelButton = new QPushButton(trUtf8("Zrušit"));
    QPushButton *acceptButton = new QPushButton(trUtf8("Potvrdit"));

    connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
    connect(acceptButton, SIGNAL(clicked()), this, SLOT(accept()));

    buttonLayout->addStretch(1);
    buttonLayout->addWidget(cancelButton);
    buttonLayout->addWidget(acceptButton);
    main_layout->addStretch(1);
    main_layout->addLayout(buttonLayout);

    this->setLayout(main_layout);



}

/**
  * vraci vybrany druh mapy (kraje, krajska mesta, obycejna mesta)
  */
ModeSelectionDialog::Map ModeSelectionDialog::getSelectedMap()
{
    if (this->regions_button->isChecked())
    {
        return REGIONS;
    }
    else if (this->region_capitals_button->isChecked())
    {
        return CAPITALS;
    }
    else if (this->towns_button->isChecked())
    {
        return TOWNS;
    }
    else
    {
        return REGIONS;
    }
}

/**
  * vraci vybrany mod (vyukovy/testovaci)
  */
ModeSelectionDialog::Mode ModeSelectionDialog::getSelectedMode()
{
    if (this->teaching_mode_button->isChecked())
    {
        return TEACHING;
    }
    else if(this->testing_mode_button->isChecked())
    {
        return TESTING;
    }
    else
    {
        return TEACHING;
    }
}
