/***************************************************************************
 * trackpagelist.h: implementation of TrackPageList class
 *
 * This file is part of KTabEdit, a KDE tabulature editor
 *
 * copyright (C) 2003-2006 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.
 ***************************************************************************/

#ifndef TRACKPAGELIST_H
#define TRACKPAGELIST_H

#include <QList>

#include "tablature/tabproperties.h"

#include "cm.h"
#include "qsizecm.h"

class QGraphicsScene;

class QPointCm;
class TabSong;
class TrackPos;
class TabTrack;
class TrackBarView;
class TrackPageView;

class TrackPageList : public QList<TrackPageView*> {
public:
	typedef QList<TrackPageView*>::const_iterator const_iterator;
	typedef QList<TrackPageView*>::iterator iterator;
	
	TrackPageList();
	virtual ~TrackPageList();
	
	virtual void setGraphicsScene(QGraphicsScene* graphicsScene);
	virtual QGraphicsScene* graphicsScene() const;
	
	virtual void setSongProperties(const TabProperties* songProperties);
	virtual const TabProperties* songProperties() const;
	
	virtual void setTabTrack(const TabTrack* tabTrack);
	virtual const TabTrack* tabTrack() const;
	
	virtual void setPageSize(const QSizeCm& pageSize);
	virtual QSizeCm pageSize();
	
	virtual void setMargins(const Cm& left, const Cm& bottom);
	virtual Cm leftMargins() const;
	virtual Cm bottomMargins() const;
	
	virtual void setDpi(uint dpi);
	virtual uint dpi();
	
	virtual void push_front(TrackPageView* trackPageView);
	virtual void push_back(TrackPageView* trackPageView);
	virtual void push_back(uint pageNb);
	
	virtual TrackPageList::iterator page(uint pageNumber);
	virtual TrackPageList::const_iterator page(uint pageNumber) const;
	
	virtual TrackPos cursorPositionAt(const QPointCm& point);
	virtual TrackBarView* barAt(const TrackPos& trackPos);
	
	virtual void draw(const TrackPageList::iterator& it);
	virtual void drawRange(const TrackPageList::iterator& from, const TrackPageList::iterator& to);
	
	virtual void draw();
	virtual void draw(uint pageNumber);
	virtual void drawRange(uint from, uint to);
	
	virtual bool isPageDraw(uint pageNumber) const;
	
	virtual void refreshPageAt(const TrackPos& trackPos);
	virtual void refreshBarAt(const TrackPos& trackPos);
	virtual void refreshTimeAt(int bar, int time);
	virtual void refreshNoteAt(const TrackPos& position);
	
	virtual bool isEmpty() const;
	virtual bool isObscured() const;
private:
	const TabProperties* mSongProperties;
	const TabTrack* mTabTrack;
	QSizeCm mPageSize;
	Cm mLeftMargins, mBottomMargins;
	uint mDpi;
	QGraphicsScene* mGraphicsScene;
};

#endif
