#include "playlistmodel.h"
#include <QDebug>

PlaylistModel::PlaylistModel(QObject* parent)
	: QStandardItemModel(parent), m_current(-1)
{}

void PlaylistModel::addFile(const QUrl& url)
{
	QStandardItem* newItem=new QStandardItem(url.path());
	newItem->setData(url);
	appendRow(newItem);
}

QUrl PlaylistModel::next()
{
	if(rowCount()==0)
		return QUrl();
	
	if(m_current>=0)
		item(m_current, 0)->setBackground(QBrush());
	
	m_current++;
	if(rowCount()<=m_current)
		m_current=0;
	
	item(m_current, 0)->setBackground(Qt::gray);
	
	return item(m_current, 0)->data().toUrl();
}

#include "playlistmodel.moc"