/***************************************************************************
 * chord.h: implementation of ChordSelector 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 CHORD_H
#define CHORD_H

#include <KDialog>
#include <tse3/MidiScheduler.h>

class QLabel;
class QRadioButton;
class QVBoxLayout;
class QWidget;
class KComboBox;
class KLineEdit;
class KListWidget;
class KPushButton;

class ChordList;
class Fingering;
class FingerList;
class Fingers;
class Strumming;
class TabTrack;

/**
\brief A dialog for adding a chord
A complex chord chooser with chord recognition and other goodies
TODO: make clear statements about the functionality of this dialog, i.e. what it should do and what it shouldn't do (I guess we don't want much more than a simple chord adding dialog (added by covaci)
**/
class ChordSelector : public KDialog
{
    Q_OBJECT
public:
	ChordSelector(TSE3::MidiScheduler* midiScheduler, const TabTrack& track);
	virtual ~ChordSelector();
	
	virtual void initUI();
	virtual void connectSignals();
	virtual void initLayout();

	Fingering & getFingering() const;
	ChordList & getChordList() const;
	int app(int x);
	
public slots:
	void detectChord();
	
private slots:
	void analyzeChordName();
	void askStrum();
	void findChords();
	void findSelection();
	void playMidi();
	void quickInsert();
	void setHighSteps();
	void setStep3();
	void setStepsFromChord();

private:
	static const int msTemplate[][6]; /**< Chord definition - see implementation */
	
	/*
		Calculate absolute notes from tonic + step user input
	*/
	bool calculateNotesFromSteps(int[], int &);
	void setApp(int x, int fret);
	int  scheme();
	
	const TabTrack& mTabTrack;
	TSE3::MidiScheduler* mScheduler;
	Fingering* mFingerging;
	FingerList* mFingerList;
	ChordList* mChords;
	
	QWidget* mainWidget;
	KLineEdit* mChordName;
	KListWidget* mTonic;
	KListWidget* mStep3;
	KListWidget* mStepHigh;
	KComboBox* mSt[7];
	KComboBox* mInv;
	KComboBox* mBassNote;
	QLabel* mCnote[7];
	QLabel* stlabel[7];
	QVBoxLayout* mComplexity;
	QRadioButton* mComplexer[3];
	KPushButton* buttonPlay;
	KPushButton* buttonStrum;
	KPushButton* buttonAnalyze;
	KPushButton* buttonQuickInsert;
	//TODO: should use the standard ones from KDialog
// 	KPushButton* buttonOk;
// 	KPushButton* buttonCancel;
	
	int mStrumScheme;
};

#endif
