/***************************************************************************
 * fingerlist.h: implementation of FingerList 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 FINGERLIST_H
#define FINGERLIST_H

#include <QTableWidget>
#include <QVector>

#include "global.h"

class QFont;

class TabTrack;

struct ChordDiagram{
	QVector<int> chord;
	
	ChordDiagram() : chord(sMaxStrings)
	{
	};
};

/**
	The FingerList class. The FingerList class draw the fingering chords.
*/
class FingerList : public QTableWidget {
	Q_OBJECT
public:
	/**
		Construct the fingering chords.
		@param track the current TabTrack
		@see QGridView
	*/
	FingerList(const TabTrack& track);
	
	/**
		Desctruct the fingering chords.
	*/
	~FingerList();
	
	void addFingering(const int a[sMaxStrings]);
	
	/**
		Clear the widget.
	*/
	void clear();
	
	/**
		Begins new "session" for fingering list, i.e. clears it and
		prepares for adding new chords.
	*/
	void beginSession();
	
	/**
		Ends adding "session" for the list, setting proper number of
		columns / rows, updating it, etc.
	*/
	void endSession();
	
	/**
		Return the number of fingering.
		@return the first fingering
	*/
	int count() const;
	
	/**
		Select the first fingering.
	*/
	void selectFirst();
	
signals:
	void chordSelected(const QVector<int>&);
	
protected:
	virtual void mousePressEvent(QMouseEvent *);
	
private:
	static const uint msIconChord;
	static const double msFontFactor;
	
	const TabTrack& mTabTrack;
	
	int mNum;
	int mPerRow;
	int mCurSel;
	int mOldCol;
	int mOldRow;
	
	QFont* mFretNumberFont;
	QVector<ChordDiagram> mChordDiagrams;
};

#endif
