/*
 *  Copyright (C) 2007-2008 CMM Sigma Andrzej Chmielowiec <cmmsigma@cmmsigma.eu>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 3
 *  as published by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 */

// CaOptionsDialog.cpp: implementation of the CaOptionsDialog class.
//
//////////////////////////////////////////////////////////////////////

#include "CaOptionsDialog.h"

CaOptionsDialog::CaOptionsDialog(QWidget *parent, Qt::WindowFlags f): QDialog(parent, f)
{
	QGridLayout *layout = new QGridLayout();
	
	mailWidget = new MailAccountWidget(true, true, this);
	ftpWidget = new FTPAccountWidget(this);

	mTab = new QTabWidget();
	mTab->addTab(mailWidget, tr("Mail account"));
	mTab->addTab(ftpWidget, tr("Sending CRL via FTP settings"));
	
	mCancel = new QPushButton(tr("Ca&ncel"));
	connect(mCancel, SIGNAL(clicked()), this, SLOT(reject()));
	mAccept = new QPushButton(tr("&Accept"));
	connect(mAccept, SIGNAL(clicked()), this, SLOT(accept()));
	
	layout->addWidget(mTab, 0, 0, 1, 3);
	layout->addWidget(mAccept, 1, 1);
	layout->addWidget(mCancel, 1, 2);
	
	layout->setColumnStretch(0, 1);
	layout->setRowStretch(0, 1);
	
	setLayout(layout);
}

CaOptionsDialog::~CaOptionsDialog()
{

}

void
CaOptionsDialog::setData(CaOptions &data)
{
	mailWidget->setData(data.mailConfig);
	ftpWidget->setData(data.ftpConfig);
}

void
CaOptionsDialog::getData(CaOptions &data)
{
	mailWidget->getData(data.mailConfig);
	ftpWidget->getData(data.ftpConfig);
}

MailAccountWidget *
CaOptionsDialog::getMailWidget()
{
	return mailWidget;
}

FTPAccountWidget *
CaOptionsDialog::getFTPWidget()
{
	return ftpWidget;
}

void
CaOptionsDialog::setStartPage(int page)
{
	mTab->setCurrentIndex(page);
}
