/***************************************************************************
 *   Copyright (C) 2008 by Andreas Silberstorff   *
 *   taki@Rivendell   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   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.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#include "kalvarecorder.h"
#include "ui_recordergui.h"

#include <KDebug>


namespace KalvaWidget {

class KALVALIB_EXPORT KalvaRecorderPrivate
{
public:
	KalvaRecorderPrivate()
	    : daysOfTheWeek( new KalvaData::DaysOfTheWeek )
	{}

//members
	Ui::RecorderGui ui;
	KalvaData::DaysOfTheWeek* daysOfTheWeek;
};

KalvaRecorder::KalvaRecorder( QWidget* parent )
	: QWidget( parent ),
	  d( new KalvaRecorderPrivate() )
{
	d->ui.setupUi( this );
	setupConnections();
}

KalvaRecorder::~KalvaRecorder()
{
	delete d;
}

void KalvaRecorder::setupConnections()
{
	connect( d->ui.mSunday, SIGNAL( toggled( bool ) ),
		 d->daysOfTheWeek, SLOT( setSundayActive( bool ) ) );
	connect( d->ui.mMonday, SIGNAL( toggled( bool ) ),
		 d->daysOfTheWeek, SLOT( setMondayActive( bool ) ) );
	connect( d->ui.mTuesday, SIGNAL( toggled( bool ) ),
		 d->daysOfTheWeek, SLOT( setTuesdayActive( bool ) ) );
	connect( d->ui.mWednesday, SIGNAL( toggled( bool ) ),
		 d->daysOfTheWeek, SLOT( setWednesdayActive( bool ) ) );
	connect( d->ui.mThursday, SIGNAL( toggled( bool ) ),
		 d->daysOfTheWeek, SLOT( setThursdayActive( bool ) ) );
	connect( d->ui.mFryday, SIGNAL( toggled( bool ) ),
		 d->daysOfTheWeek, SLOT( setFrydayActive( bool ) ) );
	connect( d->ui.mSaturday, SIGNAL( toggled( bool ) ),
		 d->daysOfTheWeek, SLOT( setSaturdayActive( bool ) ) );

	connect( d->ui.mRecordButton, SIGNAL( pressed() ),
		 this, SLOT( emitRecordButtonSelected() ) );
}

void KalvaRecorder::emitRecordButtonSelected()
{
	kDebug() << "emitRecordButtonSelected()";
	emit recordButtonSelected();
}

void KalvaRecorder::setChannel(KalvaData::Channel* channel)
{
	d->ui.mStation->setText(channel->station());
	d->ui.mChannel->setText(channel->channel());
	d->ui.mFrequence->setText(channel->frequence());
}

KalvaData::DaysOfTheWeek* KalvaRecorder::daysOfTheWeek()
{
	return d->daysOfTheWeek;
}

QString KalvaRecorder::titel()
{
	return d->ui.mTitel->text();
}

QTime KalvaRecorder::duration()
{
	return d->ui.mDuration->time();
}

} //end of namespace

#include "kalvarecorder.moc"
