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

#ifndef TRACKDURATIONVIEW_H
#define TRACKDURATIONVIEW_H

#include <list>

#include <QGraphicsItem>

#include "drawingitem.h"

#include "tablature/tabduration.h"

class Cm;
class QPointCm;
class TabTime;

class TrackDurationView : public DrawingItem
{
public:
	TrackDurationView(const TabTime* time, uint strings, const Cm& space, const Cm& width, uint dpi);
	virtual ~TrackDurationView();
	
	virtual void setPreviousDuration(Duration nextDuration);
	virtual Duration previousDuration() const;
	virtual void setPositionOfPreviousDuration(const Cm& x);
	
	virtual void setNextDuration(Duration nextDuration);
	virtual Duration nextDuration() const;
	
	virtual void hide();
	virtual void show();
	
	virtual QRectCm boundingRect() const;
	virtual Cm height() const;
	virtual Cm width() const;
	
	virtual void drawWithoutLink();
	virtual void drawWithLinkAndNoNextLink();
	virtual void drawWithLinkAndNextLink();
	
	virtual void drawTimesDuration(uint nbLines, const Cm& width);
	virtual void drawTimesDurationWithGreaterPreviousDuration(const Cm& width);
	virtual void drawTimesDuration(uint nbLines);
	
	virtual uint linesOfTimesDuration(Duration duration) const;
	virtual void drawVerticalLine();
private:
	typedef std::list<QGraphicsItem*>::iterator iterator;
	typedef std::list<QGraphicsItem*>::const_iterator const_iterator;
	
	static const double queueSpace;
	
	const TabTime* mTabTime;
	const uint nbStrings;
	const Cm lineSpaces;
	const Cm durationWidth;
	const Cm mHalfDurationWidthCm;
	
	const Cm mQueueLengthCm;
	const Cm mQueueSpaceCm;
	
	std::list<QGraphicsItem*> lineList;
	
	Duration mNextDuration;
	Duration mPreviousDuration;
	Cm mXPositionPreviousDuration;
};

#endif
