/***************************************************************************
 * kguitartab.h: implementation of KGuitarTab class
 *
 * This file is part of KTabEdit, a KDE tabulature editor
 *
 * copyright (C) 2003-2006 the KTabEdit development team <mrgwen@gmail.com>
 * copyright (C) 2002-2003 the KGuitar 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.
 ***************************************************************************/

#ifndef KGUITARTAB_H
#define KGUITARTAB_H

#include "fileexport.h"
#include "fileimport.h"

#include <QDomNode>
#include <QString>

class TabBar;
class TabTimeEffect;
class TabBend;
class TabBendPoint;
class TabChord;
class TabGraceNote;
class TabLyrics;
class TabNote;
class TabProperties;
class TabSong;
class TabTime;
class TabTrack;
class TabTrill;
class TrackProperties;

class KGuitarTab : public FileImport, public FileExport
{
public:
	KGuitarTab();
	virtual ~KGuitarTab();
	
	bool loadFile(const QString& fileName);
	bool saveFile(const QString& fileName, const TabSong& tabSong);
	
private:
	void readSongInformation(const QDomNode& domNode, TabSong* tabSong);
	
	TabProperties* readSongProperties(QDomNode node);
	TabLyrics* readLyricsProperties(QDomNode node);
	
	void readTrackInformation(QDomNode node, TabSong* tabSong);
	TrackProperties* readTrackProperties(QDomNode node);
	void readTrackSong(QDomNode node, TabTrack* tabTrack);
	
	TabBar* readBar(QDomNode node, uchar bar);
	TabTime* readTime(QDomNode node, uchar time);
	
	TabTimeEffect* readTimesEffect(QDomNode node);
	TabBend* readBendEffect(QDomNode node);
	TabBendPoint* readPointBend(QDomNode node);
	TabChord*  readChordEffect(QDomNode node);
	
	TabNote* readNote(QDomNode node, uchar chord);
	TabTrill* readTrillEffect(QDomNode node);
	TabGraceNote* readGraceNoteEffect(QDomNode node);
	
	void writeSongInformation(const QString&, QTextStream&, const TabSong&);
	void writeLyricsInformation(const QString&, QTextStream&, const TabLyrics&);
	void writeTrackInformation(const QString&, QTextStream&, const TabTrack&);
	void writeBarInformation(const QString&, QTextStream&, const TabBar&);
	void writeTimesInformation(const QString&, QTextStream&, const TabTime&);
	void writeTimesEffectInformation(const QString&, QTextStream&, const TabTimeEffect&);
	void writeBendInformation(const QString&, QTextStream&, const TabBend&);
	void writeChordInformation(const QString&, QTextStream&, const TabChord&);
	void writeNoteInformation(const QString&, QTextStream&, const TabNote&);
	void writeTrillInformation(const QString&, QTextStream&, const TabTrill&);
	void writeGraceNoteInformation(const QString&, QTextStream&, const TabGraceNote&);
	
	static const TabTimeEffect msNoBeatEffect;
	static const TabBend msNoBendEffect;
};

#endif
