/*****************************************************************************
 *
 *  consoledialog.h -- Display console for command line task output.
 *
 *  Copyright (C) 2010 Starbuck <starbuck@labdv.com>
 *  All rights reserved.
 *
 *  This file is part of the Gui4 module of the DVDx 4 application.
 *
 *  GNU Lesser General Public License Usage
 *  This file may be used under the terms of the GNU Lesser General
 *  Public License version 2.1 as published by the Free Software
 *  Foundation and appearing in the file LICENSE.LGPL included in the
 *  packaging of this file.  Please review the following information to
 *  ensure the GNU Lesser General Public License version 2.1 requirements
 *  will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 *
 *  GNU General Public License Usage
 *  Alternatively, this file may be used under the terms of the GNU
 *  General Public License version 3.0 as published by the Free Software
 *  Foundation and appearing in the file LICENSE.GPL included in the
 *  packaging of this file.  Please review the following information to
 *  ensure the GNU General Public License version 3.0 requirements will be
 *  met: http://www.gnu.org/copyleft/gpl.html.
 *
 *****************************************************************************/

#ifndef CONSOLEDIALOG_H
#define CONSOLEDIALOG_H

#include "../job/task.h"
#include <QDialog>
#include <QString>
#include <QTextEdit>
#include <QLabel>
#include <QProgressBar>
#include <QLayout>

class ConsoleDialog : public QDialog
{
	Q_OBJECT

public:
	ConsoleDialog(const QString &, const QString &, const QString &, const QString &, 
		const int, const bool =false);
	// title, name, engine and PID number are already in Task

	void displayError(QString *);
	void displayOutput(QString *);
	void displayProgress(int *, double *, int *, int *);

	void attachTask(Task *);
	inline void setTotalTime(const double t) { totalTime = t; };
	inline void setTotalFrame(const int t) { totalFrame = t; };
	inline void setTotalSize(const int kB) { totalSize = kB; };

	inline QString getTitle() { return title; };
	inline QString getName() { return name; };
	inline QString getEngine() const { return engine; };
	inline int getPidNumber() { return pid; };
	inline Task *getTask() { return task; };

signals:
	void progressUpdated(int, double, int, int);
	void progressUpdated();
	void timeUpdated(const QString &);

public slots:
	void displayProgress();

protected slots:
	void reject();
	void changeStateDisplay();

protected:
	QString title;
	QString name;
	QString engine;
	QString command;
	int pid;

	Task *task;

	QWidget *dashBoardWidget;
	QHBoxLayout *dashBoardLayout;

	QLabel *cmdLine;

	QTextEdit *stdOut;
	QTextEdit *stdErr;

	QLabel *taskTitle;
	QProgressBar *progress;

	double totalTime;
	int totalFrame;
	int totalSize;		// total size in kBytes
};

#endif
