/***************************************************************************
 * optionsmidi.h: implementation of OptionsMidi 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 OPTIONSMIDI_H
#define OPTIONSMIDI_H

#include <vector>

#include <KConfig>
#include <QWidget>
#include <QTreeWidget>
#include <QLabel>
#include <QPushButton>
#include <QCheckBox>
#include <QVBoxLayout>
#include <QHBoxLayout>

#include <tse3/MidiScheduler.h>

#include "optionspage.h"

/**
	The OptionsMidi class.  This class create the user interface
	for the midi configuration, the user can choose the midi interface,
	and see the midi configuration (midi port, device name, ...).
	And the user can launch timidity.
*/
class OptionsMidi: public OptionsPage {
	Q_OBJECT
public:
	/**
		Construct the midi widget.
		The constructor creates the widget and inits the parent (optionPage). Here are the midi
		options :
			midi port, device name, timidity launcher.
		@param midiFactory used to create the midi scheduler
		@param scheduler the midi scheduler
		@param config config is used to read and write the KTabEdit config file
		@param parent the widget parent
		@param name the widget name
	*/
	OptionsMidi(TSE3::MidiSchedulerFactory& midiFactory, TSE3::MidiScheduler** scheduler, KConfig* config, QWidget* parent);
	
	/**
		Called when the user click on the Apply button.
		The timidity configuration is written on the KTabEdit config file.
	*/
	virtual void applyBtnClicked();
	
	/**
		Called when the user click on the Default button.
		It does nothing.
	*/
	virtual void defaultBtnClicked();
	
private slots:
	void fillMidiBox();
	void launchTimidity();
	
private:
	QTreeWidget mMidiPort;
	QLabel mMidiPortLabel;
	QPushButton mMidiRefresh;
	QCheckBox mMidiTimidity;
	QVBoxLayout mMidiLayout;
	QHBoxLayout mMidiButton;
	
	std::vector<int> mPortNums;
	TSE3::MidiSchedulerFactory& mFactory;
	TSE3::MidiScheduler** mScheduler;
	
	bool mTimidity;
};

#endif
