/***************************************************************************
 * tabsongmodel.h: implementation of TabSong class
 *
 * This file is part of KTabEdit, a KDE tabulature editor
 *
 * copyright (C) 2007- the KTabEdit development team <mrgwen@gmail.com>
 ***************************************************************************/

/***************************************************************************
 * 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.
 *
 * See the file COPYING for more information.
 ***************************************************************************/

#include "tabsongmodel.h"
#include "util/assert.h"

#include <QString>

#include "tablature/tabsong.h"

TabSongModel::TabSongModel()
: mTabSong(0x0)
{
	mTabSong = new TabSong();
}

TabSongModel::TabSongModel(TabSong* song)
: mTabSong(song)
{
	POSTCONDITION( mTabSong != 0x0 );
}

TabSongModel::TabSongModel(const QString& title, int tempo)
: mTabSong(0x0)
{
	mTabSong = new TabSong(title, tempo);
}

TabSongModel::~TabSongModel()
{
	delete mTabSong;
}

void TabSongModel::setTabSong(TabSong* song)
{
	PRECONDITION( song != 0x0 );
	
	delete mTabSong;
	mTabSong = song;
	
	notifySongUpdated();
}

TabSong* TabSongModel::tabSong() const
{
	POSTCONDITION( mTabSong != 0x0 );
	
	return mTabSong;
}

void TabSongModel::push_back(TabTrack* tabTrack)
{
	mTabSong->push_back(tabTrack);
	
	notifyTrackAdded(tabTrack);
}

void TabSongModel::push_front(TabTrack* tabTrack)
{
	mTabSong->push_front(tabTrack);
	
	notifyTrackAdded(tabTrack);
}

void TabSongModel::removeFirst()
{
	TabTrack* track = front();
	
	mTabSong->removeFirst();
	
	notifyTrackDeleted(track);
}

void TabSongModel::removeLast()
{
	TabTrack* track = back();
	
	mTabSong->removeLast();
	
	notifyTrackDeleted(track);
}

void TabSongModel::removeAll(TabTrack* tabTrack)
{
	mTabSong->removeAll(tabTrack);
	
	notifyTrackDeleted(tabTrack);
}

TabTrack* TabSongModel::at(int i) const
{
	return mTabSong->at(i);
}

QList<TabTrack*>::reference TabSongModel::front()
{
	return mTabSong->front();
}

QList<TabTrack*>::const_reference TabSongModel::front() const
{
	return mTabSong->front();
}

QList<TabTrack*>::reference TabSongModel::back()
{
	return mTabSong->back();
}

QList<TabTrack*>::const_reference TabSongModel::back() const
{
	return mTabSong->back();
}

QList<TabTrack*>::iterator TabSongModel::begin()
{
	return mTabSong->begin();
}

QList<TabTrack*>::const_iterator TabSongModel::begin() const
{
	return mTabSong->begin();
}

QList<TabTrack*>::iterator TabSongModel::end()
{
	return mTabSong->end();
}

QList<TabTrack*>::const_iterator TabSongModel::end() const
{
	return mTabSong->end();
}

int TabSongModel::size() const
{
	return mTabSong->size();
}

int TabSongModel::positionOfTrack(const TabTrack* track) const
{
	return mTabSong->positionOfTrack(track);
}

uint TabSongModel::maximumOfBars() const
{
	return mTabSong->maximumOfBars();
}

void TabSongModel::setProperties(TabProperties* properties)
{
	mTabSong->setProperties(properties);
	
	notifyPropertyChanged();
}

TabProperties* TabSongModel::properties() const
{
	return mTabSong->properties();
}

bool TabSongModel::hasProperties() const
{
	return mTabSong->hasProperties();
}

bool TabSongModel::isDrumTrack() const
{
	return mTabSong->isDrumTrack();
}

int TabSongModel::drumTrack() const
{
	return mTabSong->drumTrack();
}

TabTrack* TabSongModel::at(uint track) const
{
	return mTabSong->at(track);
}

void TabSongModel::setTitle(const QString &s)
{
	mTabSong->setTitle(s);
	
	notifyPropertyChanged();
}

QString TabSongModel::title() const
{
	return mTabSong->title();
}

void TabSongModel::setSubTitle(const QString &s)
{
	mTabSong->setSubTitle(s);
	
	notifyPropertyChanged();
}

QString TabSongModel::subTitle() const
{
	return mTabSong->subTitle();
}

