/***************************************************************************
                          DialogCntPnl.h  -  description
                             -------------------
    begin                : Thu May 31 2001
    copyright            : (C) 2001 by Alex Podolsky
    email                : alexpod@users.sourceforge.net
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/
#ifndef DIALOGCNTPNL_H
#define DIALOGCNTPNL_H

#include <qvariant.h>
#include <qwidget.h>
#include <qdatetime.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <klistview.h>

#include <klocale.h>

#include "../CdboDialogBase.h"

class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QFrame;
class QGroupBox;
class QListViewItem;
class KConfig;

class DialogCntPnl : public QWidget{
    Q_OBJECT

public:
	typedef void (DialogCntPnl::*procFunk)(int,QString);
	
	DialogCntPnl( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
	~DialogCntPnl();

	void output(int type, QString message);
	void status(QString msg);
	void stopForwardTimer();
	void startForwardTimer();
	
	inline void setStartBtnTitle(QString title) { startBtn->setText( title ); }
	inline void resizeOutputViewColomns(int w1, int w2){
		outputView->setColumnWidth(0,w1);
		outputView->setColumnWidth(1,w2);
	}
	inline QPushButton* getStartBtn() { return startBtn; }
	inline QPushButton* getCancelBtn() { return cancelBtn; }
	inline QPushButton* getSettingsBtn() { return settingsBtn; }
	inline QPushButton* getDumpBtn() { return dumpBtn; }
	inline QPushButton* getQuitBtn() { return quitBtn; }
	//very important method! must call before each process
	void clearOutput();
	
	//progress
	inline void setTotalProcesses(int total) {totalToProcess = total;}
	inline void setProcessType(int type) {processType = type;}
	
protected slots:
	virtual void timerEvent(QTimerEvent *event);

	virtual void cancelSlot();
	virtual void dumpSlot();
	virtual void helpSlot();
	virtual void quitSlot();
	virtual void startSlot();
	virtual void settingsSlot();

protected:
	void updateProgress(int,QListViewItem *, QString optMess = "");

private:
	int eTimeId;
	QTime timer;
	int procTimeId;
	int staTimeId;
	int dotCount;
	KConfig *config;
	///QTime procTimer;
	bool firstMove;
	bool ignoreOutput;
	bool cddaDone;
	
	int percentDone;
	int processType;
	int totalToProcess;
	int processesDone;
	QListViewItem *progressItem;
	QListViewItem *isoProgressItem;
	QListViewItem *totalProgressItem;
	
	void initByType(int type, QString *mtype, QString *pixmap);
	
	void processCdda2wavProcessMess(int,QString);
	void processCdrecordProcessMess(int,QString);
	void processMkisofsProcessMess(int,QString);
	void processCdparanoiaProcessMess(int,QString);
	void processRippProcessMess(int,QString);
	void processUnknownProcessMess(int,QString);
	void processOggMp3ProcessMess(int,QString);
	
	void initProcFunkArr();
	procFunk procFunkArr[CdboDialogBase::unknownProcess + 1];
	
	//GUI PARTS ========================
     KListView* outputView;
	

     QLabel* statusLbl;
     QLabel* eTimeLbl;
     //QLabel* rTimeLbl;

     QPushButton* startBtn;
     QPushButton* cancelBtn;
     QPushButton* settingsBtn;
     QPushButton* dumpBtn;
     QPushButton* helpBtn;
     QPushButton* quitBtn;


     //QLabel* timeRemLbl;
     QLabel* elapsedTimeLbl;
     QFrame* Frame11_2_2_2;
     QFrame* mainFrm;
     QGroupBox* GroupBox42_2;
	QFrame* controlPanel_2;
      QHBoxLayout* DialogCntPnlLayout;
     QGridLayout* mainFrmLayout;
     QVBoxLayout* GroupBox42_2Layout;
     QHBoxLayout* Frame11_2_2_2Layout;
     QVBoxLayout* controlPanel_2Layout;
     bool event( QEvent* );
};

#endif // DIALOGCNTPNL_H
