#ifndef FORMATSCONFIG_H_INCLUDED
#define FORMATSCONFIG_H_INCLUDED

#include <qwidget.h>
#include <qvalidator.h>
#include <qdialog.h>
#include "configuration.h"

class QComboBox;
class QPushButton;
class QListView;

class FormatsListItem: public QListViewItem
{
public:
	FormatsListItem(const QString &fileExtension, const QString &mplayerArguments, QListView *parent);
	bool edit();
};

class FormatsFileExtensionValidator: public QValidator
{
public:
	FormatsFileExtensionValidator(QWidget *parent, const char *name = 0);
	QValidator::State validate(QString &input, int &) const;
	void fixup(QString &input) const;
};

class FormatsEditorDialog: public QDialog
{
public:
	FormatsEditorDialog(FormatsListItem *item, QWidget *parent = 0, const char *name = 0);
	int exec();
	
private:
	QLineEdit *fileExtensionsLineEdit_;
	QLineEdit *mplayerArgumentsLineEdit_;
	FormatsListItem *item_;	
};

class FormatsConfig : public QWidget
{
	Q_OBJECT

public:
	FormatsConfig(Configuration& config, QWidget *parent = 0, const char *name = 0);
	void setStatesByConfiguration(const Configuration& config);
	void saveStatesToConfiguration();
	
private slots:
	void editFormat(QListViewItem *);
	void editSelectedFormat();	
	void addNewFormat();
	void removeSelectedFormat();
	
private:
	void createWidgets();

	Configuration& config_;

	QPushButton *keyButton_;
	QListView *list;
};

#endif // FORMATSCONFIG_H_INCLUDED
