/***************************************************************************
 * midi.h: implementation of Tse3Assistant 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 MIDI_H
#define MIDI_H

#include <vector>

#include <QWizardPage>
#include <QTreeWidget>
#include <QWidget>
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>

// #include <tse3/Error.h>
// #include <tse3/listen/Transport.h>
// #include <tse3/Metronome.h>
#include <tse3/MidiScheduler.h>
// #include <tse3/Part.h>
// #include <tse3/PhraseEdit.h>
// #include <tse3/Song.h>
// #include <tse3/TempoTrack.h>
// #include <tse3/Track.h>
// #include <tse3/Transport.h>
// #include <tse3/util/MidiScheduler.h>

/**
	The Tse3Assistant class. This class creates the user interface for the TSE
	configuration. The user can see the midi port, the port number, if it is
	readable or writeable. The user can choose a midi port.
*/
class Tse3Assistant: public QWizardPage {
	Q_OBJECT
public:
	/**
		Construct the Tse3Assistant interface.
		The constructor creates the user interface, there is a list view which displays the midi
		configuration, and a button to refresh the view.
		@param parent the parent widget
		@param name the widget name
		@see QWidget constructor
	*/
	Tse3Assistant(TSE3::MidiSchedulerFactory& factory, QWidget* parent);
	
	/**
		Writes the midi configuration.
		If there is a midi port selected, the configuratio is written inside the MIDI group, the midi
		name, port, port number, readable, writeable fields are saved.
	*/
	virtual void writeConfig();
	
	TSE3::MidiScheduler* midiScheduler() const;
private slots:
	void fillTse3Box();
	
private:
	QTreeWidget* mMidiport;
	QLabel* mMidiportLabel;
	QPushButton* mMidiRefresh;
	QHBoxLayout* mMidiButton;
	QVBoxLayout* mMidiLayout;
	
	std::vector<int> mPortNums;
	TSE3::MidiScheduler* mScheduler;
	
	TSE3::MidiSchedulerFactory& mFactory;
};

#endif