void TabSongModel::setArtist(const QString &s)
{
	mTabSong->setArtist(s);
	
	notifyPropertyChanged();
}

QString TabSongModel::artist() const
{
	return mTabSong->artist();
}

void TabSongModel::setAlbum(const QString &s)
{
	mTabSong->setAlbum(s);
	
	notifyPropertyChanged();
}

QString TabSongModel::album() const
{
	return mTabSong->album();
}

void TabSongModel::setAuthor(const QString &s)
{
	mTabSong->setAuthor(s);
	
	notifyPropertyChanged();
}

QString TabSongModel::author() const
{
	return mTabSong->author();
}

void TabSongModel::setCopyright(const QString &s)
{
	mTabSong->setCopyright(s);
	
	notifyPropertyChanged();
}

QString TabSongModel::copyright() const
{
	return mTabSong->copyright();
}

void TabSongModel::setTranscriber(const QString &s)
{
	mTabSong->setTranscriber(s);
	
	notifyPropertyChanged();
}

QString TabSongModel::transcriber() const
{
	return mTabSong->transcriber();
}

void TabSongModel::setInstructions(const QString &s)
{
	mTabSong->setInstructions(s);
	
	notifyPropertyChanged();
}

QString TabSongModel::instructions() const
{
	return mTabSong->instructions();
}

void TabSongModel::setComments(const QString &s)
{
	mTabSong->setComments(s);
	
	notifyPropertyChanged();
}

QString TabSongModel::comments() const
{
	return mTabSong->comments();
}

void TabSongModel::setShuffle(bool i)
{
	mTabSong->setShuffle(i);
	
	notifyPropertyChanged();
}

bool TabSongModel::isShuffle() const
{
	return mTabSong->isShuffle();
}

void TabSongModel::setTempo(unsigned int i)
{
	mTabSong->setTempo(i);
	
	notifyPropertyChanged();
}

unsigned int TabSongModel::tempo() const
{
	return mTabSong->tempo();
}

void TabSongModel::setOctave(int i)
{
	mTabSong->setOctave(i);
	
	notifyPropertyChanged();
}

int TabSongModel::octave() const
{
	return mTabSong->octave();
}

void TabSongModel::setSongKey(SongKey* songKey)
{
	mTabSong->setSongKey(songKey);
	
	notifyPropertyChanged();
}

SongKey* TabSongModel::songKey() const
{
	return mTabSong->songKey();
}

void TabSongModel::setKey(QChar c)
{
	mTabSong->setKey(c);
	
	notifyKeyChanged();
}

QChar TabSongModel::key() const
{
	return mTabSong->key();
}

char TabSongModel::asciiCodeOfKey() const
{
	return mTabSong->asciiCodeOfKey();
}

QString TabSongModel::nameOfKey() const
{
	return mTabSong->nameOfKey();
}


void TabSongModel::setMinor(bool i)
{
	mTabSong->setMinor(i);
	
	notifyKeyChanged();
}

bool TabSongModel::isMinor() const
{
	return mTabSong->isMinor();
}

void TabSongModel::setTabLyrics(TabLyrics* lyrics)
{
	mTabSong->setTabLyrics(lyrics);
	
	notifyLyricsChanged();
}

TabLyrics* TabSongModel::tabLyrics() const
{
	return mTabSong->tabLyrics();
}

void TabSongModel::setLyricsTrack(int i)
{
	mTabSong->setLyricsTrack(i);
	
	notifyLyricsChanged();
}

int TabSongModel::lyricsTrack() const
{
	return mTabSong->lyricsTrack();
}

void TabSongModel::setLyricsMeasure(int i, int j)
{
	mTabSong->setLyricsMeasure(i, j);
	
	notifyLyricsChanged();
}

int TabSongModel::lyricsMeasure(int i) const
{
	return mTabSong->lyricsMeasure(i);
}

void TabSongModel::setLyrics(int i, const QString& s)
{
	mTabSong->setLyrics(i, s);
	
	notifyLyricsChanged();
}

QString TabSongModel::lyrics(int i) const
{
	return mTabSong->lyrics(i);
}

bool TabSongModel::compareTracks(const TabSong& tabSong) const
{
	return mTabSong->compareTracks(tabSong);
}

bool TabSongModel::operator==(const TabSong& tabSong) const
{
	return mTabSong->operator==(tabSong);
}

bool TabSongModel::operator!=(const TabSong& tabSong) const
{
	return mTabSong->operator!=(tabSong);
}
