/**********************************************************************
 * LeechCraft - modular cross-platform feature rich internet client.
 * Copyright (C) 2010-2011 Oleg Linkin
 *
 * Boost Software License - Version 1.0 - August 17th, 2003
 *
 * Permission is hereby granted, free of charge, to any person or organization
 * obtaining a copy of the software and accompanying documentation covered by
 * this license (the "Software") to use, reproduce, display, distribute,
 * execute, and transmit the Software, and to prepare derivative works of the
 * Software, and to permit third-parties to whom the Software is furnished to
 * do so, all subject to the following:
 *
 * The copyright notices in the Software and this entire statement, including
 * the above license grant, this restriction and the following disclaimer,
 * must be included in all copies of the Software, in whole or in part, and
 * all derivative works of the Software, unless such copies or derivative
 * works are solely in the form of machine-executable object code generated by
 * a source language processor.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
 * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
 * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 **********************************************************************/

#include "ircaccountconfigurationwidget.h"
#include <QTextCodec>


namespace LeechCraft
{
namespace Azoth
{
namespace Acetamide
{
	IrcAccountConfigurationWidget::
			IrcAccountConfigurationWidget (QWidget* parent)
	: QWidget (parent)
	{
		Ui_.setupUi (this);
		Q_FOREACH (const QByteArray& codec, QTextCodec::availableCodecs ())
			Ui_.DefaultEncoding_->addItem (QString::fromUtf8 (codec));
		Ui_.DefaultEncoding_->model ()->sort (0);
		Ui_.DefaultEncoding_->
				setCurrentIndex (Ui_.DefaultEncoding_->findText ("UTF-8"));
	}

	void IrcAccountConfigurationWidget::SetRealName (const QString& real)
	{
		Ui_.RealName_->setText (real);
	}

	QString IrcAccountConfigurationWidget::GetRealName () const
	{
		return Ui_.RealName_->text ();
	}

	void IrcAccountConfigurationWidget::SetUserName (const QString& user)
	{
		Ui_.UserName_->setText (user);
	}

	QString IrcAccountConfigurationWidget::GetUserName () const
	{
		return Ui_.UserName_->text ();
	}

	void IrcAccountConfigurationWidget::
			SetNickNames (const QStringList& nicks)
	{
		Ui_.NickNames_->setPlainText (nicks.join ("\n"));
	}

	QStringList IrcAccountConfigurationWidget::GetNickNames () const
	{
		return Ui_.NickNames_->toPlainText ().split ('\n');
	}

	void IrcAccountConfigurationWidget::SetDefaultServer (const QString& server)
	{
		Ui_.DefaultIrcServer_->setText (server);
	}

	QString IrcAccountConfigurationWidget::GetDefaultServer () const
	{
		return Ui_.DefaultIrcServer_->text ();
	}

	void IrcAccountConfigurationWidget::SetDefaultPort (int port)
	{
		Ui_.DefaultPort_->setValue (port);
	}

	int IrcAccountConfigurationWidget::GetDefaultPort () const
	{
		return Ui_.DefaultPort_->value ();
	}

	void IrcAccountConfigurationWidget::SetDefaultEncoding (const QString& encoding)
	{
		Ui_.DefaultEncoding_->
				setCurrentIndex (Ui_.DefaultEncoding_->findText (encoding));
	}

	QString IrcAccountConfigurationWidget::GetDefaultEncoding () const
	{
		return Ui_.DefaultEncoding_->currentText ();
	}

	void IrcAccountConfigurationWidget::SetDefaultChannel (const QString& channel)
	{
		Ui_.DefaultChannel_->setText (channel);
	}

	QString IrcAccountConfigurationWidget::GetDefaultChannel () const
	{
		return Ui_.DefaultChannel_->text ();
	}

};
};
};
