#ifndef CONFIRM_DIALOG_H
#define CONFIRM_DIALOG_H

#include <QtGui>
#include "ui_confirmDialog.h"
#include <cassert>

///ConfirmDialog used to submit or cancel important actions.
class ConfirmDialog : public QDialog {
	Q_OBJECT

private:
	Ui::ConfirmDialog ui_;
	std::string userData_;
signals:
	void submitSignal();
	void cancelSignal();
private slots:
	void submitButtonClickedSlot(bool checked) {
		emit submitSignal();
		accept();
	}

	void cancelButtonClickedSlot(bool checked) {
		emit cancelSignal();
		reject();
	}
public:
	ConfirmDialog(QWidget * parent) : QDialog(parent) {
		ui_.setupUi(this);

		bool connected = true;

		connected = connected && QObject::connect(ui_.submitButton, SIGNAL(clicked(bool)), this, SLOT(submitButtonClickedSlot(bool)));
		connected = connected && QObject::connect(ui_.cancelButton, SIGNAL(clicked(bool)), this, SLOT(cancelButtonClickedSlot(bool)));

		assert(connected && "Signals not connected");
	}

	void setTitle(const std::wstring & value) {
		ui_.titleLabel->setText(QString::fromUtf16(value.c_str()));
	} /**< Sets dialog title. */

	void setTitle(const std::string & value) {
		ui_.titleLabel->setText(QString::fromUtf8(value.c_str()));
	} /**< Sets dialog title. */

	void setMessage(const std::wstring & value) {
		ui_.messageLabel->setText(QString::fromUtf16(value.c_str()));
	} /**< Sets dialog message. */

	void setMessage(const std::string & value) {
		ui_.messageLabel->setText(QString::fromUtf8(value.c_str()));
	} /**< Sets dialog message. */

	void setUserData(const std::string & data) {
		this->userData_ = data;
	}

	std::string getUserData() {
		return userData_;
	}
};

#endif