/**
 * osd_userinterface_data.c: Presents submenus with metadata items
 * 
 * Copyright: See COPYING file that comes with this distribution
 *
 * Author: Matthias Feistel <hitman_47@users.sourceforge.net>, (C) 2006, 2007
 */

#include <vector>
#include <vdr/interface.h>
#include <vdr/menu.h>
#include <vdr/plugin.h>
#include "osd_userinterface_data.h"
#include "settings.h"
#include "web_metadata.h"
#include "osd_userinterface_data_recentTracks.h"
#include "osd_userinterface_data_relatedArtists.h"
#include "osd_userinterface_data_artistMetadata.h"

cUserInterface_Data::cUserInterface_Data( void ) :
	cOsdMenu( tr( "metadata" ), 20)
{
	cSettings::GetInstance().SetOsd_Path( "data" );
	// OSD-Elemente aufbauen
	BuildItems( );
}

cUserInterface_Data::~cUserInterface_Data( void )
{
	cSettings::GetInstance().SetOsd_Path( "submenu" );
}

void cUserInterface_Data::BuildItems( void )
{
	Add( new cOsdItem( hk( tr( "artistMetadata..." ) ) ) );
	Add( new cOsdItem( hk( tr( "relatedArtists..." ) ) ) );
	Add( new cOsdItem( hk( tr( "recentLovedTracks..." ) ) ) );
	Add( new cOsdItem( hk( tr( "recentBannedTracks..." ) ) ) );
	Add( new cOsdItem( hk( tr( "recentTracks..." ) ) ) );

	Display( );
}

eOSState cUserInterface_Data::ProcessKey( eKeys Key )
{
	eOSState state = cOsdMenu::ProcessKey( Key );

	if( !strcmp( cSettings::GetInstance().GetOsd_Path( ), "data" ) )
	{
		switch( Key )
		{
		// cases f�r bereits belegte Tasten werden erw�hnt, damit die vom dar�berliegenden Men� gleicherma�en belegten Tasten ignoriert werden.
		case kOk:
			if( Current( ) == 0 )
			{
				cSettings::GetInstance().SetOsd_Path( "artistMetadata" );
				AddSubMenu( new cUserInterface_Data_artistMetadata() );
			}
			if( Current( ) == 1 )
			{
				cSettings::GetInstance().SetOsd_Path( "relatedartists" );
				AddSubMenu( new cUserInterface_Data_relatedArtists() );
			}
			if( Current( ) == 2 )
			{
				cSettings::GetInstance().SetOsd_Path( "recentlovedtracks" );
				AddSubMenu( new cUserInterface_Data_recentTracks( "loved" ) );
			}
			if( Current( ) == 3 )
			{
				cSettings::GetInstance().SetOsd_Path( "recentbannedtracks" );
				AddSubMenu( new cUserInterface_Data_recentTracks( "banned" ) );
			}
			if( Current( ) == 4 )
			{
				cSettings::GetInstance().SetOsd_Path( "recenttracks" );
				AddSubMenu( new cUserInterface_Data_recentTracks( "all" ) );
			}
			return osContinue;

		default:
			break;
		}
	}

	return state;
}
